2002-06-18 08:19:38 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2011-12-04 21:07:06 +00:00
|
|
|
#ifndef strcasecmp
|
2002-06-18 08:19:38 +00:00
|
|
|
int strcasecmp(const char *s1, const char *s2)
|
|
|
|
{
|
|
|
|
while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
|
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
|
|
|
|
}
|
2011-12-04 21:07:06 +00:00
|
|
|
#endif
|
2002-06-18 08:19:38 +00:00
|
|
|
|
2011-12-04 21:07:06 +00:00
|
|
|
#ifndef strncasecmp
|
2002-06-18 08:19:38 +00:00
|
|
|
int strncasecmp(const char *s1, const char *s2, size_t n)
|
|
|
|
{
|
2010-02-07 00:37:47 +00:00
|
|
|
int d = 0;
|
|
|
|
|
|
|
|
for(; n != 0; n--)
|
|
|
|
{
|
|
|
|
int c1 = tolower(*s1++);
|
|
|
|
int c2 = tolower(*s2++);
|
|
|
|
if((d = c1 - c2) != 0 || c2 == '\0')
|
|
|
|
break;
|
2002-06-18 08:19:38 +00:00
|
|
|
}
|
2010-02-07 00:37:47 +00:00
|
|
|
|
|
|
|
return d;
|
2002-06-18 08:19:38 +00:00
|
|
|
}
|
2011-12-04 21:07:06 +00:00
|
|
|
#endif
|