changeset 1573:56e1da886c9f trunk

[svn] - remove unnecessary and crappy code
author nenolod
date Fri, 11 Aug 2006 01:32:02 -0700
parents a548346f1551
children a8a2ee855c1c
files ChangeLog Plugins/Container/xspf/xspf.c
diffstat 2 files changed, 23 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Aug 11 01:22:15 2006 -0700
+++ b/ChangeLog	Fri Aug 11 01:32:02 2006 -0700
@@ -1,3 +1,12 @@
+2006-08-11 08:22:15 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [2058]
+  - further cleanup
+  
+
+  Changes:        Modified:
+  +1 -1           trunk/Plugins/Container/xspf/xspf.c  
+
+
 2006-08-11 08:17:05 +0000  William Pitcock <nenolod@nenolod.net>
   revision [2056]
   - if uri == NULL, then continue looking for URIs in the XSPF playlist
--- a/Plugins/Container/xspf/xspf.c	Fri Aug 11 01:22:15 2006 -0700
+++ b/Plugins/Container/xspf/xspf.c	Fri Aug 11 01:32:02 2006 -0700
@@ -43,104 +43,13 @@
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 
-/* Borrowed from BMPx. */
-static int
-register_namespaces (xmlXPathContextPtr xpathCtx, const xmlChar* nsList)
-{
-    xmlChar* nsListDup;
-    xmlChar* prefix;
-    xmlChar* href;
-    xmlChar* next;
-
-    nsListDup = xmlStrdup(nsList);
-    if(nsListDup == NULL)
-    {
-	g_warning (G_STRLOC ": unable to strdup namespaces list");
-	return(-1);
-    }
-
-    next = nsListDup;
-    while (next != NULL)
-    {
-	while((*next) == ' ') next++;
-	if((*next) == '\0') break;
-
-	prefix = next;
-	next = (xmlChar*)xmlStrchr(next, '=');
-
-	if (next == NULL)
-	{
-	    g_warning (G_STRLOC ": invalid namespaces list format");
-  	    xmlFree (nsListDup);
-            return(-1);
-        }
-        *(next++) = '\0';
-
-        href = next;
-        next = (xmlChar*)xmlStrchr(next, ' ');
-        if (next != NULL)
-        {
-            *(next++) = '\0';
-        }
-
-        // do register namespace
-        if(xmlXPathRegisterNs(xpathCtx, prefix, href) != 0)
-        {
-            g_warning (G_STRLOC ": unable to register NS with prefix=\"%s\" and href=\"%s\"", prefix, href);
-            xmlFree(nsListDup);
-            return(-1);
-        }
-    }
-
-    xmlFree(nsListDup);
-    return(0);
-}
-
-/* Also borrowed from BMPx. */
-xmlXPathObjectPtr
-xml_execute_xpath_expression (xmlDocPtr doc,
-                              const xmlChar * xpathExpr,
-                              const xmlChar * nsList)
-{
-    xmlXPathContextPtr xpathCtx;
-    xmlXPathObjectPtr xpathObj;
-
-    /*
-     * Create xpath evaluation context
-     */
-    xpathCtx = xmlXPathNewContext (doc);
-    if (xpathCtx == NULL)
-    {
-        return NULL;
-    }
-
-    if (nsList)
-        register_namespaces (xpathCtx, nsList);
-
-    /*
-     * Evaluate xpath expression
-     */
-    xpathObj = xmlXPathEvalExpression (xpathExpr, xpathCtx);
-    if (xpathObj == NULL)
-    {
-        xmlXPathFreeContext (xpathCtx);
-        return NULL;
-    }
-
-    /*
-     * Cleanup
-     */
-    xmlXPathFreeContext (xpathCtx);
-
-    return xpathObj;
-}
-
 static void
 playlist_load_xspf(const gchar * filename, gint pos)
 {
-	xmlDocPtr	  doc;
-	xmlXPathObjectPtr xpathObj;
-	xmlNodeSetPtr     n;
+	xmlDocPtr	   doc;
+	xmlXPathObjectPtr  xpathObj;
+        xmlXPathContextPtr xpathCtx;
+	xmlNodeSetPtr      n;
 	gint i;
 
 	g_return_if_fail(filename != NULL);
@@ -149,11 +58,20 @@
 	if (doc == NULL)
 		return;
 
+	xpathCtx = xmlXPathNewContext(doc);
+	if (xpathCtx == NULL)
+		return;
+
+	if (xmlXPathRegisterNs(xpathCtx, "xspf", "http://xspf.org/ns/0") != 0)
+		return;
+
 	/* TODO: what about xspf:artist, xspf:title, xspf:length? */
-	xpathObj = xml_execute_xpath_expression(doc, "//xspf:location", "xspf=http://xspf.org/ns/0/");
+	xpathObj = xmlXPathEvalExpression("//xspf:location", xpathCtx);
 	if (xpathObj == NULL)
 		return;
 
+	xmlXPathFreeContext(xpathCtx);
+
 	n = xpathObj->nodesetval;
 	if (n == NULL)
 		return;