mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2025-02-02 15:07:45 -05:00
Indent closer to my favorite style(9)
Why yes, it /is/ KNF!
This commit is contained in:
parent
400ef3c9cc
commit
26dd4d2a8e
111
src/configfile.c
111
src/configfile.c
@ -118,7 +118,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"url")) {
|
||||
if (ezConfig.URL != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <url> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -131,7 +131,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"sourceuser")) {
|
||||
if (ezConfig.username != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <sourceuser> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -144,7 +144,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"sourcepassword")) {
|
||||
if (ezConfig.password != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <sourcepassword> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -157,7 +157,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"format")) {
|
||||
if (ezConfig.format != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -174,7 +174,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"filename")) {
|
||||
if (ezConfig.fileName != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <filename> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -182,7 +182,7 @@ parseConfig(const char *fileName)
|
||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
if (strlen(ls_xmlContentPtr) > PATH_MAX - 1) {
|
||||
printf("%s[%ld]: Error: Path or filename in <filename> is too long\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -193,7 +193,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_progname")) {
|
||||
if (ezConfig.metadataProgram != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <metadata_progname> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -201,7 +201,7 @@ parseConfig(const char *fileName)
|
||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
if (strlen(ls_xmlContentPtr) > PATH_MAX - 1) {
|
||||
printf("%s[%ld]: Error: Path or filename in <metadata_progname> is too long\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -212,7 +212,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_format")) {
|
||||
if (ezConfig.metadataFormat != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <metadata_format> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -222,8 +222,7 @@ parseConfig(const char *fileName)
|
||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
||||
ezConfig.metadataFormat = xstrdup(ls_xmlContentPtr);
|
||||
xmlFree(ls_xmlContentPtr);
|
||||
if ((ret = checkFormatLine(ezConfig.metadataFormat,
|
||||
fileName, xmlGetLineNo(cur)))
|
||||
if ((ret = checkFormatLine(ezConfig.metadataFormat, fileName, xmlGetLineNo(cur)))
|
||||
> 0) {
|
||||
config_error += ret;
|
||||
continue;
|
||||
@ -233,7 +232,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_refreshinterval")) {
|
||||
if (refresh_set) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <metadata_refreshinterval> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -243,7 +242,7 @@ parseConfig(const char *fileName)
|
||||
ezConfig.metadataRefreshInterval = (int)strtonum(ls_xmlContentPtr, -1LL, (long long)INT_MAX, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s[%ld]: Error: In <metadata_refreshinterval>: '%s' is %s\n",
|
||||
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
||||
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -254,7 +253,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"playlist_program")) {
|
||||
if (program_set) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <playlist_program> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -265,7 +264,7 @@ parseConfig(const char *fileName)
|
||||
ezConfig.fileNameIsProgram = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s[%ld]: Error: <playlist_program> may only contain 1 or 0\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -276,7 +275,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"shuffle")) {
|
||||
if (shuffle_set) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <shuffle> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -287,7 +286,7 @@ parseConfig(const char *fileName)
|
||||
ezConfig.shuffle = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s[%ld]: Error: <shuffle> may only contain 1 or 0\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -298,7 +297,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"stream_once")) {
|
||||
if (streamOnce_set) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <stream_once> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -309,7 +308,7 @@ parseConfig(const char *fileName)
|
||||
ezConfig.streamOnce = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s[%ld]: Error: <stream_once> may only contain 1 or 0\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -320,7 +319,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"reconnect_tries")) {
|
||||
if (reconnect_set) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <reconnect_tries> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -331,7 +330,7 @@ parseConfig(const char *fileName)
|
||||
ezConfig.reconnectAttempts = (unsigned int)strtonum(ls_xmlContentPtr, 0LL, (long long)UINT_MAX, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s[%ld]: Error: In <reconnect_tries>: '%s' is %s\n",
|
||||
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
||||
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -342,7 +341,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoname")) {
|
||||
if (ezConfig.serverName != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfoname> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -355,7 +354,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfourl")) {
|
||||
if (ezConfig.serverURL != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfourl> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -368,7 +367,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfogenre")) {
|
||||
if (ezConfig.serverGenre != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfogenre> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -381,7 +380,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfodescription")) {
|
||||
if (ezConfig.serverDescription != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfodescription> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -394,7 +393,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfobitrate")) {
|
||||
if (ezConfig.serverBitrate != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfobitrate> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -408,7 +407,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfochannels")) {
|
||||
if (ezConfig.serverChannels != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfochannels> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -421,7 +420,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfosamplerate")) {
|
||||
if (ezConfig.serverSamplerate != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfosamplerate> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -434,7 +433,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoquality")) {
|
||||
if (ezConfig.serverQuality != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfoquality> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -447,7 +446,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfopublic")) {
|
||||
if (svrinfopublic_set) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <svrinfopublic> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -458,7 +457,7 @@ parseConfig(const char *fileName)
|
||||
ezConfig.serverPublic = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s[%ld]: Error: <svrinfopublic> may only contain 1 or 0\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -476,7 +475,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur2->name, (const xmlChar *)"enable")) {
|
||||
if (enable_set) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <enable> elements\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -487,7 +486,7 @@ parseConfig(const char *fileName)
|
||||
ezConfig.reencode = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s[%ld]: Error: <enable> may only contain 1 or 0\n",
|
||||
fileName, xmlGetLineNo(cur));
|
||||
fileName, xmlGetLineNo(cur));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -506,7 +505,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"format")) {
|
||||
if (pformatEncDec->format != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -523,7 +522,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"match")) {
|
||||
if (pformatEncDec->match != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <match> elements\n",
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -540,7 +539,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"decode")) {
|
||||
if (pformatEncDec->decoder != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <decode> elements\n",
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -550,8 +549,7 @@ parseConfig(const char *fileName)
|
||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
||||
pformatEncDec->decoder = UTF8toCHAR(ls_xmlContentPtr, ICONV_REPLACE);
|
||||
xmlFree(ls_xmlContentPtr);
|
||||
if ((ret = checkDecoderLine(pformatEncDec->decoder,
|
||||
fileName, xmlGetLineNo(cur3)))
|
||||
if ((ret = checkDecoderLine(pformatEncDec->decoder, fileName, xmlGetLineNo(cur3)))
|
||||
> 0) {
|
||||
config_error += ret;
|
||||
continue;
|
||||
@ -561,7 +559,7 @@ parseConfig(const char *fileName)
|
||||
if (!xmlStrcmp(cur3->name, (const xmlChar *)"encode")) {
|
||||
if (pformatEncDec->encoder != NULL) {
|
||||
printf("%s[%ld]: Error: Cannot have multiple <encode> elements\n",
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
fileName, xmlGetLineNo(cur3));
|
||||
config_error++;
|
||||
continue;
|
||||
}
|
||||
@ -571,8 +569,7 @@ parseConfig(const char *fileName)
|
||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
||||
pformatEncDec->encoder = UTF8toCHAR(ls_xmlContentPtr, ICONV_REPLACE);
|
||||
xmlFree(ls_xmlContentPtr);
|
||||
if ((ret = checkEncoderLine(pformatEncDec->encoder,
|
||||
fileName, xmlGetLineNo(cur3)))
|
||||
if ((ret = checkEncoderLine(pformatEncDec->encoder, fileName, xmlGetLineNo(cur3)))
|
||||
> 0) {
|
||||
config_error += ret;
|
||||
continue;
|
||||
@ -664,14 +661,14 @@ checkDecoderLine(const char *str, const char *file, long line)
|
||||
errors = 0;
|
||||
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in decoder command\n",
|
||||
file, line, STRING_PLACEHOLDER);
|
||||
file, line, STRING_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
||||
p += strlen(TRACK_PLACEHOLDER);
|
||||
if ((p = strstr(p, TRACK_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
errors++;
|
||||
} else
|
||||
have_track = 1;
|
||||
@ -680,7 +677,7 @@ checkDecoderLine(const char *str, const char *file, long line)
|
||||
p += strlen(METADATA_PLACEHOLDER);
|
||||
if ((p = strstr(p, METADATA_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
||||
file, line, METADATA_PLACEHOLDER);
|
||||
file, line, METADATA_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -688,7 +685,7 @@ checkDecoderLine(const char *str, const char *file, long line)
|
||||
p += strlen(ARTIST_PLACEHOLDER);
|
||||
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
||||
file, line, ARTIST_PLACEHOLDER);
|
||||
file, line, ARTIST_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -696,14 +693,14 @@ checkDecoderLine(const char *str, const char *file, long line)
|
||||
p += strlen(TITLE_PLACEHOLDER);
|
||||
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in decoder command\n",
|
||||
file, line, TITLE_PLACEHOLDER);
|
||||
file, line, TITLE_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!have_track) {
|
||||
printf("%s[%ld]: Error: The decoder command requires the '%s' track placeholder\n",
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
|
||||
@ -719,19 +716,19 @@ checkEncoderLine(const char *str, const char *file, long line)
|
||||
errors = 0;
|
||||
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in encoder command\n",
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in encoder command\n",
|
||||
file, line, STRING_PLACEHOLDER);
|
||||
file, line, STRING_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
||||
p += strlen(METADATA_PLACEHOLDER);
|
||||
if ((p = strstr(p, METADATA_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in encoder command\n",
|
||||
file, line, METADATA_PLACEHOLDER);
|
||||
file, line, METADATA_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -739,7 +736,7 @@ checkEncoderLine(const char *str, const char *file, long line)
|
||||
p += strlen(ARTIST_PLACEHOLDER);
|
||||
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in encoder command\n",
|
||||
file, line, ARTIST_PLACEHOLDER);
|
||||
file, line, ARTIST_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -747,7 +744,7 @@ checkEncoderLine(const char *str, const char *file, long line)
|
||||
p += strlen(TITLE_PLACEHOLDER);
|
||||
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in encoder command\n",
|
||||
file, line, TITLE_PLACEHOLDER);
|
||||
file, line, TITLE_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -764,14 +761,14 @@ checkFormatLine(const char *str, const char *file, long line)
|
||||
errors = 0;
|
||||
if ((p = strstr(str, METADATA_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: `%s' placeholder not allowed in <metadata_format>\n",
|
||||
file, line, METADATA_PLACEHOLDER);
|
||||
file, line, METADATA_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
if ((p = strstr(str, TRACK_PLACEHOLDER)) != NULL) {
|
||||
p += strlen(TRACK_PLACEHOLDER);
|
||||
if ((p = strstr(p, TRACK_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
file, line, TRACK_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -779,7 +776,7 @@ checkFormatLine(const char *str, const char *file, long line)
|
||||
p += strlen(STRING_PLACEHOLDER);
|
||||
if ((p = strstr(p, STRING_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
||||
file, line, STRING_PLACEHOLDER);
|
||||
file, line, STRING_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -787,7 +784,7 @@ checkFormatLine(const char *str, const char *file, long line)
|
||||
p += strlen(ARTIST_PLACEHOLDER);
|
||||
if ((p = strstr(p, ARTIST_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
||||
file, line, ARTIST_PLACEHOLDER);
|
||||
file, line, ARTIST_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -795,7 +792,7 @@ checkFormatLine(const char *str, const char *file, long line)
|
||||
p += strlen(TITLE_PLACEHOLDER);
|
||||
if ((p = strstr(p, TITLE_PLACEHOLDER)) != NULL) {
|
||||
printf("%s[%ld]: Error: Multiple `%s' placeholders in <metadata_format>\n",
|
||||
file, line, TITLE_PLACEHOLDER);
|
||||
file, line, TITLE_PLACEHOLDER);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
124
src/ezstream.c
124
src/ezstream.c
@ -149,13 +149,13 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
||||
|
||||
if (hostname == NULL || port == NULL || mountname == NULL) {
|
||||
printf("%s: urlParse(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strncmp(url, "http://", strlen("http://")) != 0) {
|
||||
printf("%s: Error: Invalid <url>: Not an HTTP address\n",
|
||||
__progname);
|
||||
__progname);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
||||
p2 = strchr(p1, ':');
|
||||
if (p2 == NULL) {
|
||||
printf("%s: Error: Invalid <url>: Missing port\n",
|
||||
__progname);
|
||||
__progname);
|
||||
return (0);
|
||||
}
|
||||
hostsiz = (p2 - p1) + 1;
|
||||
@ -174,7 +174,7 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
||||
p3 = strchr(p2, '/');
|
||||
if (p3 == NULL || p3 - p2 >= (int)sizeof(tmpPort)) {
|
||||
printf("%s: Error: Invalid <url>: Missing mountpoint or too long port number\n",
|
||||
__progname);
|
||||
__progname);
|
||||
xfree(*hostname);
|
||||
return (0);
|
||||
}
|
||||
@ -183,7 +183,7 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
||||
*port = (unsigned short)strtonum(tmpPort, 1LL, (long long)USHRT_MAX, &errstr);
|
||||
if (errstr) {
|
||||
printf("%s: Error: Invalid <url>: Port '%s' is %s\n",
|
||||
__progname, tmpPort, errstr);
|
||||
__progname, tmpPort, errstr);
|
||||
xfree(*hostname);
|
||||
return (0);
|
||||
}
|
||||
@ -278,7 +278,7 @@ buildCommandString(const char *extension, const char *fileName,
|
||||
decoder = xstrdup(getFormatDecoder(extension));
|
||||
if (strlen(decoder) == 0) {
|
||||
printf("%s: Unknown extension '%s', cannot decode '%s'\n",
|
||||
__progname, extension, fileName);
|
||||
__progname, extension, fileName);
|
||||
xfree(localTitle);
|
||||
xfree(localArtist);
|
||||
xfree(localMetaString);
|
||||
@ -335,9 +335,9 @@ buildCommandString(const char *extension, const char *fileName,
|
||||
if (strlen(encoder) == 0) {
|
||||
if (vFlag)
|
||||
printf("%s: Passing through%s%s data from the decoder\n",
|
||||
__progname,
|
||||
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
|
||||
pezConfig->format);
|
||||
__progname,
|
||||
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
|
||||
pezConfig->format);
|
||||
commandStringLen = strlen(newDecoder) + 1;
|
||||
commandString = xcalloc(commandStringLen, sizeof(char));
|
||||
strlcpy(commandString, newDecoder, commandStringLen);
|
||||
@ -381,10 +381,10 @@ buildCommandString(const char *extension, const char *fileName,
|
||||
}
|
||||
|
||||
commandStringLen = strlen(newDecoder) + strlen(" | ") +
|
||||
strlen(newEncoder) + 1;
|
||||
strlen(newEncoder) + 1;
|
||||
commandString = xcalloc(commandStringLen, sizeof(char));
|
||||
snprintf(commandString, commandStringLen, "%s | %s", newDecoder,
|
||||
newEncoder);
|
||||
newEncoder);
|
||||
|
||||
xfree(localTitle);
|
||||
xfree(localArtist);
|
||||
@ -404,7 +404,7 @@ getMetadataString(const char *format, metadata_t *mdata)
|
||||
|
||||
if (mdata == NULL) {
|
||||
printf("%s: getMetadataString(): Internal error: NULL metadata_t\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
||||
|
||||
if (shout == NULL) {
|
||||
printf("%s: setMetadata(): Internal error: NULL shout_t\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
||||
|
||||
if ((shout_mdata = shout_metadata_new()) == NULL) {
|
||||
printf("%s: shout_metadata_new(): %s\n", __progname,
|
||||
strerror(ENOMEM));
|
||||
strerror(ENOMEM));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -505,7 +505,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
||||
if (shout_metadata_add(shout_mdata, "charset", "UTF-8") != SHOUTERR_SUCCESS) {
|
||||
/* Assume SHOUTERR_MALLOC */
|
||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||
strerror(ENOMEM));
|
||||
strerror(ENOMEM));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -517,30 +517,30 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
||||
if (artist[0] != '\0' && title[0] != '\0') {
|
||||
if (shout_metadata_add(shout_mdata, "artist", artist) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||
strerror(ENOMEM));
|
||||
strerror(ENOMEM));
|
||||
exit(1);
|
||||
}
|
||||
if (shout_metadata_add(shout_mdata, "title", title) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||
strerror(ENOMEM));
|
||||
strerror(ENOMEM));
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||
strerror(ENOMEM));
|
||||
strerror(ENOMEM));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
||||
strerror(ENOMEM));
|
||||
strerror(ENOMEM));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((ret = shout_set_metadata(shout, shout_mdata)) != SHOUTERR_SUCCESS)
|
||||
printf("%s: shout_set_metadata(): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
|
||||
shout_metadata_free(shout_mdata);
|
||||
|
||||
@ -603,7 +603,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
||||
|
||||
if (strlen(extension) == 0) {
|
||||
printf("%s: Error: Cannot determine file type of '%s'\n",
|
||||
__progname, fileName);
|
||||
__progname, fileName);
|
||||
return (filep);
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
||||
stderr_fd = dup(fileno(stderr));
|
||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
||||
printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
|
||||
__progname, _PATH_DEVNULL, strerror(errno));
|
||||
__progname, _PATH_DEVNULL, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
||||
errno = 0;
|
||||
if ((filep = popen(pCommandString, "r")) == NULL) {
|
||||
printf("%s: popen(): Error while executing '%s'",
|
||||
__progname, pCommandString);
|
||||
__progname, pCommandString);
|
||||
/* popen() does not set errno reliably ... */
|
||||
if (errno)
|
||||
printf(": %s\n", strerror(errno));
|
||||
@ -679,7 +679,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
||||
|
||||
if ((filep = fopen(fileName, "rb")) == NULL)
|
||||
printf("%s: %s: %s\n", __progname, fileName,
|
||||
strerror(errno));
|
||||
strerror(errno));
|
||||
|
||||
return (filep);
|
||||
}
|
||||
@ -696,8 +696,7 @@ reconnectServer(shout_t *shout, int closeConn)
|
||||
while (++i) {
|
||||
printf("%s: Attempting reconnection #", __progname);
|
||||
if (pezConfig->reconnectAttempts > 0)
|
||||
printf("%u/%u: ", i,
|
||||
pezConfig->reconnectAttempts);
|
||||
printf("%u/%u: ", i, pezConfig->reconnectAttempts);
|
||||
else
|
||||
printf("%u: ", i);
|
||||
|
||||
@ -707,7 +706,7 @@ reconnectServer(shout_t *shout, int closeConn)
|
||||
shout_close(shout);
|
||||
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
||||
printf("OK\n%s: Reconnect to %s successful\n",
|
||||
__progname, pezConfig->URL);
|
||||
__progname, pezConfig->URL);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@ -718,7 +717,7 @@ reconnectServer(shout_t *shout, int closeConn)
|
||||
break;
|
||||
|
||||
printf("%s: Waiting 5s for %s to come back ...\n",
|
||||
__progname, pezConfig->URL);
|
||||
__progname, pezConfig->URL);
|
||||
if (quit)
|
||||
return (0);
|
||||
else
|
||||
@ -761,7 +760,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
||||
|
||||
if (startTime == NULL) {
|
||||
printf("%s: sendStream(): Internal error: startTime is NULL\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -783,7 +782,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
||||
|
||||
if (shout_send(shout, buff, bytes_read) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_send(): %s\n", __progname,
|
||||
shout_get_error(shout));
|
||||
shout_get_error(shout));
|
||||
if (reconnectServer(shout, 1))
|
||||
break;
|
||||
else {
|
||||
@ -798,7 +797,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
||||
rereadPlaylist_notify = 0;
|
||||
if (!pezConfig->fileNameIsProgram)
|
||||
printf("%s: SIGHUP signal received, will reread playlist after this file\n",
|
||||
__progname);
|
||||
__progname);
|
||||
}
|
||||
if (skipTrack) {
|
||||
skipTrack = 0;
|
||||
@ -810,10 +809,10 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
||||
|
||||
if (queryMetadata ||
|
||||
(pezConfig->metadataRefreshInterval != -1
|
||||
&& (currentTime.tv_sec - callTime.tv_sec
|
||||
>= pezConfig->metadataRefreshInterval)
|
||||
)
|
||||
) {
|
||||
&& (currentTime.tv_sec - callTime.tv_sec
|
||||
>= pezConfig->metadataRefreshInterval)
|
||||
)
|
||||
) {
|
||||
queryMetadata = 0;
|
||||
if (metadataFromProgram) {
|
||||
ret = STREAM_UPDMDATA;
|
||||
@ -828,31 +827,30 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
||||
if (!isStdin && playlistMode) {
|
||||
if (pezConfig->fileNameIsProgram) {
|
||||
char *tmp = xstrdup(pezConfig->fileName);
|
||||
printf(" [%s]",
|
||||
local_basename(tmp));
|
||||
printf(" [%s]", local_basename(tmp));
|
||||
xfree(tmp);
|
||||
} else
|
||||
printf(" [%4lu/%-4lu]",
|
||||
playlist_get_position(playlist),
|
||||
playlist_get_num_items(playlist));
|
||||
playlist_get_position(playlist),
|
||||
playlist_get_num_items(playlist));
|
||||
}
|
||||
|
||||
oldTime = (double)timeStamp.tv_sec
|
||||
+ (double)timeStamp.tv_usec / 1000000.0;
|
||||
+ (double)timeStamp.tv_usec / 1000000.0;
|
||||
newTime = (double)currentTime.tv_sec
|
||||
+ (double)currentTime.tv_usec / 1000000.0;
|
||||
+ (double)currentTime.tv_usec / 1000000.0;
|
||||
if (songLenStr == NULL)
|
||||
printf(" [ %s]",
|
||||
getTimeString(currentTime.tv_sec -
|
||||
startTime->tv_sec));
|
||||
getTimeString(currentTime.tv_sec -
|
||||
startTime->tv_sec));
|
||||
else
|
||||
printf(" [ %s/%s]",
|
||||
getTimeString(currentTime.tv_sec -
|
||||
startTime->tv_sec),
|
||||
songLenStr);
|
||||
getTimeString(currentTime.tv_sec -
|
||||
startTime->tv_sec),
|
||||
songLenStr);
|
||||
if (newTime - oldTime >= 1.0) {
|
||||
kbps = (((double)(total - oldTotal)
|
||||
/ (newTime - oldTime)) * 8.0) / 1000.0;
|
||||
/ (newTime - oldTime)) * 8.0) / 1000.0;
|
||||
timeStamp.tv_sec = currentTime.tv_sec;
|
||||
timeStamp.tv_usec = currentTime.tv_usec;
|
||||
oldTotal = total;
|
||||
@ -872,10 +870,10 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
||||
ret = STREAM_CONT;
|
||||
} else if (errno == EBADF && isStdin)
|
||||
printf("%s: No (more) data available on standard input\n",
|
||||
__progname);
|
||||
__progname);
|
||||
else
|
||||
printf("%s: sendStream(): Error while reading '%s': %s\n",
|
||||
__progname, fileName, strerror(errno));
|
||||
__progname, fileName, strerror(errno));
|
||||
}
|
||||
|
||||
return (ret);
|
||||
@ -893,8 +891,7 @@ streamFile(shout_t *shout, const char *fileName)
|
||||
metadata_t *mdata;
|
||||
struct timeval startTime;
|
||||
|
||||
if ((filepstream = openResource(shout, fileName, &popenFlag,
|
||||
&mdata, &isStdin, &songLen))
|
||||
if ((filepstream = openResource(shout, fileName, &popenFlag, &mdata, &isStdin, &songLen))
|
||||
== NULL) {
|
||||
if (++resource_errors > 100) {
|
||||
printf("%s: Too many errors -- giving up.\n", __progname);
|
||||
@ -932,7 +929,7 @@ streamFile(shout_t *shout, const char *fileName)
|
||||
ez_gettimeofday((void *)&startTime);
|
||||
do {
|
||||
ret = sendStream(shout, filepstream, fileName, isStdin,
|
||||
songLenStr, &startTime);
|
||||
songLenStr, &startTime);
|
||||
if (quit)
|
||||
break;
|
||||
if (ret != STREAM_DONE) {
|
||||
@ -949,7 +946,7 @@ streamFile(shout_t *shout, const char *fileName)
|
||||
skipTrack = 0;
|
||||
if (!isStdin && vFlag)
|
||||
printf("%s: SIGUSR1 signal received, skipping current track\n",
|
||||
__progname);
|
||||
__progname);
|
||||
retval = 1;
|
||||
ret = STREAM_DONE;
|
||||
}
|
||||
@ -963,7 +960,7 @@ streamFile(shout_t *shout, const char *fileName)
|
||||
|
||||
if (vFlag > 1)
|
||||
printf("%s: Querying '%s' for fresh metadata\n",
|
||||
__progname, pezConfig->metadataProgram);
|
||||
__progname, pezConfig->metadataProgram);
|
||||
if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
|
||||
retval = 0;
|
||||
ret = STREAM_DONE;
|
||||
@ -977,7 +974,7 @@ streamFile(shout_t *shout, const char *fileName)
|
||||
metadata_free(&prog_mdata);
|
||||
if (vFlag > 1)
|
||||
printf("%s: New metadata: ``%s''\n",
|
||||
__progname, mdataStr);
|
||||
__progname, mdataStr);
|
||||
xfree(mdataStr);
|
||||
}
|
||||
}
|
||||
@ -1015,7 +1012,7 @@ streamPlaylist(shout_t *shout, const char *fileName)
|
||||
return (0);
|
||||
if (vFlag && playlist_get_num_items(playlist) == 0)
|
||||
printf("%s: Warning: Playlist '%s' is empty\n",
|
||||
__progname, fileName);
|
||||
__progname, fileName);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@ -1239,10 +1236,10 @@ main(int argc, char *argv[])
|
||||
}
|
||||
if (vFlag && (st.st_mode & (S_IRGRP | S_IROTH)))
|
||||
printf("%s: Warning: %s is group and/or world readable\n",
|
||||
__progname, configFile);
|
||||
__progname, configFile);
|
||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||
printf("%s: Error: %s is group and/or world writeable\n",
|
||||
__progname, configFile);
|
||||
__progname, configFile);
|
||||
return (ez_shutdown(2));
|
||||
}
|
||||
#else
|
||||
@ -1310,7 +1307,7 @@ main(int argc, char *argv[])
|
||||
for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) {
|
||||
if (sigaction(ezstream_signals[i], &act, NULL) == -1) {
|
||||
printf("%s: sigaction(): %s\n",
|
||||
__progname, strerror(errno));
|
||||
__progname, strerror(errno));
|
||||
return (ez_shutdown(1));
|
||||
}
|
||||
}
|
||||
@ -1321,7 +1318,7 @@ main(int argc, char *argv[])
|
||||
act.sa_handler = SIG_IGN;
|
||||
if (sigaction(SIGPIPE, &act, NULL) == -1) {
|
||||
printf("%s: sigaction(): %s\n",
|
||||
__progname, strerror(errno));
|
||||
__progname, strerror(errno));
|
||||
return (ez_shutdown(1));
|
||||
}
|
||||
#endif /* HAVE_SIGNALS */
|
||||
@ -1330,7 +1327,7 @@ main(int argc, char *argv[])
|
||||
int ret;
|
||||
|
||||
printf("%s: Connected to http://%s:%hu%s\n", __progname,
|
||||
host, port, mount);
|
||||
host, port, mount);
|
||||
|
||||
if (pezConfig->fileNameIsProgram ||
|
||||
strrcasecmp(pezConfig->fileName, ".m3u") == 0 ||
|
||||
@ -1345,8 +1342,7 @@ main(int argc, char *argv[])
|
||||
|
||||
do {
|
||||
if (playlistMode) {
|
||||
ret = streamPlaylist(shout,
|
||||
pezConfig->fileName);
|
||||
ret = streamPlaylist(shout, pezConfig->fileName);
|
||||
} else {
|
||||
ret = streamFile(shout, pezConfig->fileName);
|
||||
}
|
||||
@ -1359,7 +1355,7 @@ main(int argc, char *argv[])
|
||||
shout_close(shout);
|
||||
} else
|
||||
printf("%s: Connection to http://%s:%hu%s failed: %s\n", __progname,
|
||||
host, port, mount, shout_get_error(shout));
|
||||
host, port, mount, shout_get_error(shout));
|
||||
|
||||
if (quit)
|
||||
printf("\r%s: SIGINT or SIGTERM received\n", __progname);
|
||||
|
@ -98,7 +98,7 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
|
||||
|
||||
if (md == NULL || md->filename == NULL) {
|
||||
printf("%s: metadata_use_taglib(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
|
||||
(void)filep;
|
||||
|
||||
printf("%s: Internal error: metadata_use_taglib() called without TagLib support\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
#endif /* HAVE_TAGLIB */
|
||||
@ -163,7 +163,7 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
||||
(void)filep;
|
||||
|
||||
printf("%s: Internal error: metadata_use_self() called with TagLib support\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
@ -174,7 +174,7 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
||||
if (md == NULL || filep == NULL || *filep == NULL ||
|
||||
md->filename == NULL) {
|
||||
printf("%s: metadata_use_self(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -200,27 +200,27 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
||||
switch (ret) {
|
||||
case OV_EREAD:
|
||||
printf("%s: ov_open(): %s: Media read error\n",
|
||||
__progname, md->filename);
|
||||
__progname, md->filename);
|
||||
break;
|
||||
case OV_ENOTVORBIS:
|
||||
printf("%s: ov_open(): %s: Invalid Vorbis bitstream\n",
|
||||
__progname, md->filename);
|
||||
__progname, md->filename);
|
||||
break;
|
||||
case OV_EVERSION:
|
||||
printf("%s: ov_open(): %s: Vorbis version mismatch\n",
|
||||
__progname, md->filename);
|
||||
__progname, md->filename);
|
||||
break;
|
||||
case OV_EBADHEADER:
|
||||
printf("%s: ov_open(): %s: Invalid Vorbis bitstream header\n",
|
||||
__progname, md->filename);
|
||||
__progname, md->filename);
|
||||
break;
|
||||
case OV_EFAULT:
|
||||
printf("%s: Fatal: Internal libvorbisfile fault\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
default:
|
||||
printf("%s: ov_open(): %s: ov_read() returned unknown error\n",
|
||||
__progname, md->filename);
|
||||
__progname, md->filename);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -258,7 +258,7 @@ metadata_clean_md(metadata_t *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
printf("%s: Internal error: metadata_clean_md(): NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ metadata_get_extension(char *buf, size_t siz, const char *filename)
|
||||
|
||||
if (buf == NULL || siz == 0 || filename == NULL) {
|
||||
printf("%s: metadata_get_extension(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -303,13 +303,13 @@ metadata_get_name(const char *file)
|
||||
|
||||
if (file == NULL) {
|
||||
printf("%s: metadata_get_name(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
if ((p1 = local_basename(filename)) == NULL) {
|
||||
printf("%s: Internal error: basename() failed with '%s'\n",
|
||||
__progname, filename);
|
||||
__progname, filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ metadata_process_md(metadata_t *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_process_md(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ metadata_file(const char *filename, int normalize)
|
||||
|
||||
if (filename == NULL || strlen(filename) == 0) {
|
||||
printf("%s: metadata_file(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ metadata_program(const char *program, int normalize)
|
||||
|
||||
if (program == NULL || strlen(program) == 0) {
|
||||
printf("%s: metadata_program(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ metadata_program(const char *program, int normalize)
|
||||
}
|
||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||
printf("%s: Error: %s is group and/or world writeable\n",
|
||||
__progname, program);
|
||||
__progname, program);
|
||||
metadata_free(&md);
|
||||
return (NULL);
|
||||
}
|
||||
@ -473,13 +473,13 @@ metadata_file_update(metadata_t *md)
|
||||
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_file_update(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
if (md->program) {
|
||||
printf("%s: metadata_file_update(): Internal error: Called with program handle\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -508,13 +508,13 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_program_update(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
if (!md->program) {
|
||||
printf("%s: metadata_program_update(): Internal error: Received file handle\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
break;
|
||||
default:
|
||||
printf("%s: metadata_program_update(): Internal error: Unknown md_req\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -558,10 +558,10 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
errno = 0;
|
||||
if (vFlag > 1)
|
||||
printf("%s: Running command `%s`\n", __progname,
|
||||
command);
|
||||
command);
|
||||
if ((filep = popen(command, "r")) == NULL) {
|
||||
printf("%s: playlist_run_program(): Error while executing '%s'",
|
||||
__progname, command);
|
||||
__progname, command);
|
||||
/* popen() does not set errno reliably ... */
|
||||
if (errno)
|
||||
printf(": %s\n", strerror(errno));
|
||||
@ -573,7 +573,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
if (fgets(buf, (int)sizeof(buf), filep) == NULL) {
|
||||
if (ferror(filep))
|
||||
printf("%s: Error while reading output from program '%s': %s\n",
|
||||
__progname, md->filename, strerror(errno));
|
||||
__progname, md->filename, strerror(errno));
|
||||
pclose(filep);
|
||||
printf("%s: FATAL: External program '%s' not (or no longer) usable.\n",
|
||||
__progname, md->filename);
|
||||
@ -584,7 +584,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
|
||||
if (strlen(buf) == sizeof(buf) - 1)
|
||||
printf("%s: Warning: Metadata string received via '%s' is too long and has been truncated\n",
|
||||
__progname, command);
|
||||
__progname, command);
|
||||
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
buf[strcspn(buf, "\r")] = '\0';
|
||||
@ -593,7 +593,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
case METADATA_STRING:
|
||||
if (strlen(buf) == 0) {
|
||||
printf("%s: Warning: Empty metadata string received from '%s'\n",
|
||||
__progname, md->filename);
|
||||
__progname, md->filename);
|
||||
md->string = xstrdup("");
|
||||
} else
|
||||
md->string = xstrdup(buf);
|
||||
@ -609,7 +609,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
||||
case METADATA_ALL:
|
||||
default:
|
||||
printf("%s: metadata_program_update(): Internal error: METADATA_ALL in code unreachable by METADATA_ALL\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -627,13 +627,13 @@ metadata_get_string(metadata_t *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_get_string(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
if (md->string == NULL) {
|
||||
printf("%s: metadata_get_string(): Internal error: md->string cannot be NULL\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ metadata_get_artist(metadata_t *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_get_artist(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -660,7 +660,7 @@ metadata_get_title(metadata_t *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_get_title(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -675,7 +675,7 @@ metadata_get_filename(metadata_t *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_get_filename(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -691,7 +691,7 @@ metadata_get_length(metadata_t *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_get_length(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -706,7 +706,7 @@ metadata_assemble_string(metadata_t *md)
|
||||
|
||||
if (md == NULL) {
|
||||
printf("%s: metadata_assemble_string(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ playlist_read(const char *filename)
|
||||
}
|
||||
if (ferror(filep)) {
|
||||
printf("%s: playlist_read(): Error while reading %s: %s\n",
|
||||
__progname, pl->filename, strerror(errno));
|
||||
__progname, pl->filename, strerror(errno));
|
||||
fclose(filep);
|
||||
playlist_free(&pl);
|
||||
return (NULL);
|
||||
@ -221,7 +221,7 @@ playlist_program(const char *filename)
|
||||
}
|
||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||
printf("%s: Error: %s is group and/or world writeable\n",
|
||||
__progname, filename);
|
||||
__progname, filename);
|
||||
playlist_free(&pl);
|
||||
return (NULL);
|
||||
}
|
||||
@ -283,7 +283,7 @@ playlist_get_next(playlist_t *pl)
|
||||
{
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_get_next(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ playlist_peek_next(playlist_t *pl)
|
||||
{
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_peek_next(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ playlist_skip_next(playlist_t *pl)
|
||||
{
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_skip_next(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ playlist_get_num_items(playlist_t *pl)
|
||||
{
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ playlist_get_position(playlist_t *pl)
|
||||
{
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ playlist_set_position(playlist_t *pl, unsigned long idx)
|
||||
{
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_set_position(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ playlist_goto_entry(playlist_t *pl, const char *entry)
|
||||
|
||||
if (pl == NULL || entry == NULL) {
|
||||
printf("%s: playlist_goto_entry(): Internal error: Bad arguments\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ playlist_rewind(playlist_t *pl)
|
||||
{
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_rewind(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -420,7 +420,7 @@ playlist_reread(playlist_t **plist)
|
||||
|
||||
if (plist == NULL || *plist == NULL) {
|
||||
printf("%s: playlist_reread(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ playlist_shuffle(playlist_t *pl)
|
||||
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_shuffle(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ playlist_run_program(playlist_t *pl)
|
||||
|
||||
if (pl == NULL) {
|
||||
printf("%s: playlist_run_program(): Internal error: NULL argument\n",
|
||||
__progname);
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ playlist_run_program(playlist_t *pl)
|
||||
errno = 0;
|
||||
if ((filep = popen(pl->filename, "r")) == NULL) {
|
||||
printf("%s: playlist_run_program(): Error while executing '%s'",
|
||||
__progname, pl->filename);
|
||||
__progname, pl->filename);
|
||||
/* popen() does not set errno reliably ... */
|
||||
if (errno)
|
||||
printf(": %s\n", strerror(errno));
|
||||
@ -514,7 +514,7 @@ playlist_run_program(playlist_t *pl)
|
||||
|
||||
if (ferror(filep)) {
|
||||
printf("%s: Error while reading output from program '%s': %s\n",
|
||||
__progname, pl->filename, strerror(errnum));
|
||||
__progname, pl->filename, strerror(errnum));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -526,7 +526,7 @@ playlist_run_program(playlist_t *pl)
|
||||
|
||||
if (strlen(buf) == sizeof(buf) - 1) {
|
||||
printf("%s: Output from program '%s' too long\n", __progname,
|
||||
pl->filename);
|
||||
pl->filename);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
36
src/util.c
36
src/util.c
@ -95,37 +95,37 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
||||
|
||||
if (shout_set_host(shout, host) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_host(): %s\n", __progname,
|
||||
shout_get_error(shout));
|
||||
shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_protocol(): %s\n", __progname,
|
||||
shout_get_error(shout));
|
||||
shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (shout_set_port(shout, port) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_port: %s\n", __progname,
|
||||
shout_get_error(shout));
|
||||
shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (shout_set_password(shout, pezConfig->password) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_password(): %s\n", __progname,
|
||||
shout_get_error(shout));
|
||||
shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (shout_set_mount(shout, mount) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_mount(): %s\n", __progname,
|
||||
shout_get_error(shout));
|
||||
shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_user(): %s\n", __progname,
|
||||
shout_get_error(shout));
|
||||
shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
@ -133,7 +133,7 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
||||
if (!strcmp(pezConfig->format, MP3_FORMAT) &&
|
||||
shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_format(MP3): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
@ -141,7 +141,7 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
||||
!strcmp(pezConfig->format, THEORA_FORMAT)) &&
|
||||
shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_format(OGG): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
@ -149,70 +149,70 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
||||
if (pezConfig->username &&
|
||||
shout_set_user(shout, pezConfig->username) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_user(): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverName &&
|
||||
shout_set_name(shout, pezConfig->serverName) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_name(): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverURL &&
|
||||
shout_set_url(shout, pezConfig->serverURL) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_url(): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverGenre &&
|
||||
shout_set_genre(shout, pezConfig->serverGenre) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_genre(): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverDescription &&
|
||||
shout_set_description(shout, pezConfig->serverDescription) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_description(): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverBitrate &&
|
||||
shout_set_audio_info(shout, SHOUT_AI_BITRATE, pezConfig->serverBitrate) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_audio_info(AI_BITRATE): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverChannels &&
|
||||
shout_set_audio_info(shout, SHOUT_AI_CHANNELS, pezConfig->serverChannels) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_audio_info(AI_CHANNELS): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverSamplerate &&
|
||||
shout_set_audio_info(shout, SHOUT_AI_SAMPLERATE, pezConfig->serverSamplerate) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_audio_info(AI_SAMPLERATE): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
if (pezConfig->serverQuality &&
|
||||
shout_set_audio_info(shout, SHOUT_AI_QUALITY, pezConfig->serverQuality) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_audio_info(AI_QUALITY): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (shout_set_public(shout, (unsigned int)pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
|
||||
printf("%s: shout_set_public(): %s\n",
|
||||
__progname, shout_get_error(shout));
|
||||
__progname, shout_get_error(shout));
|
||||
shout_free(shout);
|
||||
return (NULL);
|
||||
}
|
||||
|
88
src/xalloc.c
88
src/xalloc.c
@ -318,16 +318,16 @@ xalloc_shutdown(void)
|
||||
|
||||
if (mem->freed_by == NULL) {
|
||||
_xalloc_debug_printf(1, "XALLOC: MEMORY LEAK (%p:%u): allocated in %s:%u, ",
|
||||
mem->ptr,
|
||||
mem->id,
|
||||
mem->allocated_by,
|
||||
mem->allocated_in_line);
|
||||
mem->ptr,
|
||||
mem->id,
|
||||
mem->allocated_by,
|
||||
mem->allocated_in_line);
|
||||
if (mem->reallocated_by != NULL)
|
||||
_xalloc_debug_printf(1, "last reallocated in %s:%u, ",
|
||||
mem->reallocated_by,
|
||||
mem->reallocated_in_line);
|
||||
mem->reallocated_by,
|
||||
mem->reallocated_in_line);
|
||||
_xalloc_debug_printf(1, "leaks %lu bytes\n",
|
||||
(unsigned long)mem->size);
|
||||
(unsigned long)mem->size);
|
||||
leaked_bytes += mem->size;
|
||||
real_free(mem->ptr);
|
||||
}
|
||||
@ -337,14 +337,14 @@ xalloc_shutdown(void)
|
||||
|
||||
if (leaked_bytes != xalloc_allocated)
|
||||
_xalloc_fatal("XALLOC: Internal error: xalloc_shutdown(): leaked_bytes(%lu) != xalloc_allocated(%lu)\n",
|
||||
(unsigned long)leaked_bytes,
|
||||
(unsigned long)xalloc_allocated);
|
||||
(unsigned long)leaked_bytes,
|
||||
(unsigned long)xalloc_allocated);
|
||||
|
||||
_xalloc_debug_printf(1, "XALLOC: STATS: leaked: %lu bytes, peak allocation: %lu bytes (freed/total: %lu/%lu bytes)\n",
|
||||
(unsigned long)xalloc_allocated,
|
||||
(unsigned long)xalloc_peak,
|
||||
(unsigned long)xalloc_freed,
|
||||
(unsigned long)xalloc_total);
|
||||
(unsigned long)xalloc_allocated,
|
||||
(unsigned long)xalloc_peak,
|
||||
(unsigned long)xalloc_freed,
|
||||
(unsigned long)xalloc_total);
|
||||
}
|
||||
#endif /* XALLOC_DEBUG */
|
||||
|
||||
@ -361,12 +361,12 @@ xmalloc_c(size_t size, const char *file, unsigned int line)
|
||||
|
||||
if (size == 0)
|
||||
_xalloc_fatal("XALLOC: xmalloc(): %s:%u: Zero size\n",
|
||||
file ? file : unknown_file, line);
|
||||
file ? file : unknown_file, line);
|
||||
|
||||
if ((ret = real_malloc(size)) == NULL)
|
||||
_xalloc_error(errno, "XALLOC: xmalloc(): %s:%u: Allocating %lu bytes",
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(size));
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(size));
|
||||
|
||||
#ifdef XALLOC_DEBUG
|
||||
if (debug_level > 0) {
|
||||
@ -386,7 +386,7 @@ xmalloc_c(size_t size, const char *file, unsigned int line)
|
||||
/* Freed pointer is being reused: */
|
||||
if (mem_exists->id != 0)
|
||||
_xalloc_fatal("XALLOC: Internal error: Assertion (mem_exists->id == 0) in %s:%u failed!\n",
|
||||
__FILE__, __LINE__);
|
||||
__FILE__, __LINE__);
|
||||
RB_REMOVE(memory_tree, &memory_tree_head, mem_exists);
|
||||
_memory_free(&mem_exists);
|
||||
RB_INSERT(memory_tree, &memory_tree_head, mem);
|
||||
@ -412,16 +412,16 @@ xcalloc_c(size_t nmemb, size_t size, int may_fail,
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
_xalloc_fatal("XALLOC: xcalloc(): %s:%u: Zero size\n",
|
||||
file ? file : unknown_file, line);
|
||||
file ? file : unknown_file, line);
|
||||
|
||||
if (SIZE_T_MAX / nmemb < size)
|
||||
_xalloc_fatal("XALLOC: xcalloc(): %s:%u: Integer overflow (nmemb * size > SIZE_T_MAX)\n",
|
||||
file ? file : unknown_file, line);
|
||||
file ? file : unknown_file, line);
|
||||
|
||||
if ((ret = real_calloc(nmemb, size)) == NULL && may_fail == 0)
|
||||
_xalloc_error(errno, "XALLOC: xcalloc(): %s:%u: Allocating %lu bytes",
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(nmemb * size));
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(nmemb * size));
|
||||
|
||||
#ifdef XALLOC_DEBUG
|
||||
if (ret != NULL && debug_level > 0) {
|
||||
@ -441,7 +441,7 @@ xcalloc_c(size_t nmemb, size_t size, int may_fail,
|
||||
/* Freed pointer is being reused: */
|
||||
if (mem_exists->id != 0)
|
||||
_xalloc_fatal("XALLOC: Internal error: Assertion (mem_exists->id == 0) in %s:%u failed!\n",
|
||||
__FILE__, __LINE__);
|
||||
__FILE__, __LINE__);
|
||||
RB_REMOVE(memory_tree, &memory_tree_head, mem_exists);
|
||||
_memory_free(&mem_exists);
|
||||
RB_INSERT(memory_tree, &memory_tree_head, mem);
|
||||
@ -471,11 +471,11 @@ xrealloc_c(void *ptr, size_t nmemb, size_t size,
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
_xalloc_fatal("XALLOC: xrealloc(): %s:%u: Zero size\n",
|
||||
file ? file : unknown_file, line);
|
||||
file ? file : unknown_file, line);
|
||||
|
||||
if (SIZE_T_MAX / nmemb < size)
|
||||
_xalloc_fatal("XALLOC: xrealloc(): %s:%u: Integer overflow (nmemb * size > SIZE_T_MAX)\n",
|
||||
file ? file : unknown_file, line);
|
||||
file ? file : unknown_file, line);
|
||||
|
||||
if (ptr == NULL) {
|
||||
ret = real_malloc(nsiz);
|
||||
@ -500,8 +500,8 @@ xrealloc_c(void *ptr, size_t nmemb, size_t size,
|
||||
find_mem.ptr = ptr;
|
||||
if ((mem = RB_FIND(memory_tree, &memory_tree_head, &find_mem)) == NULL)
|
||||
_xalloc_fatal("XALLOC: xrealloc(): %s:%u: Junk pointer %p not accounted for\n",
|
||||
file ? file : unknown_file,
|
||||
line, ptr);
|
||||
file ? file : unknown_file,
|
||||
line, ptr);
|
||||
RB_REMOVE(memory_tree, &memory_tree_head, mem);
|
||||
}
|
||||
#endif /* XALLOC_DEBUG */
|
||||
@ -520,8 +520,8 @@ xrealloc_c(void *ptr, size_t nmemb, size_t size,
|
||||
|
||||
if (ret == NULL)
|
||||
_xalloc_error(errno, "XALLOC: xrealloc(): %s:%u: (Re)allocating %lu bytes",
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(nmemb * size));
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(nmemb * size));
|
||||
|
||||
#ifdef XALLOC_DEBUG
|
||||
if (debug_level > 0) {
|
||||
@ -540,7 +540,7 @@ xrealloc_c(void *ptr, size_t nmemb, size_t size,
|
||||
/* Freed pointer is being reused: */
|
||||
if (mem_exists->id != 0)
|
||||
_xalloc_fatal("XALLOC: Internal error: Assertion (mem_exists->id == 0) in %s:%u failed!\n",
|
||||
__FILE__, __LINE__);
|
||||
__FILE__, __LINE__);
|
||||
RB_REMOVE(memory_tree, &memory_tree_head, mem_exists);
|
||||
_memory_free(&mem_exists);
|
||||
RB_INSERT(memory_tree, &memory_tree_head, mem);
|
||||
@ -563,8 +563,8 @@ xstrdup_c(const char *str, const char *file, unsigned int line)
|
||||
len = strlen(str) + 1;
|
||||
if ((nstr = xcalloc_c(len, sizeof(char), 0, file, line)) == NULL)
|
||||
_xalloc_error(errno, "XALLOC: xstrdup(): %s:%u: Allocating %lu bytes: %s\n",
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(len));
|
||||
file ? file : unknown_file, line,
|
||||
(unsigned long)(len));
|
||||
memcpy(nstr, str, len);
|
||||
return (nstr);
|
||||
}
|
||||
@ -580,7 +580,7 @@ xfree_c(void **ptr_p, const char *file, unsigned int line)
|
||||
|
||||
if (*ptr_p == NULL) {
|
||||
_xalloc_warn("XALLOC: xfree(): Warning: %s:%u: Freeing NULL pointer\n",
|
||||
file ? file : unknown_file, line);
|
||||
file ? file : unknown_file, line);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -591,22 +591,22 @@ xfree_c(void **ptr_p, const char *file, unsigned int line)
|
||||
find_mem.ptr = *ptr_p;
|
||||
if ((mem = RB_FIND(memory_tree, &memory_tree_head, &find_mem)) == NULL)
|
||||
_xalloc_fatal("XALLOC: xfree(): %s:%u: Junk pointer %p not accounted for\n",
|
||||
file ? file : unknown_file, line,
|
||||
*ptr_p);
|
||||
file ? file : unknown_file, line,
|
||||
*ptr_p);
|
||||
|
||||
if (mem->freed_by != NULL && mem->id == 0) {
|
||||
_xalloc_debug_printf(2, "XALLOC: DOUBLE FREE of pointer %p in %s:%u: allocated in %s:%u, ",
|
||||
mem->ptr,
|
||||
file ? file : unknown_file, line,
|
||||
mem->allocated_by,
|
||||
mem->allocated_in_line);
|
||||
mem->ptr,
|
||||
file ? file : unknown_file, line,
|
||||
mem->allocated_by,
|
||||
mem->allocated_in_line);
|
||||
if (mem->reallocated_by != NULL)
|
||||
_xalloc_debug_printf(2, "last reallocated in %s:%u, ",
|
||||
mem->reallocated_by,
|
||||
mem->reallocated_in_line);
|
||||
mem->reallocated_by,
|
||||
mem->reallocated_in_line);
|
||||
_xalloc_debug_printf(2, "already freed in %s:%u\n",
|
||||
mem->freed_by,
|
||||
mem->freed_in_line);
|
||||
mem->freed_by,
|
||||
mem->freed_in_line);
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -656,7 +656,7 @@ xasprintf_c(const char *file, unsigned int line,
|
||||
va_end(ap);
|
||||
if (ret == -1)
|
||||
_xalloc_error(errno, "XALLOC: xasprintf(): %s:%u: Allocating %lu bytes",
|
||||
file ? file : unknown_file, line, strsiz);
|
||||
file ? file : unknown_file, line, strsiz);
|
||||
|
||||
# ifdef XALLOC_DEBUG
|
||||
if (debug_level > 0) {
|
||||
@ -676,7 +676,7 @@ xasprintf_c(const char *file, unsigned int line,
|
||||
/* Freed pointer is being reused: */
|
||||
if (mem_exists->id != 0)
|
||||
_xalloc_fatal("XALLOC: Internal error: Assertion (mem_exists->id == 0) in %s:%u failed!\n",
|
||||
__FILE__, __LINE__);
|
||||
__FILE__, __LINE__);
|
||||
RB_REMOVE(memory_tree, &memory_tree_head, mem_exists);
|
||||
_memory_free(&mem_exists);
|
||||
RB_INSERT(memory_tree, &memory_tree_head, mem);
|
||||
|
Loading…
Reference in New Issue
Block a user