/****************************************************************************/
/* Copyright 2009 MBARI.                                                    */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
#ifndef BUFFER_H
#define BUFFER_H

typedef struct
{
    unsigned char* data;
    int head;
    int tail;
    int ptr_mask;
} ByteBuffer;

typedef struct
{
    unsigned int* data;
    int head;
    int tail;
    int ptr_mask;
} WordBuffer;

/* Note: need to figure out a more generic way for buffers 
to handle different data types */

/****************************************************************************/
/*                 Byte buffer access and status functions                  */
/****************************************************************************/
int bufBytePut(unsigned char b, ByteBuffer* buff);
int bufByteGet(unsigned char* b, ByteBuffer* buff);

void bufByteClear(ByteBuffer* buff);
int bufByteIsFull(ByteBuffer* buff);
int bufByteIsEmpty(ByteBuffer* buff);
int bufByteAvailable(ByteBuffer* buff);

/****************************************************************************/
/*                 Word buffer access and status functions                  */
/****************************************************************************/
int bufWordPut(unsigned int w, WordBuffer* buff);
int bufWordGet(unsigned int* w, WordBuffer* buff);

void bufWordClear(WordBuffer* buff);
int bufWordIsFull(WordBuffer* buff);
int bufWordIsEmpty(WordBuffer* buff);
int bufWordAvailable(WordBuffer* buff);


#endif
