From 4014499b128cab567a3b27e31ce4ee86e58be4f7 Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Fri, 16 Feb 2018 13:26:46 +1300 Subject: [PATCH] ldb_tdb: Build a key value operation library This allows sharing of the originally ldb_tdb operations to the new ldb_mdb backend. Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Tue Mar 6 01:39:16 CET 2018 on sn-devel-144 --- lib/ldb/ldb_tdb/ldb_tdb.c | 12 ++----- lib/ldb/ldb_tdb/ldb_tdb.h | 4 +++ lib/ldb/ldb_tdb/ldb_tdb_init.c | 59 ++++++++++++++++++++++++++++++++++ lib/ldb/wscript | 12 +++++-- 4 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 lib/ldb/ldb_tdb/ldb_tdb_init.c diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index 9a2b47b87c4..4f1c241e96a 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -2058,9 +2058,9 @@ int init_store(struct ltdb_private *ltdb, /* connect to the database */ -static int ltdb_connect(struct ldb_context *ldb, const char *url, - unsigned int flags, const char *options[], - struct ldb_module **_module) +int ltdb_connect(struct ldb_context *ldb, const char *url, + unsigned int flags, const char *options[], + struct ldb_module **_module) { const char *path; int tdb_flags, open_flags; @@ -2146,9 +2146,3 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, return init_store(ltdb, "ldb_tdb backend", ldb, options, _module); } - -int ldb_tdb_init(const char *version) -{ - LDB_MODULE_CHECK_VERSION(version); - return ldb_register_backend("tdb", ltdb_connect, false); -} diff --git a/lib/ldb/ldb_tdb/ldb_tdb.h b/lib/ldb/ldb_tdb/ldb_tdb.h index bf679900764..2235bd47c98 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/lib/ldb/ldb_tdb/ldb_tdb.h @@ -217,3 +217,7 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx, int init_store(struct ltdb_private *ltdb, const char *name, struct ldb_context *ldb, const char *options[], struct ldb_module **_module); + +int ltdb_connect(struct ldb_context *ldb, const char *url, + unsigned int flags, const char *options[], + struct ldb_module **_module); diff --git a/lib/ldb/ldb_tdb/ldb_tdb_init.c b/lib/ldb/ldb_tdb/ldb_tdb_init.c new file mode 100644 index 00000000000..b18c98a367c --- /dev/null +++ b/lib/ldb/ldb_tdb/ldb_tdb_init.c @@ -0,0 +1,59 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + Copyright (C) Stefan Metzmacher 2004 + Copyright (C) Simo Sorce 2006-2008 + Copyright (C) Matthias Dieter Wallnöfer 2009-2010 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see . +*/ + +/* + * Name: ldb_tdb + * + * Component: ldb tdb backend + * + * Description: core functions for tdb backend + * + * Author: Andrew Tridgell + * Author: Stefan Metzmacher + * + * Modifications: + * + * - description: make the module use asynchronous calls + * date: Feb 2006 + * Author: Simo Sorce + * + * - description: make it possible to use event contexts + * date: Jan 2008 + * Author: Simo Sorce + * + * - description: fix up memory leaks and small bugs + * date: Oct 2009 + * Author: Matthias Dieter Wallnöfer + */ + +#include "ldb_tdb.h" +#include "ldb_private.h" + +int ldb_tdb_init(const char *version) +{ + LDB_MODULE_CHECK_VERSION(version); + return ldb_register_backend("tdb", ltdb_connect, false); +} diff --git a/lib/ldb/wscript b/lib/ldb/wscript index e14fa63ec2c..1455f92eb2e 100644 --- a/lib/ldb/wscript +++ b/lib/ldb/wscript @@ -307,14 +307,20 @@ def build(bld): bld.SAMBA_MODULE('ldb_tdb', bld.SUBDIR('ldb_tdb', - '''ldb_tdb.c ldb_search.c ldb_index.c - ldb_cache.c ldb_tdb_wrap.c'''), + '''ldb_tdb_init.c'''), init_function='ldb_tdb_init', module_init_name='ldb_init_module', internal_module=False, - deps='tdb ldb', + deps='tdb ldb ldb_key_value', subsystem='ldb') + bld.SAMBA_LIBRARY('ldb_key_value', + bld.SUBDIR('ldb_tdb', + '''ldb_tdb.c ldb_search.c ldb_index.c + ldb_cache.c ldb_tdb_wrap.c'''), + private_library=True, + deps='tdb ldb') + # have a separate subsystem for common/ldb.c, so it can rebuild # for install with a different -DLDB_MODULESDIR= bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN', -- 2.34.1