2024-04-13 20:20:44 +02:00

38 lines
1.0 KiB
C

#ifndef HISTORY_H
#define HISTORY_H
#include <stdbool.h>
// one element in the buffer
typedef struct History_element_s {
void* prevEl_p;
char* line;
void* nextEl_p;
} History_element_t;
// defines all vars for the buffer to operate
typedef struct History_s {
History_element_t* FirstEl_p;
History_element_t* LastEl_p;
History_element_t* CurrEl_p;
unsigned char size;
} History_t;
// create a fifo buffer and initilizes it with zeros
extern History_t* History_init();
// destroy a fifo buffer (free up its space)
extern int History_deinit(History_t* history);
// put value i in buffer if there is still memory avaliable
extern int History_put(History_t *history, char* line);
// get value from buffer and writes it to *line
extern int History_getPrev(History_t* history, char** line);
extern int History_getNext(History_t* history, char** line);
extern int History_getFullHistory(History_t* history, char*** list);
extern unsigned int History_getSize(History_t *history);
#endif