summaryrefslogtreecommitdiff
path: root/src/lib/mdb.h
blob: a53f4b50e2ac10e977e80ab5c926e893a344e828 (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
#ifndef MDB_H
#define MDB_H

#define TABLEN 1024

typedef struct {
  char *key;
  int flag;
  union {
    char *str;
    double num;
    unsigned int boolean : 1;
  } value;
} tabidx_t;

typedef struct {
  int len;
  tabidx_t tab[TABLEN];
} tablist_t;

// Table operations
tabidx_t getkey(tablist_t *list, int id, char *key);

// Batch Operations
// TODO: make setkeys and delkeys take char ** and int
int *getkeys(tablist_t *list, int id);  // TODO: Reimplement getkeys
int setkeys(tablist_t **list, int id, char **pairs, int len);
int delkeys(tablist_t *list, int id, char **keys, int len);

// file operations
tablist_t *readdb(char *filename);
void writedb(char *filename, tablist_t *list);

#endif