aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/stringop.c14
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) {
401 found: 401 found:
402 return start; 402 return start;
403} 403}
404
405const char *strcasestr(const char *haystack, const char *needle) {
406 size_t needle_len = strlen(needle);
407 const char *pos = haystack;
408 const char *end = pos + strlen(haystack) - needle_len;
409
410 while (pos <= end) {
411 if (strncasecmp(pos, needle, needle_len) == 0) {
412 return pos;
413 }
414 ++pos;
415 }
416 return NULL;
417}