aboutsummaryrefslogtreecommitdiffstats
path: root/support.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--support.c31
1 files changed, 28 insertions, 3 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