xref: /titanic_52/usr/src/cmd/ipf/lib/common/printbuf.c (revision d58fda4376e4bf67072ce2e69f6f47036f9dbb68)
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 2001/06/09 17:09:24 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