mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -05:00
Feature: List loaded modules in stats XML
This commit is contained in:
parent
3f2246093b
commit
f541cb5c8a
28
src/module.c
28
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 *);
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user