diff options
author | Volker Lendecke <vl@samba.org> | 2009-06-12 14:50:46 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-06-12 15:04:21 +0200 |
commit | a36a3e4c838275d33b2ed087b037ed3708b04749 (patch) | |
tree | 37b0c957a77ba7e2b7ecdee6088d326242b0714b /source3/lib | |
parent | 718f9be8a2530a11e1cb16b68511b4c910a1c320 (diff) | |
download | samba-a36a3e4c838275d33b2ed087b037ed3708b04749.tar.gz samba-a36a3e4c838275d33b2ed087b037ed3708b04749.tar.bz2 samba-a36a3e4c838275d33b2ed087b037ed3708b04749.zip |
Add debugging facility to tldap, analogous to tevent
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/tldap.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c index df86f95e2c..c823f88d04 100644 --- a/source3/lib/tldap.c +++ b/source3/lib/tldap.c @@ -59,6 +59,11 @@ struct tldap_context { char *res_matcheddn; char *res_diagnosticmessage; char *res_referral; + + /* debug */ + void (*log_fn)(void *context, enum tldap_debug_level level, + const char *fmt, va_list ap); + void *log_private; }; struct tldap_message { @@ -72,6 +77,33 @@ struct tldap_message { struct tldap_attribute *attribs; }; +void tldap_set_debug(struct tldap_context *ld, + void (*log_fn)(void *log_private, + enum tldap_debug_level level, + const char *fmt, + va_list ap) PRINTF_ATTRIBUTE(3,0), + void *log_private) +{ + ld->log_fn = log_fn; + ld->log_private = log_private; +} + +static void tldap_debug(struct tldap_context *ld, + enum tldap_debug_level level, + const char *fmt, ...) +{ + va_list ap; + if (!ld) { + return; + } + if (ld->log_fn == NULL) { + return; + } + va_start(ap, fmt); + ld->log_fn(ld->log_private, level, fmt, ap); + va_end(ap); +} + static int tldap_next_msgid(struct tldap_context *ld) { int result; |