summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/compat.c28
-rw-r--r--common/compat.h4
2 files changed, 32 insertions, 0 deletions
diff --git a/common/compat.c b/common/compat.c
index 40e4c73..1c620aa 100644
--- a/common/compat.c
+++ b/common/compat.c
@@ -179,6 +179,34 @@ size_t strlcat(char* dst, const char* src, size_t siz)
#endif
+#ifndef HAVE_STRCASESTR
+
+const char* strcasestr(const char *s, const char *find)
+{
+ char c, sc;
+ size_t len;
+
+ if((c = *find++) != 0)
+ {
+ c = tolower((unsigned char)c);
+ len = strlen(find);
+ do
+ {
+ do
+ {
+ if((sc = *s++) == 0)
+ return (NULL);
+ }
+ while((char)tolower((unsigned char)sc) != c);
+ }
+ while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return((const char*)s);
+}
+
+#endif
+
#ifndef HAVE_SETENV
#include <stdio.h>
diff --git a/common/compat.h b/common/compat.h
index 44c45e0..89f7fbb 100644
--- a/common/compat.h
+++ b/common/compat.h
@@ -88,6 +88,10 @@ size_t strlcat(char *dst, const char *src, size_t size);
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
+#ifndef HAVE_STRCASESTR
+const char* strcasestr(const char *s, const char *find);
+#endif
+
#ifndef HAVE_SETENV
int setenv(const char* name, const char* value, int overwrite);
#endif