diff --git a/src/ezstream.c b/src/ezstream.c index 6a00941..f471156 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -624,7 +624,9 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag, close(stderr_fd); return (filep); - } + } else if (strrcasecmp(fileName, ".mp3") == 0) + /* MP3 streams are special: */ + setMetadata(shout, mdata, NULL); metadata_free(&mdata); @@ -816,7 +818,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName, clearerr(filepstream); ret = STREAM_CONT; } else - printf("%s: streamFile(): Error while reading '%s': %s\n", + printf("%s: sendStream(): Error while reading '%s': %s\n", __progname, fileName, strerror(errno)); } @@ -1306,21 +1308,16 @@ main(int argc, char *argv[]) if (shout_open(shout) == SHOUTERR_SUCCESS) { int ret; - char *tmpFileName, *p; printf("%s: Connected to http://%s:%d%s\n", __progname, host, port, mount); - tmpFileName = xstrdup(pezConfig->fileName); - for (p = tmpFileName; *p != '\0'; p++) - *p = tolower((int)*p); if (pezConfig->fileNameIsProgram || - strrcmp(tmpFileName, ".m3u") == 0 || - strrcmp(tmpFileName, ".txt") == 0) + strrcasecmp(pezConfig->fileName, ".m3u") == 0 || + strrcasecmp(pezConfig->fileName, ".txt") == 0) playlistMode = 1; else playlistMode = 0; - xfree(tmpFileName); if (vFlag && pezConfig->fileNameIsProgram) printf("%s: Using program '%s' to get filenames for streaming\n", diff --git a/src/util.c b/src/util.c index 32254c3..4f8f99e 100644 --- a/src/util.c +++ b/src/util.c @@ -21,9 +21,12 @@ # include "config.h" #endif +#include +#include #include #include "util.h" +#include "xalloc.h" int strrcmp(const char *s, const char *sub) @@ -36,3 +39,25 @@ strrcmp(const char *s, const char *sub) return (memcmp(s + slen - sublen, sub, sublen)); } + +int +strrcasecmp(const char *s, const char *sub) +{ + char *s_cpy = xstrdup(s); + char *sub_cpy = xstrdup(sub); + char *p; + int ret; + + for (p = s_cpy; *p != '\0'; p++) + *p = tolower((int)*p); + + for (p = sub_cpy; *p != '\0'; p++) + *p = tolower((int)*p); + + ret = strrcmp(s_cpy, sub_cpy); + + xfree(s_cpy); + xfree(sub_cpy); + + return (ret); +} diff --git a/src/util.h b/src/util.h index 7da0108..105cc67 100644 --- a/src/util.h +++ b/src/util.h @@ -21,5 +21,6 @@ #define __UTIL_H__ int strrcmp(const char *, const char *); +int strrcasecmp(const char *, const char *); #endif /* __UTIL_H__ */