xref: /illumos-gate/usr/src/cmd/sendmail/libsm/string.c (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2001 Sendmail, Inc. and its suppliers.
3*7c478bd9Sstevel@tonic-gate  *      All rights reserved.
4*7c478bd9Sstevel@tonic-gate  *
5*7c478bd9Sstevel@tonic-gate  * By using this file, you agree to the terms and conditions set
6*7c478bd9Sstevel@tonic-gate  * forth in the LICENSE file which can be found at the top level of
7*7c478bd9Sstevel@tonic-gate  * the sendmail distribution.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  */
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate #include <sm/gen.h>
12*7c478bd9Sstevel@tonic-gate SM_RCSID("@(#)$Id: string.c,v 1.1 2001/02/15 21:04:50 ca Exp $")
13*7c478bd9Sstevel@tonic-gate 
14*7c478bd9Sstevel@tonic-gate #include <ctype.h>
15*7c478bd9Sstevel@tonic-gate #include <errno.h>
16*7c478bd9Sstevel@tonic-gate 
17*7c478bd9Sstevel@tonic-gate #include <sm/string.h>
18*7c478bd9Sstevel@tonic-gate 
19*7c478bd9Sstevel@tonic-gate /*
20*7c478bd9Sstevel@tonic-gate **  STRIPQUOTES -- Strip quotes & quote bits from a string.
21*7c478bd9Sstevel@tonic-gate **
22*7c478bd9Sstevel@tonic-gate **	Runs through a string and strips off unquoted quote
23*7c478bd9Sstevel@tonic-gate **	characters and quote bits.  This is done in place.
24*7c478bd9Sstevel@tonic-gate **
25*7c478bd9Sstevel@tonic-gate **	Parameters:
26*7c478bd9Sstevel@tonic-gate **		s -- the string to strip.
27*7c478bd9Sstevel@tonic-gate **
28*7c478bd9Sstevel@tonic-gate **	Returns:
29*7c478bd9Sstevel@tonic-gate **		none.
30*7c478bd9Sstevel@tonic-gate **
31*7c478bd9Sstevel@tonic-gate **	Side Effects:
32*7c478bd9Sstevel@tonic-gate **		none.
33*7c478bd9Sstevel@tonic-gate */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate void
36*7c478bd9Sstevel@tonic-gate stripquotes(s)
37*7c478bd9Sstevel@tonic-gate 	char *s;
38*7c478bd9Sstevel@tonic-gate {
39*7c478bd9Sstevel@tonic-gate 	register char *p;
40*7c478bd9Sstevel@tonic-gate 	register char *q;
41*7c478bd9Sstevel@tonic-gate 	register char c;
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
44*7c478bd9Sstevel@tonic-gate 		return;
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate 	p = q = s;
47*7c478bd9Sstevel@tonic-gate 	do
48*7c478bd9Sstevel@tonic-gate 	{
49*7c478bd9Sstevel@tonic-gate 		c = *p++;
50*7c478bd9Sstevel@tonic-gate 		if (c == '\\')
51*7c478bd9Sstevel@tonic-gate 			c = *p++;
52*7c478bd9Sstevel@tonic-gate 		else if (c == '"')
53*7c478bd9Sstevel@tonic-gate 			continue;
54*7c478bd9Sstevel@tonic-gate 		*q++ = c;
55*7c478bd9Sstevel@tonic-gate 	} while (c != '\0');
56*7c478bd9Sstevel@tonic-gate }
57