xref: /titanic_52/usr/src/cmd/ipf/lib/common/printbuf.c (revision ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
57c478bd9Sstevel@tonic-gate  *
6*ab25eeb5Syz155240  * $Id: printbuf.c,v 1.5.4.1 2004/12/09 19:41:22 darrenr Exp $
77c478bd9Sstevel@tonic-gate  */
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate #include <ctype.h>
107c478bd9Sstevel@tonic-gate 
117c478bd9Sstevel@tonic-gate #include "ipf.h"
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate 
147c478bd9Sstevel@tonic-gate void printbuf(buf, len, zend)
157c478bd9Sstevel@tonic-gate char *buf;
167c478bd9Sstevel@tonic-gate int len, zend;
177c478bd9Sstevel@tonic-gate {
187c478bd9Sstevel@tonic-gate 	char *s, c;
197c478bd9Sstevel@tonic-gate 	int i;
207c478bd9Sstevel@tonic-gate 
217c478bd9Sstevel@tonic-gate 	for (s = buf, i = len; i; i--) {
227c478bd9Sstevel@tonic-gate 		c = *s++;
23*ab25eeb5Syz155240 		if (ISPRINT(c))
247c478bd9Sstevel@tonic-gate 			putchar(c);
257c478bd9Sstevel@tonic-gate 		else
267c478bd9Sstevel@tonic-gate 			printf("\\%03o", c);
277c478bd9Sstevel@tonic-gate 		if ((c == '\0') && zend)
287c478bd9Sstevel@tonic-gate 			break;
297c478bd9Sstevel@tonic-gate 	}
307c478bd9Sstevel@tonic-gate }
31