From 68293565de0b799dcc51e001dabf53adf88ee7ad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 09:55:05 +0000 Subject: r513: added a generic ldb debug system to allow the Samba debug functions to be cleanly interfaced to ldb (This used to be commit 74b89d5f960d6b936751e3f057b4540eb80b79cd) --- source4/lib/ldb/include/ldb.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 852389d415..adb6c31952 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -152,6 +152,21 @@ struct ldb_alloc_ops { void *context; }; +/* debugging uses one of the following levels */ +enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, + LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; + +/* + the user can optionally supply a debug function. The function + is based on the vfprintf() style of interface, but with the addition + of a severity level +*/ +struct ldb_debug_ops { + void (*debug)(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap); + void *context; +}; + /* every ldb connection is started by establishing a ldb_context @@ -165,6 +180,9 @@ struct ldb_context { /* memory allocation info */ struct ldb_alloc_ops alloc_ops; + + /* memory allocation info */ + struct ldb_debug_ops debug_ops; }; @@ -308,6 +326,17 @@ int ldb_set_alloc(struct ldb_context *ldb, void *(*alloc)(void *context, void *ptr, size_t size), void *context); +/* + this allows the user to set a debug function for error reporting +*/ +int ldb_set_debug(struct ldb_context *ldb, + void (*debug)(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap), + void *context); + +/* this sets up debug to print messages on stderr */ +int ldb_set_debug_stderr(struct ldb_context *ldb); + /* these are used as type safe versions of the ldb allocation functions */ #define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -- cgit