xref: /titanic_41/usr/src/cmd/ipf/lib/common/printbuf.c (revision dd49f125507979bb2ab505a8daf2a46d1be27051)
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