module.h 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/* 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,      Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
 */

#ifndef __MODULE_H__
#define __MODULE_H__

12 13
#include <libxml/tree.h>

14
#include "icecasttypes.h"
15
#include "refobject.h"
16

17
typedef void (*module_client_handler_function_t)(module_t *self, client_t *client);
18 19 20 21 22 23 24
typedef int  (*module_setup_handler_t)(module_t *self, void **userdata);

typedef struct {
    const char *name;
    module_client_handler_function_t cb;
} module_client_handler_t;

25 26 27
REFOBJECT_FORWARD_TYPE(module_container_t);
REFOBJECT_FORWARD_TYPE(module_t);

28 29 30
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);
31
xmlNodePtr                      module_container_get_modulelist_as_xml(module_container_t *self);
32 33 34

module_t *                      module_new(const char *name, module_setup_handler_t newcb, module_setup_handler_t freecb, void *userdata);

35 36
int                             module_add_link(module_t *self, const char *type, const char *url, const char *title);

37 38 39 40 41
/* Note: Those functions are not really thread safe as (module_client_handler_t) is not thread safe. This is by design. */
const module_client_handler_t * module_get_client_handler(module_t *self, const char *name);
int                             module_add_client_handler(module_t *self, const module_client_handler_t *handlers, size_t len);

#endif