/* Icecast
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2000-2004, Jack Moffitt <[email protected],
* Michael Smith <[email protected]>,
* oddsock <[email protected]>,
* Karl Heyes <[email protected]>
* and others (see AUTHORS for details).
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include "thread/thread.h"
#include "cfgfile.h"
#include "refbuf.h"
#include "client.h"
#include "logging.h"
#define CATMODULE "CONFIG"
#define CONFIG_DEFAULT_LOCATION "Earth"
#define CONFIG_DEFAULT_ADMIN "icemaster@localhost"
#define CONFIG_DEFAULT_CLIENT_LIMIT 256
#define CONFIG_DEFAULT_SOURCE_LIMIT 16
#define CONFIG_DEFAULT_QUEUE_SIZE_LIMIT (500*1024)
#define CONFIG_DEFAULT_BURST_SIZE (64*1024)
#define CONFIG_DEFAULT_THREADPOOL_SIZE 4
#define CONFIG_DEFAULT_CLIENT_TIMEOUT 30
#define CONFIG_DEFAULT_HEADER_TIMEOUT 15
#define CONFIG_DEFAULT_SOURCE_TIMEOUT 10
#define CONFIG_DEFAULT_SOURCE_PASSWORD "changeme"
#define CONFIG_DEFAULT_RELAY_PASSWORD "changeme"
#define CONFIG_DEFAULT_MASTER_USERNAME "relay"
#define CONFIG_DEFAULT_SHOUTCAST_MOUNT "/stream"
#define CONFIG_DEFAULT_ICE_LOGIN 0
#define CONFIG_DEFAULT_FILESERVE 1
#define CONFIG_DEFAULT_TOUCH_FREQ 5
#define CONFIG_DEFAULT_HOSTNAME "localhost"
#define CONFIG_DEFAULT_PLAYLIST_LOG NULL
#define CONFIG_DEFAULT_ACCESS_LOG "access.log"
#define CONFIG_DEFAULT_ERROR_LOG "error.log"
#define CONFIG_DEFAULT_LOG_LEVEL 4
#define CONFIG_DEFAULT_CHROOT 0
#define CONFIG_DEFAULT_CHUID 0
#define CONFIG_DEFAULT_USER NULL
#define CONFIG_DEFAULT_GROUP NULL
#define CONFIG_MASTER_UPDATE_INTERVAL 120
#define CONFIG_YP_URL_TIMEOUT 10
#ifndef _WIN32
#define CONFIG_DEFAULT_BASE_DIR "/usr/local/icecast"
#define CONFIG_DEFAULT_LOG_DIR "/usr/local/icecast/logs"
#define CONFIG_DEFAULT_WEBROOT_DIR "/usr/local/icecast/webroot"
#define CONFIG_DEFAULT_ADMINROOT_DIR "/usr/local/icecast/admin"
#else
#define CONFIG_DEFAULT_BASE_DIR ".\\"
#define CONFIG_DEFAULT_LOG_DIR ".\\logs"
#define CONFIG_DEFAULT_WEBROOT_DIR ".\\webroot"
#define CONFIG_DEFAULT_ADMINROOT_DIR ".\\admin"
#endif
static ice_config_t _current_configuration;
static ice_config_locks _locks;
static void _set_defaults(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_directory(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_security(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node,
ice_config_t *c);
static void _parse_relay(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
static void _parse_mount(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
static void _parse_listen_socket(xmlDocPtr doc, xmlNodePtr node,
ice_config_t *c);
static void _add_server(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
static void create_locks() {
thread_mutex_create(&_locks.relay_lock);
thread_rwlock_create(&_locks.config_lock);
}
static void release_locks() {
thread_mutex_destroy(&_locks.relay_lock);
thread_rwlock_destroy(&_locks.config_lock);
}
void config_initialize(void) {
create_locks();
}
void config_shutdown(void) {
config_get_config();
config_clear(&_current_configuration);
config_release_config();
release_locks();
}
void config_init_configuration(ice_config_t *configuration)
{
memset(configuration, 0, sizeof(ice_config_t));
_set_defaults(configuration);
}
static void config_clear_mount (mount_proxy *mount)
{
config_options_t *option;
xmlFree (mount->mountname);
xmlFree (mount->username);
xmlFree (mount->password);
xmlFree (mount->dumpfile);
xmlFree (mount->intro_filename);
xmlFree (mount->on_connect);
xmlFree (mount->on_disconnect);
xmlFree (mount->fallback_mount);
xmlFree (mount->stream_name);
xmlFree (mount->stream_description);
xmlFree (mount->stream_url);
xmlFree (mount->stream_genre);
xmlFree (mount->bitrate);
xmlFree (mount->type);
xmlFree (mount->cluster_password);
xmlFree (mount->auth_type);
option = mount->auth_options;
while (option)
{
config_options_t *nextopt = option->next;
xmlFree (option->name);
xmlFree (option->value);
free (option);
option = nextopt;
}
auth_release (mount->auth);
free (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
没有合适的资源?快使用搜索试试~ 我知道了~
icecast
需积分: 0 11 下载量 65 浏览量
2008-04-22
00:18:45
上传
评论
收藏 1.04MB GZ 举报
温馨提示
共262个文件
h:48个
c:39个
in:22个
这是一个比较经典的P2P开源代码,编译运行既可,它可实现MP3的共享传输!
资源详情
资源评论
资源推荐
收起资源包目录
icecast (262个子文件)
icecast2.1 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 691B
Makefile.am 657B
Makefile.am 607B
Makefile.am 530B
Makefile.am 394B
Makefile.am 393B
Makefile.am 370B
Makefile.am 370B
Makefile.am 343B
Makefile.am 297B
Makefile.am 283B
Makefile.am 244B
Makefile.am 124B
Makefile.am 117B
AUTHORS 121B
credits.bmp 312KB
icecast2title.bmp 167KB
black.bmp 151KB
icecast2logo2.bmp 17KB
stopped.bmp 5KB
running.bmp 5KB
BUILDING 405B
BUILDING 66B
BUILDING 66B
BUILDING 48B
cfgfile.c 41KB
source.c 40KB
admin.c 34KB
connection.c 30KB
avl.c 27KB
stats.c 26KB
yp.c 24KB
thread.c 21KB
format_mp3.c 20KB
slave.c 19KB
sock.c 19KB
fserve.c 19KB
format_vorbis.c 17KB
auth_url.c 17KB
util.c 16KB
auth.c 16KB
format_ogg.c 15KB
main.c 13KB
httpp.c 13KB
auth_htpasswd.c 11KB
format.c 9KB
log.c 9KB
md5.c 9KB
logging.c 7KB
client.c 6KB
xslt.c 6KB
format_theora.c 5KB
resolver.c 5KB
format_flac.c 3KB
format_speex.c 2KB
format_midi.c 2KB
event.c 2KB
refbuf.c 2KB
test.c 1KB
sighandler.c 1KB
timing.c 1KB
global.c 1KB
test_resolver.c 378B
test.c 311B
ChangeLog 149KB
changelog 8KB
Icecast2win.clw 3KB
compat 2B
compile 3KB
configure 787KB
control 862B
COPYING 25KB
COPYING 25KB
COPYING 25KB
COPYING 25KB
COPYING 25KB
COPYING 18KB
copyright 1KB
Icecast2winDlg.cpp 31KB
TabCtrlSSL.cpp 13KB
Status.cpp 4KB
icecastService.cpp 4KB
StatsTab.cpp 4KB
Icecast2win.cpp 2KB
TabPageSSL.cpp 2KB
ConfigTab.cpp 2KB
Traynot.cpp 2KB
StdAfx.cpp 213B
style.css 4KB
style.css 1KB
README.Debian 407B
icecast2.default 493B
depcomp 12KB
icecast.dsp 9KB
Icecast2win.dsp 7KB
icecast2_console.dsp 6KB
icecastService.dsp 6KB
共 262 条
- 1
- 2
- 3
zhanglike
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- NVIDIA驱动、CUDA和Pytorch及其依赖
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- python课程设计-基于tensorflow实现的图文生成程序,数据集flickr30k-images+源代码+文档说明+截图
- python作业-基于Flickr30k数据集实现图像文本跨模态搜索python源码+数据集+测试界面+项目说明(高分课程设计)
- 基于Qt实现医院信息管理系统c++源码+文档说明+数据库(期末大作业)
- 基于python实现的医院信息管理系统完整源码+sql数据库+详细注释(高分课程设计)
- 基于python的眼底图像视杯视盘分割项目源码+文档说明+截图演示+详细注释(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0