]> Pileus Git - ~andy/fetchmail/blob - strcasecmp.c
c1f3bbd82296d3ab9b41ab586950b7116327cd2d
[~andy/fetchmail] / strcasecmp.c
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 strcasecmp(char *s1, char *s2)
10 {
11     while (toupper(*s1) == toupper(*s2++))
12         if (*s1++ == '\0')
13             return(0);
14     return(toupper(*s1) - toupper(*--s2));
15 }
16
17 strncasecmp(char *s1, char *s2, register int n)
18 {
19     while (--n >= 0 && toupper(*s1) == toupper(*s2++))
20         if (toupper(*s1++) == '\0')
21             return(0);
22     return(n < 0 ? 0 : toupper(*s1) - toupper(*--s2));
23 }