1/* $NetBSD$ */ 2 3/*++ 4/* NAME 5/* printable 3 6/* SUMMARY 7/* mask non-printable characters 8/* SYNOPSIS 9/* #include <stringops.h> 10/* 11/* char *printable(buffer, replacement) 12/* char *buffer; 13/* int replacement; 14/* DESCRIPTION 15/* printable() replaces non-ASCII or non-printable characters in its input 16/* by the given replacement. 17/* 18/* Arguments: 19/* .IP buffer 20/* The null-terminated input string. 21/* .IP replacement 22/* Replacement value for characters in \fIbuffer\fR that do not 23/* pass the isprint(3) test. 24/* LICENSE 25/* .ad 26/* .fi 27/* The Secure Mailer license must be distributed with this software. 28/* AUTHOR(S) 29/* Wietse Venema 30/* IBM T.J. Watson Research 31/* P.O. Box 704 32/* Yorktown Heights, NY 10598, USA 33/*--*/ 34 35/* System library. */ 36 37#include "sys_defs.h" 38#include <ctype.h> 39 40/* Utility library. */ 41 42#include "stringops.h" 43 44char *printable(char *string, int replacement) 45{ 46 char *cp; 47 int ch; 48 49 for (cp = string; (ch = *(unsigned char *) cp) != 0; cp++) 50 if (!ISASCII(ch) || !ISPRINT(ch)) 51 *cp = replacement; 52 return (string); 53} 54