/* 
 * Book Share System Layer
 * 
 * system.h
 *
 * Interface to the book share system layer implemented at the server side.
 * The following interface functions are provided.
 * 
 * Manages the internal organization of books and reserves and provides the
 * following interface functions to programmers.
 * 
 */

#ifndef _SYSTEM_H_
#define _SYSTEM_H_

#include <system_list.h>

/*
 * system_init: initializes the system data structures
 * - users_filename: name of the file with the users data
 * - titles_filename: name of the file with the titles data
 *   returns: 0 if successful, -1 otherwise
 */
int system_init(char* users_filename, char* titles_filename);


/*
 * system_give: gives the books in titles
 * - titles: titles of the books to give
 */
void system_give(char* titles);


/*
 * system_search: searches for the books in titles
 * - username: name of a given user
 * - password: password of a given user
 * - titles: titles of the books to search for
 * - weight: weight from the client to this counter
 * - results: a list of the results of the search
 */
void system_search(char* username, char* password, char* titles, int weight, sys_list_t** results);


/*
 * system_cancel: cancels the reserves of the books in ids
 * - username: name of a given user
 * - titles: titles of the books to cancel the reserve for
 */
void system_cancel(char* username, char* titles);


/*
 * system_take: takes the books in idcs and may ask
 *              for the cover of some of those books
 * - username: name of a given user
 * - titlecs: titlecs of the books to take / covers to ask for
 * - results: a list of the results of the take command
 */
void system_take(char* username, char* titlecs, sys_list_t** results);


/*
 * system_release: releases the books in ids
 * - username: name of a given user
 * - titles: titles of the books to release
 * - makeavailable: to signal the counter to
 *					return (=1) or not (=0) the book
 */
void system_release(char* username, char* titles, int makeavailable, sys_list_t** results);


/*
 * system_return: gives the books in titles
 * - titles: titles of the books to give
 */
void system_return(char* titles);


#endif
