Prepare new maemo release
[maemo-rb.git] / firmware / common / strcasecmp.c
blobcdfbe2f81a27750601eaffbd906dff3702a35f7b
2 #include <string.h>
3 #include <ctype.h>
5 #ifndef strcasecmp
6 int strcasecmp(const char *s1, const char *s2)
8 while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
9 s1++;
10 s2++;
13 return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
15 #endif
17 #ifndef strncasecmp
18 int strncasecmp(const char *s1, const char *s2, size_t n)
20 int d = 0;
22 for(; n != 0; n--)
24 int c1 = tolower(*s1++);
25 int c2 = tolower(*s2++);
26 if((d = c1 - c2) != 0 || c2 == '\0')
27 break;
30 return d;
32 #endif