summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-22 23:22:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:19:15 -0500
commit58619eebc10cf3e1828f8ecad1362d98ca4e9845 (patch)
treeb120fcc7d8f9076e131e53aa7ca61f8cbc9413b1 /source4/lib/ldb/ldb_tdb
parent6c86ed60fc6111f3f0091e5dadbc70b39d6cfb93 (diff)
downloadsamba-58619eebc10cf3e1828f8ecad1362d98ca4e9845.tar.gz
samba-58619eebc10cf3e1828f8ecad1362d98ca4e9845.tar.bz2
samba-58619eebc10cf3e1828f8ecad1362d98ca4e9845.zip
r18831: minor build changes for samba3. The logging changes will be removed
when the tdb api is updated (This used to be commit 6ace943fac101839e35cbc83dc54fde2068f704b)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.h5
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c25
2 files changed, 28 insertions, 2 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index 7b98b9ddee..670d3b6801 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -1,7 +1,12 @@
#ifdef _SAMBA_BUILD_
#include "system/filesys.h"
+#endif
+
+#if (_SAMBA_BUILD_ >= 4)
#include "lib/tdb/include/tdb.h"
+#elif defined(_SAMBA_BUILD_)
+#include "tdb/include/tdb.h"
#else
#include "tdb.h"
#endif
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
index df9cac1307..7f81949fdc 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
@@ -58,6 +58,7 @@ static int ltdb_wrap_destructor(struct ltdb_wrap *w)
return 0;
}
+#if (_SAMBA_BUILD_ >= 4)
static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
{
@@ -90,7 +91,22 @@ static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, con
ldb_debug(ldb, ldb_level, "ltdb: tdb(%s): %s", name, message);
talloc_free(message);
}
-
+#else
+static void ltdb_log_fn(struct tdb_context *tdb, int level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+static void ltdb_log_fn(struct tdb_context *tdb, int level, const char *fmt, ...)
+{
+ /* until we merge the tdb debug changes into samba3, we don't know
+ how serious the error is, and we can't go via the ldb loggin code */
+ va_list ap;
+ const char *name = tdb_name(tdb);
+ char *message;
+ va_start(ap, fmt);
+ message = talloc_vasprintf(NULL, fmt, ap);
+ va_end(ap);
+ DEBUG(3, ("ltdb: tdb(%s): %s", name, message));
+ talloc_free(message);
+}
+#endif
/*
wrapped connection to a tdb database. The caller should _not_ free
@@ -106,9 +122,14 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
{
struct ltdb_wrap *w;
struct stat st;
+#if (_SAMBA_BUILD_ >= 4)
struct tdb_logging_context log_ctx;
+ struct tdb_logging_context log_ctx_p = &log_ctx;
log_ctx.log_fn = ltdb_log_fn;
log_ctx.log_private = ldb;
+#else
+ tdb_log_func log_ctx_p = ltdb_log_fn;
+#endif
if (stat(path, &st) == 0) {
for (w=tdb_list;w;w=w->next) {
@@ -124,7 +145,7 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
return NULL;
}
- w->tdb = tdb_open_ex(path, hash_size, tdb_flags, open_flags, mode, &log_ctx, NULL);
+ w->tdb = tdb_open_ex(path, hash_size, tdb_flags, open_flags, mode, log_ctx_p, NULL);
if (w->tdb == NULL) {
talloc_free(w);
return NULL;