xref: /freebsd/sbin/ipf/libipf/printbuf.c (revision 29fc4075e69fd27de0cded313ac6000165d99f8b)
1 /*	$FreeBSD$	*/
2 
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * $Id$
9  */
10 
11 #include <ctype.h>
12 
13 #include "ipf.h"
14 
15 
16 void
17 printbuf(char *buf, int len, int zend)
18 {
19 	char *s;
20 	int c;
21 	int i;
22 
23 	for (s = buf, i = len; i; i--) {
24 		c = *s++;
25 		if (isprint(c))
26 			putchar(c);
27 		else
28 			PRINTF("\\%03o", c);
29 		if ((c == '\0') && zend)
30 			break;
31 	}
32 }
33