File: bprint.c

package info (click to toggle)
netatalk 3.1.12~ds-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,756 kB
  • sloc: ansic: 104,976; sh: 8,247; xml: 7,394; perl: 1,936; makefile: 1,430; python: 1,342; yacc: 309; lex: 49
file content (52 lines) | stat: -rw-r--r-- 939 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef DEBUG
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include <atalk/util.h>

static const char	hexdig[] = "0123456789ABCDEF";

#define BPXLEN	50
#define BPALEN	18

void bprint( data, len )
    char	*data;
    int		len;
{
    char	xout[ BPXLEN ], aout[ BPALEN ];
    int         i;

    memset( xout, 0, BPXLEN );
    memset( aout, 0, BPALEN );

    for ( i = 0; len; len--, data++, i++ ) {
	if ( i == 16 ) {
	    printf( "%-48s\t%-16s\n", xout, aout );
	    memset( xout, 0, BPXLEN );
	    memset( aout, 0, BPALEN );
	    i = 0;
	}

	if (isprint( (unsigned char)*data )) {
	    aout[ i ] = *data;
	} else {
	    aout[ i ] = '.';
	}

	xout[ (i*3) ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
	xout[ (i*3) + 1 ] = hexdig[ *data & 0x0f ];
	xout[ (i*3) + 2 ] = ' ';
    }

    if ( i ) 	
	printf( "%-48s\t%-16s\n", xout, aout );

    printf("(end)\n");
}
#endif