/* 
 * BS Logic Layer
 * 
 * bs.h
 *
 * Interface of the BS logic layer containing the functions that manage
 * the internal logic of BS and handles the BS requests issued by clients.
 * 
 */

#ifndef _BS_HANDLERS_H_
#define _BS_HANDLERS_H_

#include <bs_proto.h>
#include <response_list.h>

/*
 * the bs handler type
 * - req: the incoming message (request)
 * - reqsz: the size of the incoming message
 * - res: list of outgoing messages (response) [out]
 */
typedef void (*bs_handler_t)(bs_pdu_req_t *req, int reqsz, res_list_t **res);


/*
 * bs_init: performs internal BS initialization; currently
 * argc and argv are not being used.
 */
void bs_init(int argc, char **argv);


/*
 * bs_free_response: frees the structures used by a response
 * element in the response list.
 * - response: element to free
 */
void bs_free_response(response_t* response);

/*
 * BS Handlers
 *
 * All handlers follow the above mentioned signature.
 * 
 */


void bs_give(bs_pdu_req_t *req, int reqsz, res_list_t **res);


void bs_search(bs_pdu_req_t *req, int reqsz, res_list_t **res);


void bs_cancel(bs_pdu_req_t *req, int reqsz, res_list_t **res);


void bs_take(bs_pdu_req_t *req, int reqsz, res_list_t **res);


void bs_release(bs_pdu_req_t *req, int reqsz, res_list_t **res);


void bs_return(bs_pdu_req_t *req, int reqsz, res_list_t **res);


#endif
