-#ifndef LDAP_HEX
- if ( isgraph( (unsigned char)*data )) {
- out[ i ] = ' ';
- out[ i+1 ] = *data;
- } else {
-#endif
- out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
- out[ i+1 ] = hexdig[ *data & 0x0f ];
-#ifndef LDAP_HEX
- }
-#endif
- i += 2;
- len--;
- data++;
-
- if ( i > BPLEN - 2 ) {
- char data[128 + BPLEN];
- sprintf( data, "\t%s\n", out );
- lber_print_error(data);
- memset( out, 0, BPLEN );
- i = 0;
- continue;
- }
- out[ i++ ] = ' ';
+ (*ber_pvt_log_print)( line );
+}
+
+#ifdef NEW_LOGGING
+int ber_output_dump(
+ const char *subsys,
+ int level,
+ BerElement *ber,
+ int inout )
+{
+ static const char hexdig[] = "0123456789abcdef";
+ char buf[132];
+ ber_len_t len;
+ char line[ BP_LEN ];
+ ber_len_t i;
+ char *data = ber->ber_ptr;
+
+ if ( inout == 1 ) {
+ len = ber_pvt_ber_remaining(ber);
+ } else {
+ len = ber_pvt_ber_write(ber);
+ }
+
+ sprintf( buf, "ber_dump: buf=0x%08lx ptr=0x%08lx end=0x%08lx len=%ld\n",
+ (long) ber->ber_buf,
+ (long) ber->ber_ptr,
+ (long) ber->ber_end,
+ (long) len );
+
+ (void) ber_pvt_log_output( subsys, level, "%s", buf );
+
+#define BP_OFFSET 9
+#define BP_GRAPH 60
+#define BP_LEN 80
+
+ assert( data != NULL );
+
+ /* in case len is zero */
+ line[0] = '\n';
+ line[1] = '\0';
+
+ for ( i = 0 ; i < len ; i++ ) {
+ int n = i % 16;
+ unsigned off;
+
+ if( !n ) {
+ 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 = i % 0x0ffffU;
+
+ line[ 2 ] = hexdig[ 0x0f & (off >> 12) ];
+ line[ 3 ] = hexdig[ 0x0f & (off >> 8) ];
+ line[ 4 ] = hexdig[ 0x0f & (off >> 4) ];
+ line[ 5 ] = hexdig[ 0x0f & off ];
+ line[ 6 ] = ':';
+ }
+
+ off = BP_OFFSET + n*3 + ((n >= 8)?1:0);
+ line[ off ] = hexdig[ 0x0f & ( data[i] >> 4 ) ];
+ line[ off+1 ] = hexdig[ 0x0f & data[i] ];
+
+ off = BP_GRAPH + n + ((n >= 8)?1:0);
+
+ if ( isprint( (unsigned char) data[i] )) {
+ line[ BP_GRAPH + n ] = data[i];
+ } else {
+ line[ BP_GRAPH + n ] = '.';
+ }