blob: 73fab1cc631061b3b08059b7e84c55b8cfcced43 [file] [log] [blame]
Christian Gmeiner2077ceb2007-09-17 23:06:23 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
Daniel Stenberga20f32d2007-09-18 07:04:05 +000010 * Copyright (C) 1991, 1992 Linus Torvalds
11 * (from linux/lib/string.c)
Christian Gmeiner2077ceb2007-09-17 23:06:23 +000012 *
13 ****************************************************************************/
14
15#include <string.h>
16
17/**
Daniel Stenberga20f32d2007-09-18 07:04:05 +000018 * strstr - Find the first substring in a %NUL terminated string
19 * @s1: The string to be searched
20 * @s2: The string to search for
Christian Gmeiner2077ceb2007-09-17 23:06:23 +000021 */
Daniel Stenberga20f32d2007-09-18 07:04:05 +000022char *strstr(const char *s1, const char *s2)
Christian Gmeiner2077ceb2007-09-17 23:06:23 +000023{
Daniel Stenberga20f32d2007-09-18 07:04:05 +000024 int l1, l2;
Christian Gmeiner2077ceb2007-09-17 23:06:23 +000025
Daniel Stenberga20f32d2007-09-18 07:04:05 +000026 l2 = strlen(s2);
27 if (!l2)
28 return (char *)s1;
29 l1 = strlen(s1);
30 while (l1 >= l2) {
31 l1--;
32 if (!memcmp(s1, s2, l2))
33 return (char *)s1;
34 s1++;
Christian Gmeiner2077ceb2007-09-17 23:06:23 +000035 }
Daniel Stenberga20f32d2007-09-18 07:04:05 +000036 return NULL;
Christian Gmeiner2077ceb2007-09-17 23:06:23 +000037}
Daniel Stenberga20f32d2007-09-18 07:04:05 +000038