static char rcsid[] = "@(#)$Id: chloc.c,v 1.6 2006/04/09 07:37:05 hurtta Exp $";

/******************************************************************************
 *  The Elm (ME+) Mail System  -  $Revision: 1.6 $   $State: Exp $
 *
 *  Modified by: Kari Hurtta <hurtta+elm@posti.FMI.FI>
 *                           (was hurtta+elm@ozone.FMI.FI)
 ******************************************************************************
 *  The Elm Mail System 
 *
 *			Copyright (c) 1988-1992 USENET Community Trust
 *			Copyright (c) 1986,1987 Dave Taylor
 *****************************************************************************/

/** 

**/

#include "headers.h"

/* Is this really needed? This does same than strchr or index, except
 *  that return type is different.
 *
 *                          - K E H <hurtta@ozone.FMI.FI>
 */

/* Argument (second) can't be char because there is both prototype and
 * non-prototype declaration.
 */
int chloc(string, ch)
     char *string;
     int ch;
{
	/** returns the index of ch in string, or -1 if not in string **/
	char *s;

	for (s = string; *s; s++)
		if (*s == ch)
			return(s - string);
	return(-1);
}

int qchloc(string, ch)
     char *string;
     int ch;
{
	/* returns the index of ch in string, or -1 if not in string
         * skips over quoted portions of the string
	 */
	register char *s;
	register int l;

	for (s = string; *s; s++) {
		l = len_next_part(s);
		if (l > 1) { /* a quoted char/string can not be a match */
			s += l - 1;
			continue;
		}

		if (*s == ch)
			return(s - string);
	}

	return(-1);
}

/*
 * Local Variables:
 *  mode:c
 *  c-basic-offset:4
 *  buffer-file-coding-system: iso-8859-1
 * End:
 */


syntax highlighted by Code2HTML, v. 0.9.1