/* Icecast * * This program is distributed under the GNU General Public License, version 2. * A copy of this license is included with this source. * * Copyright 2018-2020, Philipp "ph3-der-loewe" Schafft , */ /** * This file contains helper functions for report XML document parsing, manipulation, and rendering. */ #ifdef HAVE_CONFIG_H #include #endif #include #include "reportxml_helper.h" #include "logging.h" #define CATMODULE "reportxml-helper" void reportxml_helper_add_value(reportxml_node_t *parent, const char *type, const char *member, const char *str) { reportxml_node_t *value = reportxml_node_new(REPORTXML_NODE_TYPE_VALUE, NULL, NULL, NULL); reportxml_node_set_attribute(value, "type", type); if (member) reportxml_node_set_attribute(value, "member", member); reportxml_node_set_attribute(value, "value", str); reportxml_node_add_child(parent, value); refobject_unref(value); } void reportxml_helper_add_value_int(reportxml_node_t *parent, const char *member, long long int val) { char buf[80]; snprintf(buf, sizeof(buf), "%lli", val); reportxml_helper_add_value(parent, "int", member, buf); } void reportxml_helper_add_text(reportxml_node_t *parent, const char *definition, const char *text) { reportxml_node_t *textnode = reportxml_node_new(REPORTXML_NODE_TYPE_TEXT, NULL, definition, NULL); reportxml_node_set_content(textnode, text); reportxml_node_add_child(parent, textnode); refobject_unref(textnode); } void reportxml_helper_add_reference(reportxml_node_t *parent, const char *type, const char *href) { reportxml_node_t *referenenode = reportxml_node_new(REPORTXML_NODE_TYPE_REFERENCE, NULL, NULL, NULL); reportxml_node_set_attribute(referenenode, "type", type); reportxml_node_set_attribute(referenenode, "href", href); reportxml_node_add_child(parent, referenenode); refobject_unref(referenenode); }