From 321354ecff5571b92cda1bf4b0299e33218d9be8 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 26 Jan 1999 01:21:35 +0000 Subject: [PATCH] Add lber_pvt.h with prototypes of lber_pvt_log_print{,f}. Ripple name change through -llber & -lldap. Update -lldif to use lber_pvt_log_printf() instead of Debug. --- include/lber_pvt.h | 36 ++++++++++++++++++++++++++++++++++++ libraries/liblber/bprint.c | 22 +++++++++++----------- libraries/liblber/lber-int.h | 8 ++------ libraries/liblber/options.c | 4 +--- libraries/libldap/print.c | 6 ++---- libraries/libldif/line64.c | 22 ++++++++++++++-------- 6 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 include/lber_pvt.h diff --git a/include/lber_pvt.h b/include/lber_pvt.h new file mode 100644 index 0000000000..fc8091e0aa --- /dev/null +++ b/include/lber_pvt.h @@ -0,0 +1,36 @@ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* + * lber_pvt.h - Header for lber_pvt_ functions. These are meant to be used + * by the OpenLDAP distribution only. + */ + +#ifndef _LBER_PVT_H +#define _LBER_PVT_H 1 + +#include + +LDAP_BEGIN_DECL + +/* + * bprint.c + */ +extern BER_LOG_PRINT_FN lber_pvt_log_print; + +LDAP_F int lber_pvt_log_printf LDAP_P(( + int errlvl, + int loglvl, + char *fmt, + ... )); + +LDAP_END_DECL + +#endif + diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index 12ae005678..136d3d4a0b 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -23,7 +23,7 @@ lber_error_print( char *data ) fflush( stderr ); } -BER_LOG_PRINT_FN lber_log_print = lber_error_print; +BER_LOG_PRINT_FN lber_pvt_log_print = lber_error_print; /* * lber log @@ -34,7 +34,7 @@ static int lber_log_check( int errlvl, int loglvl ) return errlvl & loglvl ? 1 : 0; } -int lber_log_printf +int lber_pvt_log_printf #ifdef HAVE_STDARG (int errlvl, int loglvl, char *fmt, ...) #else @@ -74,7 +74,7 @@ va_dcl va_end(ap); - (*lber_log_print)( buf ); + (*lber_pvt_log_print)( buf ); return 1; } @@ -84,7 +84,7 @@ static int lber_log_puts(int errlvl, int loglvl, char *buf) return 0; } - (*lber_log_print)( buf ); + (*lber_pvt_log_print)( buf ); return 1; } @@ -116,7 +116,7 @@ ber_bprint(char *data, int len ) for ( ;; ) { if ( len < 1 ) { sprintf( buf, "\t%s\n", ( i == 0 ) ? "(end)" : out ); - (*lber_log_print)( buf ); + (*lber_pvt_log_print)( buf ); break; } @@ -138,7 +138,7 @@ ber_bprint(char *data, int len ) if ( i > BPLEN - 2 ) { char data[128 + BPLEN]; sprintf( data, "\t%s\n", out ); - (*lber_log_print)(data); + (*lber_pvt_log_print)(data); memset( out, 0, BPLEN ); i = 0; continue; @@ -168,7 +168,7 @@ ber_dump( BerElement *ber, int inout ) (long) ber->ber_ptr, (long) ber->ber_end ); - (*lber_log_print)( buf ); + (*lber_pvt_log_print)( buf ); if ( inout == 1 ) { sprintf( buf, " current len %ld, contents:\n", @@ -199,22 +199,22 @@ ber_sos_dump( Seqorset *sos ) { char buf[132]; - (*lber_log_print)( "*** sos dump ***\n" ); + (*lber_pvt_log_print)( "*** 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_log_print)( buf ); + (*lber_pvt_log_print)( buf ); sprintf( buf, " current len %ld contents:\n", (long) (sos->sos_ptr - sos->sos_first) ); - (*lber_log_print)( buf ); + (*lber_pvt_log_print)( buf ); ber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first ); sos = sos->sos_next; } - (*lber_log_print)( "*** end dump ***\n" ); + (*lber_pvt_log_print)( "*** end dump ***\n" ); } diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index d90bca59c5..37db2a986b 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -19,6 +19,7 @@ #include "lber.h" #include "ldap_log.h" +#include "lber_pvt.h" LDAP_BEGIN_DECL @@ -26,6 +27,7 @@ LDAP_BEGIN_DECL #define LBER_ITEM_SOCKBUF 2 extern int lber_int_debug; +#define lber_log_printf lber_pvt_log_printf struct berelement { short ber_item_type; /* always LBER_ITEM_BERELEMENT */ @@ -85,12 +87,6 @@ struct seqorset { /* * 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, diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index 5e882dbeb3..6bdacc6bfc 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -73,9 +73,7 @@ lber_set_option( 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; + lber_pvt_log_print = (BER_LOG_PRINT_FN) invalue; return LBER_OPT_SUCCESS; } diff --git a/libraries/libldap/print.c b/libraries/libldap/print.c index 4b865b7b48..764f12850f 100644 --- a/libraries/libldap/print.c +++ b/libraries/libldap/print.c @@ -14,8 +14,6 @@ #include "ldap-int.h" -extern BER_LOG_PRINT_FN lber_log_print; - /* * ldap log */ @@ -74,7 +72,7 @@ va_dcl va_end(ap); - (*lber_log_print)( buf ); + (*lber_pvt_log_print)( buf ); return 1; } @@ -84,6 +82,6 @@ static int lber_log_puts(int errlvl, int loglvl, char *buf) return 0; } - (*lber_log_print)( buf ); + (*lber_pvt_log_print)( buf ); return 1; } diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index fba438c67e..b4f8968e74 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -12,8 +12,8 @@ int ldif_debug = 0; -#define ldap_debug ldif_debug #include "ldap_log.h" +#include "lber_pvt.h" #include "ldif.h" #define RIGHT2 0x03 @@ -70,7 +70,8 @@ ldif_parse_line( for ( s = line; *s && *s != ':'; s++ ) ; /* NULL */ if ( *s == '\0' ) { - Debug( LDAP_DEBUG_PARSE, "parse_line missing ':'\n", 0, 0, 0 ); + lber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug, + "ldif_parse_line missing ':'\n"); return( -1 ); } @@ -97,7 +98,8 @@ ldif_parse_line( /* if no value is present, error out */ if ( *s == '\0' ) { - Debug( LDAP_DEBUG_PARSE, "parse_line missing value\n", 0,0,0 ); + lber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug, + "ldif_parse_line missing value\n"); return( -1 ); } @@ -116,9 +118,9 @@ ldif_parse_line( for ( i = 0; i < 4; i++ ) { if ( p[i] != '=' && (p[i] & 0x80 || b642nib[ p[i] & 0x7f ] > 0x3f) ) { - Debug( LDAP_DEBUG_ANY, - "invalid base 64 encoding char (%c) 0x%x\n", - p[i], p[i], 0 ); + lber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug, +"ldif_parse_line: invalid base 64 encoding char (%c) 0x%x\n", + p[i], p[i] ); return( -1 ); } } @@ -302,8 +304,12 @@ ldif_type_and_value( char *type, char *val, int vlen ) int tlen; tlen = strlen( type ); - if (( buf = (char *)malloc( LDIF_SIZE_NEEDED( tlen, vlen ) + 1 )) != - NULL ) { + if (( buf = (char *) malloc( LDIF_SIZE_NEEDED( tlen, vlen ) + 1 )) + == NULL ) + { + lber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug, + "ldif_type_and_value: malloc failed!" ); + return NULL; } p = buf; -- 2.39.5