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 \
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
#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
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;
#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"
* 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;
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
*/
--- /dev/null
+/*
+ * 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;
+}