Add support for LBER_OPT_LOG_PRINT_FN option.

This commit is contained in:
Kurt Zeilenga 1999-01-25 22:55:00 +00:00
parent 01cd11c308
commit d7079a10c3
3 changed files with 22 additions and 10 deletions

View file

@ -76,7 +76,11 @@ typedef int (*BERTranslateProc) LDAP_P(( char **bufp,
/* get/set options for BerElement */ /* get/set options for BerElement */
#define LBER_OPT_BER_OPTIONS 0x01 #define LBER_OPT_BER_OPTIONS 0x01
#define LBER_OPT_BER_DEBUG 0x02 #define LBER_OPT_BER_DEBUG 0x02
#define LBER_OPT_DEBUG_LEVEL LBER_OPT_BER_DEBUG #define LBER_OPT_DEBUG_LEVEL LBER_OPT_BER_DEBUG
#define LBER_OPT_LOG_PRINT_FN 0x8001
typedef void (*BER_LOG_PRINT_FN) LDAP_P(( char *buf ));
/* LBER Sockbuf options */ /* LBER Sockbuf options */
#define LBER_TO_FILE 0x01 /* to a file referenced by sb_fd */ #define LBER_TO_FILE 0x01 /* to a file referenced by sb_fd */

View file

@ -17,12 +17,14 @@
* Print stuff * Print stuff
*/ */
static void static void
lber_print_error( char *data ) lber_error_print( char *data )
{ {
fputs( data, stderr ); fputs( data, stderr );
fflush( stderr ); fflush( stderr );
} }
BER_LOG_PRINT_FN lber_log_print = lber_error_print;
/* /*
* lber log * lber log
*/ */
@ -72,7 +74,7 @@ va_dcl
va_end(ap); va_end(ap);
lber_print_error( buf ); (*lber_log_print)( buf );
return 1; return 1;
} }
@ -82,7 +84,7 @@ static int lber_log_puts(int errlvl, int loglvl, char *buf)
return 0; return 0;
} }
lber_print_error( buf ); (*lber_log_print)( buf );
return 1; return 1;
} }
@ -114,7 +116,7 @@ ber_bprint(char *data, int len )
for ( ;; ) { for ( ;; ) {
if ( len < 1 ) { if ( len < 1 ) {
sprintf( buf, "\t%s\n", ( i == 0 ) ? "(end)" : out ); sprintf( buf, "\t%s\n", ( i == 0 ) ? "(end)" : out );
lber_print_error( buf ); (*lber_log_print)( buf );
break; break;
} }
@ -136,7 +138,7 @@ ber_bprint(char *data, int len )
if ( i > BPLEN - 2 ) { if ( i > BPLEN - 2 ) {
char data[128 + BPLEN]; char data[128 + BPLEN];
sprintf( data, "\t%s\n", out ); sprintf( data, "\t%s\n", out );
lber_print_error(data); (*lber_log_print)(data);
memset( out, 0, BPLEN ); memset( out, 0, BPLEN );
i = 0; i = 0;
continue; continue;
@ -166,7 +168,7 @@ ber_dump( BerElement *ber, int inout )
(long) ber->ber_ptr, (long) ber->ber_ptr,
(long) ber->ber_end ); (long) ber->ber_end );
lber_print_error( buf ); (*lber_log_print)( buf );
if ( inout == 1 ) { if ( inout == 1 ) {
sprintf( buf, " current len %ld, contents:\n", sprintf( buf, " current len %ld, contents:\n",
@ -197,22 +199,22 @@ ber_sos_dump( Seqorset *sos )
{ {
char buf[132]; char buf[132];
lber_print_error( "*** sos dump ***\n" ); (*lber_log_print)( "*** sos dump ***\n" );
while ( sos != NULLSEQORSET ) { while ( sos != NULLSEQORSET ) {
sprintf( buf, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n", 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 ); (long) sos->sos_clen, (long) sos->sos_first, (long) sos->sos_ptr );
lber_print_error( buf ); (*lber_log_print)( buf );
sprintf( buf, " current len %ld contents:\n", sprintf( buf, " current len %ld contents:\n",
(long) (sos->sos_ptr - sos->sos_first) ); (long) (sos->sos_ptr - sos->sos_first) );
lber_print_error( buf ); (*lber_log_print)( buf );
ber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first ); ber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first );
sos = sos->sos_next; sos = sos->sos_next;
} }
lber_print_error( "*** end dump ***\n" ); (*lber_log_print)( "*** end dump ***\n" );
} }

View file

@ -71,6 +71,12 @@ lber_set_option(
if(option == LBER_OPT_BER_DEBUG) { if(option == LBER_OPT_BER_DEBUG) {
lber_int_debug = * (int *) invalue; lber_int_debug = * (int *) invalue;
return LBER_OPT_SUCCESS; return LBER_OPT_SUCCESS;
} else if(option == LBER_OPT_LOG_PRINT_FN) {
extern BER_LOG_PRINT_FN lber_log_print;
lber_log_print = (BER_LOG_PRINT_FN) invalue;
return LBER_OPT_SUCCESS;
} }
return LBER_OPT_ERROR; return LBER_OPT_ERROR;