1 #include <u.h> 2 #include <libc.h> 3 4 /* 5 * Return pointer to first occurrence of s2 in s1, 6 * 0 if none 7 */ 8 char* 9 strstr(char *s1, char *s2) 10 { 11 char *p; 12 int f, n; 13 14 f = s2[0]; 15 if(f == 0) 16 return s1; 17 n = strlen(s2); 18 for(p=strchr(s1, f); p; p=strchr(p+1, f)) 19 if(strncmp(p, s2, n) == 0) 20 return p; 21 return 0; 22 } 23