aboutsummaryrefslogtreecommitdiff
path: root/sbin/ipf/libipf/printbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/ipf/libipf/printbuf.c')
-rw-r--r--sbin/ipf/libipf/printbuf.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sbin/ipf/libipf/printbuf.c b/sbin/ipf/libipf/printbuf.c
new file mode 100644
index 000000000000..0fef3c5de854
--- /dev/null
+++ b/sbin/ipf/libipf/printbuf.c
@@ -0,0 +1,31 @@
+
+/*
+ * Copyright (C) 2012 by Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ *
+ * $Id$
+ */
+
+#include <ctype.h>
+
+#include "ipf.h"
+
+
+void
+printbuf(char *buf, int len, int zend)
+{
+ char *s;
+ int c;
+ int i;
+
+ for (s = buf, i = len; i; i--) {
+ c = *s++;
+ if (isprint(c))
+ putchar(c);
+ else
+ PRINTF("\\%03o", c);
+ if ((c == '\0') && zend)
+ break;
+ }
+}