Updated other codes as needed.
guidelines for developers
Client developers seeking a stable development platform
- should use -stable.
+ should use -stable or the latest OpenLDAP release.
OpenLDAP 1.1 README
## Makefile Template for Shared Libraries
##
-LINK = $(LTLINK) -version-info $(LIBVERSION)
+LTVERSION = -version-info $(LIBVERSION)
+LINK = $(LTLINK)
COMPILE = $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c
MKDEPFLAG = -l
LIBTOOL = @LIBTOOL@
LIBVERSION = 0:0:0
-LTLINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LFLAGS)
+LTLINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LFLAGS) $(LTVERSION)
LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
# Misc UNIX commands used in makefiles
#include "ldapconfig.h"
#include "lber.h"
#include "ldap.h"
+
+#define ldap_debug debug
#include "ldap_log.h"
+
#include "lutil.h"
#include "disptmpl.h"
break;
case 'd': /* debug level */
- debug = atoi( optarg );
+ debug |= atoi( optarg );
break;
case 'f': /* ldap filter file */
}
#endif /* FD_SETSIZE*/
-
/* detach if stderr is redirected or no debugging */
if ( inetd == 0 )
lutil_detach( debug && !isatty( 1 ), 1 );
else
myname = strdup( myname + 1 );
+ if ( debug ) {
+ lber_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
+ ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
+ }
+
if ( dosyslog ) {
#ifdef LOG_LOCAL3
openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
#include "lber.h"
#include "ldap.h"
+
+#define ldap_debug debug
#include "ldap_log.h"
+
#include "lutil.h"
#include "disptmpl.h"
break;
case 'd': /* debugging level */
- debug = atoi( optarg );
-#ifdef LDAP_DEBUG
- ldap_debug = debug;
-#else
- fprintf( stderr, "warning: ldap debugging requires LDAP_DEBUG\n" );
-#endif
+ debug |= atoi( optarg );
break;
case 'f': /* ldap filter file */
else
myname = strdup( myname + 1 );
+
+ if ( debug ) {
+ lber_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
+ ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
+ }
+
if ( dosyslog ) {
#ifdef LOG_LOCAL3
openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
char *usage = "usage: %s [-n] [-v] [-k] [-W] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
char buf[ 4096 ];
FILE *fp;
- int i, rc, authmethod, want_bindpw;
+ int i, rc, authmethod, want_bindpw, debug;
- not = verbose = contoper = want_bindpw = 0;
+ not = verbose = contoper = want_bindpw = debug = 0;
fp = NULL;
authmethod = LDAP_AUTH_SIMPLE;
}
break;
case 'd':
-#ifdef LDAP_DEBUG
- ldap_debug = lber_debug = atoi( optarg ); /* */
-#else /* LDAP_DEBUG */
- fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
-#endif /* LDAP_DEBUG */
+ debug |= atoi( optarg );
break;
case 'p':
ldapport = atoi( optarg );
}
}
+ if ( debug ) {
+ lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
+ ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
+ }
+
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
perror( "ldap_open" );
exit( 1 );
{
char *infile, *rbuf, *start, *p, *q;
FILE *fp;
- int rc, i, use_ldif, authmethod, want_bindpw;
+ int rc, i, use_ldif, authmethod, want_bindpw, debug;
char *usage = "usage: %s [-abcknrvWF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
new = ( strcmp( prog, "ldapadd" ) == 0 );
infile = NULL;
- not = verbose = valsfromfiles = want_bindpw = 0;
+ not = verbose = valsfromfiles = want_bindpw = debug = 0;
authmethod = LDAP_AUTH_SIMPLE;
while (( i = getopt( argc, argv, "WFabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
passwd = strdup( optarg );
break;
case 'd':
-#ifdef LDAP_DEBUG
- ldap_debug = lber_debug = atoi( optarg ); /* */
-#else /* LDAP_DEBUG */
- fprintf( stderr, "%s: compile with -DLDAP_DEBUG for debugging\n",
- prog );
-#endif /* LDAP_DEBUG */
+ debug |= atoi( optarg );
break;
case 'f': /* read from file */
infile = strdup( optarg );
fp = stdin;
}
+ if ( debug ) {
+ lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
+ ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
+ ldif_debug = debug;
+ }
if ( !not ) {
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
}
/* this seems prudent */
- ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
+ {
+ int deref = LDAP_DEREF_NEVER;
+ ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
+ }
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
char *usage = "usage: %s [-nvkWc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
char *myname,*infile, *entrydn, *rdn, buf[ 4096 ];
FILE *fp;
- int rc, i, remove, havedn, authmethod, want_bindpw;
+ int rc, i, remove, havedn, authmethod, want_bindpw, debug;
infile = NULL;
- not = contoper = verbose = remove = want_bindpw = 0;
+ not = contoper = verbose = remove = want_bindpw = debug = 0;
authmethod = LDAP_AUTH_SIMPLE;
myname = (myname = strrchr(argv[0], '/')) == NULL ? argv[0] : ++myname;
passwd = strdup( optarg );
break;
case 'd':
-#ifdef LDAP_DEBUG
- ldap_debug = lber_debug = atoi( optarg ); /* */
-#else /* LDAP_DEBUG */
- fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
-#endif /* LDAP_DEBUG */
+ debug |= atoi( optarg );
break;
case 'f': /* read from file */
infile = strdup( optarg );
fp = stdin;
}
+ if ( debug ) {
+ lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
+ ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
+ }
+
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
perror( "ldap_open" );
exit( 1 );
}
/* this seems prudent */
- ldap_set_option( ld, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
+ {
+ int deref = LDAP_DEREF_NEVER;
+ ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
+ }
if (want_bindpw)
passwd = getpass("Enter LDAP Password: ");
int hashtype = HASHTYPE_CRYPT;
int i, j;
int ldapport = 0;
+ int debug = 0;
int scope = LDAP_SCOPE_SUBTREE;
int sizelimit = LDAP_NO_LIMIT;
int timelimit = LDAP_NO_LIMIT;
break;
case 'd': /* debugging option */
-#ifdef LDAP_DEBUG
- ldap_debug = lber_debug = atoi (optarg); /* */
-#else
- fprintf (stderr, "compile with -DLDAP_DEBUG for debugging\n");
-#endif
+ debug |= atoi (optarg);
break;
case 'E': /* prompt for new password */
}
}
+ if ( debug ) {
+ lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
+ ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
+ }
+
/* connect to server */
if ((ld = ldap_open (ldaphost, ldapport)) == NULL)
{
ldap_set_option (ld, LDAP_OPT_TIMELIMIT, (void *)&timelimit);
ldap_set_option (ld, LDAP_OPT_SIZELIMIT, (void *)&sizelimit);
+ /* this seems prudent */
+ {
+ int deref = LDAP_DEREF_NEVER;
+ ldap_set_option( ld, LDAP_OPT_DEREF, &deref);
+ }
+
+
/* authenticate to server */
if (ldap_bind_s (ld, binddn, bindpw, authmethod) != LDAP_SUCCESS)
{
char *infile, *filtpattern, **attrs, line[ BUFSIZ ];
FILE *fp;
int rc, i, first, scope, deref, attrsonly;
- int referrals, timelimit, sizelimit, authmethod, want_bindpw;
+ int referrals, timelimit, sizelimit, debug;
+ int authmethod, want_bindpw;
LDAP *ld;
infile = NULL;
deref = verbose = allow_binary = not = vals2tmp =
attrsonly = ldif = want_bindpw = 0;
referrals = (int) LDAP_OPT_ON;
- sizelimit = timelimit = 0;
+ sizelimit = timelimit = debug = 0;
scope = LDAP_SCOPE_SUBTREE;
authmethod = LDAP_AUTH_SIMPLE;
++verbose;
break;
case 'd':
-#ifdef LDAP_DEBUG
- ldap_debug = lber_debug = atoi( optarg ); /* */
-#else /* LDAP_DEBUG */
- fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
-#endif /* LDAP_DEBUG */
+ debug |= atoi( optarg );
break;
case 'k': /* use kerberos bind */
#ifdef HAVE_KERBEROS
printf( "ldap_open( %s, %d )\n", ldaphost, ldapport );
}
+ if ( debug ) {
+ lber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug );
+ ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug );
+ ldif_debug = debug;
+ }
+
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) {
perror( ldaphost );
exit( 1 );
#ifdef DEBUG
int debug; /* debug flag */
#endif
+int ldebug; /* library debug flag */
int
while ((c = getopt(argc, argv, "c:d:Df:l:p:s:u:vV")) != -1) {
switch (c) {
case 'l' :
-#ifdef LDAP_DEBUG
- ldap_debug = (int) strtol(optarg, (char **) NULL, 0);
- lber_debug = ldap_debug;
-#endif
+ ldebug |= (int) strtol(optarg, (char **) NULL, 0);
break;
case 'd' :
#ifdef DEBUG
- debug = (int) strtol(optarg, (char **) NULL, 0);
+ debug |= (int) strtol(optarg, (char **) NULL, 0);
#endif
break;
case 's' :
if (debug & D_TRACE)
printf("->initialize_client()\n");
#endif
+
+ if (ldebug) {
+ lber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &ldebug);
+ ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldebug);
+ }
+
/*
* A per-user config file has precedence over any system-wide
* config file, if one exists.
ol_enable_syslog=no
dnl OL_ARG_ENABLE(syslog,[ --enable-syslog enable syslog support], auto)dnl
OL_ARG_ENABLE(proctitle,[ --enable-proctitle enable proctitle support], yes)dnl
-OL_ARG_ENABLE(libui,[ --enable-libui enable library user interface], yes)dnl
OL_ARG_ENABLE(cache,[ --enable-cache enable caching], yes)dnl
OL_ARG_ENABLE(dns,[ --enable-dns enable V2 DNS extension], no)dnl
OL_ARG_ENABLE(referrals,[ --enable-referrals enable V2 Referrals extension], yes)dnl
Modify libraries to use application specified memory allocation routines
Extend configure.in to support autodetect of ISODE features.
Port slurpd to NT
+Update manual page
Small projects
.LP
.nf
.ft B
-typedef struct berelement {
- char *ber_buf;
- char *ber_ptr;
- char *ber_end;
- struct seqorset *ber_sos;
- int ber_tag;
- int ber_usertag;
-} BerElement;
+typedef struct berelement BerElement;
.ft
.fi
.LP
.nf
.ft B
-typedef struct sockbuf {
- int sb_sd;
- BerElement sb_ber;
-} Sockbuf;
+typedef struct sockbuf Sockbuf;
.ft
.fi
.LP
--- /dev/null
+ber_get_next.3
+ber_skip_tag.3
+ber_peek_tag.3
+ber_scanf.3
+ber_get_int.3
+ber_get_stringa.3
+ber_get_stringb.3
+ber_get_null.3
+ber_get_boolean.3
+ber_get_bitstring.3
+ber_first_element.3
+ber_next_element.3
.LP
.nf
.ft B
-typedef struct berelement {
- char *ber_buf;
- char *ber_ptr;
- char *ber_end;
- struct seqorset *ber_sos;
- int ber_tag;
- int ber_usertag;
-} BerElement;
+typedef struct berelement BerElement;
.ft
.fi
.LP
.nf
.ft B
-typedef struct sockbuf {
- int sb_sd;
- BerElement sb_ber;
-} Sockbuf;
+typedef struct sockbuf Sockbuf;
.ft
.fi
.LP
--- /dev/null
+ber_alloc.3
+ber_flush.3
+ber_printf.3
+ber_put_int.3
+ber_put_ostring.3
+ber_put_string.3
+ber_put_null.3
+ber_start_set.3
+ber_put_seq.3
+ber_put_set.3
#define OLD_LBER_SEQUENCE 0x10L /* w/o constructed bit - broken */
#define OLD_LBER_SET 0x11L /* w/o constructed bit - broken */
-/* get/set options for BerElement */
-#define LBER_SOCKBUF_OPT_TO_FILE 0x01
-#define LBER_SOCKBUF_OPT_TO_FILE_ONLY 0x02
-#define LBER_SOCKBUF_OPT_TO_MAX_INCOMING_SIZE 0x04
-#define LBER_SOCKBUF_OPT_TO_NO_READ_AHEAD 0x08
-#define LBER_SOCKBUF_OPT_TO_DESC 0x10
-#define LBER_SOCKBUF_OPT_TO_COPYDESC 0x20
-#define LBER_SOCKBUF_OPT_TO_READFN 0x40
-#define LBER_SOCKBUF_OPT_TO_WRITE_FN 0x80
-
-/* LBER on/off values */
-#define LBER_OPT_ON ((void *) 1)
-#define LBER_OPT_OFF ((void *) 0)
-
typedef int (*BERTranslateProc) LDAP_P(( char **bufp,
unsigned long *buflenp,
int free_input ));
+/* LBER BerElement options */
#define LBER_USE_DER 0x01
#define LBER_USE_INDEFINITE_LEN 0x02
#define LBER_TRANSLATE_STRINGS 0x04
+/* get/set options for BerElement */
+#define LBER_OPT_BER_OPTIONS 0x01
+#define LBER_OPT_BER_DEBUG 0x02
+#define LBER_OPT_DEBUG_LEVEL LBER_OPT_BER_DEBUG
+
+/* LBER Sockbuf options */
+#define LBER_TO_FILE 0x01 /* to a file referenced by sb_fd */
+#define LBER_TO_FILE_ONLY 0x02 /* only write to file, not network */
+#define LBER_MAX_INCOMING_SIZE 0x04 /* impose limit on incoming stuff */
+#define LBER_NO_READ_AHEAD 0x08 /* read only as much as requested */
+
+/* get/set options for Sockbuf */
+#define LBER_OPT_SOCKBUF_DESC 0x1000
+#define LBER_OPT_SOCKBUF_OPTIONS 0x1001
+#define LBER_OPT_SOCKBUF_DEBUG 0x1002
+
+/* on/off values */
+#define LBER_OPT_ON ((void *) 1)
+#define LBER_OPT_OFF ((void *) 0)
+
+#define LBER_OPT_SUCCESS 0
+#define LBER_OPT_ERROR (-1)
+
typedef struct berelement BerElement;
#define NULLBER ((BerElement *) 0)
typedef struct sockbuf Sockbuf;
-#define READBUFSIZ 8192
typedef struct seqorset Seqorset;
#define NULLSEQORSET ((Seqorset *) 0)
char *bv_val;
};
-#ifdef LDAP_DEBUG
-extern int lber_debug;
-#endif
-
/*
* in bprint.c:
*/
LDAP_F void ber_print_error LDAP_P(( char *data ));
LDAP_F void ber_bprint LDAP_P(( char *data, int len ));
-#define lber_bprint(d,l) ber_bprint((d),(l))
+#define lber_bprint(d,l) ber_bprint((d),(l))
+
+LDAP_F void ber_dump LDAP_P(( BerElement *ber, int inout ));
+LDAP_F void ber_sos_dump LDAP_P(( Seqorset *sos ));
+
/*
* in decode.c:
LDAP_F BerElement *der_alloc LDAP_P(( void ));
LDAP_F BerElement *ber_alloc_t LDAP_P(( int options ));
LDAP_F BerElement *ber_dup LDAP_P(( BerElement *ber ));
-LDAP_F void ber_dump LDAP_P(( BerElement *ber, int inout ));
-LDAP_F void ber_sos_dump LDAP_P(( Seqorset *sos ));
LDAP_F unsigned long ber_get_next LDAP_P(( Sockbuf *sb, unsigned long *len,
BerElement *ber ));
LDAP_F void ber_init_w_nullc LDAP_P(( BerElement *ber, int options ));
LDAP_F void ber_reset LDAP_P(( BerElement *ber, int was_writing ));
/*
- * LDAP draft-ietf-ldapext-ldap-c-api-01 routines
+ * LBER draft-ietf-ldapext-ldap-c-api-01 routines
*/
LDAP_F BerElement *ber_init LDAP_P(( struct berval *bv ));
LDAP_F int ber_flatten LDAP_P(( BerElement *ber, struct berval **bvPtr ));
+/*
+ * LBER ber accessor functions
+ */
+LDAP_F int
+lber_get_option LDAP_P((void *item, int option, void *outvalue));
+
+LDAP_F int
+lber_set_option LDAP_P((void *item, int option, void *invalue));
+
+/*
+ * LBER Sockbuf functions
+ */
+LDAP_F Sockbuf *lber_sockbuf_alloc LDAP_P((void));
+LDAP_F Sockbuf *lber_sockbuf_alloc_fd LDAP_P((int fd));
+LDAP_F void lber_sockbuf_free LDAP_P((Sockbuf *sb));
+
LDAP_END_DECL
#endif /* _LBER_H */
/* for LDAPv2 compatibility */
#define LDAP_OPT_DNS 0x1001 /* use DN & DNS */
+/* OpenLDAP specific options */
+#define LDAP_OPT_DEBUG_LEVEL 0x4001 /* OpenLDAP - debug level */
+
/* on/off values */
#define LDAP_OPT_ON ((void *) 1)
#define LDAP_OPT_OFF ((void *) 0)
#define LDAP_OPT_SUCCESS 0
#define LDAP_OPT_ERROR (-1)
-#ifdef LDAP_DEBUG
-extern int ldap_debug;
-#endif
-
#define LDAP_API_INFO_VERSION 1
typedef struct ldapapiinfo {
int ldapai_info_version; /* version of LDAPAPIInfo (1) */
/* debugging stuff */
#ifdef LDAP_DEBUG
+
+#ifndef ldap_debug
extern int ldap_debug;
+#endif /* !ldap_debug */
+
#ifdef LDAP_SYSLOG
extern int ldap_syslog;
extern int ldap_syslog_level;
#endif /* LDAP_SYSLOG */
-#define LDAP_DEBUG_TRACE 0x001
-#define LDAP_DEBUG_PACKETS 0x002
-#define LDAP_DEBUG_ARGS 0x004
-#define LDAP_DEBUG_CONNS 0x008
-#define LDAP_DEBUG_BER 0x010
-#define LDAP_DEBUG_FILTER 0x020
-#define LDAP_DEBUG_CONFIG 0x040
-#define LDAP_DEBUG_ACL 0x080
-#define LDAP_DEBUG_STATS 0x100
-#define LDAP_DEBUG_STATS2 0x200
-#define LDAP_DEBUG_SHELL 0x400
-#define LDAP_DEBUG_PARSE 0x800
-#define LDAP_DEBUG_ANY 0xffff
+#define LDAP_DEBUG_TRACE 0x0001
+#define LDAP_DEBUG_PACKETS 0x0002
+#define LDAP_DEBUG_ARGS 0x0004
+#define LDAP_DEBUG_CONNS 0x0008
+#define LDAP_DEBUG_BER 0x0010
+#define LDAP_DEBUG_FILTER 0x0020
+#define LDAP_DEBUG_CONFIG 0x0040
+#define LDAP_DEBUG_ACL 0x0080
+#define LDAP_DEBUG_STATS 0x0100
+#define LDAP_DEBUG_STATS2 0x0200
+#define LDAP_DEBUG_SHELL 0x0400
+#define LDAP_DEBUG_PARSE 0x0800
+
+#define LDAP_DEBUG_NONE 0x8000
+#define LDAP_DEBUG_ANY -1
/* this doesn't below as part of ldap.h */
#ifdef LDAP_SYSLOG
LDAP_BEGIN_DECL
+extern int ldif_debug;
+
#define LINE_WIDTH 76 /* maximum length of LDIF lines */
/*
LIBRARY = liblber.la
XLIBRARY = ../liblber.a
-SRCS= decode.c encode.c io.c bprint.c
-OBJS= decode.lo encode.lo io.lo bprint.lo
+SRCS= decode.c encode.c io.c bprint.c options.c
+OBJS= decode.lo encode.lo io.lo bprint.lo options.lo
XSRCS= version.c
PROGRAMS= dtest etest idtest
#include <stdio.h>
-#if defined( LDAP_DEBUG ) && defined( LDAP_LIBUI )
#include <ac/ctype.h>
-#endif /* LDAP_DEBUG && LDAP_LIBUI */
+#include <ac/stdarg.h>
#include <ac/string.h>
#include "lber-int.h"
/*
* Print stuff
*/
-void
-ber_print_error( char *data)
+static void
+lber_print_error( char *data )
{
fputs( data, stderr );
fflush( stderr );
}
+/*
+ * lber log
+ */
+
+static int lber_log_check( int errlvl, int loglvl )
+{
+ return errlvl & loglvl ? 1 : 0;
+}
+
+int lber_log_printf
+#ifdef HAVE_STDARG
+ (int errlvl, int loglvl, char *fmt, ...)
+#else
+ ( va_alist )
+va_dcl
+#endif
+{
+ char buf[ 1024 ];
+ va_list ap;
+
+#ifdef HAVE_STDARG
+ va_start( ap, fmt );
+#else
+ int errlvl, loglvl;
+ char *fmt;
+
+ va_start( ap );
+
+ errlvl = va_arg( ap, int );
+ loglvl = va_arg( ap, int );
+ fmt = va_arg( ap, char * );
+#endif
+
+ if ( !lber_log_check( errlvl, loglvl )) {
+ return 0;
+ }
+
+#ifdef HAVE_VSNPRINTF
+ buf[sizeof(buf) - 1] = '\0';
+ vsnprintf( buf, sizeof(buf)-1, fmt, ap );
+#elif
+ 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_print_error( buf );
+ return 1;
+}
+
+static int lber_log_puts(int errlvl, int loglvl, char *buf)
+{
+ if ( !lber_log_check( errlvl, loglvl )) {
+ return 0;
+ }
+
+ lber_print_error( buf );
+ return 1;
+}
+
/*
* Print arbitrary stuff, for debugging.
*/
-void
-ber_bprint( char *data, int len )
+int
+lber_log_bprint(int errlvl, int loglvl, char *data, int len )
{
-#if defined( LDAP_DEBUG ) && defined( LDAP_LIBUI )
-#define BPLEN 48
+ if ( !lber_log_check( errlvl, loglvl )) {
+ return 0;
+ }
+ ber_bprint(data, len);
+ return 1;
+}
+
+void
+ber_bprint(char *data, int len )
+{
static char hexdig[] = "0123456789abcdef";
+#define BPLEN 48
char out[ BPLEN ];
+ char buf[ BPLEN + sizeof("\t%s\n") ];
int i = 0;
memset( out, 0, BPLEN );
for ( ;; ) {
if ( len < 1 ) {
- fprintf( stderr, "\t%s\n", ( i == 0 ) ? "(end)" : out );
+ sprintf( buf, "\t%s\n", ( i == 0 ) ? "(end)" : out );
+ lber_print_error( buf );
break;
}
-#ifndef HEX
+#ifndef LDAP_HEX
if ( isgraph( (unsigned char)*data )) {
out[ i ] = ' ';
out[ i+1 ] = *data;
#endif
out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
out[ i+1 ] = hexdig[ *data & 0x0f ];
-#ifndef HEX
+#ifndef LDAP_HEX
}
#endif
i += 2;
if ( i > BPLEN - 2 ) {
char data[128 + BPLEN];
sprintf( data, "\t%s\n", out );
- ber_print_error(data);
+ lber_print_error(data);
memset( out, 0, BPLEN );
i = 0;
continue;
}
out[ i++ ] = ' ';
}
+}
+
+int
+lber_log_dump( int errlvl, int loglvl, BerElement *ber, int inout )
+{
+ if ( !lber_log_check( errlvl, loglvl )) {
+ return 0;
+ }
+
+ ber_dump(ber, inout);
+ return 1;
+}
+
+void
+ber_dump( BerElement *ber, int inout )
+{
+ char buf[132];
+
+ sprintf( buf, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n",
+ (long) ber->ber_buf,
+ (long) ber->ber_ptr,
+ (long) ber->ber_end );
+
+ lber_print_error( buf );
+
+ if ( inout == 1 ) {
+ sprintf( buf, " current len %ld, contents:\n",
+ (long) (ber->ber_end - ber->ber_ptr) );
+ ber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr );
+
+ } else {
+ sprintf( buf, " current len %ld, contents:\n",
+ (long) (ber->ber_ptr - ber->ber_buf) );
+
+ ber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf );
+ }
+}
+
+int
+lber_log_sos_dump( int errlvl, int loglvl, Seqorset *sos )
+{
+ if ( !lber_log_check( errlvl, loglvl )) {
+ return 0;
+ }
+
+ ber_sos_dump( sos );
+ return 1;
+}
+
+void
+ber_sos_dump( Seqorset *sos )
+{
+ char buf[132];
+
+ lber_print_error( "*** sos dump ***\n" );
+
+ while ( sos != NULLSEQORSET ) {
+ sprintf( buf, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n",
+ (long) sos->sos_clen, (long) sos->sos_first, (long) sos->sos_ptr );
+ lber_print_error( buf );
+
+ sprintf( buf, " current len %ld contents:\n",
+ (long) (sos->sos_ptr - sos->sos_first) );
+ lber_print_error( buf );
+
+ ber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first );
+
+ sos = sos->sos_next;
+ }
-#endif /* LDAP_DEBUG && LDAP_LIBUI */
+ lber_print_error( "*** end dump ***\n" );
}
#include "lber-int.h"
-#ifdef LDAP_DEBUG
-int lber_debug;
-#endif
-
static int ber_getnint LDAP_P(( BerElement *ber, long *num, int len ));
/* return the tag - LBER_DEFAULT returned means trouble */
fmt = va_arg( ap, char * );
#endif
-#ifdef LDAP_DEBUG
- if ( lber_debug & 64 ) {
- fprintf( stderr, "ber_scanf fmt (%s) ber:\n", fmt );
- ber_dump( ber, 1 );
+ if ( ber->ber_debug ) {
+ lber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug,
+ "ber_scanf fmt (%s) ber:\n", fmt );
+ lber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 );
}
-#endif
for ( rc = 0; *fmt && rc != LBER_DEFAULT; fmt++ ) {
switch ( *fmt ) {
break;
default:
-#ifdef LDAP_LIBUI
- fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* LDAP_LIBUI */
+ if( ber->ber_debug ) {
+ lber_log_printf( LDAP_DEBUG_ANY, ber->ber_debug,
+ "ber_scanf: unknown fmt %c\n", *fmt );
+ }
rc = LBER_DEFAULT;
break;
}
#include <console.h>
#endif /* MACOS */
-#include "lber-int.h"
+#include <lber.h>
static void usage( char *name )
{
long i;
unsigned long len;
int tag;
- BerElement ber;
- Sockbuf sb;
+ BerElement *ber;
+ Sockbuf *sb;
#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
#endif /* MACOS */
- memset( &sb, 0, sizeof(sb) );
- sb.sb_sd = 0;
- sb.sb_ber.ber_buf = NULL;
+ sb = lber_sockbuf_alloc_fd( fileno(stdin) );
- if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
+ if( (ber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
+ perror( "ber_alloc_t" );
+ exit( 1 );
+ }
+
+ if ( (tag = ber_get_next( sb, &len, ber )) == -1 ) {
perror( "ber_get_next" );
exit( 1 );
}
printf( "message has tag 0x%x and length %ld\n", tag, len );
- if ( ber_scanf( &ber, "i", &i ) == -1 ) {
+ if ( ber_scanf( ber, "i", &i ) == -1 ) {
fprintf( stderr, "ber_scanf returns -1\n" );
exit( 1 );
}
printf( "got int %ld\n", i );
+ lber_sockbuf_free( sb );
return( 0 );
}
break;
default:
-#ifdef LDAP_LIBUI
- fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* LDAP_LIBUI */
+ if( ber->ber_debug ) {
+ lber_log_printf( LDAP_DEBUG_ANY, ber->ber_debug,
+ "ber_printf: unknown fmt %c\n", *fmt );
+ }
rc = -1;
break;
}
#include <console.h>
#endif /* HAVE_CONSOLE_H */
-#include "lber-int.h"
+#include <lber.h>
static void usage( char *name )
{
int i, len;
char *s, *p;
#endif
- int num;
+ int fd, num;
Seqorset *sos = NULLSEQORSET;
BerElement *ber;
- Sockbuf sb;
+ Sockbuf *sb;
if ( argc < 2 ) {
usage( argv[0] );
exit( 1 );
}
- memset( &sb, 0, sizeof(sb) );
- sb.sb_sd = 1;
- sb.sb_ber.ber_buf = NULL;
#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
- if (( sb.sb_sd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY ))
+ if (( fd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY ))
< 0 ) {
perror( "open" );
exit( 1 );
}
+#else
+ fd = fileno(stdout);
#endif /* MACOS */
+ sb = lber_sockbuf_alloc_fd( fd );
+
if ( (ber = ber_alloc()) == NULLBER ) {
perror( "ber_alloc" );
exit( 1 );
exit( 1 );
}
- if ( ber_flush( &sb, ber, 1 ) == -1 ) {
+ if ( ber_flush( sb, ber, 1 ) == -1 ) {
perror( "ber_flush" );
exit( 1 );
}
#endif
+ lber_sockbuf_free( sb );
return( 0 );
}
if ( sb->sb_naddr > 0 ) {
#ifdef LDAP_CONNECTIONLESS
rc = udp_read(sb, sb->sb_ber.ber_buf, READBUFSIZ, addrlen );
-#ifdef LDAP_DEBUG
- if ( lber_debug ) {
- fprintf( stderr, "ber_filbuf udp_read %d bytes\n",
- rc );
- if ( lber_debug > 1 && rc > 0 )
- lber_bprint( sb->sb_ber.ber_buf, rc );
+
+ if ( sb->sb_debug ) {
+ lber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug,
+ "ber_filbuf udp_read %d bytes\n",
+ rc );
+ if ( rc > 0 )
+ lber_log_bprint( LDAP_DEBUG_PACKETS, sb->sb_debug,
+ sb->sb_ber.ber_buf, rc );
}
-#endif /* LDAP_DEBUG */
#else /* LDAP_CONNECTIONLESS */
rc = -1;
#endif /* LDAP_CONNECTIONLESS */
}
towrite = ber->ber_ptr - ber->ber_rwptr;
-#ifdef LDAP_DEBUG
- if ( lber_debug ) {
- fprintf( stderr, "ber_flush: %ld bytes to sd %ld%s\n", towrite,
+ if ( sb->sb_debug ) {
+ lber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug,
+ "ber_flush: %ld bytes to sd %ld%s\n", towrite,
(long) sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)"
: "" );
- if ( lber_debug > 1 )
- lber_bprint( ber->ber_rwptr, towrite );
+ lber_log_bprint( LDAP_DEBUG_PACKETS, sb->sb_debug,
+ ber->ber_rwptr, towrite );
}
-#endif
+
#if !defined(MACOS) && !defined(DOS)
if ( sb->sb_options & (LBER_TO_FILE | LBER_TO_FILE_ONLY) ) {
rc = write( sb->sb_fd, ber->ber_buf, towrite );
if ( (ber = (BerElement *) calloc( 1, sizeof(BerElement) )) == NULLBER )
return( NULLBER );
ber->ber_tag = LBER_DEFAULT;
- ber->ber_options = (char) options;
+ ber->ber_options = options;
+ ber->ber_debug = lber_int_debug;
return( ber );
}
ber->ber_rwptr = NULL;
}
-
-#ifdef LDAP_DEBUG
-
-void
-ber_dump( BerElement *ber, int inout )
-{
- fprintf( stderr, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n",
- (long) ber->ber_buf,
- (long) ber->ber_ptr,
- (long) ber->ber_end );
- if ( inout == 1 ) {
- fprintf( stderr, " current len %ld, contents:\n",
- (long) (ber->ber_end - ber->ber_ptr) );
- lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr );
- } else {
- fprintf( stderr, " current len %ld, contents:\n",
- (long) (ber->ber_ptr - ber->ber_buf) );
- lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf );
- }
-}
-
-void
-ber_sos_dump( Seqorset *sos )
-{
- fprintf( stderr, "*** sos dump ***\n" );
- while ( sos != NULLSEQORSET ) {
- fprintf( stderr, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n",
- (long) sos->sos_clen, (long) sos->sos_first, (long) sos->sos_ptr );
- fprintf( stderr, " current len %ld contents:\n",
- (long) (sos->sos_ptr - sos->sos_first) );
- lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first );
-
- sos = sos->sos_next;
- }
- fprintf( stderr, "*** end dump ***\n" );
-}
-
-#endif
-
/* return the tag - LBER_DEFAULT returned means trouble */
static unsigned long
get_tag( Sockbuf *sb )
long noctets;
unsigned int diff;
-#ifdef LDAP_DEBUG
- if ( lber_debug )
- fprintf( stderr, "ber_get_next\n" );
-#endif
+ if ( ber->ber_debug ) {
+ lber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug,
+ "ber_get_next\n" );
+ }
/*
* Any ber element looks like this: tag length contents.
ber->ber_rwptr += rc;
} while ( toread > 0 );
-#ifdef LDAP_DEBUG
- if ( lber_debug ) {
- fprintf( stderr, "ber_get_next: tag 0x%lx len %ld contents:\n",
+ if ( ber->ber_debug ) {
+ lber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug,
+ "ber_get_next: tag 0x%lx len %ld contents:\n",
tag, ber->ber_len );
- if ( lber_debug > 1 )
- ber_dump( ber, 1 );
+
+ lber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 );
}
-#endif
*len = ber->ber_len;
ber->ber_rwptr = NULL;
return( ber->ber_tag );
}
+
+Sockbuf *lber_sockbuf_alloc( void )
+{
+ Sockbuf *sb = calloc(1, sizeof(Sockbuf));
+ sb->sb_debug = lber_int_debug;
+ return sb;
+}
+
+Sockbuf *lber_sockbuf_alloc_fd( int fd )
+{
+ Sockbuf *sb = lber_sockbuf_alloc();
+ sb->sb_sd = fd;
+
+ return sb;
+}
+
+void lber_sockbuf_free( Sockbuf *sb )
+{
+ if(sb == NULL) return;
+
+ free(sb);
+}
+
+int lber_sockbuf_get_option( Sockbuf *sb, int opt, void *outvalue )
+{
+ return LBER_OPT_ERROR;
+}
+
+int lber_sockbuf_set_option( Sockbuf *sb, int opt, void *invalue )
+{
+ return LBER_OPT_ERROR;
+}
#define _LBER_INT_H
#include "lber.h"
+#include "ldap_log.h"
LDAP_BEGIN_DECL
+#define LBER_ITEM_BERELEMENT 1
+#define LBER_ITEM_SOCKBUF 2
+
+extern int lber_int_debug;
+
struct berelement {
+ short ber_item_type; /* always LBER_ITEM_BERELEMENT */
+ short ber_options;
+ int ber_debug;
+
+ int ber_usertag;
+
+ unsigned long ber_tag;
+ unsigned long ber_len;
+
char *ber_buf;
char *ber_ptr;
char *ber_end;
+
struct seqorset *ber_sos;
- unsigned long ber_tag;
- unsigned long ber_len;
- int ber_usertag;
- char ber_options;
-#define LBER_USE_DER 0x01
-#define LBER_USE_INDEFINITE_LEN 0x02
-#define LBER_TRANSLATE_STRINGS 0x04
char *ber_rwptr;
BERTranslateProc ber_encode_translate_proc;
BERTranslateProc ber_decode_translate_proc;
#define NULLBER ((BerElement *) 0)
struct sockbuf {
+ short sb_item_type; /* always LBER_ITEM_SOCKBUF */
+ short sb_options; /* to support copying ber elements */
+ int sb_debug;
+
+ int sb_fd;
#ifndef MACOS
int sb_sd;
#else /* MACOS */
void *sb_sd;
#endif /* MACOS */
+
+ long sb_max_incoming;
+
BerElement sb_ber;
- int sb_naddr; /* > 0 implies using CLDAP (UDP) */
+ int sb_naddr; /* > 0 implies using CLDAP (UDP) */
void *sb_useaddr; /* pointer to sockaddr to use next */
void *sb_fromaddr; /* pointer to message source sockaddr */
void **sb_addrs; /* actually an array of pointers to
sockaddrs */
-
- int sb_options; /* to support copying ber elements */
-#define LBER_TO_FILE 0x01 /* to a file referenced by sb_fd */
-#define LBER_TO_FILE_ONLY 0x02 /* only write to file, not network */
-#define LBER_MAX_INCOMING_SIZE 0x04 /* impose limit on incoming stuff */
-#define LBER_NO_READ_AHEAD 0x08 /* read only as much as requested */
- int sb_fd;
- long sb_max_incoming;
};
#define READBUFSIZ 8192
};
#define NULLSEQORSET ((Seqorset *) 0)
+/*
+ * bprint.c
+ */
+LDAP_F int lber_log_printf LDAP_P((
+ int errlvl,
+ int loglvl,
+ char *fmt,
+ ... ));
+
+LDAP_F int lber_log_bprint LDAP_P((
+ int errlvl,
+ int loglvl,
+ char *data,
+ int len ));
+
+LDAP_F int lber_log_dump LDAP_P((
+ int errlvl,
+ int loglvl,
+ BerElement *ber,
+ int inout ));
+
+LDAP_F int lber_log_sos_dump LDAP_P((
+ int errlvl,
+ int loglvl,
+ Seqorset *sos ));
+
#endif /* _LBER_INT_H */
--- /dev/null
+#include "portable.h"
+
+#include <stdlib.h>
+
+#include "lber-int.h"
+
+int lber_int_debug = 0;
+
+int
+lber_get_option(
+ void *item,
+ int option,
+ void *outvalue)
+{
+ BerElement *ber;
+ Sockbuf *sb;
+
+ if(outvalue == NULL) {
+ /* no place to get to */
+ return LBER_OPT_ERROR;
+ }
+
+ if(item == NULL) {
+ if(option == LBER_OPT_BER_DEBUG) {
+ * (int *) outvalue = lber_int_debug;
+ return LBER_OPT_SUCCESS;
+ }
+
+ return LBER_OPT_ERROR;
+ }
+
+ ber = (BerElement *) item;
+ sb = (Sockbuf *) item;
+
+ switch(option) {
+ case LBER_OPT_BER_OPTIONS:
+ * (int *) outvalue = ber->ber_options;
+ return LBER_OPT_SUCCESS;
+
+ case LBER_OPT_BER_DEBUG:
+ * (int *) outvalue = ber->ber_debug;
+ return LBER_OPT_SUCCESS;
+
+ default:
+ /* bad param */
+ break;
+ }
+
+ return LBER_OPT_ERROR;
+}
+
+int
+lber_set_option(
+ void *item,
+ int option,
+ void *invalue)
+{
+ BerElement *ber;
+ Sockbuf *sb;
+
+ if(invalue == NULL) {
+ /* no place to set from */
+ return LBER_OPT_ERROR;
+ }
+
+ if(item == NULL) {
+ if(option == LBER_OPT_BER_DEBUG) {
+ lber_int_debug = * (int *) invalue;
+ return LBER_OPT_SUCCESS;
+ }
+
+ return LBER_OPT_ERROR;
+ }
+
+ ber = (BerElement *) item;
+ sb = (Sockbuf *) item;
+
+ switch(option) {
+ case LBER_OPT_BER_OPTIONS:
+ ber->ber_options = * (int *) invalue;
+ return LBER_OPT_SUCCESS;
+
+ case LBER_OPT_BER_DEBUG:
+ ber->ber_debug = * (int *) invalue;
+ return LBER_OPT_SUCCESS;
+
+ default:
+ /* bad param */
+ break;
+ }
+
+ return LBER_OPT_ERROR;
+}
if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
fprintf( stderr, "cldap_parsemsg add message id %d type %d:\n",
ldm->lm_msgid, ldm->lm_msgtype );
- ber_dump( ldm->lm_ber, 1 );
+ lber_log_dump( LDAP_DEBUG_BER, ldap_debug, ldm->lm_ber, 1 );
}
#endif /* LDAP_DEBUG */
gopts.ldo_timelimit = LDAP_NO_LIMIT;
gopts.ldo_sizelimit = LDAP_NO_LIMIT;
+ gopts.ldo_debug = 0;
+
gopts.ldo_defhost = ldap_strdup("localhost");
gopts.ldo_defport = LDAP_PORT;
#endif
#include "../liblber/lber-int.h"
+
+#define ldap_debug (openldap_ldap_global_options.ldo_debug)
+
#include "ldap_log.h"
+
#include "ldap.h"
LDAP_BEGIN_DECL
int ldo_timelimit;
int ldo_sizelimit;
+ int ldo_debug;
+
char* ldo_defbase;
char* ldo_defhost;
int ldo_defport;
#include "ldap-int.h"
-#ifdef LDAP_DEBUG
-int ldap_debug;
-#endif
-
-
/*
* ldap_open - initialize and connect to an ldap server. A magic cookie to
* be used for future communication is returned on success, NULL on failure.
}
break;
+ case LDAP_OPT_DEBUG_LEVEL:
+ * (int *) outvalue = lo->ldo_debug;
+ break;
+
default:
/* bad param */
break;
ld->ld_error = err;
} return 0;
+ case LDAP_OPT_DEBUG_LEVEL:
+ lo->ldo_debug = * (int *) invalue;
+ return 0;
+
default:
/* bad param */
break;
if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
Debug( LDAP_DEBUG_ANY, "re_encode_request new request is:\n",
0, 0, 0 );
- ber_dump( ber, 0 );
+ lber_log_dump( LDAP_DEBUG_BER, ldap_debug, ber, 0 );
}
#endif /* LDAP_DEBUG */
case 'd':
#ifdef LDAP_DEBUG
ldap_debug = atoi( optarg );
+#ifdef LBER_DEBUG
if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
lber_debug = ldap_debug;
}
+#endif
#else
printf( "Compile with -DLDAP_DEBUG for debugging\n" );
#endif
#ifdef LDAP_DEBUG
getline( line, sizeof(line), stdin, "debug level? " );
ldap_debug = atoi( line );
+#ifdef LBER_DEBUG
if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
lber_debug = ldap_debug;
}
+#endif
#else
printf( "Compile with -DLDAP_DEBUG for debugging\n" );
#endif
#include <ac/socket.h>
#include <ac/time.h>
+int ldif_debug = 0;
+
+#define ldap_debug ldif_debug
#include "ldap_log.h"
#include "ldif.h"
-
#define RIGHT2 0x03
#define RIGHT4 0x0f
#define CONTINUED_LINE_MARKER '\001'
return( 0 );
}
- return( be->be_rootdn ? strcasecmp( be->be_rootdn, dn ) == 0
+ return( be->be_rootdn != NULL
+ ? strcasecmp( be->be_rootdn, dn ) == 0
: 0 );
}
* read-only global variables or variables only written by the listener
* thread (after they are initialized) - no need to protect them with a mutex.
*/
-int ldap_debug = 0;
+int slap_debug = 0;
+
#ifdef LDAP_DEBUG
int ldap_syslog = LDAP_DEBUG_STATS;
#else
int ldap_syslog;
#endif
+
int ldap_syslog_level = LOG_DEBUG;
int udp;
char *default_referral;
LDAP_DEBUG_ANY );
exit( 0 );
} else {
- ldap_debug |= atoi( optarg );
- lber_debug = (ldap_debug & LDAP_DEBUG_BER);
+ slap_debug |= atoi( optarg );
}
break;
#else
}
}
+ lber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug);
+ ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug);
+ ldif_debug = slap_debug;
+
Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 );
if ( (myname = strrchr( argv[0], '/' )) == NULL ) {
#include <assert.h>
#include "avl.h"
+
+#ifndef ldap_debug
+#define ldap_debug slap_debug
+#endif
+
+#include "ldap_log.h"
+
#include "../../libraries/liblber/lber-int.h"
#include "ldap.h"
-#include "ldap_log.h"
#include "lthread.h"
#include "lthread_rdwr.h"
LDAP_BEGIN_DECL
+extern int slap_debug;
+
struct op;
struct conn;
while ( (i = getopt( argc, argv, "hd:f:r:t:k:o" )) != EOF ) {
switch ( i ) {
-#ifdef LDAP_DEBUG
case 'd': /* turn on debugging */
+#ifdef LDAP_DEBUG
if ( optarg[0] == '?' ) {
printf( "Debug levels:\n" );
printf( "\tLDAP_DEBUG_TRACE\t%d\n",
LDAP_DEBUG_ANY );
return( -1 );
} else {
- ldap_debug = atoi( optarg );
+ ldap_debug |= atoi( optarg );
}
- break;
#else /* LDAP_DEBUG */
- case 'd': /* can't enable debugging - not built with debug code */
+ /* can't enable debugging - not built with debug code */
fprintf( stderr, "must compile with LDAP_DEBUG for debugging\n" );
- break;
#endif /* LDAP_DEBUG */
+ break;
case 'f': /* slapd config file */
g->slapd_configfile = strdup( optarg );
break;
sprintf( g->slurpd_status_file, "%s/%s", g->slurpd_rdir,
DEFAULT_SLURPD_STATUS_FILE );
+ lber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug);
+ ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldap_debug);
+ ldif_debug = ldap_debug;
+
#ifdef LOG_LOCAL4
openlog( g->myname, OPENLOG_OPTIONS, LOG_LOCAL4 );
#else
#include <ac/string.h>
#include <ac/ctype.h>
-#include "../slapd/slap.h"
#include "slurp.h"
#include "globals.h"
+#include "../slapd/slap.h"
+
/* Forward references */
static Rh *get_repl_hosts LDAP_P(( char *, int *, char ** ));
static int gettype LDAP_P(( char * ));
#define LDAP_SYSLOG 1
#endif
-#include <ac/syslog.h>
#include <ac/errno.h>
+#include <ac/syslog.h>
#include <sys/param.h>
#include "lber.h"
#include "ldap.h"
+
+#define ldap_debug slurp_debug
#include "ldap_log.h"
#include "lthread.h"