diff options
Diffstat (limited to 'common/stringop.c')
-rw-r--r-- | common/stringop.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/stringop.c b/common/stringop.c index d9ae9925..d2c91c24 100644 --- a/common/stringop.c +++ b/common/stringop.c @@ -401,3 +401,17 @@ char *argsep(char **stringp, const char *delim) { found: return start; } + +const char *strcasestr(const char *haystack, const char *needle) { + size_t needle_len = strlen(needle); + const char *pos = haystack; + const char *end = pos + strlen(haystack) - needle_len; + + while (pos <= end) { + if (strncasecmp(pos, needle, needle_len) == 0) { + return pos; + } + ++pos; + } + return NULL; +} |