xref: /illumos-gate/usr/src/cmd/ipf/lib/common/binprint.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
5*7c478bd9Sstevel@tonic-gate  *
6*7c478bd9Sstevel@tonic-gate  * $Id: binprint.c,v 1.8 2002/05/14 15:18:56 darrenr Exp $
7*7c478bd9Sstevel@tonic-gate  */
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate #include "ipf.h"
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate 
binprint(ptr,size)12*7c478bd9Sstevel@tonic-gate void binprint(ptr, size)
13*7c478bd9Sstevel@tonic-gate void *ptr;
14*7c478bd9Sstevel@tonic-gate size_t size;
15*7c478bd9Sstevel@tonic-gate {
16*7c478bd9Sstevel@tonic-gate 	u_char *s;
17*7c478bd9Sstevel@tonic-gate 	int i, j;
18*7c478bd9Sstevel@tonic-gate 
19*7c478bd9Sstevel@tonic-gate 	for (i = size, j = 0, s = (u_char *)ptr; i; i--, s++) {
20*7c478bd9Sstevel@tonic-gate 		j++;
21*7c478bd9Sstevel@tonic-gate 		printf("%02x ", *s);
22*7c478bd9Sstevel@tonic-gate 		if (j == 16) {
23*7c478bd9Sstevel@tonic-gate 			printf("\n");
24*7c478bd9Sstevel@tonic-gate 			j = 0;
25*7c478bd9Sstevel@tonic-gate 		}
26*7c478bd9Sstevel@tonic-gate 	}
27*7c478bd9Sstevel@tonic-gate 	putchar('\n');
28*7c478bd9Sstevel@tonic-gate 	(void)fflush(stdout);
29*7c478bd9Sstevel@tonic-gate }
30