mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-11-03 04:17:18 -05:00
Use log API for all regular output messages
This makes ezstream log via syslog and stderr. The "real-time status line" remains unaffected. While here, make the output more concise and consistent.
This commit is contained in:
parent
19af508eae
commit
41058dac79
176
src/configfile.c
176
src/configfile.c
@ -17,12 +17,14 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ezstream.h"
|
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
#include "cfg.h"
|
#include "ezstream.h"
|
||||||
|
|
||||||
|
#include <libxml/parser.h>
|
||||||
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
@ -77,6 +79,13 @@ getFormatDecoder(const char *match)
|
|||||||
return (blankString);
|
return (blankString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CFGERROR_TOO_MANY(x) \
|
||||||
|
do { \
|
||||||
|
log_error("%s[%ld]: more than one <%s> element", \
|
||||||
|
fileName, xmlGetLineNo(cur), (x)); \
|
||||||
|
config_error++; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
int
|
int
|
||||||
parseConfig(const char *fileName)
|
parseConfig(const char *fileName)
|
||||||
{
|
{
|
||||||
@ -90,14 +99,14 @@ parseConfig(const char *fileName)
|
|||||||
|
|
||||||
xmlLineNumbersDefault(1);
|
xmlLineNumbersDefault(1);
|
||||||
if ((doc = xmlParseFile(fileName)) == NULL) {
|
if ((doc = xmlParseFile(fileName)) == NULL) {
|
||||||
printf("%s: Parse error (not well-formed XML.)\n", fileName);
|
log_error("%s: not well-formed", fileName);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur = xmlDocGetRootElement(doc);
|
cur = xmlDocGetRootElement(doc);
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
printf("%s: Parse error (empty XML document.)\n", fileName);
|
log_error("%s: empty document", fileName);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -116,9 +125,7 @@ parseConfig(const char *fileName)
|
|||||||
for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
|
for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"url")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"url")) {
|
||||||
if (ezConfig.URL != NULL) {
|
if (ezConfig.URL != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <url> elements\n",
|
CFGERROR_TOO_MANY("url");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -129,9 +136,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"sourceuser")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"sourceuser")) {
|
||||||
if (ezConfig.username != NULL) {
|
if (ezConfig.username != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <sourceuser> elements\n",
|
CFGERROR_TOO_MANY("sourceuser");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -142,9 +147,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"sourcepassword")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"sourcepassword")) {
|
||||||
if (ezConfig.password != NULL) {
|
if (ezConfig.password != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <sourcepassword> elements\n",
|
CFGERROR_TOO_MANY("sourcepassword");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -155,9 +158,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"format")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"format")) {
|
||||||
if (ezConfig.format != NULL) {
|
if (ezConfig.format != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
|
CFGERROR_TOO_MANY("format");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -172,15 +173,13 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"filename")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"filename")) {
|
||||||
if (ezConfig.fileName != NULL) {
|
if (ezConfig.fileName != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <filename> elements\n",
|
CFGERROR_TOO_MANY("filename");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
if (strlen(ls_xmlContentPtr) > PATH_MAX - 1) {
|
if (strlen(ls_xmlContentPtr) > PATH_MAX - 1) {
|
||||||
printf("%s[%ld]: Error: Path or filename in <filename> is too long\n",
|
log_error("%s[%ld]: path or filename in <filename> too long",
|
||||||
fileName, xmlGetLineNo(cur));
|
fileName, xmlGetLineNo(cur));
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -191,15 +190,13 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_progname")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_progname")) {
|
||||||
if (ezConfig.metadataProgram != NULL) {
|
if (ezConfig.metadataProgram != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <metadata_progname> elements\n",
|
CFGERROR_TOO_MANY("metadata_progname");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
if (strlen(ls_xmlContentPtr) > PATH_MAX - 1) {
|
if (strlen(ls_xmlContentPtr) > PATH_MAX - 1) {
|
||||||
printf("%s[%ld]: Error: Path or filename in <metadata_progname> is too long\n",
|
log_error("%s[%ld]: path or filename in <metadata_progname> too long",
|
||||||
fileName, xmlGetLineNo(cur));
|
fileName, xmlGetLineNo(cur));
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -210,9 +207,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_format")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_format")) {
|
||||||
if (ezConfig.metadataFormat != NULL) {
|
if (ezConfig.metadataFormat != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <metadata_format> elements\n",
|
CFGERROR_TOO_MANY("metadata_format");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -230,9 +225,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_refreshinterval")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_refreshinterval")) {
|
||||||
if (refresh_set) {
|
if (refresh_set) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <metadata_refreshinterval> elements\n",
|
CFGERROR_TOO_MANY("metadata_refreshinterval");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -240,7 +233,7 @@ parseConfig(const char *fileName)
|
|||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
ezConfig.metadataRefreshInterval = (int)strtonum(ls_xmlContentPtr, -1LL, (long long)INT_MAX, &errstr);
|
ezConfig.metadataRefreshInterval = (int)strtonum(ls_xmlContentPtr, -1LL, (long long)INT_MAX, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s[%ld]: Error: In <metadata_refreshinterval>: '%s' is %s\n",
|
log_error("%s[%ld]: <metadata_refreshinterval>: %s: %s",
|
||||||
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -251,9 +244,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"playlist_program")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"playlist_program")) {
|
||||||
if (program_set) {
|
if (program_set) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <playlist_program> elements\n",
|
CFGERROR_TOO_MANY("playlist_program");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -262,7 +253,7 @@ parseConfig(const char *fileName)
|
|||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
ezConfig.fileNameIsProgram = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
ezConfig.fileNameIsProgram = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s[%ld]: Error: <playlist_program> may only contain 1 or 0\n",
|
log_error("%s[%ld]: <playlist_program> may only contain 1 or 0",
|
||||||
fileName, xmlGetLineNo(cur));
|
fileName, xmlGetLineNo(cur));
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -273,9 +264,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"shuffle")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"shuffle")) {
|
||||||
if (shuffle_set) {
|
if (shuffle_set) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <shuffle> elements\n",
|
CFGERROR_TOO_MANY("shuffle");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -284,7 +273,7 @@ parseConfig(const char *fileName)
|
|||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
ezConfig.shuffle = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
ezConfig.shuffle = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s[%ld]: Error: <shuffle> may only contain 1 or 0\n",
|
log_error("%s[%ld]: <shuffle> may only contain 1 or 0",
|
||||||
fileName, xmlGetLineNo(cur));
|
fileName, xmlGetLineNo(cur));
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -295,9 +284,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"stream_once")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"stream_once")) {
|
||||||
if (streamOnce_set) {
|
if (streamOnce_set) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <stream_once> elements\n",
|
CFGERROR_TOO_MANY("stream_once");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -306,7 +293,7 @@ parseConfig(const char *fileName)
|
|||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
ezConfig.streamOnce = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
ezConfig.streamOnce = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s[%ld]: Error: <stream_once> may only contain 1 or 0\n",
|
log_error("%s[%ld]: <stream_once> may only contain 1 or 0",
|
||||||
fileName, xmlGetLineNo(cur));
|
fileName, xmlGetLineNo(cur));
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -317,9 +304,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"reconnect_tries")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"reconnect_tries")) {
|
||||||
if (reconnect_set) {
|
if (reconnect_set) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <reconnect_tries> elements\n",
|
CFGERROR_TOO_MANY("reconnect_tries");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -328,7 +313,7 @@ parseConfig(const char *fileName)
|
|||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
ezConfig.reconnectAttempts = (unsigned int)strtonum(ls_xmlContentPtr, 0LL, (long long)UINT_MAX, &errstr);
|
ezConfig.reconnectAttempts = (unsigned int)strtonum(ls_xmlContentPtr, 0LL, (long long)UINT_MAX, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s[%ld]: Error: In <reconnect_tries>: '%s' is %s\n",
|
log_error("%s[%ld]: <reconnect_tries>: %s: %s",
|
||||||
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -339,9 +324,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoname")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoname")) {
|
||||||
if (ezConfig.serverName != NULL) {
|
if (ezConfig.serverName != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfoname> elements\n",
|
CFGERROR_TOO_MANY("svrinfoname");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -352,9 +335,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfourl")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfourl")) {
|
||||||
if (ezConfig.serverURL != NULL) {
|
if (ezConfig.serverURL != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfourl> elements\n",
|
CFGERROR_TOO_MANY("svrinfourl");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -365,9 +346,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfogenre")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfogenre")) {
|
||||||
if (ezConfig.serverGenre != NULL) {
|
if (ezConfig.serverGenre != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfogenre> elements\n",
|
CFGERROR_TOO_MANY("svrinfogenre");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -378,9 +357,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfodescription")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfodescription")) {
|
||||||
if (ezConfig.serverDescription != NULL) {
|
if (ezConfig.serverDescription != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfodescription> elements\n",
|
CFGERROR_TOO_MANY("svrinfodescription");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -391,9 +368,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfobitrate")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfobitrate")) {
|
||||||
if (ezConfig.serverBitrate != NULL) {
|
if (ezConfig.serverBitrate != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfobitrate> elements\n",
|
CFGERROR_TOO_MANY("svrinfobitrate");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -405,9 +380,7 @@ parseConfig(const char *fileName)
|
|||||||
|
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfochannels")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfochannels")) {
|
||||||
if (ezConfig.serverChannels != NULL) {
|
if (ezConfig.serverChannels != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfochannels> elements\n",
|
CFGERROR_TOO_MANY("svrinfochannels");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -418,9 +391,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfosamplerate")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfosamplerate")) {
|
||||||
if (ezConfig.serverSamplerate != NULL) {
|
if (ezConfig.serverSamplerate != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfosamplerate> elements\n",
|
CFGERROR_TOO_MANY("svrinfosamplerate");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -431,9 +402,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoquality")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoquality")) {
|
||||||
if (ezConfig.serverQuality != NULL) {
|
if (ezConfig.serverQuality != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfoquality> elements\n",
|
CFGERROR_TOO_MANY("svrinfoquality");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -444,9 +413,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfopublic")) {
|
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfopublic")) {
|
||||||
if (svrinfopublic_set) {
|
if (svrinfopublic_set) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfopublic> elements\n",
|
CFGERROR_TOO_MANY("svrinfopublic");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur->xmlChildrenNode != NULL) {
|
if (cur->xmlChildrenNode != NULL) {
|
||||||
@ -455,7 +422,7 @@ parseConfig(const char *fileName)
|
|||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||||
ezConfig.serverPublic = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
ezConfig.serverPublic = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s[%ld]: Error: <svrinfopublic> may only contain 1 or 0\n",
|
log_error("%s[%ld]: <svrinfopublic> may only contain 1 or 0",
|
||||||
fileName, xmlGetLineNo(cur));
|
fileName, xmlGetLineNo(cur));
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -473,9 +440,7 @@ parseConfig(const char *fileName)
|
|||||||
cur2 = cur2->next) {
|
cur2 = cur2->next) {
|
||||||
if (!xmlStrcmp(cur2->name, (const xmlChar *)"enable")) {
|
if (!xmlStrcmp(cur2->name, (const xmlChar *)"enable")) {
|
||||||
if (enable_set) {
|
if (enable_set) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <enable> elements\n",
|
CFGERROR_TOO_MANY("enable");
|
||||||
fileName, xmlGetLineNo(cur));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur2->xmlChildrenNode != NULL) {
|
if (cur2->xmlChildrenNode != NULL) {
|
||||||
@ -484,7 +449,7 @@ parseConfig(const char *fileName)
|
|||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
|
||||||
ezConfig.reencode = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
ezConfig.reencode = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s[%ld]: Error: <enable> may only contain 1 or 0\n",
|
log_error("%s[%ld]: <enable> may only contain 1 or 0",
|
||||||
fileName, xmlGetLineNo(cur));
|
fileName, xmlGetLineNo(cur));
|
||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
@ -503,9 +468,7 @@ parseConfig(const char *fileName)
|
|||||||
cur3 != NULL; cur3 = cur3->next) {
|
cur3 != NULL; cur3 = cur3->next) {
|
||||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"format")) {
|
if (!xmlStrcmp(cur3->name, (const xmlChar *)"format")) {
|
||||||
if (pformatEncDec->format != NULL) {
|
if (pformatEncDec->format != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
|
CFGERROR_TOO_MANY("format");
|
||||||
fileName, xmlGetLineNo(cur3));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur3->xmlChildrenNode != NULL) {
|
if (cur3->xmlChildrenNode != NULL) {
|
||||||
@ -520,9 +483,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"match")) {
|
if (!xmlStrcmp(cur3->name, (const xmlChar *)"match")) {
|
||||||
if (pformatEncDec->match != NULL) {
|
if (pformatEncDec->match != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <match> elements\n",
|
CFGERROR_TOO_MANY("match");
|
||||||
fileName, xmlGetLineNo(cur3));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur3->xmlChildrenNode != NULL) {
|
if (cur3->xmlChildrenNode != NULL) {
|
||||||
@ -537,9 +498,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"decode")) {
|
if (!xmlStrcmp(cur3->name, (const xmlChar *)"decode")) {
|
||||||
if (pformatEncDec->decoder != NULL) {
|
if (pformatEncDec->decoder != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <decode> elements\n",
|
CFGERROR_TOO_MANY("decode");
|
||||||
fileName, xmlGetLineNo(cur3));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur3->xmlChildrenNode != NULL) {
|
if (cur3->xmlChildrenNode != NULL) {
|
||||||
@ -557,9 +516,7 @@ parseConfig(const char *fileName)
|
|||||||
}
|
}
|
||||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"encode")) {
|
if (!xmlStrcmp(cur3->name, (const xmlChar *)"encode")) {
|
||||||
if (pformatEncDec->encoder != NULL) {
|
if (pformatEncDec->encoder != NULL) {
|
||||||
printf("%s[%ld]: Error: Cannot have multiple <encode> elements\n",
|
CFGERROR_TOO_MANY("encode");
|
||||||
fileName, xmlGetLineNo(cur3));
|
|
||||||
config_error++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cur3->xmlChildrenNode != NULL) {
|
if (cur3->xmlChildrenNode != NULL) {
|
||||||
@ -589,8 +546,7 @@ parseConfig(const char *fileName)
|
|||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
freeConfig(&ezConfig);
|
freeConfig(&ezConfig);
|
||||||
printf("%s: %u configuration error(s) in %s\n", cfg_progname(),
|
log_error("%s: %u configuration error(s)", fileName, config_error);
|
||||||
config_error, fileName);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -659,14 +615,14 @@ checkDecoderLine(const char *str, const char *file, long line)
|
|||||||
|
|
||||||
errors = 0;
|
errors = 0;
|
||||||
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in decoder command\n",
|
log_error("%s[%ld]: '%s' placeholder not allowed in decoder command",
|
||||||
file, line, STRING_PLACEHOLDER);
|
file, line, STRING_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(TRACK_PLACEHOLDER);
|
p += strlen(TRACK_PLACEHOLDER);
|
||||||
if ((p = strstr(p, TRACK_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, TRACK_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in decoder command",
|
||||||
file, line, TRACK_PLACEHOLDER);
|
file, line, TRACK_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
} else
|
} else
|
||||||
@ -675,7 +631,7 @@ checkDecoderLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(METADATA_PLACEHOLDER);
|
p += strlen(METADATA_PLACEHOLDER);
|
||||||
if ((p = strstr(p, METADATA_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, METADATA_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in decoder command",
|
||||||
file, line, METADATA_PLACEHOLDER);
|
file, line, METADATA_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -683,7 +639,7 @@ checkDecoderLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(ARTIST_PLACEHOLDER);
|
p += strlen(ARTIST_PLACEHOLDER);
|
||||||
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in decoder command",
|
||||||
file, line, ARTIST_PLACEHOLDER);
|
file, line, ARTIST_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -691,14 +647,14 @@ checkDecoderLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(TITLE_PLACEHOLDER);
|
p += strlen(TITLE_PLACEHOLDER);
|
||||||
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in decoder command",
|
||||||
file, line, TITLE_PLACEHOLDER);
|
file, line, TITLE_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!have_track) {
|
if (!have_track) {
|
||||||
printf("%s[%ld]: Error: The decoder command requires the '%s' track placeholder\n",
|
log_error("%s[%ld]: decoder command requires '%s' track placeholder",
|
||||||
file, line, TRACK_PLACEHOLDER);
|
file, line, TRACK_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -714,19 +670,19 @@ checkEncoderLine(const char *str, const char *file, long line)
|
|||||||
|
|
||||||
errors = 0;
|
errors = 0;
|
||||||
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in encoder command\n",
|
log_error("%s[%ld]: '%s' placeholder not allowed in encoder command",
|
||||||
file, line, TRACK_PLACEHOLDER);
|
file, line, TRACK_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in encoder command\n",
|
log_error("%s[%ld]: '%s' placeholder not allowed in encoder command",
|
||||||
file, line, STRING_PLACEHOLDER);
|
file, line, STRING_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(METADATA_PLACEHOLDER);
|
p += strlen(METADATA_PLACEHOLDER);
|
||||||
if ((p = strstr(p, METADATA_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, METADATA_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in encoder command\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in encoder command",
|
||||||
file, line, METADATA_PLACEHOLDER);
|
file, line, METADATA_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -734,7 +690,7 @@ checkEncoderLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(ARTIST_PLACEHOLDER);
|
p += strlen(ARTIST_PLACEHOLDER);
|
||||||
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in encoder command\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in encoder command",
|
||||||
file, line, ARTIST_PLACEHOLDER);
|
file, line, ARTIST_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -742,7 +698,7 @@ checkEncoderLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(TITLE_PLACEHOLDER);
|
p += strlen(TITLE_PLACEHOLDER);
|
||||||
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in encoder command\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in encoder command",
|
||||||
file, line, TITLE_PLACEHOLDER);
|
file, line, TITLE_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -759,14 +715,14 @@ checkFormatLine(const char *str, const char *file, long line)
|
|||||||
|
|
||||||
errors = 0;
|
errors = 0;
|
||||||
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in <metadata_format>\n",
|
log_error("%s[%ld]: '%s' placeholder not allowed in <metadata_format>",
|
||||||
file, line, METADATA_PLACEHOLDER);
|
file, line, METADATA_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(TRACK_PLACEHOLDER);
|
p += strlen(TRACK_PLACEHOLDER);
|
||||||
if ((p = strstr(p, TRACK_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, TRACK_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in <metadata_format>",
|
||||||
file, line, TRACK_PLACEHOLDER);
|
file, line, TRACK_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -774,7 +730,7 @@ checkFormatLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(STRING_PLACEHOLDER);
|
p += strlen(STRING_PLACEHOLDER);
|
||||||
if ((p = strstr(p, STRING_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, STRING_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in <metadata_format>",
|
||||||
file, line, STRING_PLACEHOLDER);
|
file, line, STRING_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -782,7 +738,7 @@ checkFormatLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(ARTIST_PLACEHOLDER);
|
p += strlen(ARTIST_PLACEHOLDER);
|
||||||
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in <metadata_format>",
|
||||||
file, line, ARTIST_PLACEHOLDER);
|
file, line, ARTIST_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
@ -790,7 +746,7 @@ checkFormatLine(const char *str, const char *file, long line)
|
|||||||
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
||||||
p += strlen(TITLE_PLACEHOLDER);
|
p += strlen(TITLE_PLACEHOLDER);
|
||||||
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
||||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
log_error("%s[%ld]: more than one '%s' placeholder in <metadata_format>",
|
||||||
file, line, TITLE_PLACEHOLDER);
|
file, line, TITLE_PLACEHOLDER);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
#ifndef __CONFIGFILE_H__
|
#ifndef __CONFIGFILE_H__
|
||||||
#define __CONFIGFILE_H__
|
#define __CONFIGFILE_H__
|
||||||
|
|
||||||
#include <libxml/parser.h>
|
|
||||||
|
|
||||||
#define MP3_FORMAT "MP3"
|
#define MP3_FORMAT "MP3"
|
||||||
#define VORBIS_FORMAT "VORBIS"
|
#define VORBIS_FORMAT "VORBIS"
|
||||||
#define THEORA_FORMAT "THEORA"
|
#define THEORA_FORMAT "THEORA"
|
||||||
|
218
src/ezstream.c
218
src/ezstream.c
@ -17,6 +17,8 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
#include "ezstream.h"
|
#include "ezstream.h"
|
||||||
|
|
||||||
#ifdef HAVE_SIGNAL_H
|
#ifdef HAVE_SIGNAL_H
|
||||||
@ -25,9 +27,9 @@
|
|||||||
|
|
||||||
#include <shout/shout.h>
|
#include <shout/shout.h>
|
||||||
|
|
||||||
#include "compat.h"
|
#include "cfg.h"
|
||||||
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
#include "log.h"
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -132,33 +134,33 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
|
||||||
if (hostname == NULL || port == NULL || mountname == NULL) {
|
if (hostname == NULL || port == NULL || mountname == NULL) {
|
||||||
printf("%s: urlParse(): Internal error: Bad arguments\n",
|
log_alert("urlParse: bad arguments");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(url, "http://", strlen("http://")) != 0) {
|
if (strncmp(url, "http://", strlen("http://")) != 0) {
|
||||||
printf("%s: Error: Invalid <url>: Not an HTTP address\n",
|
log_error("invalid <url>: not an HTTP address");
|
||||||
cfg_progname());
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
p1 = url + strlen("http://");
|
p1 = url + strlen("http://");
|
||||||
p2 = strchr(p1, ':');
|
p2 = strchr(p1, ':');
|
||||||
if (p2 == NULL) {
|
if (p2 == NULL) {
|
||||||
printf("%s: Error: Invalid <url>: Missing port\n",
|
log_error("invalid <url>: missing port");
|
||||||
cfg_progname());
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
hostsiz = (p2 - p1) + 1;
|
hostsiz = (p2 - p1) + 1;
|
||||||
|
if (hostsiz <= 1) {
|
||||||
|
log_error("invalid <url>: missing host");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
*hostname = xmalloc(hostsiz);
|
*hostname = xmalloc(hostsiz);
|
||||||
strlcpy(*hostname, p1, hostsiz);
|
strlcpy(*hostname, p1, hostsiz);
|
||||||
|
|
||||||
p2++;
|
p2++;
|
||||||
p3 = strchr(p2, '/');
|
p3 = strchr(p2, '/');
|
||||||
if (p3 == NULL || p3 - p2 >= (int)sizeof(tmpPort)) {
|
if (p3 == NULL || p3 - p2 >= (int)sizeof(tmpPort)) {
|
||||||
printf("%s: Error: Invalid <url>: Missing mountpoint or too long port number\n",
|
log_error("invalid <url>: mountpoint missing, or port number too long");
|
||||||
cfg_progname());
|
|
||||||
xfree(*hostname);
|
xfree(*hostname);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -166,8 +168,7 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
|||||||
strlcpy(tmpPort, p2, (p3 - p2) + 1UL);
|
strlcpy(tmpPort, p2, (p3 - p2) + 1UL);
|
||||||
*port = (unsigned short)strtonum(tmpPort, 1LL, (long long)USHRT_MAX, &errstr);
|
*port = (unsigned short)strtonum(tmpPort, 1LL, (long long)USHRT_MAX, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s: Error: Invalid <url>: Port '%s' is %s\n",
|
log_error("invalid <url>: port: %s is %s", tmpPort, errstr);
|
||||||
cfg_progname(), tmpPort, errstr);
|
|
||||||
xfree(*hostname);
|
xfree(*hostname);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -261,8 +262,8 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
|
|
||||||
decoder = xstrdup(getFormatDecoder(extension));
|
decoder = xstrdup(getFormatDecoder(extension));
|
||||||
if (strlen(decoder) == 0) {
|
if (strlen(decoder) == 0) {
|
||||||
printf("%s: Unknown extension '%s', cannot decode '%s'\n",
|
log_error("cannot decode: %s: unknown file extension %s",
|
||||||
cfg_progname(), extension, fileName);
|
fileName, extension);
|
||||||
xfree(localTitle);
|
xfree(localTitle);
|
||||||
xfree(localArtist);
|
xfree(localArtist);
|
||||||
xfree(localMetaString);
|
xfree(localMetaString);
|
||||||
@ -317,9 +318,7 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
|
|
||||||
encoder = xstrdup(getFormatEncoder(pezConfig->format));
|
encoder = xstrdup(getFormatEncoder(pezConfig->format));
|
||||||
if (strlen(encoder) == 0) {
|
if (strlen(encoder) == 0) {
|
||||||
if (cfg_verbosity())
|
log_notice("passing through%s%s data from the decoder",
|
||||||
printf("%s: Passing through%s%s data from the decoder\n",
|
|
||||||
cfg_progname(),
|
|
||||||
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
|
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
|
||||||
pezConfig->format);
|
pezConfig->format);
|
||||||
commandStringLen = strlen(newDecoder) + 1;
|
commandStringLen = strlen(newDecoder) + 1;
|
||||||
@ -387,8 +386,7 @@ getMetadataString(const char *format, metadata_t *mdata)
|
|||||||
char *tmp, *str;
|
char *tmp, *str;
|
||||||
|
|
||||||
if (mdata == NULL) {
|
if (mdata == NULL) {
|
||||||
printf("%s: getMetadataString(): Internal error: NULL metadata_t\n",
|
log_alert("getMetadataString: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,8 +458,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
int ret = SHOUTERR_SUCCESS;
|
int ret = SHOUTERR_SUCCESS;
|
||||||
|
|
||||||
if (shout == NULL) {
|
if (shout == NULL) {
|
||||||
printf("%s: setMetadata(): Internal error: NULL shout_t\n",
|
log_alert("setMetadata: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,8 +469,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((shout_mdata = shout_metadata_new()) == NULL) {
|
if ((shout_mdata = shout_metadata_new()) == NULL) {
|
||||||
printf("%s: shout_metadata_new(): %s\n", cfg_progname(),
|
log_syserr(ALERT, ENOMEM, "shout_metadata_new");
|
||||||
strerror(ENOMEM));
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,8 +484,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
*/
|
*/
|
||||||
if (shout_metadata_add(shout_mdata, "charset", "UTF-8") != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "charset", "UTF-8") != SHOUTERR_SUCCESS) {
|
||||||
/* Assume SHOUTERR_MALLOC */
|
/* Assume SHOUTERR_MALLOC */
|
||||||
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
log_syserr(ALERT, ENOMEM, "shout_metadata_add");
|
||||||
strerror(ENOMEM));
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,31 +495,29 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
songInfo = metadata_assemble_string(mdata);
|
songInfo = metadata_assemble_string(mdata);
|
||||||
if (artist[0] != '\0' && title[0] != '\0') {
|
if (artist[0] != '\0' && title[0] != '\0') {
|
||||||
if (shout_metadata_add(shout_mdata, "artist", artist) != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "artist", artist) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
log_syserr(ALERT, ENOMEM,
|
||||||
strerror(ENOMEM));
|
"shout_metadata_add");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (shout_metadata_add(shout_mdata, "title", title) != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "title", title) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
log_syserr(ALERT, ENOMEM,
|
||||||
strerror(ENOMEM));
|
"shout_metadata_add");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
log_syserr(ALERT, ENOMEM,
|
||||||
strerror(ENOMEM));
|
"shout_metadata_add");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
} else if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
log_syserr(ALERT, ENOMEM, "shout_metadata_add");
|
||||||
strerror(ENOMEM));
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = shout_set_metadata(shout, shout_mdata)) != SHOUTERR_SUCCESS)
|
if ((ret = shout_set_metadata(shout, shout_mdata)) != SHOUTERR_SUCCESS)
|
||||||
printf("%s: shout_set_metadata(): %s\n",
|
log_warning("shout_set_metadata: %s", shout_get_error(shout));
|
||||||
cfg_progname(), shout_get_error(shout));
|
|
||||||
|
|
||||||
shout_metadata_free(shout_mdata);
|
shout_metadata_free(shout_mdata);
|
||||||
|
|
||||||
@ -583,8 +576,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
*p = tolower((int)*p);
|
*p = tolower((int)*p);
|
||||||
|
|
||||||
if (strlen(extension) == 0) {
|
if (strlen(extension) == 0) {
|
||||||
printf("%s: Error: Cannot determine file type of '%s'\n",
|
log_error("%s: cannot determine file type", fileName);
|
||||||
cfg_progname(), fileName);
|
|
||||||
return (filep);
|
return (filep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,17 +599,15 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
*mdata_p = mdata;
|
*mdata_p = mdata;
|
||||||
else
|
else
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
if (cfg_verbosity() > 1)
|
log_info("running command: %s", pCommandString);
|
||||||
printf("%s: Running command `%s`\n", cfg_progname(),
|
|
||||||
pCommandString);
|
|
||||||
|
|
||||||
if (cfg_quiet_stderr()) {
|
if (cfg_quiet_stderr()) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
stderr_fd = dup(fileno(stderr));
|
stderr_fd = dup(fileno(stderr));
|
||||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
||||||
printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
|
log_alert("%s: %s", _PATH_DEVNULL,
|
||||||
cfg_progname(), _PATH_DEVNULL, strerror(errno));
|
strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,13 +619,13 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if ((filep = popen(pCommandString, "r")) == NULL) {
|
if ((filep = popen(pCommandString, "r")) == NULL) {
|
||||||
printf("%s: popen(): Error while executing '%s'",
|
|
||||||
cfg_progname(), pCommandString);
|
|
||||||
/* popen() does not set errno reliably ... */
|
/* popen() does not set errno reliably ... */
|
||||||
if (errno)
|
if (errno)
|
||||||
printf(": %s\n", strerror(errno));
|
log_error("execution error: %s: %s",
|
||||||
|
pCommandString, strerror(errno));
|
||||||
else
|
else
|
||||||
printf("\n");
|
log_error("execution error: %s",
|
||||||
|
pCommandString);
|
||||||
} else {
|
} else {
|
||||||
*popenFlag = 1;
|
*popenFlag = 1;
|
||||||
}
|
}
|
||||||
@ -655,9 +645,10 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
else
|
else
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
|
|
||||||
if ((filep = fopen(fileName, "rb")) == NULL)
|
if ((filep = fopen(fileName, "rb")) == NULL) {
|
||||||
printf("%s: %s: %s\n", cfg_progname(), fileName,
|
log_error("%s: %s", fileName, strerror(errno));
|
||||||
strerror(errno));
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return (filep);
|
return (filep);
|
||||||
}
|
}
|
||||||
@ -668,41 +659,41 @@ reconnectServer(shout_t *shout, int closeConn)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
int close_conn = closeConn;
|
int close_conn = closeConn;
|
||||||
|
|
||||||
printf("%s: Connection to %s lost\n", cfg_progname(), pezConfig->URL);
|
log_warning("%s: connection lost", pezConfig->URL);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (++i) {
|
while (++i) {
|
||||||
printf("%s: Attempting reconnection #", cfg_progname());
|
|
||||||
if (pezConfig->reconnectAttempts > 0)
|
if (pezConfig->reconnectAttempts > 0)
|
||||||
printf("%u/%u: ", i, pezConfig->reconnectAttempts);
|
log_notice("reconnect: %s: attempt #%u/%u ...",
|
||||||
|
pezConfig->URL, i, pezConfig->reconnectAttempts);
|
||||||
else
|
else
|
||||||
printf("%u: ", i);
|
log_notice("reconnect: %s: attempt #%u ...",
|
||||||
|
pezConfig->URL, i);
|
||||||
|
|
||||||
if (close_conn == 0)
|
if (close_conn == 0)
|
||||||
close_conn = 1;
|
close_conn = 1;
|
||||||
else
|
else
|
||||||
shout_close(shout);
|
shout_close(shout);
|
||||||
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
||||||
printf("OK\n%s: Reconnect to %s successful\n",
|
log_notice("reconnect: %s: success",
|
||||||
cfg_progname(), pezConfig->URL);
|
pezConfig->URL);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("FAILED: %s\n", shout_get_error(shout));
|
log_warning("reconnect failed: %s: %s",
|
||||||
|
pezConfig->URL, shout_get_error(shout));
|
||||||
|
|
||||||
if (pezConfig->reconnectAttempts > 0 &&
|
if (pezConfig->reconnectAttempts > 0 &&
|
||||||
i >= pezConfig->reconnectAttempts)
|
i >= pezConfig->reconnectAttempts)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
printf("%s: Waiting 5s for %s to come back ...\n",
|
|
||||||
cfg_progname(), pezConfig->URL);
|
|
||||||
if (quit)
|
if (quit)
|
||||||
return (0);
|
return (0);
|
||||||
else
|
else
|
||||||
sleep(5);
|
sleep(5);
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("%s: Giving up\n", cfg_progname());
|
log_warning("reconnect failed: giving up");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,8 +728,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
struct timeval callTime, currentTime;
|
struct timeval callTime, currentTime;
|
||||||
|
|
||||||
if (startTime == NULL) {
|
if (startTime == NULL) {
|
||||||
printf("%s: sendStream(): Internal error: startTime is NULL\n",
|
log_alert("sendStream: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,8 +749,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
shout_sync(shout);
|
shout_sync(shout);
|
||||||
|
|
||||||
if (shout_send(shout, buff, bytes_read) != SHOUTERR_SUCCESS) {
|
if (shout_send(shout, buff, bytes_read) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_send(): %s\n", cfg_progname(),
|
log_error("shout_send: %s", shout_get_error(shout));
|
||||||
shout_get_error(shout));
|
|
||||||
if (reconnectServer(shout, 1))
|
if (reconnectServer(shout, 1))
|
||||||
break;
|
break;
|
||||||
else {
|
else {
|
||||||
@ -774,8 +763,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
if (rereadPlaylist_notify) {
|
if (rereadPlaylist_notify) {
|
||||||
rereadPlaylist_notify = 0;
|
rereadPlaylist_notify = 0;
|
||||||
if (!pezConfig->fileNameIsProgram)
|
if (!pezConfig->fileNameIsProgram)
|
||||||
printf("%s: SIGHUP signal received, will reread playlist after this file\n",
|
log_notice("HUP signal received: playlist re-read scheduled");
|
||||||
cfg_progname());
|
|
||||||
}
|
}
|
||||||
if (skipTrack) {
|
if (skipTrack) {
|
||||||
skipTrack = 0;
|
skipTrack = 0;
|
||||||
@ -847,11 +835,10 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
clearerr(filepstream);
|
clearerr(filepstream);
|
||||||
ret = STREAM_CONT;
|
ret = STREAM_CONT;
|
||||||
} else if (errno == EBADF && isStdin)
|
} else if (errno == EBADF && isStdin)
|
||||||
printf("%s: No (more) data available on standard input\n",
|
log_notice("no (more) data available on standard input");
|
||||||
cfg_progname());
|
|
||||||
else
|
else
|
||||||
printf("%s: sendStream(): Error while reading '%s': %s\n",
|
log_error("sendStream: %s: %s", fileName,
|
||||||
cfg_progname(), fileName, strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
@ -872,7 +859,7 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
if ((filepstream = openResource(shout, fileName, &popenFlag, &mdata, &isStdin, &songLen))
|
if ((filepstream = openResource(shout, fileName, &popenFlag, &mdata, &isStdin, &songLen))
|
||||||
== NULL) {
|
== NULL) {
|
||||||
if (++resource_errors > 100) {
|
if (++resource_errors > 100) {
|
||||||
printf("%s: Too many errors -- giving up.\n", cfg_progname());
|
log_error("too many errors; giving up");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/* Continue with next resource on failure: */
|
/* Continue with next resource on failure: */
|
||||||
@ -887,11 +874,7 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
if ((metaData = UTF8toCHAR(tmp, ICONV_REPLACE)) == NULL)
|
if ((metaData = UTF8toCHAR(tmp, ICONV_REPLACE)) == NULL)
|
||||||
metaData = xstrdup("(unknown title)");
|
metaData = xstrdup("(unknown title)");
|
||||||
xfree(tmp);
|
xfree(tmp);
|
||||||
printf("%s: Streaming ``%s''", cfg_progname(), metaData);
|
log_notice("streaming: %s (%s)", metaData, fileName);
|
||||||
if (cfg_verbosity())
|
|
||||||
printf(" (file: %s)\n", fileName);
|
|
||||||
else
|
|
||||||
printf("\n");
|
|
||||||
xfree(metaData);
|
xfree(metaData);
|
||||||
|
|
||||||
/* MP3 streams are special, so set the metadata explicitly: */
|
/* MP3 streams are special, so set the metadata explicitly: */
|
||||||
@ -900,7 +883,7 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
|
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
} else if (isStdin)
|
} else if (isStdin)
|
||||||
printf("%s: Streaming from standard input\n", cfg_progname());
|
log_notice("streaming: standard input");
|
||||||
|
|
||||||
if (songLen > 0)
|
if (songLen > 0)
|
||||||
songLenStr = xstrdup(getTimeString(songLen));
|
songLenStr = xstrdup(getTimeString(songLen));
|
||||||
@ -922,9 +905,8 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
}
|
}
|
||||||
if (ret == STREAM_SKIP || skipTrack) {
|
if (ret == STREAM_SKIP || skipTrack) {
|
||||||
skipTrack = 0;
|
skipTrack = 0;
|
||||||
if (!isStdin && cfg_verbosity())
|
if (!isStdin)
|
||||||
printf("%s: SIGUSR1 signal received, skipping current track\n",
|
log_notice("USR1 signal received: skipping current track");
|
||||||
cfg_progname());
|
|
||||||
retval = 1;
|
retval = 1;
|
||||||
ret = STREAM_DONE;
|
ret = STREAM_DONE;
|
||||||
}
|
}
|
||||||
@ -936,9 +918,8 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
char *mdataStr = NULL;
|
char *mdataStr = NULL;
|
||||||
metadata_t *prog_mdata;
|
metadata_t *prog_mdata;
|
||||||
|
|
||||||
if (cfg_verbosity() > 1)
|
log_info("running metadata program: %s",
|
||||||
printf("%s: Querying '%s' for fresh metadata\n",
|
pezConfig->metadataProgram);
|
||||||
cfg_progname(), pezConfig->metadataProgram);
|
|
||||||
if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
|
if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
ret = STREAM_DONE;
|
ret = STREAM_DONE;
|
||||||
@ -950,9 +931,7 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
metadata_free(&prog_mdata);
|
metadata_free(&prog_mdata);
|
||||||
if (cfg_verbosity() > 1)
|
log_info("new metadata: %s", mdataStr);
|
||||||
printf("%s: New metadata: ``%s''\n",
|
|
||||||
cfg_progname(), mdataStr);
|
|
||||||
xfree(mdataStr);
|
xfree(mdataStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -988,9 +967,8 @@ streamPlaylist(shout_t *shout, const char *fileName)
|
|||||||
} else {
|
} else {
|
||||||
if ((playlist = playlist_read(fileName)) == NULL)
|
if ((playlist = playlist_read(fileName)) == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
if (cfg_verbosity() && playlist_get_num_items(playlist) == 0)
|
if (playlist_get_num_items(playlist) == 0)
|
||||||
printf("%s: Warning: Playlist '%s' is empty\n",
|
log_notice("%s: playlist empty", fileName);
|
||||||
cfg_progname(), fileName);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -1014,7 +992,7 @@ streamPlaylist(shout_t *shout, const char *fileName)
|
|||||||
rereadPlaylist = rereadPlaylist_notify = 0;
|
rereadPlaylist = rereadPlaylist_notify = 0;
|
||||||
if (pezConfig->fileNameIsProgram)
|
if (pezConfig->fileNameIsProgram)
|
||||||
continue;
|
continue;
|
||||||
printf("%s: Rereading playlist\n", cfg_progname());
|
log_notice("rereading playlist");
|
||||||
if (!playlist_reread(&playlist))
|
if (!playlist_reread(&playlist))
|
||||||
return (0);
|
return (0);
|
||||||
if (pezConfig->shuffle)
|
if (pezConfig->shuffle)
|
||||||
@ -1107,22 +1085,22 @@ main(int argc, char *argv[])
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat(configFile, &st) == -1) {
|
if (stat(configFile, &st) == -1) {
|
||||||
printf("%s: %s\n", configFile, strerror(errno));
|
log_error("%s: %s", configFile, strerror(errno));
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
if (cfg_verbosity() && (st.st_mode & (S_IRGRP | S_IROTH)))
|
if (cfg_verbosity() && (st.st_mode & (S_IRGRP | S_IROTH)))
|
||||||
printf("%s: Warning: %s is group and/or world readable\n",
|
log_warning("%s: group and/or world readable",
|
||||||
cfg_progname(), configFile);
|
configFile);
|
||||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||||
printf("%s: Error: %s is group and/or world writeable\n",
|
log_error("%s: group and/or world writeable",
|
||||||
cfg_progname(), configFile);
|
configFile);
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
FILE *tmp;
|
FILE *tmp;
|
||||||
|
|
||||||
if ((tmp = fopen(configFile, "r")) == NULL) {
|
if ((tmp = fopen(configFile, "r")) == NULL) {
|
||||||
printf("%s: %s\n", configFile, strerror(errno));
|
log_error("%s: %s", configFile, strerror(errno));
|
||||||
usage();
|
usage();
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
@ -1134,34 +1112,25 @@ main(int argc, char *argv[])
|
|||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
|
|
||||||
if (pezConfig->URL == NULL) {
|
if (pezConfig->URL == NULL) {
|
||||||
printf("%s: Error: Missing <url>\n", configFile);
|
log_error("%s: missing <url>", configFile);
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
if (!urlParse(pezConfig->URL, &host, &port, &mount)) {
|
if (!urlParse(pezConfig->URL, &host, &port, &mount)) {
|
||||||
printf("Must be of the form ``http://server:port/mountpoint''\n");
|
log_error("%s: <url>: must be of the form ``http://server:port/mountpoint''",
|
||||||
return (ez_shutdown(2));
|
configFile);
|
||||||
}
|
|
||||||
if (strlen(host) == 0) {
|
|
||||||
printf("%s: Error: Invalid <url>: Missing server:\n", configFile);
|
|
||||||
printf("Must be of the form ``http://server:port/mountpoint''\n");
|
|
||||||
return (ez_shutdown(2));
|
|
||||||
}
|
|
||||||
if (strlen(mount) == 0) {
|
|
||||||
printf("%s: Error: Invalid <url>: Missing mountpoint:\n", configFile);
|
|
||||||
printf("Must be of the form ``http://server:port/mountpoint''\n");
|
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
if (pezConfig->password == NULL) {
|
if (pezConfig->password == NULL) {
|
||||||
printf("%s: Error: Missing <sourcepassword>\n", configFile);
|
log_error("%s: <sourcepassword> missing", configFile);
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
if (pezConfig->fileName == NULL) {
|
if (pezConfig->fileName == NULL) {
|
||||||
printf("%s: Error: Missing <filename>\n", configFile);
|
log_error("%s: <filename> missing", configFile);
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
if (pezConfig->format == NULL) {
|
if (pezConfig->format == NULL) {
|
||||||
printf("%s: Warning: Missing <format>:\n", configFile);
|
log_error("%s: <format> missing or unsupported value",
|
||||||
printf("Specify a stream format of either MP3, VORBIS or THEORA\n");
|
configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((shout = stream_setup(host, port, mount)) == NULL)
|
if ((shout = stream_setup(host, port, mount)) == NULL)
|
||||||
@ -1180,8 +1149,7 @@ main(int argc, char *argv[])
|
|||||||
# endif
|
# endif
|
||||||
for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) {
|
for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) {
|
||||||
if (sigaction(ezstream_signals[i], &act, NULL) == -1) {
|
if (sigaction(ezstream_signals[i], &act, NULL) == -1) {
|
||||||
printf("%s: sigaction(): %s\n",
|
log_syserr(ERROR, errno, "sigaction");
|
||||||
cfg_progname(), strerror(errno));
|
|
||||||
return (ez_shutdown(1));
|
return (ez_shutdown(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1191,8 +1159,7 @@ main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
if (sigaction(SIGPIPE, &act, NULL) == -1) {
|
if (sigaction(SIGPIPE, &act, NULL) == -1) {
|
||||||
printf("%s: sigaction(): %s\n",
|
log_syserr(ERROR, errno, "sigaction");
|
||||||
cfg_progname(), strerror(errno));
|
|
||||||
return (ez_shutdown(1));
|
return (ez_shutdown(1));
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SIGNALS */
|
#endif /* HAVE_SIGNALS */
|
||||||
@ -1200,8 +1167,7 @@ main(int argc, char *argv[])
|
|||||||
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
||||||
int cont;
|
int cont;
|
||||||
|
|
||||||
printf("%s: Connected to http://%s:%hu%s\n", cfg_progname(),
|
log_notice("connected: http://%s:%hu%s", host, port, mount);
|
||||||
host, port, mount);
|
|
||||||
|
|
||||||
if (pezConfig->fileNameIsProgram ||
|
if (pezConfig->fileNameIsProgram ||
|
||||||
strrcasecmp(pezConfig->fileName, ".m3u") == 0 ||
|
strrcasecmp(pezConfig->fileName, ".m3u") == 0 ||
|
||||||
@ -1210,10 +1176,6 @@ main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
playlistMode = 0;
|
playlistMode = 0;
|
||||||
|
|
||||||
if (cfg_verbosity() && pezConfig->fileNameIsProgram)
|
|
||||||
printf("%s: Using program '%s' to get filenames for streaming\n",
|
|
||||||
cfg_progname(), pezConfig->fileName);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (playlistMode) {
|
if (playlistMode) {
|
||||||
cont = streamPlaylist(shout, pezConfig->fileName);
|
cont = streamPlaylist(shout, pezConfig->fileName);
|
||||||
@ -1228,14 +1190,16 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
shout_close(shout);
|
shout_close(shout);
|
||||||
} else
|
} else
|
||||||
printf("%s: Connection to http://%s:%hu%s failed: %s\n", cfg_progname(),
|
log_error("connection failed: http://%s:%hu%s: %s",
|
||||||
host, port, mount, shout_get_error(shout));
|
host, port, mount, shout_get_error(shout));
|
||||||
|
|
||||||
if (quit)
|
if (quit) {
|
||||||
printf("\r%s: SIGINT or SIGTERM received\n", cfg_progname());
|
if (cfg_quiet_stderr() && cfg_verbosity())
|
||||||
|
printf("\r");
|
||||||
|
log_notice("INT or TERM signal received");
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg_verbosity())
|
log_info("exiting");
|
||||||
printf("%s: Exiting ...\n", cfg_progname());
|
|
||||||
|
|
||||||
xfree(host);
|
xfree(host);
|
||||||
xfree(mount);
|
xfree(mount);
|
||||||
|
136
src/metadata.c
136
src/metadata.c
@ -30,7 +30,7 @@
|
|||||||
#endif /* HAVE_VORBISFILE */
|
#endif /* HAVE_VORBISFILE */
|
||||||
#include <shout/shout.h>
|
#include <shout/shout.h>
|
||||||
|
|
||||||
#include "cfg.h"
|
#include "log.h"
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
@ -93,8 +93,7 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
|
|||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if (md == NULL || md->filename == NULL) {
|
if (md == NULL || md->filename == NULL) {
|
||||||
printf("%s: metadata_use_taglib(): Internal error: Bad arguments\n",
|
log_alert("metadata_use_taglib: bad arguments");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,8 +144,7 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
|
|||||||
(void)md;
|
(void)md;
|
||||||
(void)filep;
|
(void)filep;
|
||||||
|
|
||||||
printf("%s: Internal error: metadata_use_taglib() called without TagLib support\n",
|
log_alert("metadata_use_taglib() called without TagLib support");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif /* HAVE_TAGLIB */
|
#endif /* HAVE_TAGLIB */
|
||||||
@ -158,8 +156,7 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
|||||||
(void)md;
|
(void)md;
|
||||||
(void)filep;
|
(void)filep;
|
||||||
|
|
||||||
printf("%s: Internal error: metadata_use_self() called with TagLib support\n",
|
log_alert("metadata_use_self() called with TagLib support");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -169,8 +166,7 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
|||||||
|
|
||||||
if (md == NULL || filep == NULL || *filep == NULL ||
|
if (md == NULL || filep == NULL || *filep == NULL ||
|
||||||
md->filename == NULL) {
|
md->filename == NULL) {
|
||||||
printf("%s: metadata_use_self(): Internal error: Bad arguments\n",
|
log_alert("metadata_use_self: bad arguments");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,28 +191,27 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
|||||||
if ((ret = ov_open(*filep, &vf, NULL, 0L)) != 0) {
|
if ((ret = ov_open(*filep, &vf, NULL, 0L)) != 0) {
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case OV_EREAD:
|
case OV_EREAD:
|
||||||
printf("%s: ov_open(): %s: Media read error\n",
|
log_error("%s: media read error",
|
||||||
cfg_progname(), md->filename);
|
md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_ENOTVORBIS:
|
case OV_ENOTVORBIS:
|
||||||
printf("%s: ov_open(): %s: Invalid Vorbis bitstream\n",
|
log_error("%s: invalid Vorbis bitstream",
|
||||||
cfg_progname(), md->filename);
|
md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_EVERSION:
|
case OV_EVERSION:
|
||||||
printf("%s: ov_open(): %s: Vorbis version mismatch\n",
|
log_error("%s: Vorbis version mismatch",
|
||||||
cfg_progname(), md->filename);
|
md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_EBADHEADER:
|
case OV_EBADHEADER:
|
||||||
printf("%s: ov_open(): %s: Invalid Vorbis bitstream header\n",
|
log_error("%s: invalid Vorbis bitstream header",
|
||||||
cfg_progname(), md->filename);
|
md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_EFAULT:
|
case OV_EFAULT:
|
||||||
printf("%s: Fatal: Internal libvorbisfile fault\n",
|
log_alert("libvorbisfile fault");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
default:
|
default:
|
||||||
printf("%s: ov_open(): %s: ov_read() returned unknown error\n",
|
log_error("%s: unknown error",
|
||||||
cfg_progname(), md->filename);
|
md->filename);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -253,8 +248,7 @@ void
|
|||||||
metadata_clean_md(metadata_t *md)
|
metadata_clean_md(metadata_t *md)
|
||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: Internal error: metadata_clean_md(): NULL argument\n",
|
log_alert("metadata_clean_md: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,8 +272,7 @@ metadata_get_extension(char *buf, size_t siz, const char *filename)
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (buf == NULL || siz == 0 || filename == NULL) {
|
if (buf == NULL || siz == 0 || filename == NULL) {
|
||||||
printf("%s: metadata_get_extension(): Internal error: Bad arguments\n",
|
log_alert("metadata_get_extension: bad arguments");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,14 +291,13 @@ metadata_get_name(const char *file)
|
|||||||
char *p1, *p2, *name;
|
char *p1, *p2, *name;
|
||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
printf("%s: metadata_get_name(): Internal error: Bad arguments\n",
|
log_alert("metadata_get_name: bad arguments");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p1 = basename(filename)) == NULL) {
|
if ((p1 = basename(filename)) == NULL) {
|
||||||
printf("%s: Internal error: basename() failed with '%s'\n",
|
log_alert("basename: unexpected failure with input: %s",
|
||||||
cfg_progname(), filename);
|
filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,8 +317,7 @@ void
|
|||||||
metadata_process_md(metadata_t *md)
|
metadata_process_md(metadata_t *md)
|
||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_process_md(): Internal error: Bad arguments\n",
|
log_alert("metadata_process_md: bad arguments");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,8 +368,7 @@ metadata_file(const char *filename, int normalize)
|
|||||||
metadata_t *md;
|
metadata_t *md;
|
||||||
|
|
||||||
if (filename == NULL || strlen(filename) == 0) {
|
if (filename == NULL || strlen(filename) == 0) {
|
||||||
printf("%s: metadata_file(): Internal error: Bad arguments\n",
|
log_alert("metadata_file: bad arguments");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,8 +394,7 @@ metadata_program(const char *program, int normalize)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (program == NULL || strlen(program) == 0) {
|
if (program == NULL || strlen(program) == 0) {
|
||||||
printf("%s: metadata_program(): Internal error: Bad arguments\n",
|
log_alert("metadata_program: bad arguments");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,24 +404,24 @@ metadata_program(const char *program, int normalize)
|
|||||||
|
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
if (stat(program, &st) == -1) {
|
if (stat(program, &st) == -1) {
|
||||||
printf("%s: %s: %s\n", cfg_progname(), program, strerror(errno));
|
log_error("%s: %s", program, strerror(errno));
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||||
printf("%s: Error: %s is group and/or world writeable\n",
|
log_error("%s: group and/or world writeable",
|
||||||
cfg_progname(), program);
|
program);
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
||||||
printf("%s: %s: Not an executable program\n", cfg_progname(), program);
|
log_error("%s: not an executable program", program);
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((filep = fopen(program, "r")) == NULL) {
|
if ((filep = fopen(program, "r")) == NULL) {
|
||||||
printf("%s: %s: %s\n", cfg_progname(), program, strerror(errno));
|
log_error("%s: %s", program, strerror(errno));
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -468,19 +457,17 @@ metadata_file_update(metadata_t *md)
|
|||||||
FILE *filep;
|
FILE *filep;
|
||||||
|
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_file_update(): Internal error: NULL argument\n",
|
log_alert("metadata_file_update: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md->program) {
|
if (md->program) {
|
||||||
printf("%s: metadata_file_update(): Internal error: Called with program handle\n",
|
log_alert("metadata_file_update: called with program handle");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filep = fopen(md->filename, "rb")) == NULL) {
|
if ((filep = fopen(md->filename, "rb")) == NULL) {
|
||||||
printf("%s: %s: %s\n", cfg_progname(), md->filename, strerror(errno));
|
log_error("%s: %s", md->filename, strerror(errno));
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,14 +490,12 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
char command[PATH_MAX + sizeof(" artist")];
|
char command[PATH_MAX + sizeof(" artist")];
|
||||||
|
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_program_update(): Internal error: NULL argument\n",
|
log_alert("metadata_program_update: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!md->program) {
|
if (!md->program) {
|
||||||
printf("%s: metadata_program_update(): Internal error: Received file handle\n",
|
log_alert("metadata_program_update: called with file handle");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,42 +530,37 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("%s: metadata_program_update(): Internal error: Unknown md_req\n",
|
log_alert("metadata_program_update: unknown md_req");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (cfg_verbosity() > 1)
|
log_debug("running command: %s", command);
|
||||||
printf("%s: Running command `%s`\n", cfg_progname(),
|
|
||||||
command);
|
|
||||||
if ((filep = popen(command, "r")) == NULL) {
|
if ((filep = popen(command, "r")) == NULL) {
|
||||||
printf("%s: playlist_run_program(): Error while executing '%s'",
|
|
||||||
cfg_progname(), command);
|
|
||||||
/* popen() does not set errno reliably ... */
|
/* popen() does not set errno reliably ... */
|
||||||
if (errno)
|
if (errno)
|
||||||
printf(": %s\n", strerror(errno));
|
log_error("execution error: %s: %s", command,
|
||||||
|
strerror(errno));
|
||||||
else
|
else
|
||||||
printf("\n");
|
log_error("execution error: %s", command);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fgets(buf, (int)sizeof(buf), filep) == NULL) {
|
if (fgets(buf, (int)sizeof(buf), filep) == NULL) {
|
||||||
if (ferror(filep))
|
if (ferror(filep))
|
||||||
printf("%s: Error while reading output from program '%s': %s\n",
|
log_error("%s: output read error: %s", md->filename,
|
||||||
cfg_progname(), md->filename, strerror(errno));
|
strerror(errno));
|
||||||
pclose(filep);
|
pclose(filep);
|
||||||
printf("%s: FATAL: External program '%s' not (or no longer) usable.\n",
|
log_alert("program not (or no longer) usable: %s",
|
||||||
cfg_progname(), md->filename);
|
md->filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pclose(filep);
|
pclose(filep);
|
||||||
|
|
||||||
if (strlen(buf) == sizeof(buf) - 1)
|
if (strlen(buf) == sizeof(buf) - 1)
|
||||||
printf("%s: Warning: Metadata string received via '%s' is too long and has been truncated\n",
|
log_warning("metadata output truncated: %s", command);
|
||||||
cfg_progname(), command);
|
|
||||||
|
|
||||||
buf[strcspn(buf, "\n")] = '\0';
|
buf[strcspn(buf, "\n")] = '\0';
|
||||||
buf[strcspn(buf, "\r")] = '\0';
|
buf[strcspn(buf, "\r")] = '\0';
|
||||||
@ -588,8 +568,8 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
switch (md_req) {
|
switch (md_req) {
|
||||||
case METADATA_STRING:
|
case METADATA_STRING:
|
||||||
if (strlen(buf) == 0) {
|
if (strlen(buf) == 0) {
|
||||||
printf("%s: Warning: Empty metadata string received from '%s'\n",
|
log_warning("metadata output empty: %s",
|
||||||
cfg_progname(), md->filename);
|
md->filename);
|
||||||
md->string = xstrdup("");
|
md->string = xstrdup("");
|
||||||
} else
|
} else
|
||||||
md->string = xstrdup(buf);
|
md->string = xstrdup(buf);
|
||||||
@ -604,8 +584,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
break;
|
break;
|
||||||
case METADATA_ALL:
|
case METADATA_ALL:
|
||||||
default:
|
default:
|
||||||
printf("%s: metadata_program_update(): Internal error: METADATA_ALL in code unreachable by METADATA_ALL\n",
|
log_alert("metadata_program_update: METADATA_ALL in code unreachable by METADATA_ALL");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,14 +601,12 @@ const char *
|
|||||||
metadata_get_string(metadata_t *md)
|
metadata_get_string(metadata_t *md)
|
||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_string(): Internal error: Bad arguments\n",
|
log_alert("metadata_get_string: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md->string == NULL) {
|
if (md->string == NULL) {
|
||||||
printf("%s: metadata_get_string(): Internal error: md->string cannot be NULL\n",
|
log_alert("metadata_get_string: md->string is NULL");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,8 +617,7 @@ const char *
|
|||||||
metadata_get_artist(metadata_t *md)
|
metadata_get_artist(metadata_t *md)
|
||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_artist(): Internal error: Bad arguments\n",
|
log_alert("metadata_get_artist: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,8 +631,7 @@ const char *
|
|||||||
metadata_get_title(metadata_t *md)
|
metadata_get_title(metadata_t *md)
|
||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_title(): Internal error: Bad arguments\n",
|
log_alert("metadata_get_title: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,8 +645,7 @@ const char *
|
|||||||
metadata_get_filename(metadata_t *md)
|
metadata_get_filename(metadata_t *md)
|
||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_filename(): Internal error: Bad arguments\n",
|
log_alert("metadata_get_filename: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,8 +660,7 @@ int
|
|||||||
metadata_get_length(metadata_t *md)
|
metadata_get_length(metadata_t *md)
|
||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_length(): Internal error: Bad arguments\n",
|
log_alert("metadata_get_length: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,8 +674,7 @@ metadata_assemble_string(metadata_t *md)
|
|||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_assemble_string(): Internal error: Bad arguments\n",
|
log_alert("metadata_assemble_string: bad argument");
|
||||||
cfg_progname());
|
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "ezstream.h"
|
#include "ezstream.h"
|
||||||
|
|
||||||
#include "cfg.h"
|
#include "log.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
@ -61,9 +61,8 @@ playlist_add(playlist_t *pl, const char *entry)
|
|||||||
size_t num;
|
size_t num;
|
||||||
|
|
||||||
if (pl == NULL || entry == NULL) {
|
if (pl == NULL || entry == NULL) {
|
||||||
printf("%s: playlist_add(): Internal error: Bad arguments\n",
|
log_alert("playlist_add: bad arguments");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
num = pl->num + 1;
|
num = pl->num + 1;
|
||||||
@ -133,7 +132,7 @@ playlist_read(const char *filename)
|
|||||||
pl = playlist_create(filename);
|
pl = playlist_create(filename);
|
||||||
|
|
||||||
if ((filep = fopen(filename, "r")) == NULL) {
|
if ((filep = fopen(filename, "r")) == NULL) {
|
||||||
printf("%s: %s: %s\n", cfg_progname(), filename, strerror(errno));
|
log_error("%s: %s", filename, strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ playlist_read(const char *filename)
|
|||||||
pl = playlist_create("stdin");
|
pl = playlist_create("stdin");
|
||||||
|
|
||||||
if ((filep = fdopen(STDIN_FILENO, "r")) == NULL) {
|
if ((filep = fdopen(STDIN_FILENO, "r")) == NULL) {
|
||||||
printf("%s: stdin: %s\n", cfg_progname(), strerror(errno));
|
log_error("stdin: %s", strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -154,7 +153,7 @@ playlist_read(const char *filename)
|
|||||||
if (strlen(buf) == sizeof(buf) - 1) {
|
if (strlen(buf) == sizeof(buf) - 1) {
|
||||||
char skip_buf[2];
|
char skip_buf[2];
|
||||||
|
|
||||||
printf("%s[%lu]: File or path name too long\n",
|
log_error("%s[%lu]: file or path name too long",
|
||||||
pl->filename, line);
|
pl->filename, line);
|
||||||
/* Discard any excess chars in that line. */
|
/* Discard any excess chars in that line. */
|
||||||
while (fgets(skip_buf, (int)sizeof(skip_buf), filep) != NULL) {
|
while (fgets(skip_buf, (int)sizeof(skip_buf), filep) != NULL) {
|
||||||
@ -188,8 +187,8 @@ playlist_read(const char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ferror(filep)) {
|
if (ferror(filep)) {
|
||||||
printf("%s: playlist_read(): Error while reading %s: %s\n",
|
log_error("playlist_read: %s: %s", pl->filename,
|
||||||
cfg_progname(), pl->filename, strerror(errno));
|
strerror(errno));
|
||||||
fclose(filep);
|
fclose(filep);
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -214,24 +213,24 @@ playlist_program(const char *filename)
|
|||||||
|
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
if (stat(filename, &st) == -1) {
|
if (stat(filename, &st) == -1) {
|
||||||
printf("%s: %s: %s\n", cfg_progname(), filename, strerror(errno));
|
log_error("%s: %s", filename, strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||||
printf("%s: Error: %s is group and/or world writeable\n",
|
log_error("%s: group and/or world writeable",
|
||||||
cfg_progname(), filename);
|
filename);
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
||||||
printf("%s: %s: Not an executable program\n", cfg_progname(), filename);
|
log_error("%s: not an executable program", filename);
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((filep = fopen(filename, "r")) == NULL) {
|
if ((filep = fopen(filename, "r")) == NULL) {
|
||||||
printf("%s: %s: %s\n", cfg_progname(), filename, strerror(errno));
|
log_error("%s: %s", filename, strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -281,9 +280,8 @@ const char *
|
|||||||
playlist_get_next(playlist_t *pl)
|
playlist_get_next(playlist_t *pl)
|
||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_get_next(): Internal error: NULL argument\n",
|
log_alert("playlist_get_next: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program)
|
if (pl->program)
|
||||||
@ -299,9 +297,8 @@ const char *
|
|||||||
playlist_peek_next(playlist_t *pl)
|
playlist_peek_next(playlist_t *pl)
|
||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_peek_next(): Internal error: NULL argument\n",
|
log_alert("playlist_peek_next: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program || pl->num == 0)
|
if (pl->program || pl->num == 0)
|
||||||
@ -314,9 +311,8 @@ void
|
|||||||
playlist_skip_next(playlist_t *pl)
|
playlist_skip_next(playlist_t *pl)
|
||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_skip_next(): Internal error: NULL argument\n",
|
log_alert("playlist_skip_next: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program || pl->num == 0)
|
if (pl->program || pl->num == 0)
|
||||||
@ -330,9 +326,8 @@ unsigned long
|
|||||||
playlist_get_num_items(playlist_t *pl)
|
playlist_get_num_items(playlist_t *pl)
|
||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
log_alert("playlist_get_position: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program)
|
if (pl->program)
|
||||||
@ -345,9 +340,8 @@ unsigned long
|
|||||||
playlist_get_position(playlist_t *pl)
|
playlist_get_position(playlist_t *pl)
|
||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
log_alert("playlist_get_position: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program)
|
if (pl->program)
|
||||||
@ -360,9 +354,8 @@ int
|
|||||||
playlist_set_position(playlist_t *pl, unsigned long idx)
|
playlist_set_position(playlist_t *pl, unsigned long idx)
|
||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_set_position(): Internal error: NULL argument\n",
|
log_alert("playlist_set_position: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program || idx > pl->num - 1)
|
if (pl->program || idx > pl->num - 1)
|
||||||
@ -379,9 +372,8 @@ playlist_goto_entry(playlist_t *pl, const char *entry)
|
|||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
|
||||||
if (pl == NULL || entry == NULL) {
|
if (pl == NULL || entry == NULL) {
|
||||||
printf("%s: playlist_goto_entry(): Internal error: Bad arguments\n",
|
log_alert("playlist_goto_entry: bad arguments");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program)
|
if (pl->program)
|
||||||
@ -401,9 +393,8 @@ void
|
|||||||
playlist_rewind(playlist_t *pl)
|
playlist_rewind(playlist_t *pl)
|
||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_rewind(): Internal error: NULL argument\n",
|
log_alert("playlist_rewind: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program)
|
if (pl->program)
|
||||||
@ -418,9 +409,8 @@ playlist_reread(playlist_t **plist)
|
|||||||
playlist_t *new_pl, *pl;
|
playlist_t *new_pl, *pl;
|
||||||
|
|
||||||
if (plist == NULL || *plist == NULL) {
|
if (plist == NULL || *plist == NULL) {
|
||||||
printf("%s: playlist_reread(): Internal error: NULL argument\n",
|
log_alert("playlist_reread: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pl = *plist;
|
pl = *plist;
|
||||||
@ -447,9 +437,8 @@ playlist_shuffle(playlist_t *pl)
|
|||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_shuffle(): Internal error: NULL argument\n",
|
log_alert("playlist_shuffle: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->program || pl->num < 2)
|
if (pl->program || pl->num < 2)
|
||||||
@ -485,9 +474,8 @@ playlist_run_program(playlist_t *pl)
|
|||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_run_program(): Internal error: NULL argument\n",
|
log_alert("playlist_run_program: bad argument");
|
||||||
cfg_progname());
|
abort();
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pl->program)
|
if (!pl->program)
|
||||||
@ -495,14 +483,14 @@ playlist_run_program(playlist_t *pl)
|
|||||||
|
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
log_debug("running command: %s", pl->filename);
|
||||||
if ((filep = popen(pl->filename, "r")) == NULL) {
|
if ((filep = popen(pl->filename, "r")) == NULL) {
|
||||||
printf("%s: playlist_run_program(): Error while executing '%s'",
|
|
||||||
cfg_progname(), pl->filename);
|
|
||||||
/* popen() does not set errno reliably ... */
|
/* popen() does not set errno reliably ... */
|
||||||
if (errno)
|
if (errno)
|
||||||
printf(": %s\n", strerror(errno));
|
log_error("execution error: %s: %s", pl->filename,
|
||||||
|
strerror(errno));
|
||||||
else
|
else
|
||||||
printf("\n");
|
log_error("execution error: %s", pl->filename);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,8 +500,8 @@ playlist_run_program(playlist_t *pl)
|
|||||||
pclose(filep);
|
pclose(filep);
|
||||||
|
|
||||||
if (ferror(filep)) {
|
if (ferror(filep)) {
|
||||||
printf("%s: Error while reading output from program '%s': %s\n",
|
log_alert("%s: output read error: %s", pl->filename,
|
||||||
cfg_progname(), pl->filename, strerror(errnum));
|
strerror(errnum));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,8 +512,7 @@ playlist_run_program(playlist_t *pl)
|
|||||||
pclose(filep);
|
pclose(filep);
|
||||||
|
|
||||||
if (strlen(buf) == sizeof(buf) - 1) {
|
if (strlen(buf) == sizeof(buf) - 1) {
|
||||||
printf("%s: Output from program '%s' too long\n", cfg_progname(),
|
log_error("%s: output too long", pl->filename);
|
||||||
pl->filename);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
69
src/util.c
69
src/util.c
@ -36,8 +36,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <shout/shout.h>
|
#include <shout/shout.h>
|
||||||
|
|
||||||
#include "util.h"
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "util.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
#ifndef BUFSIZ
|
#ifndef BUFSIZ
|
||||||
@ -88,42 +89,42 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
|||||||
shout_t *shout = NULL;
|
shout_t *shout = NULL;
|
||||||
|
|
||||||
if ((shout = shout_new()) == NULL) {
|
if ((shout = shout_new()) == NULL) {
|
||||||
printf("%s: shout_new(): %s", cfg_progname(), strerror(ENOMEM));
|
log_syserr(ERROR, ENOMEM, "shout_new");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shout_set_host(shout, host) != SHOUTERR_SUCCESS) {
|
if (shout_set_host(shout, host) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_host(): %s\n", cfg_progname(),
|
log_error("shout_set_host: %s",
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
|
if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_protocol(): %s\n", cfg_progname(),
|
log_error("shout_set_protocol: %s",
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_port(shout, port) != SHOUTERR_SUCCESS) {
|
if (shout_set_port(shout, port) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_port: %s\n", cfg_progname(),
|
log_error("shout_set_port: %s",
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_password(shout, pezConfig->password) != SHOUTERR_SUCCESS) {
|
if (shout_set_password(shout, pezConfig->password) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_password(): %s\n", cfg_progname(),
|
log_error("shout_set_password: %s",
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_mount(shout, mount) != SHOUTERR_SUCCESS) {
|
if (shout_set_mount(shout, mount) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_mount(): %s\n", cfg_progname(),
|
log_error("shout_set_mount: %s",
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) {
|
if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_user(): %s\n", cfg_progname(),
|
log_error("shout_set_user: %s",
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -131,87 +132,87 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
|||||||
|
|
||||||
if (!strcmp(pezConfig->format, MP3_FORMAT) &&
|
if (!strcmp(pezConfig->format, MP3_FORMAT) &&
|
||||||
shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
|
shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_format(MP3): %s\n",
|
log_error("shout_set_format(MP3): %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if ((!strcmp(pezConfig->format, VORBIS_FORMAT) ||
|
if ((!strcmp(pezConfig->format, VORBIS_FORMAT) ||
|
||||||
!strcmp(pezConfig->format, THEORA_FORMAT)) &&
|
!strcmp(pezConfig->format, THEORA_FORMAT)) &&
|
||||||
shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) {
|
shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_format(OGG): %s\n",
|
log_error("shout_set_format(OGG): %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pezConfig->username &&
|
if (pezConfig->username &&
|
||||||
shout_set_user(shout, pezConfig->username) != SHOUTERR_SUCCESS) {
|
shout_set_user(shout, pezConfig->username) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_user(): %s\n",
|
log_error("shout_set_user: %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverName &&
|
if (pezConfig->serverName &&
|
||||||
shout_set_name(shout, pezConfig->serverName) != SHOUTERR_SUCCESS) {
|
shout_set_name(shout, pezConfig->serverName) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_name(): %s\n",
|
log_error("shout_set_name: %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverURL &&
|
if (pezConfig->serverURL &&
|
||||||
shout_set_url(shout, pezConfig->serverURL) != SHOUTERR_SUCCESS) {
|
shout_set_url(shout, pezConfig->serverURL) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_url(): %s\n",
|
log_error("shout_set_url: %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverGenre &&
|
if (pezConfig->serverGenre &&
|
||||||
shout_set_genre(shout, pezConfig->serverGenre) != SHOUTERR_SUCCESS) {
|
shout_set_genre(shout, pezConfig->serverGenre) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_genre(): %s\n",
|
log_error("shout_set_genre: %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverDescription &&
|
if (pezConfig->serverDescription &&
|
||||||
shout_set_description(shout, pezConfig->serverDescription) != SHOUTERR_SUCCESS) {
|
shout_set_description(shout, pezConfig->serverDescription) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_description(): %s\n",
|
log_error("shout_set_description: %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverBitrate &&
|
if (pezConfig->serverBitrate &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_BITRATE, pezConfig->serverBitrate) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_BITRATE, pezConfig->serverBitrate) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_BITRATE): %s\n",
|
log_error("shout_set_audio_info(AI_BITRATE): %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverChannels &&
|
if (pezConfig->serverChannels &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_CHANNELS, pezConfig->serverChannels) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_CHANNELS, pezConfig->serverChannels) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_CHANNELS): %s\n",
|
log_error("shout_set_audio_info(AI_CHANNELS): %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverSamplerate &&
|
if (pezConfig->serverSamplerate &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_SAMPLERATE, pezConfig->serverSamplerate) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_SAMPLERATE, pezConfig->serverSamplerate) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_SAMPLERATE): %s\n",
|
log_error("shout_set_audio_info(AI_SAMPLERATE): %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverQuality &&
|
if (pezConfig->serverQuality &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_QUALITY, pezConfig->serverQuality) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_QUALITY, pezConfig->serverQuality) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_QUALITY): %s\n",
|
log_error("shout_set_audio_info(AI_QUALITY): %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shout_set_public(shout, (unsigned int)pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
|
if (shout_set_public(shout, (unsigned int)pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_public(): %s\n",
|
log_error("shout_set_public: %s",
|
||||||
cfg_progname(), shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -292,7 +293,7 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
|||||||
(cd = iconv_open("", from)) == (iconv_t)-1 &&
|
(cd = iconv_open("", from)) == (iconv_t)-1 &&
|
||||||
(cd = iconv_open(tocode, "")) == (iconv_t)-1) {
|
(cd = iconv_open(tocode, "")) == (iconv_t)-1) {
|
||||||
xfree(tocode);
|
xfree(tocode);
|
||||||
printf("%s: iconv_open(): %s\n", cfg_progname(), strerror(errno));
|
log_syserr(ERROR, errno, "iconv_open");
|
||||||
return (xstrdup(in_str));
|
return (xstrdup(in_str));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +332,7 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iconv_close(cd) == -1) {
|
if (iconv_close(cd) == -1) {
|
||||||
printf("%s: iconv_close(): %s\n", cfg_progname(), strerror(errno));
|
log_syserr(ERROR, errno, "iconv_close");
|
||||||
xfree(output);
|
xfree(output);
|
||||||
xfree(tocode);
|
xfree(tocode);
|
||||||
return (xstrdup(in_str));
|
return (xstrdup(in_str));
|
||||||
|
Loading…
Reference in New Issue
Block a user