X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=common%2Fstringring.h;fp=common%2Fstringring.h;h=7aedeb4724319462758b749dae1f24ba249ddd86;hb=973130f7802a00204d7b032bd941b2d9cdac8e81;hp=0000000000000000000000000000000000000000;hpb=b8fe46e27d53b5a03b5d27b59bae40a6445e9b8d;p=blerg.git diff --git a/common/stringring.h b/common/stringring.h new file mode 100644 index 0000000..7aedeb4 --- /dev/null +++ b/common/stringring.h @@ -0,0 +1,30 @@ +#ifndef _STRINGRING_H +#define _STRINGRING_H + +#include + +#define STRINGRING_DATA_SIZE 32 +#define STRINGRING_N_ENTRIES 102 + +struct stringring { + uint8_t counter; + uint8_t reserved[15]; + struct { + uint64_t timestamp; + uint8_t data[STRINGRING_DATA_SIZE]; + } entries[STRINGRING_N_ENTRIES]; +}; + +struct stringring_handle { + int fd; + struct stringring *sr; +}; + +struct stringring_handle * stringring_open(const char *filename); +void stringring_close(struct stringring_handle *sh); +int stringring_add(struct stringring_handle *sh, const char *data); +int stringring_find(struct stringring_handle *sh, const char *data, unsigned int max_age); +int stringring_remove(struct stringring_handle *sh, const char *data); +int stringring_clear(struct stringring_handle *sh); + +#endif /* _STRINGRING_H */