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