tags must be preceeded by whitespace or start at the beginning of the record
[blerg.git] / database / database.h
1 /* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
2  * BSD-style license.  Please see the COPYING file for details.
3  */
4 #ifndef _DATABASE_H
5 #define _DATABASE_H
6
7 #include <stdint.h>
8 #include <time.h>
9
10 struct record {
11         uint32_t offset;
12         uint16_t length;
13         uint16_t flags;
14         time_t timestamp;
15 };
16
17 struct meta {
18         uint64_t sequence;
19 };
20
21 struct blerg {
22         int meta_fd;
23         int index_fd;
24         int data_fd;
25         char *name;
26         char *base_path;
27         struct meta *meta;
28         struct record *index;
29         char *data;
30         int current_segment;
31         int data_size;
32 };
33
34 int blerg_exists(const char *);
35 struct blerg *blerg_open(const char *);
36 int blerg_close(struct blerg *);
37 int blerg_store(struct blerg *, const char *, int);
38 int blerg_fetch(struct blerg *, int, char **, int *);
39 uint64_t blerg_get_record_count(struct blerg *);
40 time_t blerg_get_timestamp(struct blerg *blerg, int record);
41
42 #endif //_DATABASE_H