c20144690b3726db6bf05bfed4e3d40164840b32
[citadel.git] / citadel / database.h
1 /* $Id$ */
2
3 #ifndef DATABASE_H
4 #define DATABASE_H
5
6
7 void open_databases (void);
8 void close_databases (void);
9 int cdb_store (int cdb, void *key, int keylen, void *data, int datalen);
10 int cdb_delete (int cdb, void *key, int keylen);
11 struct cdbdata *cdb_fetch (int cdb, void *key, int keylen);
12 void cdb_free (struct cdbdata *cdb);
13 void cdb_rewind (int cdb);
14 struct cdbdata *cdb_next_item (int cdb);
15 void cdb_close_cursor(int cdb);
16 void cdb_begin_transaction(void);
17 void cdb_end_transaction(void);
18 void cdb_allocate_tsd(void);
19 void cdb_free_tsd(void);
20 void cdb_check_handles(void);
21 void cdb_trunc(int cdb);
22 void *checkpoint_thread(void *arg);
23 void cdb_chmod_data(void);
24 void cdb_checkpoint(void);
25 void check_handles(void *arg);
26
27 /*
28  * Database records beginning with this magic number are assumed to
29  * be compressed.  In the event that a database record actually begins with
30  * this magic number, we *must* compress it whether we want to or not,
31  * because the fetch function will try to uncompress it anyway.
32  * 
33  * (No need to #ifdef this stuff; it compiles ok even if zlib is not present
34  * and doesn't declare anything so it won't bloat the code)
35  */
36 #define COMPRESS_MAGIC  0xc0ffeeee
37
38 struct CtdlCompressHeader {
39         int magic;
40         size_t uncompressed_len;
41         size_t compressed_len;
42 };
43
44 #endif /* DATABASE_H */
45