/*<html><pre>*/
#ifndef	V_FIFO_H
#define V_FIFO_H

typedef struct	u8_fifo_s	/*	Byte queue */
{
	u32_t	size;
	u32_t	head;
	u32_t	tail;
	u32_t	avail;
	u8_t		*buf;
} u8_fifo_t, *u8_fifo_p;

typedef struct	fifo_s		/*	Block queue */
{
	u32_t	element_size;
	u32_t	size;
	u32_t	avail;
	u8_t		*buf,*head,*tail,*limit;
} fifo_t, *fifo_p;

#ifdef	__cplusplus
extern "C" {
#endif	/* __cplusplus */
	void	V_GLOBAL	u8fInit(u8_fifo_t *fifo);
	void	V_GLOBAL	fifoInit(fifo_t *fifo,u32_t element_size);
	void	V_GLOBAL	u8fPush(u8_fifo_t *fifo,u8_t element);
	void	V_GLOBAL	fifoPush(fifo_t *fifo,void *element);
	void	V_GLOBAL	u8fPushBuffer(u8_fifo_t *fifo,u8_t *src,
		u32_t num_bytes);
	vboolean V_GLOBAL	u8fPop(u8_fifo_t *fifo,u8_t *element);
	vboolean V_GLOBAL	fifoPop(fifo_t *fifo,void *element);
	/* Returns number of stored bytes, which CAN be less than
	 * 'num_bytes'. */
	u32_t	V_GLOBAL	u8fPopBuffer(u8_fifo_t *fifo,u8_t *dst,
		u32_t num_bytes);
	void	V_GLOBAL	u8fClear(u8_fifo_t *fifo);
	void	V_GLOBAL	fifoClear(fifo_t *fifo);
	/* Discards contents of FIFO, but not affects size of buffer
	 * (buffer is NOT memFree()'d). */
	void	V_GLOBAL	u8fPurge(u8_fifo_t *fifo);
	void	V_GLOBAL	fifoPurge(fifo_t *fifo);
#ifndef	FIFO_NO_MACRO
#define	u8fCount(fifo)				((fifo)->size-(fifo)->avail)
#define	fifoCount(fifo)				((fifo)->size-(fifo)->avail)
#else	/* FIFO_NO_MACRO */
	u32_t	V_GLOBAL	u8fCount(u8_fifo_t *fifo);
	u32_t	V_GLOBAL	fifoCount(fifo_t *fifo);
#endif	/* FIFO_NO_MACRO */
#ifdef	__cplusplus
}
#endif	/* __cplusplus */

#endif	/* V_FIFO_H */
/*</pre></html>*/
/*EOF*/
