2007-02-24 17:25:28 -05:00
|
|
|
/*
|
|
|
|
* ezstream - source client for Icecast with external en-/decoder support
|
|
|
|
* Copyright (C) 2003, 2004, 2005, 2006 Ed Zaleski <oddsock@oddsock.org>
|
2007-07-13 21:32:28 -04:00
|
|
|
* Copyright (C) 2007 Moritz Grimm <mdgrimm@gmx.net>
|
2007-02-24 17:25:28 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-03-04 10:16:36 -05:00
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
2007-02-24 17:25:28 -05:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
2004-01-30 12:19:45 -05:00
|
|
|
#include <string.h>
|
2007-02-24 17:25:28 -05:00
|
|
|
|
2007-03-07 16:01:16 -05:00
|
|
|
#include "compat.h"
|
2004-01-30 12:19:45 -05:00
|
|
|
#include "configfile.h"
|
2007-03-02 07:52:10 -05:00
|
|
|
#include "strfctns.h"
|
2007-02-24 17:25:28 -05:00
|
|
|
#include "util.h"
|
|
|
|
|
2007-03-02 07:52:10 -05:00
|
|
|
extern char *__progname;
|
|
|
|
|
Various cleanups and auto-fu tweaks.
* Make Makefile.am files look alike as much as possible.
* Remove debug: target and don't mess with the users DEBUG environment
variable: Autoconf checks for -g and automatically adds it to CFLAGS, which
is overridden by the user's $DEBUG. If the user didn't specify one, "make
install" will strip the resulting binaries and leave the debugging symbols
intact otherwise.
* Remove profile: target, as it is quite pointless in Ezstream. Also, the user
can add profiling flags via the $DEBUG variable as well.
* Remove -ffast-math and -fsigned-char from gcc, and enable two additional
warnings instead.
* Unconfuse Solaris compiler flags (unfortunately, the configure script still
fails in the libshout check with some obscure linker error): Do not force
-x04 and -fast optimizations, let the user decide (it doesn't matter for
Ezstream anyways.) Remove -xgc92, which is deprecated and actually makes
the resulting binary run slower on SPARC. Also remove -fsimple, which does
not help and has the potential of causing trouble, and don't enable verbose
warnings just to disable them afterwards with -w. Leave only -v for verbose
warnings.
* Const'ify getFormat*() functions and blankString, and squelch a few const-
related warnings.
* Squelch a signedness warning and fix two ;; syntax errors.
* Add a snapshot target to Makefile.am that creates a tarball of the form
ezstream-snapshot-YYYYMMDD.tar.gz.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12562 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-25 09:00:15 -05:00
|
|
|
static EZCONFIG ezConfig;
|
|
|
|
static const char *blankString = "";
|
2004-01-30 12:19:45 -05:00
|
|
|
|
2007-03-09 21:27:48 -05:00
|
|
|
void freeConfig(EZCONFIG *);
|
|
|
|
unsigned int checkDecoderLine(const char *, const char *, long);
|
|
|
|
unsigned int checkEncoderLine(const char *, const char *, long);
|
2007-03-10 14:03:07 -05:00
|
|
|
unsigned int checkFormatLine(const char *, const char *, long);
|
2007-02-24 18:05:51 -05:00
|
|
|
|
2007-02-24 17:25:28 -05:00
|
|
|
EZCONFIG *
|
|
|
|
getEZConfig(void)
|
|
|
|
{
|
|
|
|
return (&ezConfig);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
Various cleanups and auto-fu tweaks.
* Make Makefile.am files look alike as much as possible.
* Remove debug: target and don't mess with the users DEBUG environment
variable: Autoconf checks for -g and automatically adds it to CFLAGS, which
is overridden by the user's $DEBUG. If the user didn't specify one, "make
install" will strip the resulting binaries and leave the debugging symbols
intact otherwise.
* Remove profile: target, as it is quite pointless in Ezstream. Also, the user
can add profiling flags via the $DEBUG variable as well.
* Remove -ffast-math and -fsigned-char from gcc, and enable two additional
warnings instead.
* Unconfuse Solaris compiler flags (unfortunately, the configure script still
fails in the libshout check with some obscure linker error): Do not force
-x04 and -fast optimizations, let the user decide (it doesn't matter for
Ezstream anyways.) Remove -xgc92, which is deprecated and actually makes
the resulting binary run slower on SPARC. Also remove -fsimple, which does
not help and has the potential of causing trouble, and don't enable verbose
warnings just to disable them afterwards with -w. Leave only -v for verbose
warnings.
* Const'ify getFormat*() functions and blankString, and squelch a few const-
related warnings.
* Squelch a signedness warning and fix two ;; syntax errors.
* Add a snapshot target to Makefile.am that creates a tarball of the form
ezstream-snapshot-YYYYMMDD.tar.gz.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12562 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-25 09:00:15 -05:00
|
|
|
const char *
|
2007-02-24 17:56:18 -05:00
|
|
|
getFormatEncoder(const char *format)
|
2004-07-18 23:12:31 -04:00
|
|
|
{
|
2007-02-24 17:56:18 -05:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ezConfig.numEncoderDecoders; i++) {
|
|
|
|
if (ezConfig.encoderDecoders[i] != NULL &&
|
|
|
|
ezConfig.encoderDecoders[i]->format != NULL &&
|
|
|
|
strcmp(ezConfig.encoderDecoders[i]->format, format) == 0) {
|
|
|
|
if (ezConfig.encoderDecoders[i]->encoder != NULL)
|
|
|
|
return (ezConfig.encoderDecoders[i]->encoder);
|
|
|
|
else
|
|
|
|
return (blankString);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 17:56:18 -05:00
|
|
|
|
|
|
|
return (blankString);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
|
Various cleanups and auto-fu tweaks.
* Make Makefile.am files look alike as much as possible.
* Remove debug: target and don't mess with the users DEBUG environment
variable: Autoconf checks for -g and automatically adds it to CFLAGS, which
is overridden by the user's $DEBUG. If the user didn't specify one, "make
install" will strip the resulting binaries and leave the debugging symbols
intact otherwise.
* Remove profile: target, as it is quite pointless in Ezstream. Also, the user
can add profiling flags via the $DEBUG variable as well.
* Remove -ffast-math and -fsigned-char from gcc, and enable two additional
warnings instead.
* Unconfuse Solaris compiler flags (unfortunately, the configure script still
fails in the libshout check with some obscure linker error): Do not force
-x04 and -fast optimizations, let the user decide (it doesn't matter for
Ezstream anyways.) Remove -xgc92, which is deprecated and actually makes
the resulting binary run slower on SPARC. Also remove -fsimple, which does
not help and has the potential of causing trouble, and don't enable verbose
warnings just to disable them afterwards with -w. Leave only -v for verbose
warnings.
* Const'ify getFormat*() functions and blankString, and squelch a few const-
related warnings.
* Squelch a signedness warning and fix two ;; syntax errors.
* Add a snapshot target to Makefile.am that creates a tarball of the form
ezstream-snapshot-YYYYMMDD.tar.gz.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12562 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-25 09:00:15 -05:00
|
|
|
const char *
|
2007-02-24 17:56:18 -05:00
|
|
|
getFormatDecoder(const char *match)
|
2004-07-18 23:12:31 -04:00
|
|
|
{
|
2007-02-24 17:56:18 -05:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ezConfig.numEncoderDecoders; i++) {
|
|
|
|
if (ezConfig.encoderDecoders[i] != NULL &&
|
|
|
|
ezConfig.encoderDecoders[i]->match != NULL &&
|
|
|
|
strcmp(ezConfig.encoderDecoders[i]->match, match) == 0) {
|
|
|
|
if (ezConfig.encoderDecoders[i]->decoder != NULL)
|
|
|
|
return (ezConfig.encoderDecoders[i]->decoder);
|
|
|
|
else
|
|
|
|
return (blankString);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 17:56:18 -05:00
|
|
|
|
|
|
|
return (blankString);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
|
2007-02-24 18:26:16 -05:00
|
|
|
int
|
|
|
|
parseConfig(const char *fileName)
|
2004-01-30 12:19:45 -05:00
|
|
|
{
|
2007-02-24 18:26:16 -05:00
|
|
|
xmlDocPtr doc;
|
|
|
|
xmlNodePtr cur;
|
|
|
|
char *ls_xmlContentPtr;
|
2007-03-01 19:57:11 -05:00
|
|
|
int program_set, reconnect_set, shuffle_set,
|
|
|
|
streamOnce_set, svrinfopublic_set;
|
2007-03-02 07:52:10 -05:00
|
|
|
unsigned int config_error;
|
2007-02-24 18:26:16 -05:00
|
|
|
|
|
|
|
xmlLineNumbersDefault(1);
|
|
|
|
if ((doc = xmlParseFile(fileName)) == NULL) {
|
|
|
|
printf("%s: Parse error (not well-formed XML.)\n", fileName);
|
|
|
|
return (0);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
cur = xmlDocGetRootElement(doc);
|
|
|
|
|
|
|
|
if (cur == NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
printf("%s: Parse error (empty XML document.)\n", fileName);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFreeDoc(doc);
|
2007-02-24 18:26:16 -05:00
|
|
|
return (0);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&ezConfig, '\000', sizeof(ezConfig));
|
|
|
|
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error = 0;
|
2007-02-28 16:48:01 -05:00
|
|
|
program_set = 0;
|
2007-03-01 19:57:11 -05:00
|
|
|
reconnect_set = 0;
|
2007-02-24 18:26:16 -05:00
|
|
|
shuffle_set = 0;
|
2007-02-28 16:48:01 -05:00
|
|
|
streamOnce_set = 0;
|
2007-02-24 18:26:16 -05:00
|
|
|
svrinfopublic_set = 0;
|
2007-03-04 10:59:06 -05:00
|
|
|
for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "url")) {
|
|
|
|
if (ezConfig.URL != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <url> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.URL = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "sourcepassword")) {
|
|
|
|
if (ezConfig.password != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <sourcepassword> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.password = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "format")) {
|
|
|
|
if (ezConfig.format != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.format = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-02-24 18:26:16 -05:00
|
|
|
for (p = ezConfig.format; *p != '\0'; p++)
|
|
|
|
*p = toupper((int)*p);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "filename")) {
|
|
|
|
if (ezConfig.fileName != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <filename> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
if (strlen(ls_xmlContentPtr) > PATH_MAX - 1) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Path or filename in <filename> is too long\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
ezConfig.fileName = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-03-08 21:30:29 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "metadata_progname")) {
|
|
|
|
if (ezConfig.metadataProgram != NULL) {
|
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <metadata_progname> elements\n",
|
|
|
|
fileName, xmlGetLineNo(cur));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
|
|
|
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));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ezConfig.metadataProgram = xstrdup(ls_xmlContentPtr);
|
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-03-10 14:03:07 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "metadata_format")) {
|
|
|
|
if (ezConfig.metadataFormat != NULL) {
|
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <metadata_format> elements\n",
|
|
|
|
fileName, xmlGetLineNo(cur));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
|
|
|
unsigned int ret;
|
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.metadataFormat = xstrdup(ls_xmlContentPtr);
|
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
if ((ret = checkFormatLine(ezConfig.metadataFormat,
|
|
|
|
fileName, xmlGetLineNo(cur)))
|
|
|
|
> 0) {
|
|
|
|
config_error += ret;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-02-28 16:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "playlist_program")) {
|
|
|
|
if (program_set) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <playlist_program> elements\n",
|
2007-02-28 16:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-28 16:26:16 -05:00
|
|
|
}
|
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
const char *errstr;
|
2007-02-28 16:26:16 -05:00
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
2007-03-03 15:17:33 -05:00
|
|
|
ezConfig.fileNameIsProgram = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
|
2007-03-02 07:52:10 -05:00
|
|
|
if (errstr) {
|
|
|
|
printf("%s[%ld]: Error: <playlist_program> may only contain 1 or 0\n",
|
|
|
|
fileName, xmlGetLineNo(cur));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
2007-02-28 16:26:16 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
program_set = 1;
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "shuffle")) {
|
|
|
|
if (shuffle_set) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <shuffle> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
const char *errstr;
|
2007-02-24 18:26:16 -05:00
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
2007-03-03 15:17:33 -05:00
|
|
|
ezConfig.shuffle = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
|
2007-03-02 07:52:10 -05:00
|
|
|
if (errstr) {
|
|
|
|
printf("%s[%ld]: Error: <shuffle> may only contain 1 or 0\n",
|
|
|
|
fileName, xmlGetLineNo(cur));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-02-24 18:26:16 -05:00
|
|
|
shuffle_set = 1;
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
2007-02-28 16:48:01 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "stream_once")) {
|
|
|
|
if (streamOnce_set) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <stream_once> elements\n",
|
2007-02-28 16:48:01 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-28 16:48:01 -05:00
|
|
|
}
|
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
const char *errstr;
|
2007-02-28 16:48:01 -05:00
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
2007-03-03 15:17:33 -05:00
|
|
|
ezConfig.streamOnce = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
|
2007-03-02 07:52:10 -05:00
|
|
|
if (errstr) {
|
|
|
|
printf("%s[%ld]: Error: <stream_once> may only contain 1 or 0\n",
|
|
|
|
fileName, xmlGetLineNo(cur));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
2007-02-28 16:48:01 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
streamOnce_set = 1;
|
|
|
|
}
|
|
|
|
}
|
2007-03-01 19:57:11 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "reconnect_tries")) {
|
|
|
|
if (reconnect_set) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <reconnect_tries> elements\n",
|
2007-03-01 19:57:11 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-03-01 19:57:11 -05:00
|
|
|
}
|
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
const char *errstr;
|
|
|
|
|
2007-03-01 19:57:11 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
2007-03-03 15:17:33 -05:00
|
|
|
ezConfig.reconnectAttempts = (unsigned int)strtonum(ls_xmlContentPtr, 0, UINT_MAX, &errstr);
|
2007-03-02 07:52:10 -05:00
|
|
|
if (errstr) {
|
|
|
|
printf("%s[%ld]: Error: In <reconnect_tries>: '%s' is %s\n",
|
|
|
|
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
2007-03-01 19:57:11 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
reconnect_set = 1;
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfoname")) {
|
|
|
|
if (ezConfig.serverName != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfoname> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverName = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfourl")) {
|
|
|
|
if (ezConfig.serverURL != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfourl> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverURL = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfogenre")) {
|
|
|
|
if (ezConfig.serverGenre != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfogenre> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverGenre = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfodescription")) {
|
|
|
|
if (ezConfig.serverDescription != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfodescription> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverDescription = xstrdup(ls_xmlContentPtr);
|
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfobitrate")) {
|
|
|
|
if (ezConfig.serverBitrate != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfobitrate> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverBitrate = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfochannels")) {
|
|
|
|
if (ezConfig.serverChannels != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfochannels> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverChannels = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfosamplerate")) {
|
|
|
|
if (ezConfig.serverSamplerate != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfosamplerate> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverSamplerate = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfoquality")) {
|
|
|
|
if (ezConfig.serverQuality != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfoquality> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
|
|
|
ezConfig.serverQuality = xstrdup(ls_xmlContentPtr);
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfopublic")) {
|
|
|
|
if (svrinfopublic_set) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <svrinfopublic> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
if (cur->xmlChildrenNode != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
const char *errstr;
|
2007-02-24 18:26:16 -05:00
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
|
2007-03-03 15:17:33 -05:00
|
|
|
ezConfig.serverPublic = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
|
2007-03-02 07:52:10 -05:00
|
|
|
if (errstr) {
|
|
|
|
printf("%s[%ld]: Error: <svrinfopublic> may only contain 1 or 0\n",
|
|
|
|
fileName, xmlGetLineNo(cur));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-02-24 18:26:16 -05:00
|
|
|
svrinfopublic_set = 1;
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur->name, BAD_CAST "reencode")) {
|
|
|
|
xmlNodePtr cur2;
|
|
|
|
int enable_set;
|
|
|
|
|
|
|
|
enable_set = 0;
|
2007-03-04 10:59:06 -05:00
|
|
|
for (cur2 = cur->xmlChildrenNode; cur2 != NULL;
|
|
|
|
cur2 = cur2->next) {
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur2->name, BAD_CAST "enable")) {
|
|
|
|
if (enable_set) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <enable> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
if (cur2->xmlChildrenNode != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
const char *errstr;
|
2007-02-24 18:26:16 -05:00
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
|
2007-03-03 15:17:33 -05:00
|
|
|
ezConfig.reencode = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
|
2007-03-02 07:52:10 -05:00
|
|
|
if (errstr) {
|
|
|
|
printf("%s[%ld]: Error: <enable> may only contain 1 or 0\n",
|
|
|
|
fileName, xmlGetLineNo(cur));
|
|
|
|
config_error++;
|
|
|
|
continue;
|
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-02-24 18:26:16 -05:00
|
|
|
enable_set = 1;
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur2->name, BAD_CAST "encdec")) {
|
|
|
|
xmlNodePtr cur3;
|
|
|
|
FORMAT_ENCDEC *pformatEncDec;
|
|
|
|
|
|
|
|
pformatEncDec = xcalloc(1, sizeof(FORMAT_ENCDEC));
|
|
|
|
|
2007-03-04 10:59:06 -05:00
|
|
|
for (cur3 = cur2->xmlChildrenNode;
|
|
|
|
cur3 != NULL; cur3 = cur3->next) {
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur3->name, BAD_CAST "format")) {
|
|
|
|
if (pformatEncDec->format != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur3));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
if (cur3->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
|
|
|
pformatEncDec->format = xstrdup(ls_xmlContentPtr);
|
2004-07-18 23:12:31 -04:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-02-24 18:26:16 -05:00
|
|
|
for (p = pformatEncDec->format; *p != '\0'; p++)
|
|
|
|
*p = toupper((int)*p);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur3->name, BAD_CAST "match")) {
|
|
|
|
if (pformatEncDec->match != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <match> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur3));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
if (cur3->xmlChildrenNode != NULL) {
|
2007-02-24 18:26:16 -05:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
|
|
|
pformatEncDec->match = xstrdup(ls_xmlContentPtr);
|
2004-07-18 23:12:31 -04:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-02-24 18:26:16 -05:00
|
|
|
for (p = pformatEncDec->match; *p != '\0'; p++)
|
|
|
|
*p = tolower((int)*p);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur3->name, BAD_CAST "decode")) {
|
|
|
|
if (pformatEncDec->decoder != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <decode> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur3));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
if (cur3->xmlChildrenNode != NULL) {
|
2007-03-09 21:27:48 -05:00
|
|
|
unsigned int ret;
|
|
|
|
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
|
|
|
pformatEncDec->decoder = xstrdup(ls_xmlContentPtr);
|
2004-07-18 23:12:31 -04:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-03-09 21:27:48 -05:00
|
|
|
if ((ret = checkDecoderLine(pformatEncDec->decoder,
|
|
|
|
fileName, xmlGetLineNo(cur3)))
|
|
|
|
> 0) {
|
|
|
|
config_error += ret;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
if (!xmlStrcmp(cur3->name, BAD_CAST "encode")) {
|
|
|
|
if (pformatEncDec->encoder != NULL) {
|
2007-03-02 07:52:10 -05:00
|
|
|
printf("%s[%ld]: Error: Cannot have multiple <encode> elements\n",
|
2007-02-24 18:26:16 -05:00
|
|
|
fileName, xmlGetLineNo(cur3));
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error++;
|
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
if (cur3->xmlChildrenNode != NULL) {
|
2007-03-09 21:27:48 -05:00
|
|
|
unsigned int ret;
|
|
|
|
|
2007-02-24 18:26:16 -05:00
|
|
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
|
|
|
pformatEncDec->encoder = xstrdup(ls_xmlContentPtr);
|
2004-07-18 23:12:31 -04:00
|
|
|
xmlFree(ls_xmlContentPtr);
|
2007-03-09 21:27:48 -05:00
|
|
|
if ((ret = checkEncoderLine(pformatEncDec->encoder,
|
|
|
|
fileName, xmlGetLineNo(cur3)))
|
|
|
|
> 0) {
|
|
|
|
config_error += ret;
|
2007-03-02 07:52:10 -05:00
|
|
|
continue;
|
2007-02-24 18:26:16 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ezConfig.encoderDecoders[ezConfig.numEncoderDecoders] = pformatEncDec;
|
|
|
|
ezConfig.numEncoderDecoders++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
2007-02-24 18:26:16 -05:00
|
|
|
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
|
2007-03-02 07:52:10 -05:00
|
|
|
if (config_error == 0)
|
|
|
|
return (1);
|
2007-02-24 18:26:16 -05:00
|
|
|
|
|
|
|
freeConfig(&ezConfig);
|
2007-03-07 07:53:47 -05:00
|
|
|
printf("%s: %u configuration error(s) in %s\n", __progname,
|
2007-03-02 07:52:10 -05:00
|
|
|
config_error, fileName);
|
|
|
|
|
2007-02-24 18:26:16 -05:00
|
|
|
return (0);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
2007-03-09 21:27:48 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
freeConfig(EZCONFIG *cfg)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (cfg == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cfg->URL != NULL)
|
|
|
|
xfree(cfg->URL);
|
|
|
|
if (cfg->password != NULL)
|
|
|
|
xfree(cfg->password);
|
|
|
|
if (cfg->format != NULL)
|
|
|
|
xfree(cfg->format);
|
|
|
|
if (cfg->fileName != NULL)
|
|
|
|
xfree(cfg->fileName);
|
|
|
|
if (cfg->metadataProgram != NULL)
|
|
|
|
xfree(cfg->metadataProgram);
|
2007-03-10 14:03:07 -05:00
|
|
|
if (cfg->metadataFormat != NULL)
|
|
|
|
xfree(cfg->metadataFormat);
|
2007-03-09 21:27:48 -05:00
|
|
|
if (cfg->serverName != NULL)
|
|
|
|
xfree(cfg->serverName);
|
|
|
|
if (cfg->serverURL != NULL)
|
|
|
|
xfree(cfg->serverURL);
|
|
|
|
if (cfg->serverGenre != NULL)
|
|
|
|
xfree(cfg->serverGenre);
|
|
|
|
if (cfg->serverDescription != NULL)
|
|
|
|
xfree(cfg->serverDescription);
|
|
|
|
if (cfg->serverBitrate != NULL)
|
|
|
|
xfree(cfg->serverBitrate);
|
|
|
|
if (cfg->serverChannels != NULL)
|
|
|
|
xfree(cfg->serverChannels);
|
|
|
|
if (cfg->serverSamplerate != NULL)
|
|
|
|
xfree(cfg->serverSamplerate);
|
|
|
|
if (cfg->serverQuality != NULL)
|
|
|
|
xfree(cfg->serverQuality);
|
|
|
|
if (cfg->encoderDecoders != NULL) {
|
|
|
|
for (i = 0; i < MAX_FORMAT_ENCDEC; i++) {
|
|
|
|
if (cfg->encoderDecoders[i] != NULL) {
|
|
|
|
if (cfg->encoderDecoders[i]->format != NULL)
|
|
|
|
xfree(cfg->encoderDecoders[i]->format);
|
|
|
|
if (cfg->encoderDecoders[i]->match != NULL)
|
|
|
|
xfree(cfg->encoderDecoders[i]->match);
|
|
|
|
if (cfg->encoderDecoders[i]->encoder != NULL)
|
|
|
|
xfree(cfg->encoderDecoders[i]->encoder);
|
|
|
|
if (cfg->encoderDecoders[i]->decoder != NULL)
|
|
|
|
xfree(cfg->encoderDecoders[i]->decoder);
|
|
|
|
xfree(cfg->encoderDecoders[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(cfg, 0, sizeof(EZCONFIG));
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
checkDecoderLine(const char *str, const char *file, long line)
|
|
|
|
{
|
|
|
|
unsigned int errors;
|
|
|
|
char *p;
|
2007-03-10 14:03:07 -05:00
|
|
|
int have_track = 0;
|
2007-03-09 21:27:48 -05:00
|
|
|
|
|
|
|
errors = 0;
|
2007-03-10 14:03:07 -05:00
|
|
|
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
|
|
|
printf("%s[%ld]: Error: `%s' placeholder not allowed in decoder command\n",
|
|
|
|
file, line, STRING_PLACEHOLDER);
|
|
|
|
errors++;
|
|
|
|
}
|
2007-03-09 21:27:48 -05:00
|
|
|
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);
|
|
|
|
errors++;
|
2007-03-10 14:03:07 -05:00
|
|
|
} else
|
|
|
|
have_track = 1;
|
2007-03-09 21:27:48 -05:00
|
|
|
}
|
|
|
|
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 decoder command\n",
|
|
|
|
file, line, METADATA_PLACEHOLDER);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-10 14:03:07 -05:00
|
|
|
if (!have_track) {
|
|
|
|
printf("%s[%ld]: Error: The decoder command requires the '%s' track placeholder\n",
|
|
|
|
file, line, TRACK_PLACEHOLDER);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
|
2007-03-09 21:27:48 -05:00
|
|
|
return (errors);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
checkEncoderLine(const char *str, const char *file, long line)
|
|
|
|
{
|
|
|
|
unsigned int errors;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
2007-03-10 14:03:07 -05:00
|
|
|
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
|
|
|
printf("%s[%ld]: Error: `%s' placeholder not allowed in encoder command\n",
|
|
|
|
file, line, STRING_PLACEHOLDER);
|
|
|
|
errors++;
|
|
|
|
}
|
2007-03-09 21:27:48 -05:00
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (errors);
|
|
|
|
}
|
2007-03-10 14:03:07 -05:00
|
|
|
|
|
|
|
unsigned int
|
|
|
|
checkFormatLine(const char *str, const char *file, long line)
|
|
|
|
{
|
|
|
|
unsigned int errors;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((p = strstr(str, STRING_PLACEHOLDER)) != NULL) {
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((p = strstr(str, ARTIST_PLACEHOLDER)) != NULL) {
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((p = strstr(str, TITLE_PLACEHOLDER)) != NULL) {
|
|
|
|
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);
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (errors);
|
|
|
|
}
|