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