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