blob: 6e6fca9683b24a95329c83fb153e12005a0405f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
|