summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8070f93)
raw | patch | inline | side by side (parent: 8070f93)
| author | Kalle Wallin <kaw@linux.se> | |
| Mon, 22 Mar 2004 19:37:17 +0000 (19:37 +0000) | ||
| committer | Kalle Wallin <kaw@linux.se> | |
| Mon, 22 Mar 2004 19:37:17 +0000 (19:37 +0000) | 
| support.c | patch | blob | history | |
| support.h | patch | blob | history | 
diff --git a/support.c b/support.c
index 15f084c1cd84afb006ab604bc6ff55f7255e91d4..28297e41846657f2a20f81ce625f6c4835302aa0 100644 (file)
--- a/support.c
+++ b/support.c
+#include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #endif
-#ifndef HAVE_LIBGEN_H
-
 char *
 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)
 {
   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 c0b9c34dc05b33ca0b88d8c69249de203b5deaa8..da5ac5ed800457bd9740264bb884ab5e0a11ad92 100644 (file)
--- a/support.h
+++ b/support.h
 #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);
![[tokkee]](http://tokkee.org/images/avatar.png)
