From d0efb73a7bf5cf81fd9944b19b08e3a9b13807c4 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Wed, 8 Aug 2018 13:20:07 +0000 Subject: [PATCH] Feature: Also report loaded modules in report XML --- src/admin.h | 2 ++ src/client.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/admin.h b/src/admin.h index 6d4b03c6..1245a194 100644 --- a/src/admin.h +++ b/src/admin.h @@ -21,6 +21,8 @@ #include "compat.h" #include "resourcematch.h" +#define ADMIN_ICESTATS_LEGACY_EXTENSION_APPLICATION "http://icecast.org/specs/legacy-icestats" + /* types */ #define ADMINTYPE_ERROR (-1) #define ADMINTYPE_GENERAL 1 diff --git a/src/client.c b/src/client.c index 65b6301e..41f5ce2d 100644 --- a/src/client.c +++ b/src/client.c @@ -24,6 +24,8 @@ #include #include +#include + #include "common/thread/thread.h" #include "common/avl/avl.h" #include "common/httpp/httpp.h" @@ -51,7 +53,7 @@ #include "listensocket.h" #include "fastevent.h" -/* for ADMIN_COMMAND_ERROR */ +/* for ADMIN_COMMAND_ERROR, and ADMIN_ICESTATS_LEGACY_EXTENSION_APPLICATION */ #include "admin.h" #ifdef _WIN32 @@ -602,6 +604,31 @@ void client_send_reportxml(client_t *client, reportxml_t *report, document_domai xmlFreeDoc(doc); } +static void client_get_reportxml__add_basic_stats(reportxml_t *report) +{ + reportxml_node_t *rootnode, *extension; + xmlNodePtr xmlroot; + xmlNodePtr modules; + + rootnode = reportxml_get_root_node(report); + + extension = reportxml_node_new(REPORTXML_NODE_TYPE_EXTENSION, NULL, NULL, NULL); + reportxml_node_set_attribute(extension, "application", ADMIN_ICESTATS_LEGACY_EXTENSION_APPLICATION); + + reportxml_node_add_child(rootnode, extension); + + refobject_unref(rootnode); + + xmlroot = xmlNewNode(NULL, XMLSTR("icestats")); + modules = module_container_get_modulelist_as_xml(global.modulecontainer); + xmlAddChild(xmlroot, modules); + + + reportxml_node_add_xml_child(extension, xmlroot); + refobject_unref(extension); + xmlFreeNode(xmlroot); +} + reportxml_t *client_get_reportxml(const char *state_definition, const char *state_akindof, const char *state_text) { reportxml_t *report = NULL; @@ -638,6 +665,8 @@ reportxml_t *client_get_reportxml(const char *state_definition, const char *stat refobject_unref(rootnode); } + client_get_reportxml__add_basic_stats(report); + return report; }