admin.h 2.56 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

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

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

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

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

45
void admin_handle_request(client_t *client, const char *uri);
46

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

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

56
xmlNodePtr admin_add_role_to_authentication(auth_t *auth, xmlNodePtr parent);
57

58 59
admin_command_id_t admin_get_command(const char *command);
int admin_get_command_type(admin_command_id_t command);
60

61 62 63 64 65 66
/* 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);

67
#endif  /* __ADMIN_H__ */