From: Art Cancro Date: Wed, 9 Aug 2023 15:41:23 +0000 (-0400) Subject: Moved cdb_ prototypes from berkeley_db.c to database.c where they belong X-Git-Tag: v989~89 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=8df8fc391009e9ebd2c464aa81a195176f56fb08;p=citadel.git Moved cdb_ prototypes from berkeley_db.c to database.c where they belong --- diff --git a/citadel/server/backends/berkeley_db/berkeley_db.c b/citadel/server/backends/berkeley_db/berkeley_db.c index dec082234..edf7a902c 100644 --- a/citadel/server/backends/berkeley_db/berkeley_db.c +++ b/citadel/server/backends/berkeley_db/berkeley_db.c @@ -19,11 +19,6 @@ #include #include #include - -#if DB_VERSION_MAJOR < 18 -#error Citadel requires Berkeley DB v18.0 or newer. Please upgrade. -#endif - #include #include "../../ctdl_module.h" #include "../../control.h" @@ -31,23 +26,10 @@ #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) diff --git a/citadel/server/database.c b/citadel/server/database.c index 2ba0102ca..5aa7d0e27 100644 --- a/citadel/server/database.c +++ b/citadel/server/database.c @@ -5,7 +5,6 @@ // 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 #include @@ -17,8 +16,30 @@ #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. }