# HG changeset patch # User nenolod # Date 1155285122 25200 # Node ID 56e1da886c9f8e7a29f03597b78cc7a5c41da399 # Parent a548346f15514123102852bb30f0b033798ed016 [svn] - remove unnecessary and crappy code diff -r a548346f1551 -r 56e1da886c9f ChangeLog --- 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 + revision [2058] + - further cleanup + + + Changes: Modified: + +1 -1 trunk/Plugins/Container/xspf/xspf.c + + 2006-08-11 08:17:05 +0000 William Pitcock revision [2056] - if uri == NULL, then continue looking for URIs in the XSPF playlist diff -r a548346f1551 -r 56e1da886c9f Plugins/Container/xspf/xspf.c --- 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 #include -/* 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;