aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--support.c31
-rw-r--r--support.h11
2 files changed, 38 insertions, 4 deletions
diff --git a/support.c b/support.c
index 15f084c1c..28297e418 100644
--- a/support.c
+++ b/support.c
@@ -1,3 +1,4 @@
+#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -34,8 +35,6 @@ iconv_t iconv_to_uft8 = (iconv_t)(-1);
#endif
-#ifndef HAVE_LIBGEN_H
-
char *
remove_trailing_slash(char *path)
{
@@ -51,7 +50,25 @@ remove_trailing_slash(char *path)
return path;
}
+char *
+lowerstr(char *str)
+{
+ size_t i;
+ size_t len = strlen(str);
+ if( str==NULL )
+ return NULL;
+
+ i=0;
+ while(i<len && str[i])
+ {
+ str[i] = tolower(str[i]);
+ i++;
+ }
+ return str;
+}
+
+#ifndef HAVE_BASENAME
char *
basename(char *path)
{
@@ -68,8 +85,16 @@ basename(char *path)
return path;
}
+#endif /* HAVE_BASENAME */
+
-#endif /* HAVE_LIBGEN_H */
+#ifndef HAVE_STRCASESTR
+char *
+strcasestr(const char *haystack, const char *needle)
+{
+ return strstr(lowerstr(haystack), lowerstr(needle));
+}
+#endif /* HAVE_STRCASESTR */
int
diff --git a/support.h b/support.h
index c0b9c34dc..da5ac5ed8 100644
--- a/support.h
+++ b/support.h
@@ -1,10 +1,19 @@
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
-#else
+#endif
+
+
+#ifndef HAVE_BASENAME
char *basename(char *path);
#endif
+#ifndef HAVE_STRCASESTR
+char *strcasestr(const char *haystack, const char *needle);
+#endif
+
+char *remove_trailing_slash(char *path);
+char *lowerstr(char *str);
int charset_init(void);