1145519Sdarrenr/* $FreeBSD: releng/11.0/contrib/ipfilter/lib/printbuf.c 255332 2013-09-06 23:11:19Z cy $ */ 2145510Sdarrenr 3145510Sdarrenr/* 4255332Scy * Copyright (C) 2012 by Darren Reed. 5145510Sdarrenr * 6145510Sdarrenr * See the IPFILTER.LICENCE file for details on licencing. 7145510Sdarrenr * 8255332Scy * $Id$ 9145510Sdarrenr */ 10145510Sdarrenr 11145510Sdarrenr#include <ctype.h> 12145510Sdarrenr 13145510Sdarrenr#include "ipf.h" 14145510Sdarrenr 15145510Sdarrenr 16255332Scyvoid 17255332Scyprintbuf(buf, len, zend) 18255332Scy char *buf; 19255332Scy int len, zend; 20145510Sdarrenr{ 21255332Scy char *s; 22255332Scy int c; 23145510Sdarrenr int i; 24145510Sdarrenr 25145510Sdarrenr for (s = buf, i = len; i; i--) { 26145510Sdarrenr c = *s++; 27255332Scy if (isprint(c)) 28145510Sdarrenr putchar(c); 29145510Sdarrenr else 30255332Scy PRINTF("\\%03o", c); 31145510Sdarrenr if ((c == '\0') && zend) 32145510Sdarrenr break; 33145510Sdarrenr } 34145510Sdarrenr} 35