190792Sgshapiro/*
2261194Sgshapiro * Copyright (c) 2001 Proofpoint, Inc. and its suppliers.
390792Sgshapiro *      All rights reserved.
490792Sgshapiro *
590792Sgshapiro * By using this file, you agree to the terms and conditions set
690792Sgshapiro * forth in the LICENSE file which can be found at the top level of
790792Sgshapiro * the sendmail distribution.
890792Sgshapiro *
990792Sgshapiro */
1090792Sgshapiro
1190792Sgshapiro#include <sm/gen.h>
12266527SgshapiroSM_RCSID("@(#)$Id: string.c,v 1.4 2013-11-22 20:51:43 ca Exp $")
1390792Sgshapiro
1490792Sgshapiro#include <ctype.h>
1590792Sgshapiro#include <errno.h>
1690792Sgshapiro
1790792Sgshapiro#include <sm/string.h>
1890792Sgshapiro
1990792Sgshapiro/*
2090792Sgshapiro**  STRIPQUOTES -- Strip quotes & quote bits from a string.
2190792Sgshapiro**
2290792Sgshapiro**	Runs through a string and strips off unquoted quote
2390792Sgshapiro**	characters and quote bits.  This is done in place.
2490792Sgshapiro**
2590792Sgshapiro**	Parameters:
2690792Sgshapiro**		s -- the string to strip.
2790792Sgshapiro**
2890792Sgshapiro**	Returns:
2990792Sgshapiro**		none.
3090792Sgshapiro**
3190792Sgshapiro**	Side Effects:
3290792Sgshapiro**		none.
3390792Sgshapiro*/
3490792Sgshapiro
3590792Sgshapirovoid
3690792Sgshapirostripquotes(s)
3790792Sgshapiro	char *s;
3890792Sgshapiro{
3990792Sgshapiro	register char *p;
4090792Sgshapiro	register char *q;
4190792Sgshapiro	register char c;
4290792Sgshapiro
4390792Sgshapiro	if (s == NULL)
4490792Sgshapiro		return;
4590792Sgshapiro
4690792Sgshapiro	p = q = s;
4790792Sgshapiro	do
4890792Sgshapiro	{
4990792Sgshapiro		c = *p++;
5090792Sgshapiro		if (c == '\\')
5190792Sgshapiro			c = *p++;
5290792Sgshapiro		else if (c == '"')
5390792Sgshapiro			continue;
5490792Sgshapiro		*q++ = c;
5590792Sgshapiro	} while (c != '\0');
5690792Sgshapiro}
57