summaryrefslogtreecommitdiff
path: root/source4/lib/tdb/common/open.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-07-10 12:51:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:59 -0500
commit35fda6c5f344e71b1ed0bd195a62161e31401149 (patch)
tree6fd96d68dceac6bdde0ddf557b66103207e7be33 /source4/lib/tdb/common/open.c
parentbfc02627ceb02046fb23c62f28dc69765c8aa8f0 (diff)
downloadsamba-35fda6c5f344e71b1ed0bd195a62161e31401149.tar.gz
samba-35fda6c5f344e71b1ed0bd195a62161e31401149.tar.bz2
samba-35fda6c5f344e71b1ed0bd195a62161e31401149.zip
r16916: Implement metze's proposed changes to the tdb logging API.
This clearly links the log function with its private pointer, and makes the argument list for tdb_open_ex a bit shorter. Andrew Bartlett (This used to be commit 5d5503e8d8a10ead3ef21a5ffda52cadb9a07727)
Diffstat (limited to 'source4/lib/tdb/common/open.c')
-rw-r--r--source4/lib/tdb/common/open.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/source4/lib/tdb/common/open.c b/source4/lib/tdb/common/open.c
index 6332e34f13..ff4b38e41a 100644
--- a/source4/lib/tdb/common/open.c
+++ b/source4/lib/tdb/common/open.c
@@ -119,7 +119,7 @@ static int tdb_already_open(dev_t device,
struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode)
{
- return tdb_open_ex(name, hash_size, tdb_flags, open_flags, mode, NULL, NULL, NULL);
+ return tdb_open_ex(name, hash_size, tdb_flags, open_flags, mode, NULL, NULL);
}
/* a default logging function */
@@ -131,7 +131,7 @@ static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, con
struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode,
- tdb_log_func log_fn, void *log_private,
+ const struct tdb_logging_context *log_ctx,
tdb_hash_func hash_fn)
{
struct tdb_context *tdb;
@@ -151,8 +151,12 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
tdb->map_ptr = NULL;
tdb->flags = tdb_flags;
tdb->open_flags = open_flags;
- tdb->log_fn = log_fn?log_fn:null_log_fn;
- tdb->log_private = log_fn?log_private:NULL;
+ if (log_ctx) {
+ tdb->log = *log_ctx;
+ } else {
+ tdb->log.log_fn = null_log_fn;
+ tdb->log.log_private = NULL;
+ }
tdb->hash_fn = hash_fn ? hash_fn : default_tdb_hash;
/* cache the page size */
@@ -366,15 +370,15 @@ int tdb_close(struct tdb_context *tdb)
}
/* register a loging function */
-void tdb_logging_function(struct tdb_context *tdb, tdb_log_func log_fn, void *log_private)
+void tdb_set_logging_function(struct tdb_context *tdb,
+ const struct tdb_logging_context *log)
{
- tdb->log_fn = log_fn?log_fn:null_log_fn;
- tdb->log_private = log_fn?log_private:NULL;
+ tdb->log = *log;
}
-void *tdb_logging_private(struct tdb_context *tdb)
+void *tdb_get_logging_private(struct tdb_context *tdb)
{
- return tdb->log_private;
+ return tdb->log.log_private;
}
/* reopen a tdb - this can be used after a fork to ensure that we have an independent