Main Page | Class List | File List | Class Members | File Members

Buffer.h

Go to the documentation of this file.
00001 /* BUFFER.H */
00002 
00003 /*
00004  * definitions for buffer modules.
00005  */
00006 #ifndef _BUFFER_H_
00007 #define _BUFFER_H_
00008 
00009 #include "standard.h"
00010 
00011 typedef struct {
00012   int head, tail;
00013   int full;
00014   int n;
00015   size_t len;
00016   void *data;
00017 } Buffer;
00018 
00019 Buffer *mkbuffer(int n, size_t len);
00020 /*
00021  * mkbuffer creates a buffer for up to n records of length len;
00022  */ 
00023 
00024 int bsize(Buffer *b);
00025 /*
00026  * returns the total size of the buffer (n)
00027  */
00028 
00029 int bhead(Buffer *b);
00030 /*
00031  * returns the position of the buffer's head 
00032  */
00033 
00034 int btail(Buffer *b);
00035 /*
00036  * returns the position of the buffer's tail
00037  */
00038 
00039 void bwrite(Buffer *b, void *data);
00040 /* 
00041  * writes a record from *data to the buffer
00042  */
00043 
00044 int bread(Buffer *b, void *data);
00045 /* 
00046  * reads a record from the buffer to *data
00047  */
00048 
00049 int blevel(Buffer *b);
00050 /*
00051  * returns the number of records in the buffer
00052  */
00053 
00054 void *bpeek(Buffer *b, int n);
00055 /*
00056  * bpeek returns a pointer to the nth record in the buffer.
00057  */
00058 
00059 void closebuffer(Buffer *b);
00060 /*
00061  * frees up memory used by buffer b
00062  */
00063 
00064 
00065 #endif
00066 
00067 

Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1