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