+int stricmp (const char *s1, const char *s2) {
+ return stricmplen(s1, s2, -1);
+}
+
+int stricmplen(const char *s1, const char *s2, int len) {
+ if (s1 == NULL)
+ return (s2 == NULL ? 0 : -(*s2));
+ if (s2 == NULL)
+ return *s1;
+ char c1, c2;
+ int i = 0;
+ while ((c1 = tolower(*s1)) == (c2 = tolower(*s2))) {
+ if (*s1 == '\0')
+ break;
+ i++;
+ s1++;
+ s2++;
+ if(len != -1 && i == len) break;
+ }
+ return c1 - c2;
+}
+