From 04f76e2ceed2f4d79bb6f9361ed1a9bbe589c27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Priit=20J=C3=A4rv?= Date: Sun, 12 Jan 2014 19:09:43 +0200 Subject: [PATCH] added the missing function body for wg_attach_logged_database() --- Db/dbmem.c | 23 +++++++++++++++++++++++ wgdb.def | 1 + 2 files changed, 24 insertions(+) diff --git a/Db/dbmem.c b/Db/dbmem.c index 2a094e2..deb2156 100644 --- a/Db/dbmem.c +++ b/Db/dbmem.c @@ -137,6 +137,29 @@ void* wg_attach_existing_database(char* dbasename){ return shm; } +/** returns a pointer to the existing database, NULL if failure. + * + * Starts journal logging in the database. + */ + +void* wg_attach_logged_database(char* dbasename, gint size){ + void* shm = wg_attach_memsegment(dbasename, size, size, 1, 1); + if(shm) { + int err; + /* Check the header for compatibility. + * XXX: this is not required for a fresh database. */ + if((err = wg_check_header_compat(dbmemsegh(shm)))) { + if(err < -1) { + show_memory_error("Existing segment header is incompatible"); + wg_print_code_version(); + wg_print_header_version(dbmemsegh(shm)); + } + return NULL; + } + } + return shm; +} + /** Attach to shared memory segment. * Normally called internally by wg_attach_database() diff --git a/wgdb.def b/wgdb.def index 02c0c5f..52c3a57 100644 --- a/wgdb.def +++ b/wgdb.def @@ -6,6 +6,7 @@ LIBRARY WGDB EXPORTS wg_attach_database wg_attach_existing_database + wg_attach_logged_database wg_detach_database wg_delete_database wg_create_record