xref: /illumos-gate/usr/src/cmd/ipf/lib/printbuf.c (revision d7574e9aa8a3a5b2d6e2411b5c915becca76ce5a)
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