+
+ 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 ] = '.';
+ }
+ }
+
+ return ber_pvt_log_output( subsys, level, "%s", line );