#include <dirent.h>
#include <zlib.h>
#include <db.h>
-
-#if DB_VERSION_MAJOR < 18
-#error Citadel requires Berkeley DB v18.0 or newer. Please upgrade.
-#endif
-
#include <libcitadel.h>
#include "../../ctdl_module.h"
#include "../../control.h"
#include "../../config.h"
#include "berkeley_db.h"
-void (*cdb_open_databases)(void) = NULL;
-void (*cdb_close_databases)(void) = NULL;
-int (*cdb_store)(int, const void *, int, void *, int) = NULL;
-int (*cdb_delete)(int, void *, int) = NULL;
-void (*cdb_free)(struct cdbdata *) = NULL;
-struct cdbdata * (*cdb_next_item)(int) = NULL;
-void (*cdb_close_cursor)(int) = NULL;
-void (*cdb_begin_transaction)(void) = NULL;
-void (*cdb_end_transaction)(void) = NULL;
-void (*cdb_check_handles)(void) = NULL;
-void (*cdb_trunc)(int) = NULL;
-void (*cdb_chmod_data)(void) = NULL;
-void (*check_handles)(void *) = NULL;
-void (*cdb_compact)(void) = NULL;
-void (*cdb_checkpoint)(void) = NULL;
-void (*cdb_rewind)(int) = NULL;
-struct cdbdata * (*cdb_fetch)(int, const void *, int) = NULL;
+#if DB_VERSION_MAJOR < 18
+#error Citadel requires Berkeley DB v18.0 or newer. Please upgrade.
+#endif
+
static DB *dbp[MAXCDB]; // One DB handle for each Citadel database
static DB_ENV *dbenv; // The DB environment (global)
// The functions in this file handle the selection and activation of a storage backend for Citadel Server.
// Right now, it simply activates Berkeley DB because that's the only one we have.
-
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include "citserver.h"
#include "config.h"
+// Header files for all available backends must be included here.
#include "backends/berkeley_db/berkeley_db.h"
+// Backends must include implementations of all these functions, but with their own prefix instead of "cdb_".
+// The initialization function of the selected backend will map them.
+void (*cdb_open_databases)(void) = NULL;
+void (*cdb_close_databases)(void) = NULL;
+int (*cdb_store)(int, const void *, int, void *, int) = NULL;
+int (*cdb_delete)(int, void *, int) = NULL;
+void (*cdb_free)(struct cdbdata *) = NULL;
+struct cdbdata * (*cdb_next_item)(int) = NULL;
+void (*cdb_close_cursor)(int) = NULL;
+void (*cdb_begin_transaction)(void) = NULL;
+void (*cdb_end_transaction)(void) = NULL;
+void (*cdb_check_handles)(void) = NULL;
+void (*cdb_trunc)(int) = NULL;
+void (*cdb_chmod_data)(void) = NULL;
+void (*check_handles)(void *) = NULL;
+void (*cdb_compact)(void) = NULL;
+void (*cdb_checkpoint)(void) = NULL;
+void (*cdb_rewind)(int) = NULL;
+struct cdbdata * (*cdb_fetch)(int, const void *, int) = NULL;
+
+// This function is responsible for choosing and initializing a back end.
void cdb_init_backends(void) {
- bdb_init_backend();
+ bdb_init_backend(); // for now, this is the only one, so we select it always.
}