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