10Sstevel@tonic-gate /*
2*3857Sstevel * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
3*3857Sstevel * Use is subject to license terms.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate
60Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
70Sstevel@tonic-gate
80Sstevel@tonic-gate #include <stdio.h>
90Sstevel@tonic-gate #include <string.h>
100Sstevel@tonic-gate #include <ctype.h>
110Sstevel@tonic-gate #include "lber.h"
120Sstevel@tonic-gate
130Sstevel@tonic-gate /*
140Sstevel@tonic-gate * Print arbitrary stuff, for debugging.
150Sstevel@tonic-gate */
160Sstevel@tonic-gate
170Sstevel@tonic-gate #ifdef LDAP_DEBUG
180Sstevel@tonic-gate
190Sstevel@tonic-gate #ifndef NO_USERINTERFACE
200Sstevel@tonic-gate #define BPLEN 48
210Sstevel@tonic-gate
220Sstevel@tonic-gate void
lber_bprint(char * data,int len)230Sstevel@tonic-gate lber_bprint( char *data, int len )
240Sstevel@tonic-gate {
250Sstevel@tonic-gate static char hexdig[] = "0123456789abcdef";
260Sstevel@tonic-gate char out[ BPLEN ];
270Sstevel@tonic-gate int i = 0;
280Sstevel@tonic-gate
290Sstevel@tonic-gate (void) memset( out, 0, BPLEN );
300Sstevel@tonic-gate for ( ;; ) {
310Sstevel@tonic-gate if ( len < 1 ) {
320Sstevel@tonic-gate (void) fprintf( stderr, "\t%s\n", ( i == 0 ) ? catgets(slapdcat, 1, 72, "(end)") : out );
330Sstevel@tonic-gate break;
340Sstevel@tonic-gate }
350Sstevel@tonic-gate
360Sstevel@tonic-gate #ifndef HEX
370Sstevel@tonic-gate if ( isgraph( (unsigned char)*data )) {
380Sstevel@tonic-gate out[ i ] = ' ';
390Sstevel@tonic-gate out[ i+1 ] = *data;
400Sstevel@tonic-gate } else {
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
430Sstevel@tonic-gate out[ i+1 ] = hexdig[ *data & 0x0f ];
440Sstevel@tonic-gate #ifndef HEX
450Sstevel@tonic-gate }
460Sstevel@tonic-gate #endif
470Sstevel@tonic-gate i += 2;
480Sstevel@tonic-gate len--;
490Sstevel@tonic-gate data++;
500Sstevel@tonic-gate
510Sstevel@tonic-gate if ( i > BPLEN - 2 ) {
520Sstevel@tonic-gate (void) fprintf( stderr, "\t%s\n", out );
530Sstevel@tonic-gate (void) memset( out, 0, BPLEN );
540Sstevel@tonic-gate i = 0;
550Sstevel@tonic-gate continue;
560Sstevel@tonic-gate }
570Sstevel@tonic-gate out[ i++ ] = ' ';
580Sstevel@tonic-gate }
590Sstevel@tonic-gate }
600Sstevel@tonic-gate #else /* NO_USERINTERFACE */
610Sstevel@tonic-gate void
lber_bprint(char * data,int len)620Sstevel@tonic-gate lber_bprint( char *data, int len )
630Sstevel@tonic-gate {
640Sstevel@tonic-gate }
650Sstevel@tonic-gate #endif /* NO_USERINTERFACE */
660Sstevel@tonic-gate
670Sstevel@tonic-gate #endif
68