/* $Id: strcasecmp.c,v 1.1 1997/04/15 10:09:54 archer Exp $
 *	STRCASECMP.C - Subroutines not included with your OS
 */
#include "config.h"
#include <ctype.h>


#ifndef HAVE_STRCASECMP
/**
 ** STRCASECMP
 **	Old systems do not have this yet
 **/
int strcasecmp(const char *s1, const char *s2)
{
char	a, b;
	while (*s1) {
		if (isupper(*s1))
			a = *s1++ | 0x20;
		else
			a = *s1++;
		if (isupper(*s2))
			b = *s2++ | 0x20;
		else
			b = *s2++;
		if (a < b)
			return -1;
		if (a > b)
			return 1;
	}
	if (*s2)
		return -1;
	return 0;
}


/**
 ** STRNCASECMP
 **	Old systems do not have this yet
 **/
int strncasecmp(const char *s1, const char *s2, size_t n)
{
char	a, b;
	while (*s1) {
		if (isupper(*s1))
			a = *s1++ | 0x20;
		else
			a = *s1++;
		if (isupper(*s2))
			b = *s2++ | 0x20;
		else
			b = *s2++;
		if (a < b)
			return -1;
		if (a > b)
			return 1;
		if (--n <= 0)
			return 0;
	}
	if (*s2)
		return -1;
	return 0;
}
#endif /*!HAVE_STRCASECMP*/
