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