summaryrefslogtreecommitdiff
path: root/utils/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/utils.c')
-rw-r--r--utils/utils.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/utils.c b/utils/utils.c
index 1db7f18b9..fca35ab21 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -214,3 +214,24 @@ const char *rfc1123_date(time_t t)
return ret;
}
+
+/**
+ * Case insensitive strstr implementation
+ *
+ * \param haystack String to search in
+ * \param needle String to look for
+ * \return Pointer to start of found substring, or NULL if not found
+ */
+char *strcasestr(const char *haystack, const char *needle)
+{
+ size_t needle_len = strlen(needle);
+ const char * last_start = haystack + (strlen(haystack) - needle_len);
+
+ while (haystack <= last_start) {
+ if (strncasecmp(haystack, needle, needle_len) == 0)
+ return (char *)haystack;
+ haystack++;
+ }
+
+ return NULL;
+}