Skip to content
Snippets Groups Projects
Commit 7eec2674 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Add lber_log_print support to libldap.

Redefine Debug macro to call ldap_log_printf(NULL, lvl, fmt, ...)
Should replace each Debug statement with direct call to ldap_log_printf
passing LDAP session if available.
parent f988fdbe
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ SRCS = bind.c open.c result.c error.c compare.c search.c \
free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
getdn.c getentry.c getattr.c getvalues.c addentry.c \
request.c getdxbyname.c os-ip.c url.c charset.c \
init.c options.c string.c util-int.c
init.c options.c print.c string.c util-int.c
OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
controls.lo messages.lo references.lo \
modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
......@@ -23,7 +23,7 @@ OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
init.lo options.lo string.lo util-int.lo
init.lo options.lo print.lo string.lo util-int.lo
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
......
......@@ -15,7 +15,7 @@
#include "ldap-int.h"
#include "ldapconfig.h"
struct ldapoptions openldap_ldap_global_options;
struct ldapoptions openldap_ldap_global_options = { LDAP_DEBUG_NONE };
#undef gopts
#define gopts openldap_ldap_global_options
......@@ -284,9 +284,9 @@ void openldap_ldap_initialize( void )
if ( openldap_ldap_initialized ) {
return;
}
ldap_pvt_init_utils();
gopts.ldo_version = LDAP_VERSION2;
gopts.ldo_deref = LDAP_DEREF_NEVER;
gopts.ldo_timelimit = LDAP_NO_LIMIT;
......
......@@ -19,6 +19,9 @@
#include "../liblber/lber-int.h"
#define ldap_debug (openldap_ldap_global_options.ldo_debug)
#undef Debug
#define Debug( level, fmt, arg1, arg2, arg3 ) \
ldap_log_printf( NULL, (level), (fmt), (arg1), (arg2), (arg3) )
#include "ldap_log.h"
......@@ -76,13 +79,13 @@ struct ldapmsg {
* which have global defaults.
*/
struct ldapoptions {
int ldo_debug;
int ldo_version; /* version to connect at */
int ldo_deref;
int ldo_timelimit;
int ldo_sizelimit;
int ldo_debug;
int ldo_defport;
char* ldo_defbase;
char* ldo_defhost;
......@@ -239,6 +242,11 @@ extern int openldap_ldap_initialized;
extern struct ldapoptions openldap_ldap_global_options;
void openldap_ldap_initialize LDAP_P((void));
/*
* in print.c
*/
int ldap_log_printf LDAP_P((LDAP *ld, int level, char *fmt, ...));
/*
* in cache.c
*/
......
/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/ctype.h>
#include <ac/stdarg.h>
#include <ac/string.h>
#include <ac/time.h>
#include "ldap-int.h"
extern BER_LOG_PRINT_FN lber_log_print;
/*
* ldap log
*/
static int ldap_log_check( LDAP *ld, int loglvl )
{
int errlvl;
if(ld == NULL) {
errlvl = ldap_debug;
} else {
errlvl = ld->ld_errno;
}
return errlvl & loglvl ? 1 : 0;
}
int ldap_log_printf
#ifdef HAVE_STDARG
( LDAP *ld, int loglvl, char *fmt, ... )
#else
( va_alist )
va_dcl
#endif
{
char buf[ 1024 ];
va_list ap;
#ifdef HAVE_STDARG
va_start( ap, fmt );
#else
LD *ld
int loglvl;
char *fmt;
va_start( ap );
errlvl = va_arg( ap, LD * );
loglvl = va_arg( ap, int );
fmt = va_arg( ap, char * );
#endif
if ( !ldap_log_check( ld, loglvl )) {
return 0;
}
#ifdef HAVE_VSNPRINTF
buf[sizeof(buf) - 1] = '\0';
vsnprintf( buf, sizeof(buf)-1, fmt, ap );
#elif HAVE_VSPRINTF
vsprintf( buf, fmt, ap ); /* hope it's not too long */
#else
/* use doprnt() */
chokeme = "choke me! I don't have a doprnt manual handy!";
#endif
va_end(ap);
(*lber_log_print)( buf );
return 1;
}
static int lber_log_puts(int errlvl, int loglvl, char *buf)
{
if ( !ldap_log_check( errlvl, loglvl )) {
return 0;
}
(*lber_log_print)( buf );
return 1;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment