summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/string.h1
-rw-r--r--src/lib/string.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/include/string.h b/src/include/string.h
index 8eef0680cb..3cfa18d33c 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -29,6 +29,7 @@ int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, int maxlen);
int strspn(const char *str, const char *spn);
int strcspn(const char *str, const char *spn);
+char *strstr(const char *haystack, const char *needle);
char *strtok_r(char *str, const char *delim, char **ptr);
char *strtok(char *str, const char *delim);
long atol(const char *str);
diff --git a/src/lib/string.c b/src/lib/string.c
index e8f72a28e8..9677520137 100644
--- a/src/lib/string.c
+++ b/src/lib/string.c
@@ -163,6 +163,16 @@ int strcspn(const char *str, const char *spn)
return ret;
}
+char *strstr(const char *haystack, const char *needle)
+{
+ size_t needle_len = strlen(needle);
+ for (; *haystack; haystack++) {
+ if (!strncmp(haystack, needle, needle_len))
+ return (char *)haystack;
+ }
+ return NULL;
+}
+
char *strtok_r(char *str, const char *delim, char **ptr)
{
char *start;