EMS31_submodules/FIFOBuff/FIFOBuffChar.h

48 lines
1.7 KiB
C

#ifndef FIFOBuffChar_h
#define FIFOBuffChar_h
#include <stdbool.h>
// interface for a buffer with chars's
// one element in the buffer
typedef struct FIFOBuffChar_element_s {
char character; // "char character" replaced "int value" because the elements are going to be characters
void* nextElement;
} FIFOBuffChar_element_t;
// defines all vars for the buffer to operate
typedef struct 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_create();
// destroy a fifo buffer (free up its space)
// returns true on success or false otherways
extern bool FIFOBuffChar_delete(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); //moet dit "char" zijn of "uint8_t"
// 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);
// pop last added value from the buffer
extern bool FIFOBuffChar_pop(FIFOBuffChar_t *fifo);
// 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(FIFOBuffChar_t *fifo);
#endif