ab5cb97cb2bff44ead73eb44c554518ea5245fa1
[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 *name;
21         char *base_path;
22         struct meta *meta;
23         struct record *index;
24         char *data;
25         int current_segment;
26         int data_size;
27 };
28
29 int blerg_exists(const char *);
30 struct blerg *blerg_open(const char *);
31 int blerg_close(struct blerg *);
32 int blerg_store(struct blerg *, const char *, int);
33 int blerg_fetch(struct blerg *, int, char **, int *);
34
35 #endif //_DATABASE_H