69043e68f27f19afd77ee5d6c28de0e55bfba9b2
[blerg.git] / database.h
1 #ifndef _DATABASE_H
2 #define _DATABASE_H
3
4 #include <stdint.h>
5
6 struct record {
7         uint32_t offset;
8         uint16_t length;
9         uint16_t flags;
10 };
11
12 struct meta {
13         uint64_t sequence;
14 };
15
16 struct blerg {
17         int meta_fd;
18         int index_fd;
19         int data_fd;
20         char *base_path;
21         struct meta *meta;
22         struct record *index;
23         char *data;
24         int current_segment;
25         int data_size;
26 };
27
28 struct blerg *blerg_open(const char *);
29 int blerg_close(struct blerg *);
30 int blerg_store(struct blerg *, const char *, int);
31 int blerg_fetch(struct blerg *, int, char **, int *);
32
33 #endif //_DATABASE_H