1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Feature: Added constants for XML namespaces

This commit is contained in:
Philipp Schafft 2020-10-10 07:44:26 +00:00
parent a8a3207cce
commit cc13aba182
4 changed files with 14 additions and 7 deletions

View File

@ -456,9 +456,9 @@ void admin_send_response(xmlDocPtr doc,
char *json;
if (strcmp((const char *)xmlroot->name, "iceresponse") == 0) {
ns = "http://icecast.org/specs/legacyresponse-0.0.1";
ns = XMLNS_LEGACY_RESPONSE;
} else {
ns = "http://icecast.org/specs/legacystats-0.0.1";
ns = XMLNS_LEGACY_STATS;
}
json = xml2json_render_doc_simple(doc, ns);

View File

@ -15,6 +15,13 @@
#include "compat.h"
/* ---[ * ]--- */
/* XML namespaces */
#define XMLNS_REPORTXML "http://icecast.org/specs/reportxml-0.0.1"
#define XMLNS_XSPF "http://xspf.org/ns/0/"
#define XMLNS_LEGACY_STATS "http://icecast.org/specs/legacystats-0.0.1"
#define XMLNS_LEGACY_RESPONSE "http://icecast.org/specs/legacyresponse-0.0.1"
/* ---[ client.[ch] ]--- */
typedef struct _client_tag client_t;

View File

@ -165,7 +165,7 @@ xmlNodePtr playlist_render_xspf(playlist_t *playlist)
rootnode = xmlNewNode(NULL, XMLSTR("playlist"));
xmlSetProp(rootnode, XMLSTR("version"), XMLSTR("1"));
xmlSetProp(rootnode, XMLSTR("xmlns"), XMLSTR("http://xspf.org/ns/0/"));
xmlSetProp(rootnode, XMLSTR("xmlns"), XMLSTR(XMLNS_XSPF));
tracklist = xmlNewNode(NULL, XMLSTR("trackList"));
xmlAddChild(rootnode, tracklist);

View File

@ -309,7 +309,7 @@ static void render_node_legacystats(json_renderer_t *renderer, xmlDocPtr doc, xm
json_renderer_write_key(renderer, "name", JSON_RENDERER_FLAGS_NONE);
json_renderer_write_string(renderer, "icestats", JSON_RENDERER_FLAGS_NONE);
json_renderer_write_key(renderer, "ns", JSON_RENDERER_FLAGS_NONE);
json_renderer_write_string(renderer, "http://icecast.org/specs/legacystats-0.0.1", JSON_RENDERER_FLAGS_NONE);
json_renderer_write_string(renderer, XMLNS_LEGACY_STATS, JSON_RENDERER_FLAGS_NONE);
json_renderer_end(renderer);
}
json_renderer_begin(renderer, JSON_ELEMENT_TYPE_OBJECT);
@ -634,11 +634,11 @@ static void render_node(json_renderer_t *renderer, xmlDocPtr doc, xmlNodePtr nod
href = (const char *)workaroundProp;
if (href) {
if (strcmp(href, "http://icecast.org/specs/legacyresponse-0.0.1") == 0) {
if (strcmp(href, XMLNS_LEGACY_RESPONSE) == 0) {
render = render_node_legacyresponse;
} else if (strcmp(href, "http://icecast.org/specs/legacystats-0.0.1") == 0) {
} else if (strcmp(href, XMLNS_LEGACY_STATS) == 0) {
render = render_node_legacystats;
} else if (strcmp(href, "http://xspf.org/ns/0/") == 0) {
} else if (strcmp(href, XMLNS_XSPF) == 0) {
render = render_node_xspf;
}
}