156cd124msmith/*
256cd124msmith * Copyright (c) 1987, 1993
356cd124msmith *	The Regents of the University of California.  All rights reserved.
456cd124msmith *
556cd124msmith * Redistribution and use in source and binary forms, with or without
656cd124msmith * modification, are permitted provided that the following conditions
756cd124msmith * are met:
856cd124msmith * 1. Redistributions of source code must retain the above copyright
956cd124msmith *    notice, this list of conditions and the following disclaimer.
1056cd124msmith * 2. Redistributions in binary form must reproduce the above copyright
1156cd124msmith *    notice, this list of conditions and the following disclaimer in the
1256cd124msmith *    documentation and/or other materials provided with the distribution.
137e6cabdimp * 3. Neither the name of the University nor the names of its contributors
1456cd124msmith *    may be used to endorse or promote products derived from this software
1556cd124msmith *    without specific prior written permission.
1656cd124msmith *
1756cd124msmith * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1856cd124msmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1956cd124msmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2056cd124msmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2156cd124msmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2256cd124msmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2356cd124msmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2456cd124msmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2556cd124msmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2656cd124msmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2756cd124msmith * SUCH DAMAGE.
2856cd124msmith */
2956cd124msmith
3056cd124msmith#include <sys/cdefs.h>
31f6666a6dillon__FBSDID("$FreeBSD$");
32f6666a6dillon
33f6666a6dillon#include <sys/cdefs.h>
3456cd124msmith#include <string.h>
3556cd124msmith#include "stand.h"
3656cd124msmith
3756cd124msmith#if defined(LIBC_SCCS) && !defined(lint)
3856cd124msmithstatic char sccsid[] = "@(#)strcasecmp.c	8.1 (Berkeley) 6/4/93";
3956cd124msmith#endif /* LIBC_SCCS and not lint */
4056cd124msmith
4156cd124msmithint
4256cd124msmithstrcasecmp(s1, s2)
4356cd124msmith	const char *s1, *s2;
4456cd124msmith{
45084b458obrien	const u_char
4656cd124msmith			*us1 = (const u_char *)s1,
4756cd124msmith			*us2 = (const u_char *)s2;
4856cd124msmith
4956cd124msmith	while (tolower(*us1) == tolower(*us2++))
5056cd124msmith		if (*us1++ == '\0')
5156cd124msmith			return (0);
5256cd124msmith	return (tolower(*us1) - tolower(*--us2));
5356cd124msmith}
5456cd124msmith
5556cd124msmithint
5656cd124msmithstrncasecmp(s1, s2, n)
5756cd124msmith	const char *s1, *s2;
58084b458obrien	size_t n;
5956cd124msmith{
6056cd124msmith	if (n != 0) {
61084b458obrien		const u_char
6256cd124msmith				*us1 = (const u_char *)s1,
6356cd124msmith				*us2 = (const u_char *)s2;
6456cd124msmith
6556cd124msmith		do {
6656cd124msmith			if (tolower(*us1) != tolower(*us2++))
6756cd124msmith				return (tolower(*us1) - tolower(*--us2));
6856cd124msmith			if (*us1++ == '\0')
6956cd124msmith				break;
7056cd124msmith		} while (--n != 0);
7156cd124msmith	}
7256cd124msmith	return (0);
7356cd124msmith}
74