[xiph-commits] r18799 - icecast/trunk/icecast/src

ph3-der-loewe at svn.xiph.org ph3-der-loewe at svn.xiph.org
Sat Feb 23 12:55:59 PST 2013


Author: ph3-der-loewe
Date: 2013-02-23 12:55:58 -0800 (Sat, 23 Feb 2013)
New Revision: 18799

Modified:
   icecast/trunk/icecast/src/slave.c
Log:
Allow full URLs to be returned by the master server. close #1878

Modified: icecast/trunk/icecast/src/slave.c
===================================================================
--- icecast/trunk/icecast/src/slave.c	2013-02-23 17:51:16 UTC (rev 18798)
+++ icecast/trunk/icecast/src/slave.c	2013-02-23 20:55:58 UTC (rev 18799)
@@ -39,6 +39,7 @@
 
 #include "compat.h"
 
+#include <libxml/uri.h>
 #include "thread/thread.h"
 #include "avl/avl.h"
 #include "net/sock.h"
@@ -666,18 +667,37 @@
             if (!strlen(buf))
                 continue;
             DEBUG2 ("read %d from master \"%s\"", count++, buf);
+            xmlURIPtr parsed_uri = xmlParseURI(buf);
+            if (parsed_uri == NULL) {
+                DEBUG0("Error while parsing line from master. Ignoring line.");
+                continue;
+            }
             r = calloc (1, sizeof (relay_server));
             if (r)
             {
-                r->server = (char *)xmlCharStrdup (master);
-                r->port = port;
-                r->mount = (char *)xmlCharStrdup (buf);
-                r->localmount = (char *)xmlCharStrdup (buf);
+                if (parsed_uri->server != NULL)
+                {
+                  r->server = strdup(parsed_uri->server);
+                  if (parsed_uri->port == 0)
+                    r->port = 80;
+                  else
+                    r->port = parsed_uri->port;
+                }
+                else
+                {
+                  r->server = (char *)xmlCharStrdup (master);
+                  r->port = port;
+                }
+
+                r->mount = strdup(parsed_uri->path);
+                r->localmount = strdup(parsed_uri->path);
                 r->mp3metadata = 1;
                 r->on_demand = on_demand;
                 r->next = new_relays;
+                DEBUG3 ("Added relay host=\"%s\", port=%d, mount=\"%s\"", r->server, r->port, r->mount);
                 new_relays = r;
             }
+            xmlFreeURI(parsed_uri);
         }
         sock_close (mastersock);
 



More information about the commits mailing list