]> arthur.barton.de Git - netatalk.git/blob - libatalk/atp/atp_bprint.c
massive commenting/autoconf changes
[netatalk.git] / libatalk / atp / atp_bprint.c
1 /*
2  * $Id: atp_bprint.c,v 1.4 2001-06-29 14:14:46 rufustfirefly Exp $
3  *
4  * Copyright (c) 1990,1991 Regents of The University of Michigan.
5  * All Rights Reserved.
6  *
7  * Permission to use, copy, modify, and distribute this software and
8  * its documentation for any purpose and without fee is hereby granted,
9  * provided that the above copyright notice appears in all copies and
10  * that both that copyright notice and this permission notice appear
11  * in supporting documentation, and that the name of The University
12  * of Michigan not be used in advertising or publicity pertaining to
13  * distribution of the software without specific, written prior
14  * permission. This software is supplied as is without expressed or
15  * implied warranties of any kind.
16  *
17  *      Research Systems Unix Group
18  *      The University of Michigan
19  *      c/o Mike Clark
20  *      535 W. William Street
21  *      Ann Arbor, Michigan
22  *      +1-313-763-0525
23  *      netatalk@itd.umich.edu
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif /* HAVE_CONFIG_H */
29
30 #define BPLEN   48
31 #include <stdio.h>
32 #include <ctype.h>
33 #include <string.h>
34 char    hexdig[] = "0123456789abcdef";
35
36 void bprint( data, len )
37     char        *data;
38     int         len;
39 {
40     char        out[ BPLEN ];
41     int         i = 0;
42
43     memset( out, 0, BPLEN );
44     for ( ;; ) {
45         if ( len < 1 ) {
46             printf( "\t%s\n", ( i == 0 ) ? "(end)" : out );
47             break;
48         }
49
50         if ( isgraph( (unsigned char)*data )) {
51             out[ i ] = ' ';
52             out[ i+1 ] = *data;
53         } else {
54             out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
55             out[ i+1 ] = hexdig[ *data & 0x0f ];
56         }
57         i += 2;
58         len--;
59         data++;
60
61         if ( i > BPLEN - 2 ) {
62             printf( "\t%s\n", out );
63             memset( out, 0, BPLEN );
64             i = 0;
65             continue;
66         }
67         out[ i++ ] = ' ';
68     }
69 }