aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/lib/string/strstr.c
blob: 720df8cb9655fcc4824aa5fd528b431bee37cae4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <lib/stdlib.h>
#include <stdint.h>

char *strstr(const char *in, const char *str)
{
	char c;
	u32 len;

	c = *str++;
	if (!c)
		return (char *)in;

	len = strlen(str);
	do {
		char sc;

		do {
			sc = *in++;
			if (!sc)
				return (char *)0;
		} while (sc != c);
	} while (strncmp(in, str, len) != 0);

	return (char *)(in - 1);
}