mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: New config block to define YP directories
Adds a new config block, <yp-directory> with the mandatory "url" attribute and optional <option> entries in the block: <yp-directory url="http://example.org/yp-cgi"> <option name="timeout" value="5" /> <option name="touch-interval" value="45" /> </yp-directory>
This commit is contained in:
parent
6d3bf28be1
commit
632f67b0c8
@ -161,6 +161,7 @@ static void _set_defaults(ice_config_t *c);
|
|||||||
static void _parse_root(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
static void _parse_root(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
||||||
static void _parse_limits(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
static void _parse_limits(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
||||||
static void _parse_oldstyle_directory(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
static void _parse_oldstyle_directory(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
||||||
|
static void _parse_yp_directory(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
||||||
static void _parse_paths(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
static void _parse_paths(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
||||||
static void _parse_logging(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
static void _parse_logging(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
||||||
static void _parse_security(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
static void _parse_security(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
|
||||||
@ -1088,6 +1089,8 @@ static void _parse_root(xmlDocPtr doc,
|
|||||||
_parse_mount(doc, node, configuration);
|
_parse_mount(doc, node, configuration);
|
||||||
} else if (xmlStrcmp(node->name, XMLSTR("directory")) == 0) {
|
} else if (xmlStrcmp(node->name, XMLSTR("directory")) == 0) {
|
||||||
_parse_oldstyle_directory(doc, node->xmlChildrenNode, configuration);
|
_parse_oldstyle_directory(doc, node->xmlChildrenNode, configuration);
|
||||||
|
} else if (xmlStrcmp(node->name, XMLSTR("yp-directory")) == 0) {
|
||||||
|
_parse_yp_directory(doc, node, configuration);
|
||||||
} else if (xmlStrcmp(node->name, XMLSTR("paths")) == 0) {
|
} else if (xmlStrcmp(node->name, XMLSTR("paths")) == 0) {
|
||||||
_parse_paths(doc, node->xmlChildrenNode, configuration);
|
_parse_paths(doc, node->xmlChildrenNode, configuration);
|
||||||
} else if (xmlStrcmp(node->name, XMLSTR("logging")) == 0) {
|
} else if (xmlStrcmp(node->name, XMLSTR("logging")) == 0) {
|
||||||
@ -2088,6 +2091,55 @@ static void _parse_oldstyle_directory(xmlDocPtr doc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _parse_yp_directory(xmlDocPtr doc,
|
||||||
|
xmlNodePtr node,
|
||||||
|
ice_config_t *configuration)
|
||||||
|
{
|
||||||
|
char *url;
|
||||||
|
config_options_t *options;
|
||||||
|
yp_directory_t *yp_dir,
|
||||||
|
*current, *last;
|
||||||
|
|
||||||
|
url = (char *)xmlGetProp(node, XMLSTR("url"));
|
||||||
|
if (url == NULL) {
|
||||||
|
ICECAST_LOG_ERROR("Missing mandatory attribute 'url' for <yp-directory>.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
yp_dir = calloc(1, sizeof(*yp_dir));
|
||||||
|
if (yp_dir == NULL) {
|
||||||
|
ICECAST_LOG_ERROR("Can not allocate memory for YP directory entry.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
yp_dir->url = url;
|
||||||
|
|
||||||
|
options = config_parse_options(node);
|
||||||
|
for (config_options_t *opt = options; opt; opt = opt->next) {
|
||||||
|
if (!opt->name || !opt->value)
|
||||||
|
continue;
|
||||||
|
if (strcmp(opt->name, "timeout") == 0) {
|
||||||
|
yp_dir->timeout = util_str_to_int(opt->value, yp_dir->timeout);
|
||||||
|
} else if (strcmp(opt->name, "touch-interval") == 0) {
|
||||||
|
yp_dir->touch_interval = util_str_to_int(opt->value, yp_dir->touch_interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
config_clear_options(options);
|
||||||
|
|
||||||
|
/* Append YP directory entry to the global list */
|
||||||
|
current = configuration->yp_directories;
|
||||||
|
last = NULL;
|
||||||
|
while (current) {
|
||||||
|
last = current;
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
if (last) {
|
||||||
|
last->next = yp_dir;
|
||||||
|
} else {
|
||||||
|
configuration->yp_directories = yp_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _parse_resource(xmlDocPtr doc,
|
static void _parse_resource(xmlDocPtr doc,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
ice_config_t *configuration)
|
ice_config_t *configuration)
|
||||||
|
Loading…
Reference in New Issue
Block a user