static int _parse_mount (xmlNodePtr node, void *arg) { ice_config_t *config = arg; mount_proxy *mount = calloc(1, sizeof(mount_proxy)); struct cfg_tag icecast_tags[] = { { "mount-name", config_get_str, &mount->mountname }, { "source-timeout", config_get_int, &mount->source_timeout }, { "queue-size", config_get_int, &mount->queue_size_limit }, { "burst-size", config_get_int, &mount->burst_size}, { "min-queue-size", config_get_int, &mount->min_queue_size}, { "username", config_get_str, &mount->username }, { "password", config_get_str, &mount->password }, { "dump-file", config_get_str, &mount->dumpfile }, { "intro", config_get_str, &mount->intro_filename }, { "file-seekable", config_get_bool, &mount->file_seekable }, { "fallback-mount", config_get_str, &mount->fallback_mount }, { "fallback-override", config_get_bool, &mount->fallback_override }, { "fallback-when-full", config_get_bool, &mount->fallback_when_full }, { "max-listeners", config_get_int, &mount->max_listeners }, { "max-bandwidth", config_get_bitrate, &mount->max_bandwidth }, { "wait-time", config_get_int, &mount->wait_time }, { "filter-theora", config_get_bool, &mount->filter_theora }, { "limit-rate", config_get_bitrate, &mount->limit_rate }, { "skip-accesslog", config_get_bool, &mount->skip_accesslog }, { "charset", config_get_str, &mount->charset }, { "qblock-size", config_get_int, &mount->queue_block_size }, { "redirect", config_get_str, &mount->redirect }, { "metadata-interval", config_get_int, &mount->mp3_meta_interval }, { "mp3-metadata-interval", config_get_int, &mount->mp3_meta_interval }, { "ogg-passthrough", config_get_bool, &mount->ogg_passthrough }, { "admin_comments_only",config_get_bool, &mount->admin_comments_only }, { "allow-url-ogg-metadata", config_get_bool, &mount->url_ogg_meta }, { "no-mount", config_get_bool, &mount->no_mount }, { "ban-client", config_get_int, &mount->ban_client }, { "so-sndbuf", config_get_int, &mount->so_sndbuf }, { "hidden", config_get_bool, &mount->hidden }, { "authentication", auth_get_authenticator, &mount->auth }, { "on-connect", config_get_str, &mount->on_connect }, { "on-disconnect", config_get_str, &mount->on_disconnect }, { "max-stream-duration", config_get_int, &mount->max_stream_duration }, { "max-listener-duration", config_get_int, &mount->max_listener_duration }, { "accesslog", _parse_accesslog, &mount->access_log }, /* YP settings */ { "cluster-password", config_get_str, &mount->cluster_password }, { "stream-name", config_get_str, &mount->stream_name }, { "stream-description", config_get_str, &mount->stream_description }, { "stream-url", config_get_str, &mount->stream_url }, { "genre", config_get_str, &mount->stream_genre }, { "bitrate", config_get_str, &mount->bitrate }, { "public", config_get_bool, &mount->yp_public }, { "type", config_get_str, &mount->type }, { "subtype", config_get_str, &mount->subtype }, { NULL, NULL, NULL }, }; /* default <mount> settings */ mount->max_listeners = -1; mount->max_bandwidth = -1; mount->burst_size = -1; mount->min_queue_size = -1; mount->mp3_meta_interval = -1; mount->yp_public = -1; mount->url_ogg_meta = 1; mount->source_timeout = config->source_timeout; mount->file_seekable = 1; mount->access_log.type = LOG_ACCESS_CLF; mount->access_log.logid = -1; mount->access_log.log_ip = 1; mount->fallback_override = 1; if (parse_xml_tags (node, icecast_tags)) return -1; if (mount->mountname == NULL) { config_clear_mount (mount); return -1; } if (mount->auth) mount->auth->mount = strdup (mount->mountname); if (mount->admin_comments_only) mount->url_ogg_meta = 1; if (mount->url_ogg_meta) mount->ogg_passthrough = 0; if (mount->min_queue_size < 0) mount->min_queue_size = mount->burst_size; if (mount->queue_block_size < 100) mount->queue_block_size = 1400; if (mount->ban_client < 0) mount->no_mount = 0; mount->next = config->mounts; config->mounts = mount; return 0; }
void config_clear(ice_config_t *c) { ice_config_dir_t *dirnode, *nextdirnode; aliases *alias, *nextalias; int i; free(c->config_filename); xmlFree (c->server_id); if (c->location) xmlFree(c->location); if (c->admin) xmlFree(c->admin); if (c->source_password) xmlFree(c->source_password); if (c->admin_username) xmlFree(c->admin_username); if (c->admin_password) xmlFree(c->admin_password); if (c->relay_username) xmlFree(c->relay_username); if (c->relay_password) xmlFree(c->relay_password); if (c->hostname) xmlFree(c->hostname); if (c->base_dir) xmlFree(c->base_dir); if (c->log_dir) xmlFree(c->log_dir); if (c->webroot_dir) xmlFree(c->webroot_dir); if (c->adminroot_dir) xmlFree(c->adminroot_dir); if (c->cert_file) xmlFree(c->cert_file); if (c->pidfile) xmlFree(c->pidfile); if (c->banfile) xmlFree(c->banfile); if (c->allowfile) xmlFree (c->allowfile); if (c->agentfile) xmlFree (c->agentfile); if (c->playlist_log.name) xmlFree(c->playlist_log.name); if (c->access_log.name) xmlFree(c->access_log.name); if (c->error_log.name) xmlFree(c->error_log.name); if (c->access_log.exclude_ext) xmlFree (c->access_log.exclude_ext); if (c->shoutcast_mount) xmlFree(c->shoutcast_mount); global_lock(); while ((c->listen_sock = config_clear_listener (c->listen_sock))) ; global_unlock(); if (c->master_server) xmlFree(c->master_server); if (c->master_username) xmlFree(c->master_username); if (c->master_password) xmlFree(c->master_password); if (c->master_bind) xmlFree(c->master_bind); if (c->user) xmlFree(c->user); if (c->group) xmlFree(c->group); if (c->mimetypes_fn) xmlFree (c->mimetypes_fn); while (c->relay) c->relay = config_clear_relay (c->relay); while (c->redirect_hosts) c->redirect_hosts = config_clear_redirect (c->redirect_hosts); while (c->mounts) { mount_proxy *to_go = c->mounts; c->mounts = to_go->next; config_clear_mount (to_go); } alias = c->aliases; while(alias) { nextalias = alias->next; if (alias->source) xmlFree(alias->source); if (alias->destination) xmlFree(alias->destination); if (alias->bind_address) xmlFree(alias->bind_address); free(alias); alias = nextalias; } dirnode = c->dir_list; while(dirnode) { nextdirnode = dirnode->next; if (dirnode->host) xmlFree(dirnode->host); free(dirnode); dirnode = nextdirnode; } #ifdef USE_YP i = 0; while (i < c->num_yp_directories) { if (c->yp_url[i]) xmlFree (c->yp_url[i]); i++; } #endif memset(c, 0, sizeof(ice_config_t)); }
void config_clear(ice_config_t *c) { ice_config_dir_t *dirnode, *nextdirnode; relay_server *relay, *nextrelay; mount_proxy *mount, *nextmount; aliases *alias, *nextalias; int i; free(c->config_filename); xmlFree (c->server_id); if (c->location) xmlFree(c->location); if (c->admin) xmlFree(c->admin); if (c->source_password) xmlFree(c->source_password); if (c->admin_username) xmlFree(c->admin_username); if (c->admin_password) xmlFree(c->admin_password); if (c->relay_username) xmlFree(c->relay_username); if (c->relay_password) xmlFree(c->relay_password); if (c->hostname) xmlFree(c->hostname); if (c->base_dir) xmlFree(c->base_dir); if (c->log_dir) xmlFree(c->log_dir); if (c->webroot_dir) xmlFree(c->webroot_dir); if (c->adminroot_dir) xmlFree(c->adminroot_dir); if (c->cert_file) xmlFree(c->cert_file); if (c->pidfile) xmlFree(c->pidfile); if (c->banfile) xmlFree(c->banfile); if (c->allowfile) xmlFree(c->allowfile); if (c->playlist_log) xmlFree(c->playlist_log); if (c->access_log) xmlFree(c->access_log); if (c->error_log) xmlFree(c->error_log); if (c->shoutcast_mount) xmlFree(c->shoutcast_mount); if (c->master_server) xmlFree(c->master_server); if (c->master_username) xmlFree(c->master_username); if (c->master_password) xmlFree(c->master_password); if (c->user) xmlFree(c->user); if (c->group) xmlFree(c->group); if (c->mimetypes_fn) xmlFree (c->mimetypes_fn); while ((c->listen_sock = config_clear_listener (c->listen_sock))) ; thread_mutex_lock(&(_locks.relay_lock)); relay = c->relay; while(relay) { nextrelay = relay->next; xmlFree(relay->server); xmlFree(relay->mount); xmlFree(relay->localmount); free(relay); relay = nextrelay; } thread_mutex_unlock(&(_locks.relay_lock)); mount = c->mounts; while(mount) { nextmount = mount->next; config_clear_mount (mount); mount = nextmount; } alias = c->aliases; while(alias) { nextalias = alias->next; xmlFree(alias->source); xmlFree(alias->destination); xmlFree(alias->bind_address); free(alias); alias = nextalias; } dirnode = c->dir_list; while(dirnode) { nextdirnode = dirnode->next; xmlFree(dirnode->host); free(dirnode); dirnode = nextdirnode; } #ifdef USE_YP i = 0; while (i < c->num_yp_directories) { xmlFree (c->yp_url[i]); i++; } #endif memset(c, 0, sizeof(ice_config_t)); }
static void _parse_mount(xmlDocPtr doc, xmlNodePtr node, ice_config_t *configuration) { char *tmp; mount_proxy *mount = acalloc(1, sizeof(mount_proxy)); mount_proxy *current = configuration->mounts; mount_proxy *last=NULL; /* default <mount> settings */ mount->max_listeners = -1; mount->burst_size = -1; mount->mp3_meta_interval = -1; mount->yp_public = -1; mount->next = NULL; do { if (node == NULL) break; if (xmlIsBlankNode(node)) continue; if (xmlStrcmp (node->name, XMLSTR("mount-name")) == 0) { mount->mountname = (char *)xmlNodeListGetString (doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("username")) == 0) { mount->username = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("password")) == 0) { mount->password = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("dump-file")) == 0) { mount->dumpfile = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("intro")) == 0) { mount->intro_filename = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("fallback-mount")) == 0) { mount->fallback_mount = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("fallback-when-full")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->fallback_when_full = atoi(tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("max-listeners")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->max_listeners = atoi(tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("charset")) == 0) { mount->charset = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("mp3-metadata-interval")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->mp3_meta_interval = atoi(tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("fallback-override")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->fallback_override = atoi(tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("no-mount")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->no_mount = atoi(tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("no-yp")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->yp_public = atoi(tmp) == 0 ? -1 : 0; if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("hidden")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->hidden = atoi(tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("authentication")) == 0) { mount->auth = auth_get_authenticator (node); } else if (xmlStrcmp (node->name, XMLSTR("on-connect")) == 0) { mount->on_connect = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("on-disconnect")) == 0) { mount->on_disconnect = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("max-listener-duration")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->max_listener_duration = atoi(tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("queue-size")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->queue_size_limit = atoi (tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("source-timeout")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); if (tmp) { mount->source_timeout = atoi (tmp); xmlFree(tmp); } } else if (xmlStrcmp (node->name, XMLSTR("burst-size")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->burst_size = atoi(tmp); if (tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("cluster-password")) == 0) { mount->cluster_password = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("stream-name")) == 0) { mount->stream_name = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("stream-description")) == 0) { mount->stream_description = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("stream-url")) == 0) { mount->stream_url = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("genre")) == 0) { mount->stream_genre = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("bitrate")) == 0) { mount->bitrate = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("public")) == 0) { tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); mount->yp_public = atoi (tmp); if(tmp) xmlFree(tmp); } else if (xmlStrcmp (node->name, XMLSTR("type")) == 0) { mount->type = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("subtype")) == 0) { mount->subtype = (char *)xmlNodeListGetString( doc, node->xmlChildrenNode, 1); } } while ((node = node->next)); /* make sure we have at least the mountpoint name */ if (mount->mountname == NULL) { config_clear_mount (mount); return; } if (mount->auth) mount->auth->mount = strdup ((char *)mount->mountname); while(current) { last = current; current = current->next; } if(last) last->next = mount; else configuration->mounts = mount; }
void config_clear(ice_config_t *c) { ice_config_dir_t *dirnode, *nextdirnode; relay_server *relay, *nextrelay; mount_proxy *mount, *nextmount; aliases *alias, *nextalias; int i; if (c->config_filename) free(c->config_filename); if (c->location && c->location != CONFIG_DEFAULT_LOCATION) xmlFree(c->location); if (c->admin && c->admin != CONFIG_DEFAULT_ADMIN) xmlFree(c->admin); if (c->source_password && c->source_password != CONFIG_DEFAULT_SOURCE_PASSWORD) xmlFree(c->source_password); if (c->admin_username) xmlFree(c->admin_username); if (c->admin_password) xmlFree(c->admin_password); if (c->relay_username) xmlFree(c->relay_username); if (c->relay_password) xmlFree(c->relay_password); if (c->hostname && c->hostname != CONFIG_DEFAULT_HOSTNAME) xmlFree(c->hostname); if (c->base_dir && c->base_dir != CONFIG_DEFAULT_BASE_DIR) xmlFree(c->base_dir); if (c->log_dir && c->log_dir != CONFIG_DEFAULT_LOG_DIR) xmlFree(c->log_dir); if (c->webroot_dir && c->webroot_dir != CONFIG_DEFAULT_WEBROOT_DIR) xmlFree(c->webroot_dir); if (c->adminroot_dir && c->adminroot_dir != CONFIG_DEFAULT_ADMINROOT_DIR) xmlFree(c->adminroot_dir); if (c->pidfile) xmlFree(c->pidfile); if (c->playlist_log && c->playlist_log != CONFIG_DEFAULT_PLAYLIST_LOG) xmlFree(c->playlist_log); if (c->access_log && c->access_log != CONFIG_DEFAULT_ACCESS_LOG) xmlFree(c->access_log); if (c->error_log && c->error_log != CONFIG_DEFAULT_ERROR_LOG) xmlFree(c->error_log); if (c->shoutcast_mount && c->shoutcast_mount != CONFIG_DEFAULT_SHOUTCAST_MOUNT) xmlFree(c->shoutcast_mount); for(i=0; i < MAX_LISTEN_SOCKETS; i++) { if (c->listeners[i].bind_address) xmlFree(c->listeners[i].bind_address); } if (c->master_server) xmlFree(c->master_server); if (c->master_username) xmlFree(c->master_username); if (c->master_password) xmlFree(c->master_password); if (c->user) xmlFree(c->user); if (c->group) xmlFree(c->group); thread_mutex_lock(&(_locks.relay_lock)); relay = c->relay; while(relay) { nextrelay = relay->next; xmlFree(relay->server); xmlFree(relay->mount); xmlFree(relay->localmount); free(relay); relay = nextrelay; } thread_mutex_unlock(&(_locks.relay_lock)); mount = c->mounts; while(mount) { nextmount = mount->next; config_clear_mount (mount); mount = nextmount; } alias = c->aliases; while(alias) { nextalias = alias->next; xmlFree(alias->source); xmlFree(alias->destination); xmlFree(alias->bind_address); free(alias); alias = nextalias; } dirnode = c->dir_list; while(dirnode) { nextdirnode = dirnode->next; xmlFree(dirnode->host); free(dirnode); dirnode = nextdirnode; } #ifdef USE_YP i = 0; while (i < c->num_yp_directories) { xmlFree (c->yp_url[i]); i++; } #endif memset(c, 0, sizeof(ice_config_t)); }