diff --git a/src/module.c b/src/module.c index 07e3d59a..46542748 100644 --- a/src/module.c +++ b/src/module.c @@ -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 *); diff --git a/src/module.h b/src/module.h index 8d2ad781..f0f1ee33 100644 --- a/src/module.h +++ b/src/module.h @@ -9,6 +9,8 @@ #ifndef __MODULE_H__ #define __MODULE_H__ +#include + #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); diff --git a/src/stats.c b/src/stats.c index 0f9d9ce9..73ec6a28 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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) {