]> arthur.barton.de Git - netatalk.git/blob - libatalk/util/bprint.c
Merge 2-2
[netatalk.git] / libatalk / util / bprint.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #ifdef DEBUG
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <ctype.h>
10
11 #include <atalk/util.h>
12
13 static const char       hexdig[] = "0123456789ABCDEF";
14
15 #define BPXLEN  50
16 #define BPALEN  18
17
18 void bprint( data, len )
19     char        *data;
20     int         len;
21 {
22     char        xout[ BPXLEN ], aout[ BPALEN ];
23     int         i;
24
25     memset( xout, 0, BPXLEN );
26     memset( aout, 0, BPALEN );
27
28     for ( i = 0; len; len--, data++, i++ ) {
29         if ( i == 16 ) {
30             printf( "%-48s\t%-16s\n", xout, aout );
31             memset( xout, 0, BPXLEN );
32             memset( aout, 0, BPALEN );
33             i = 0;
34         }
35
36         if (isprint( (unsigned char)*data )) {
37             aout[ i ] = *data;
38         } else {
39             aout[ i ] = '.';
40         }
41
42         xout[ (i*3) ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
43         xout[ (i*3) + 1 ] = hexdig[ *data & 0x0f ];
44         xout[ (i*3) + 2 ] = ' ';
45     }
46
47     if ( i )    
48         printf( "%-48s\t%-16s\n", xout, aout );
49
50     printf("(end)\n");
51 }
52 #endif