xref: /netbsd-src/external/bsd/ipf/dist/lib/printbuf.c (revision 13885a665959c62f13a82b3caedf986eaa17aa31)
1 /*	$NetBSD: printbuf.c,v 1.2 2012/07/22 14:27:36 darrenr Exp $	*/
2 
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * Id: printbuf.c,v 1.1.1.2 2012/07/22 13:44:40 darrenr Exp $
9  */
10 
11 #include <ctype.h>
12 
13 #include "ipf.h"
14 
15 
16 void
printbuf(buf,len,zend)17 printbuf(buf, len, zend)
18 	char *buf;
19 	int len, zend;
20 {
21 	char *s;
22 	int c;
23 	int i;
24 
25 	for (s = buf, i = len; i; i--) {
26 		c = *s++;
27 		if (isprint(c))
28 			putchar(c);
29 		else
30 			PRINTF("\\%03o", c);
31 		if ((c == '\0') && zend)
32 			break;
33 	}
34 }
35