1 /* $NetBSD: allprint.c,v 1.1.1.1 2009/06/23 10:08:58 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* allprint 3 6 /* SUMMARY 7 /* predicate if string is all printable 8 /* SYNOPSIS 9 /* #include <stringops.h> 10 /* 11 /* int allprint(buffer) 12 /* const char *buffer; 13 /* DESCRIPTION 14 /* allprint() determines if its argument is an all-printable string. 15 /* 16 /* Arguments: 17 /* .IP buffer 18 /* The null-terminated input string. 19 /* LICENSE 20 /* .ad 21 /* .fi 22 /* The Secure Mailer license must be distributed with this software. 23 /* AUTHOR(S) 24 /* Wietse Venema 25 /* IBM T.J. Watson Research 26 /* P.O. Box 704 27 /* Yorktown Heights, NY 10598, USA 28 /*--*/ 29 30 /* System library. */ 31 32 #include <sys_defs.h> 33 #include <ctype.h> 34 35 /* Utility library. */ 36 37 #include "stringops.h" 38 39 /* allprint - return true if string is all printable */ 40 41 int allprint(const char *string) 42 { 43 const char *cp; 44 int ch; 45 46 if (*string == 0) 47 return (0); 48 for (cp = string; (ch = *(unsigned char *) cp) != 0; cp++) 49 if (!ISASCII(ch) || !ISPRINT(ch)) 50 return (0); 51 return (1); 52 } 53