#ifndef _COMMLIB_LEAF_H_
#define _COMMLIB_LEAF_H_


#include "commlib-common.h"


/**************************************************/
/* functions which should match their C semantics */
/**************************************************/

FILE * leaf_fopen(const char *filename, const char *mode);
int leaf_fclose(void *stream);
int leaf_fread(unsigned char *ptr, size_t size, size_t nitems, void *stream);
int leaf_fwrite(const char *ptr, size_t size, size_t nitems, void *stream);
int leaf_fseek(void *stream, long offset, int whence);



/**********************************************/
/* miscellaneous functions relating to the PC */
/**********************************************/

/* leaf_send_packet: send a packet to PC, doesn't wait for ack */
/* requires checksum to be precomputed */
void leaf_send_packet(const pcdata *pkt);
/* leaf_send_packet: send a packet to PC, doesn't wait for ack */
/* computes its own checksum */
void leaf_send_packet_args(const unsigned char EventID,
			   const unsigned char DataLength,
			   const unsigned char *Data);
/* leaf_recv_packet: get data from PC, placing result in passed object */
/* returns diff between actual and expected checksum (0 on success) */
unsigned char leaf_recv_packet(pcdata *pkt);
/* pc_recv_packet_args: Functionally equivalent to leaf_recv_packet,
 * but doesn't require data structure to be filled out. */
unsigned char leaf_recv_packet_args(unsigned char *EventID,
			 unsigned char *DataLength,
			 unsigned char *Data);
/* leaf_debug: send debug message to leaf; truncates at 255 characters */
void leaf_debug(char *message);

#endif /* ifdef _COMMLIB_LEAF_H_ */
