From 341359b6e4be08539984ad2f1b562b878d36c10c Mon Sep 17 00:00:00 2001 From: FReenen Date: Wed, 20 Mar 2024 17:27:11 +0100 Subject: [PATCH] add FIFOBuff header file --- FIFOBuff/FIFOBuffChar.h | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 FIFOBuff/FIFOBuffChar.h diff --git a/FIFOBuff/FIFOBuffChar.h b/FIFOBuff/FIFOBuffChar.h new file mode 100644 index 0000000..06048db --- /dev/null +++ b/FIFOBuff/FIFOBuffChar.h @@ -0,0 +1,45 @@ +#ifndef FIFOBuffChar_h +#define FIFOBuffChar_h + +#include + +// interface for a buffer with chars's + +// one element in the buffer +struct FIFOBuffChar_element_s { + char value; + void* nextEl; +}; + +// defines all vars for the buffer to operate +typedef FIFOBuffChar_s { + struct FIFOBuffChar_element_s* FirstEl_p; + struct FIFOBuffChar_element_s* LastEl_p; + unsigned char size; + bool full; +} FIFOBuffChar_t; + +// create a fifo buffer and initilizes it with zeros +extern FIFOBuffChar_t* FIFOBuffChar_init(); + +// destroy a fifo buffer (free up its space) +// returns true on success or false otherways +extern bool FIFOBuffChar_deinit(FIFOBuffChar_t* fifo); + +// put value i in buffer if there is still memory avaliable +// returns true on success or false otherways +extern bool FIFOBuffChar_put(FIFOBuffChar_t *fifo, char i); + +// get value from buffer and writes it to *p if buffer not empty +// returns true on success or false otherways +extern bool FIFOBuffChar_get(FIFOBuffChar_t *fifo, char *p); + +// returns false if last put fails to gain memory and no get is called afterwards or true otherwise +extern bool FIFOBuffChar_is_full(FIFOBuffChar_t *fifo); + +// returns true when buffer is empty or false otherways +extern bool FIFOBuffChar_is_empty(FIFOBuffChar_t *fifo); + +extern unsigned int FIFOBuffChar_getSize(); + +#endif \ No newline at end of file