xref: /haiku/src/system/libroot/posix/string/strstr.c (revision 24159a0c7d6d6dcba9f2a0c1a7c08d2c8167f21b)
1 /*
2 ** Copyright 2001, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 
6 #include <sys/types.h>
7 #include <string.h>
8 
9 
10 char *
11 strstr(char const *s1, char const *s2)
12 {
13 	int l1, l2;
14 
15 	l2 = strlen(s2);
16 	if (!l2)
17 		return (char *)s1;
18 	l1 = strlen(s1);
19 	while (l1 >= l2) {
20 		l1--;
21 		if (!memcmp(s1,s2,l2))
22 			return (char *)s1;
23 		s1++;
24 	}
25 	return NULL;
26 }
27