From 7c8e83f655e41b11e970fd0abad5a96a3fb73e47 Mon Sep 17 00:00:00 2001 From: bpc2003 Date: Mon, 10 Mar 2025 11:15:04 -0400 Subject: Consolidated each header into single header --- src/include/mdb.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/include/mdb.h (limited to 'src/include/mdb.h') diff --git a/src/include/mdb.h b/src/include/mdb.h new file mode 100644 index 0000000..6e6fca9 --- /dev/null +++ b/src/include/mdb.h @@ -0,0 +1,48 @@ +#ifndef FILEOPS_H +#define FILEOPS_H + +#define TABLEN 1024 + +extern int blen; + +enum btype { + BEGIN = 1, + END, PAIR, + + ERROR +}; + +struct byte { + enum btype type; + char *value; +}; + +struct byte *parse(unsigned char *buf); + +union value { + char *str; + double num; + unsigned int b : 1; +}; + +struct keytab { + char *key; + int flag; + union value v; +}; + +struct keytablist { + struct keytab tab[TABLEN]; +}; + +int *getkeys(struct keytablist *list, int id); +struct keytab getkey(struct keytablist *list, int id, char *key); +void setkey(struct keytablist **list, int *len, int id, char *pair); +void delkey(struct keytablist *list, int id, char *key); + +// TODO: integrate every header into single file +// TODO: make readdb return struct keytab list* +unsigned char *readdb(char *filename); +void writedb(char *filename, struct keytablist *list, int len); + +#endif -- cgit v1.2.3