1
/* 
2
 * scratch implementation of strcasecmp(), 
3
 * in case your C library doesn't have it 
4
 *
5
 * For license terms, see the file COPYING in this directory.
6
 */
7
#include <ctype.h>
8
9
int strcasecmp(char *s1, char *s2)
10
{
11
    while (toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
12
	if (*s1++ == '\0')
13
	    return 0;
14
    return(toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
15
}
16
17
int strncasecmp(char *s1, char *s2, register int n)
18
{
19
    while (--n >= 0 && toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
20
	if (*s1++ == '\0')
21
	    return 0;
22
    return(n < 0 ? 0 : toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
23
}