xref: /titanic_44/usr/src/cmd/ipf/lib/common/printbuf.c (revision 4496171313bed39e96f21bc2f9faf2868e267ae3)
1 /*
2  * Copyright (C) 1993-2001 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: printbuf.c,v 1.5.4.1 2004/12/09 19:41:22 darrenr Exp $
7  */
8 
9 #include <ctype.h>
10 
11 #include "ipf.h"
12 
13 
14 void printbuf(buf, len, zend)
15 char *buf;
16 int len, zend;
17 {
18 	char *s, c;
19 	int i;
20 
21 	for (s = buf, i = len; i; i--) {
22 		c = *s++;
23 		if (ISPRINT(c))
24 			putchar(c);
25 		else
26 			printf("\\%03o", c);
27 		if ((c == '\0') && zend)
28 			break;
29 	}
30 }
31