51 lines
1.4 KiB
C
51 lines
1.4 KiB
C
#ifndef BOATS_h
|
|
#define BOATS_h
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
typedef struct Boats_s {
|
|
uint16_t id;
|
|
char* name;
|
|
bool avaliable;
|
|
bool locked;
|
|
} Boats_t;
|
|
|
|
typedef struct BoatsDB_el_s {
|
|
Boats_t boat;
|
|
void* nextEl;
|
|
} BoatsDB_el_t;
|
|
|
|
// defines all vars for the buffer to operate
|
|
typedef struct BoatsDB_s {
|
|
BoatsDB_el_t* FirstEl_p;
|
|
BoatsDB_el_t* LastEl_p;
|
|
unsigned char size;
|
|
bool full;
|
|
} BoatsDB_t;
|
|
|
|
// create a fifo buffer and initilizes it with zeros
|
|
extern BoatsDB_t* BoatsDB_init();
|
|
|
|
// destroy a fifo buffer (free up its space)
|
|
// returns true on success or false otherways
|
|
extern bool BoatsDB_deinit(BoatsDB_t* fifo);
|
|
|
|
// put value i in buffer if there is still memory avaliable
|
|
// returns true on success or false otherways
|
|
extern bool BoatsDB_put(BoatsDB_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 BoatsDB_getById(BoatsDB_t *fifo, uint16_t id, );
|
|
|
|
// returns false if last put fails to gain memory and no get is called afterwards or true otherwise
|
|
extern bool BoatsDB_is_full(BoatsDB_t *fifo);
|
|
|
|
// returns true when buffer is empty or false otherways
|
|
extern bool BoatsDB_is_empty(BoatsDB_t *fifo);
|
|
|
|
extern unsigned int BoatsDB_getSize(BoatsDB_t *fifo);
|
|
|
|
#endif |