/* 
 * Storage Layer
 * 
 * storage.h
 *
 * Interface to the storage layer.
 * 
 */

#ifndef _STORAGE_H_
#define _STORAGE_H_


#define MAX_FILENAME_SIZE 256
#define MAX_BOOKNAME_SIZE 3


/*
 * storage_new: defines a storage file (assumes authentication layer was created successfully)
 * - filename: the file name that stores the books data
 *   returns: 0 if success, -1 if not
 */
int storage_new(char *filename);


/*
 * storage_give: increase the quantity of a book
 * - bookname - the name of the book
 */
void storage_give(char *bookname);


/*
 * storage_search: search for a book, and if it exists reserves it
 * - username - the username of the user
 * - password - the password of the user
 * - bookname - the name of the book
 *   returns: 0 if book reserved, -1 if authentication failed, -2 if book doesn't exist
 */
int storage_search(char *username, char *password, char *bookname);


/*
 * storage_take: take a book, it must have been reserved before
 * - username - the username of the user
 * - bookname - the name of the book
 *   returns: 0 if book taken, -1 if authentication failed, -2 if book isn't reserved
 */
int storage_take(char *username, char *bookname);


/*
 * storage_cancel: cancel a book, it must have been reserved before
 * - username - the username of the user
 * - bookname - the name of the book
 *   returns: 0 if book cancel, -1 if authentication failed, -2 if book isn't reserved
 */
int storage_cancel(char *username, char *bookname);


/*
 * storage_release: release a book, make the book available again
 * - username - the username of the user
 * - bookname - the name of the book
 * - makeavailable - if 1 make the book available
 *   returns: 0 if book released, -1 if authentication failed, -2 if book isn't taken
 */
int storage_release(char *username, char *bookname, int makeavailable);


/*
 * storage_dump: dumps the content of storage
 */
void storage_dump();


#endif
