diff options
author | Kalle Wallin <kaw@linux.se> | 2004-03-22 19:37:17 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2004-03-22 19:37:17 +0000 |
commit | 740715e48c06d79963bb192292cb802f02a03a4d (patch) | |
tree | 1e04c149c4f11eaca61c914fb874d965054e6979 /support.c | |
parent | 8070f9392e545a7b87ebb188d025afc5358c98f1 (diff) | |
download | mpd-740715e48c06d79963bb192292cb802f02a03a4d.tar.gz mpd-740715e48c06d79963bb192292cb802f02a03a4d.tar.xz mpd-740715e48c06d79963bb192292cb802f02a03a4d.zip |
Added an implementation of strcasecmp for non glibc systems.
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'support.c')
-rw-r--r-- | support.c | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -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 |