1 // Copyright 2016 The Fuchsia Authors 2 // Copyright (c) 2008 Travis Geiselbrecht 3 // 4 // Use of this source code is governed by a MIT-style 5 // license that can be found in the LICENSE file or at 6 // https://opensource.org/licenses/MIT 7 8 #include <string.h> 9 #include <sys/types.h> 10 11 char * strstr(char const * s1,char const * s2)12strstr(char const *s1, char const *s2) 13 { 14 int l1, l2; 15 16 l2 = strlen(s2); 17 if (!l2) 18 return (char *)s1; 19 l1 = strlen(s1); 20 while (l1 >= l2) { 21 l1--; 22 if (!memcmp(s1,s2,l2)) 23 return (char *)s1; 24 s1++; 25 } 26 return NULL; 27 } 28