From c6a686560e88f73cc5554c434f6b78822dd4b2d3 Mon Sep 17 00:00:00 2001 From: moritz Date: Wed, 22 Jul 2009 20:19:38 +0000 Subject: [PATCH] Akos Veres suggested that ezstream should be able to set the login username, and I concur. git-svn-id: https://svn.xiph.org/trunk/ezstream@16319 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- NEWS | 3 +++ doc/ezstream.1.in | 9 +++++++++ examples/ezstream_mp3.xml | 5 +++++ examples/ezstream_vorbis.xml | 5 +++++ src/configfile.c | 13 +++++++++++++ src/configfile.h | 1 + src/util.c | 7 +++++++ 7 files changed, 43 insertions(+) diff --git a/NEWS b/NEWS index d165734..29d7322 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ Changes in 0.5.5, released on XXXX-XX-XX: * various: - [MISC] Further improvements and minor fixes in the build system. + - [NEW] New optional configuration option, to change the + username used in authentication with Icecast. Suggested by + Akos Veres. diff --git a/doc/ezstream.1.in b/doc/ezstream.1.in index 9b469f1..5625704 100644 --- a/doc/ezstream.1.in +++ b/doc/ezstream.1.in @@ -130,6 +130,15 @@ The content must be of the form For example: .Pp .Dl \&http://example.com:8000/stream.ogg\& +.It Sy \& +.Pq Optional. +Sets the source username for authentication with the Icecast server. +The default user +.Po +usually +.Dq Li source +.Pc +is used if this element is not provided. .It Sy \& .Pq Mandatory. Sets the source password for authentication with the Icecast server. diff --git a/examples/ezstream_mp3.xml b/examples/ezstream_mp3.xml index 681ae15..2308512 100644 --- a/examples/ezstream_mp3.xml +++ b/examples/ezstream_mp3.xml @@ -8,6 +8,11 @@ --> http://localhost:8000/stream + + hackme MP3 playlist.m3u diff --git a/examples/ezstream_vorbis.xml b/examples/ezstream_vorbis.xml index 35c3a2b..70d6ffe 100644 --- a/examples/ezstream_vorbis.xml +++ b/examples/ezstream_vorbis.xml @@ -8,6 +8,11 @@ --> http://localhost:8000/vorbis.ogg + + hackme VORBIS playlist.m3u diff --git a/src/configfile.c b/src/configfile.c index ec3f86c..6072fc9 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -128,6 +128,19 @@ parseConfig(const char *fileName) xmlFree(ls_xmlContentPtr); } } + if (!xmlStrcmp(cur->name, (const xmlChar *)"sourceuser")) { + if (ezConfig.username != NULL) { + printf("%s[%ld]: Error: Cannot have multiple elements\n", + fileName, xmlGetLineNo(cur)); + config_error++; + continue; + } + if (cur->xmlChildrenNode != NULL) { + ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + ezConfig.username = xstrdup(ls_xmlContentPtr); + xmlFree(ls_xmlContentPtr); + } + } if (!xmlStrcmp(cur->name, (const xmlChar *)"sourcepassword")) { if (ezConfig.password != NULL) { printf("%s[%ld]: Error: Cannot have multiple elements\n", diff --git a/src/configfile.h b/src/configfile.h index c1cfb2e..a2d5649 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -44,6 +44,7 @@ typedef struct tag_FORMAT_ENCDEC { typedef struct tag_EZCONFIG { char *URL; + char *username; char *password; char *format; char *fileName; diff --git a/src/util.c b/src/util.c index dec3c3d..da3b8b2 100644 --- a/src/util.c +++ b/src/util.c @@ -151,6 +151,13 @@ stream_setup(const char *host, unsigned short port, const char *mount) return (NULL); } + if (pezConfig->username && + shout_set_user(shout, pezConfig->username) != SHOUTERR_SUCCESS) { + printf("%s: shout_set_user(): %s\n", + __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",