Commit f541cb5c authored by Philipp Schafft's avatar Philipp Schafft 🦁

Feature: List loaded modules in stats XML

parent 3f224609
......@@ -18,6 +18,7 @@
#include "refobject.h"
#include "module.h"
#include "cfgfile.h" /* for XMLSTR() */
struct module_tag {
refobject_base_t __base;
......@@ -118,6 +119,33 @@ module_t * module_container_get_module(module_container_t *self, co
return ret;
}
xmlNodePtr module_container_get_modulelist_as_xml(module_container_t *self)
{
xmlNodePtr root;
avl_node *avlnode;
if (!self)
return NULL;
root = xmlNewNode(NULL, XMLSTR("modules"));
if (!root)
return NULL;
thread_mutex_lock(&(self->lock));
avlnode = avl_get_first(self->module);
while (avlnode) {
module_t *module = avlnode->key;
xmlNodePtr node = xmlNewChild(root, NULL, XMLSTR("module"), NULL);
xmlSetProp(node, XMLSTR("name"), XMLSTR(refobject_get_name(module)));
avlnode = avl_get_next(avlnode);
}
thread_mutex_unlock(&(self->lock));
return root;
}
static void __module_free(refobject_t self, void **userdata)
{
module_t *mod = REFOBJECT_TO_TYPE(self, module_t *);
......
......@@ -9,6 +9,8 @@
#ifndef __MODULE_H__
#define __MODULE_H__
#include <libxml/tree.h>
#include "icecasttypes.h"
typedef void (*module_client_handler_function_t)(module_t *self, client_t *client, const char *uri);
......@@ -23,6 +25,7 @@ module_container_t * module_container_new(void);
int module_container_add_module(module_container_t *self, module_t *module);
int module_container_delete_module(module_container_t *self, const char *name);
module_t * module_container_get_module(module_container_t *self, const char *name);
xmlNodePtr module_container_get_modulelist_as_xml(module_container_t *self);
module_t * module_new(const char *name, module_setup_handler_t newcb, module_setup_handler_t freecb, void *userdata);
......
......@@ -1063,12 +1063,16 @@ xmlDocPtr stats_get_xml(int show_hidden, const char *show_mount, client_t *clien
{
xmlDocPtr doc;
xmlNodePtr node;
xmlNodePtr modules;
source_t * source;
doc = xmlNewDoc (XMLSTR("1.0"));
node = xmlNewDocNode (doc, NULL, XMLSTR("icestats"), NULL);
xmlDocSetRootElement(doc, node);
modules = module_container_get_modulelist_as_xml(global.modulecontainer);
xmlAddChild(node, modules);
node = _dump_stats_to_doc(node, show_mount, show_hidden, client);
if (show_mount && node) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment