1 #include <ctype.h> 2 #include <stddef.h> 3 4 #ifndef CONFIG_STRCASESTR 5 strcasestr(const char * s1,const char * s2)6char *strcasestr(const char *s1, const char *s2) 7 { 8 const char *s = s1; 9 const char *p = s2; 10 11 do { 12 if (!*p) 13 return (char *) s1; 14 if ((*p == *s) || 15 (tolower(*p) == tolower(*s))) { 16 ++p; 17 ++s; 18 } else { 19 p = s2; 20 if (!*s) 21 return NULL; 22 s = ++s1; 23 } 24 } while (1); 25 26 return *p ? NULL : (char *) s1; 27 } 28 29 #endif 30