admin.h 2.66 KB
Newer Older
1 2 3 4 5
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
6
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
7 8 9 10
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
11
 * Copyright 2011-2018, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
12 13
 */

14 15 16
#ifndef __ADMIN_H__
#define __ADMIN_H__

17 18
#include <libxml/parser.h>
#include <libxml/tree.h>
19

20
#include "icecasttypes.h"
21
#include "compat.h"
22
#include "resourcematch.h"
23

24 25
#define ADMIN_ICESTATS_LEGACY_EXTENSION_APPLICATION     "http://icecast.org/specs/legacy-icestats"

Philipp Schafft's avatar
Philipp Schafft committed
26 27 28 29 30 31
/* types */
#define ADMINTYPE_ERROR   (-1)
#define ADMINTYPE_GENERAL   1
#define ADMINTYPE_MOUNT     2
#define ADMINTYPE_HYBRID    (ADMINTYPE_GENERAL|ADMINTYPE_MOUNT)

32
/* special commands */
33 34
#define ADMIN_COMMAND_ERROR ((admin_command_id_t)(-1))
#define ADMIN_COMMAND_ANY   ((admin_command_id_t)0) /* for ACL framework */
35

36
typedef void (*admin_request_function_ptr)(client_t * client, source_t * source, admin_format_t format);
37
typedef void (*admin_request_function_with_parameters_ptr)(client_t * client, source_t * source, admin_format_t format, resourcematch_extract_t *parameters);
38 39 40 41 42 43

typedef struct admin_command_handler {
    const char                         *route;
    const int                           type;
    const int                           format;
    const admin_request_function_ptr    function;
44
    const admin_request_function_with_parameters_ptr function_with_parameters;
45 46
} admin_command_handler_t;

47
void admin_handle_request(client_t *client, const char *uri);
48

49 50 51 52
void admin_send_response(xmlDocPtr       doc,
                         client_t       *client,
                         admin_format_t  response,
                         const char     *xslt_template);
Marvin Scholz's avatar
Marvin Scholz committed
53

54 55 56
void admin_add_listeners_to_mount(source_t       *source,
                                  xmlNodePtr      parent,
                                  operation_mode  mode);
Marvin Scholz's avatar
Marvin Scholz committed
57

58
xmlNodePtr admin_add_role_to_authentication(auth_t *auth, xmlNodePtr parent);
59

60 61
admin_command_id_t admin_get_command(const char *command);
int admin_get_command_type(admin_command_id_t command);
62

63 64 65 66 67 68
/* Register and unregister admin commands below /admin/$prefix/.
 * All parameters must be kept in memory as long as the registration is valid as there will be no copy made.
 */
int admin_command_table_register(const char *prefix, size_t handlers_length, const admin_command_handler_t *handlers);
int admin_command_table_unregister(const char *prefix);

69
#endif  /* __ADMIN_H__ */