printbuf.c revision 170268
1/* $FreeBSD: head/contrib/ipfilter/lib/printbuf.c 170268 2007-06-04 02:54:36Z darrenr $ */ 2 3/* 4 * Copyright (C) 2000-2004 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * $Id: printbuf.c,v 1.5.4.2 2006/06/16 17:21:10 darrenr Exp $ 9 */ 10 11#include <ctype.h> 12 13#include "ipf.h" 14 15 16void printbuf(buf, len, zend) 17char *buf; 18int len, zend; 19{ 20 char *s, 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