]> code.citadel.org Git - citadel.git/blob - citadel/server/database.c
Revert "Changed the API for cdb_rewind() / cdb_next_item() to make the caller hold...
[citadel.git] / citadel / server / database.c
1 // Copyright (c) 1987-2023 by the citadel.org team
2 // This program is open source software.  Use, duplication, or disclosure
3 // are subject to the terms of the GNU General Public License, version 3.
4
5 // The functions in this file handle the selection and activation of a storage backend for Citadel Server.
6 // Right now, it simply activates Berkeley DB because that's the only one we have.
7
8 #include "sysdep.h"
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <sys/stat.h>
12 #include <stdio.h>
13 #include <libcitadel.h>
14 #include "ctdl_module.h"
15 #include "control.h"
16 #include "citserver.h"
17 #include "config.h"
18
19 // Header files for all available backends must be included here.
20 #include "backends/berkeley_db/berkeley_db.h"
21
22 // Backends must include implementations of all these functions, but with their own prefix instead of "cdb_".
23 // The initialization function of the selected backend will map them.
24 void                    (*cdb_open_databases)(void)                             = NULL;
25 void                    (*cdb_close_databases)(void)                            = NULL;
26 int                     (*cdb_store)(int, const void *, int, void *, int)       = NULL;
27 int                     (*cdb_delete)(int, void *, int)                         = NULL;
28 void                    (*cdb_free)(struct cdbdata *)                           = NULL;
29 struct cdbdata *        (*cdb_next_item)(int)                                   = NULL;
30 void                    (*cdb_close_cursor)(int)                                = NULL;
31 void                    (*cdb_begin_transaction)(void)                          = NULL;
32 void                    (*cdb_end_transaction)(void)                            = NULL;
33 void                    (*cdb_check_handles)(void)                              = NULL;
34 void                    (*cdb_trunc)(int)                                       = NULL;
35 void                    (*cdb_chmod_data)(void)                                 = NULL;
36 void                    (*check_handles)(void *)                                = NULL;
37 void                    (*cdb_compact)(void)                                    = NULL;
38 void                    (*cdb_checkpoint)(void)                                 = NULL;
39 void                    (*cdb_rewind)(int)                                      = NULL;
40 struct cdbdata *        (*cdb_fetch)(int, const void *, int)                    = NULL;
41
42 // This function is responsible for choosing and initializing a back end.
43 void cdb_init_backends(void) {
44         bdb_init_backend();             // for now, this is the only one, so we select it always.
45 }