* Began (but did not finish) applying GPL3+ declarations to each source file. This...
[citadel.git] / citadel / database.h
1 /* $Id$
2  *
3  * Copyright (c) 1987-2009 by the citadel.org team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef DATABASE_H
21 #define DATABASE_H
22
23
24 void open_databases (void);
25 void close_databases (void);
26 int cdb_store (int cdb, void *key, int keylen, void *data, int datalen);
27 int cdb_delete (int cdb, void *key, int keylen);
28 struct cdbdata *cdb_fetch (int cdb, void *key, int keylen);
29 void cdb_free (struct cdbdata *cdb);
30 void cdb_rewind (int cdb);
31 struct cdbdata *cdb_next_item (int cdb);
32 void cdb_close_cursor(int cdb);
33 void cdb_begin_transaction(void);
34 void cdb_end_transaction(void);
35 void cdb_allocate_tsd(void);
36 void cdb_free_tsd(void);
37 void cdb_check_handles(void);
38 void cdb_trunc(int cdb);
39 void *checkpoint_thread(void *arg);
40 void cdb_chmod_data(void);
41 void cdb_checkpoint(void);
42 void check_handles(void *arg);
43
44 /*
45  * Database records beginning with this magic number are assumed to
46  * be compressed.  In the event that a database record actually begins with
47  * this magic number, we *must* compress it whether we want to or not,
48  * because the fetch function will try to uncompress it anyway.
49  * 
50  * (No need to #ifdef this stuff; it compiles ok even if zlib is not present
51  * and doesn't declare anything so it won't bloat the code)
52  */
53 #define COMPRESS_MAGIC  0xc0ffeeee
54
55 struct CtdlCompressHeader {
56         int magic;
57         size_t uncompressed_len;
58         size_t compressed_len;
59 };
60
61 #endif /* DATABASE_H */
62