/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "lber-int.h"
-typedef void (*BER_LOG_FN) LDAP_P((FILE *file, char *subsys, int level, const char *fmt, va_list vl));
-
-static int ber_log_check( int errlvl, int loglvl );
+#define ber_log_check(errlvl, loglvl) ((errlvl) & (loglvl))
BER_LOG_FN ber_int_log_proc = NULL;
* lber log
*/
-int ber_pvt_log_output( char *subsystem, int level, const char *fmt, ... )
+int ber_pvt_log_output(
+ const char *subsystem,
+ int level,
+ const char *fmt,
+ ... )
{
char buf[ 1024 ];
va_list vl;
{
int level;
ber_get_option( NULL, LBER_OPT_BER_DEBUG, &level );
-#ifdef HAVE_VSNPRINTF
buf[sizeof(buf) - 1] = '\0';
vsnprintf( buf, sizeof(buf)-1, fmt, vl );
-#elif HAVE_VSPRINTF
- vsprintf( buf, fmt, vl ); /* hope it's not too long */
-#else
- /* use doprnt() */
-#error "vsprintf() required.";
-#endif
if ( ber_log_check( LDAP_DEBUG_BER, level ) )
(*ber_pvt_log_print)( buf );
}
return 1;
}
-static int ber_log_check( int errlvl, int loglvl )
-{
- return errlvl & loglvl ? 1 : 0;
-}
-
int ber_pvt_log_printf( int errlvl, int loglvl, const char *fmt, ... )
{
char buf[ 1024 ];
va_start( ap, fmt );
-#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() */
-#error "vsprintf() required."
-#endif
va_end(ap);
off = BP_GRAPH + n + ((n >= 8)?1:0);
- if ( isprint( data[i] )) {
+ if ( isprint( (unsigned char) data[i] )) {
line[ BP_GRAPH + n ] = data[i];
} else {
line[ BP_GRAPH + n ] = '.';
#ifdef NEW_LOGGING
int ber_output_dump(
- char *subsys,
- int level,
- BerElement *ber,
- int inout )
+ const char *subsys,
+ int level,
+ BerElement *ber,
+ int inout )
{
static const char hexdig[] = "0123456789abcdef";
char buf[132];
(long) ber->ber_end,
(long) len );
- ber_pvt_log_output( subsys, level, "%s", buf );
+ (void) ber_pvt_log_output( subsys, level, "%s", buf );
#define BP_OFFSET 9
#define BP_GRAPH 60
unsigned off;
if( !n ) {
- if( i ) ber_pvt_log_output( subsys, level, "%s", line );
+ if( i ) {
+ (void) ber_pvt_log_output( subsys, level, "%s", line );
+ }
memset( line, ' ', sizeof(line)-2 );
line[sizeof(line)-2] = '\n';
line[sizeof(line)-1] = '\0';
off = BP_GRAPH + n + ((n >= 8)?1:0);
- if ( isprint( data[i] )) {
+ if ( isprint( (unsigned char) data[i] )) {
line[ BP_GRAPH + n ] = data[i];
} else {
line[ BP_GRAPH + n ] = '.';
}
}
- ber_pvt_log_output( subsys, level, "%s", line );
+ return ber_pvt_log_output( subsys, level, "%s", line );
}
#endif
int inout )
{
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( !ber_log_check( errlvl, loglvl )) {
return 0;
ber_len_t len;
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( inout == 1 ) {
len = ber_pvt_ber_remaining(ber);
(long) ber->ber_end,
(long) len );
- (*ber_pvt_log_print)( buf );
+ (void) (*ber_pvt_log_print)( buf );
ber_bprint( ber->ber_ptr, len );
}