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