1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-02-02 15:07:36 -05:00

better coding style, patch by ePirat. refs #2059

svn path=/icecast/trunk/icecast/; revision=19376
This commit is contained in:
Philipp Schafft 2014-11-30 20:32:30 +00:00
parent ea71438af3
commit 93194594f7
43 changed files with 443 additions and 443 deletions

View File

@ -249,7 +249,7 @@ xmlDocPtr admin_build_sourcelist (const char *mount)
xmlNewChild(srcnode, NULL, XMLSTR("fallback"), xmlNewChild(srcnode, NULL, XMLSTR("fallback"),
(source->fallback_mount != NULL)? (source->fallback_mount != NULL)?
XMLSTR(source->fallback_mount):XMLSTR("")); XMLSTR(source->fallback_mount):XMLSTR(""));
snprintf (buf, sizeof(buf), "%lu", source->listeners); snprintf(buf, sizeof(buf), "%lu", source->listeners);
xmlNewChild(srcnode, NULL, XMLSTR("listeners"), XMLSTR(buf)); xmlNewChild(srcnode, NULL, XMLSTR("listeners"), XMLSTR(buf));
config = config_get_config(); config = config_get_config();
@ -297,8 +297,8 @@ void admin_send_response (xmlDocPtr doc, client_t *client,
if (buf_len < 4096) if (buf_len < 4096)
buf_len = 4096; buf_len = 4096;
client_set_queue (client, NULL); client_set_queue(client, NULL);
client->refbuf = refbuf_new (buf_len); client->refbuf = refbuf_new(buf_len);
ret = util_http_build_header(client->refbuf->data, buf_len, 0, ret = util_http_build_header(client->refbuf->data, buf_len, 0,
0, 200, NULL, 0, 200, NULL,
@ -721,7 +721,7 @@ static void command_show_listeners(client_t *client, source_t *source,
xmlNodePtr node, srcnode; xmlNodePtr node, srcnode;
char buf[22]; char buf[22];
doc = xmlNewDoc (XMLSTR("1.0")); doc = xmlNewDoc(XMLSTR("1.0"));
node = xmlNewDocNode(doc, NULL, XMLSTR("icestats"), NULL); node = xmlNewDocNode(doc, NULL, XMLSTR("icestats"), NULL);
srcnode = xmlNewChild(node, NULL, XMLSTR("source"), NULL); srcnode = xmlNewChild(node, NULL, XMLSTR("source"), NULL);
xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount)); xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount));
@ -761,7 +761,7 @@ static void command_buildm3u(client_t *client, const char *mount)
config = config_get_config(); config = config_get_config();
snprintf (client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret, snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
"Content-Disposition = attachment; filename=listen.m3u\r\n\r\n" "Content-Disposition = attachment; filename=listen.m3u\r\n\r\n"
"http://%s:%s@%s:%d%s\r\n", "http://%s:%s@%s:%d%s\r\n",
username, username,
@ -814,7 +814,7 @@ static void command_manageauth(client_t *client, source_t *source,
if (!strcmp(action, "add")) if (!strcmp(action, "add"))
{ {
const char *password = NULL; const char *password = NULL;
COMMAND_OPTIONAL (client, "password", password); COMMAND_OPTIONAL(client, "password", password);
if (username == NULL || password == NULL) if (username == NULL || password == NULL)
{ {
@ -848,7 +848,7 @@ static void command_manageauth(client_t *client, source_t *source,
} }
} }
doc = xmlNewDoc (XMLSTR("1.0")); doc = xmlNewDoc(XMLSTR("1.0"));
node = xmlNewDocNode(doc, NULL, XMLSTR("icestats"), NULL); node = xmlNewDocNode(doc, NULL, XMLSTR("icestats"), NULL);
srcnode = xmlNewChild(node, NULL, XMLSTR("source"), NULL); srcnode = xmlNewChild(node, NULL, XMLSTR("source"), NULL);
xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount)); xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount));
@ -966,7 +966,7 @@ static void command_metadata(client_t *client, source_t *source,
xmlNodePtr node; xmlNodePtr node;
int same_ip = 1; int same_ip = 1;
doc = xmlNewDoc (XMLSTR("1.0")); doc = xmlNewDoc(XMLSTR("1.0"));
node = xmlNewDocNode (doc, NULL, XMLSTR("iceresponse"), NULL); node = xmlNewDocNode (doc, NULL, XMLSTR("iceresponse"), NULL);
xmlDocSetRootElement(doc, node); xmlDocSetRootElement(doc, node);

View File

@ -268,7 +268,7 @@ static void *auth_run_thread (void *arg)
if (auth->head == NULL) if (auth->head == NULL)
auth->tailp = &auth->head; auth->tailp = &auth->head;
auth->pending_count--; auth->pending_count--;
thread_mutex_unlock (&auth->lock); thread_mutex_unlock(&auth->lock);
auth_user->next = NULL; auth_user->next = NULL;
if (auth_user->process) { if (auth_user->process) {
@ -409,9 +409,9 @@ static int get_authenticator (auth_t *auth, config_options_t *options)
} }
auth_t *auth_get_authenticator (xmlNodePtr node) auth_t *auth_get_authenticator(xmlNodePtr node)
{ {
auth_t *auth = calloc (1, sizeof (auth_t)); auth_t *auth = calloc(1, sizeof(auth_t));
config_options_t *options = NULL, **next_option = &options; config_options_t *options = NULL, **next_option = &options;
xmlNodePtr option; xmlNodePtr option;
char *method; char *method;

View File

@ -150,7 +150,7 @@ static void htpasswd_recheckfile (htpasswd_auth_state *htpasswd)
htpasswd_user *entry; htpasswd_user *entry;
num++; num++;
if(!line[0] || line[0] == '#') if (!line[0] || line[0] == '#')
continue; continue;
sep = strrchr (line, ':'); sep = strrchr (line, ':');
@ -247,7 +247,7 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options)
authenticator->state = state; authenticator->state = state;
thread_rwlock_create(&state->file_rwlock); thread_rwlock_create(&state->file_rwlock);
htpasswd_recheckfile (state); htpasswd_recheckfile(state);
return 0; return 0;
} }
@ -376,8 +376,8 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username)
} }
} }
free(tmpfile); free(tmpfile);
thread_rwlock_unlock (&state->file_rwlock); thread_rwlock_unlock(&state->file_rwlock);
htpasswd_recheckfile (state); htpasswd_recheckfile(state);
return AUTH_USERDELETED; return AUTH_USERDELETED;
} }

View File

@ -17,7 +17,7 @@
#include <config.h> #include <config.h>
#endif #endif
int auth_get_htpasswd_auth (auth_t *auth, config_options_t *options); int auth_get_htpasswd_auth(auth_t *auth, config_options_t *options);
#endif #endif

View File

@ -60,11 +60,11 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#ifndef _WIN32 #ifndef _WIN32
#include <sys/wait.h> # include <sys/wait.h>
#include <strings.h> # include <strings.h>
#else #else
#define snprintf _snprintf # define snprintf _snprintf
#define strncasecmp strnicmp # define strncasecmp strnicmp
#endif #endif
#include <curl/curl.h> #include <curl/curl.h>
@ -415,7 +415,7 @@ static auth_result auth_url_listuser (auth_t *auth, xmlNodePtr srcnode)
return AUTH_FAILED; return AUTH_FAILED;
} }
int auth_get_url_auth (auth_t *authenticator, config_options_t *options) int auth_get_url_auth(auth_t *authenticator, config_options_t *options)
{ {
auth_url *url_info; auth_url *url_info;
const char * addaction = "listener_add"; const char * addaction = "listener_add";
@ -430,8 +430,8 @@ int auth_get_url_auth (auth_t *authenticator, config_options_t *options)
authenticator->state = url_info; authenticator->state = url_info;
/* default headers */ /* default headers */
url_info->auth_header = strdup ("icecast-auth-user: 1\r\n"); url_info->auth_header = strdup("icecast-auth-user: 1\r\n");
url_info->timelimit_header = strdup ("icecast-auth-timelimit:"); url_info->timelimit_header = strdup("icecast-auth-timelimit:");
/* force auth thread to call function. this makes sure the auth_t is attached to client */ /* force auth thread to call function. this makes sure the auth_t is attached to client */
authenticator->authenticate_client = url_add_client; authenticator->authenticate_client = url_add_client;

View File

@ -313,7 +313,7 @@ static inline ice_config_http_header_t * config_copy_http_header(ice_config_http
return ret; return ret;
} }
static void config_clear_mount (mount_proxy *mount) static void config_clear_mount(mount_proxy *mount)
{ {
if (mount->mountname) xmlFree (mount->mountname); if (mount->mountname) xmlFree (mount->mountname);
if (mount->dumpfile) xmlFree (mount->dumpfile); if (mount->dumpfile) xmlFree (mount->dumpfile);
@ -391,7 +391,7 @@ void config_clear(ice_config_t *c)
thread_mutex_lock(&(_locks.relay_lock)); thread_mutex_lock(&(_locks.relay_lock));
relay = c->relay; relay = c->relay;
while(relay) { while (relay) {
nextrelay = relay->next; nextrelay = relay->next;
xmlFree(relay->server); xmlFree(relay->server);
xmlFree(relay->mount); xmlFree(relay->mount);
@ -402,14 +402,14 @@ void config_clear(ice_config_t *c)
thread_mutex_unlock(&(_locks.relay_lock)); thread_mutex_unlock(&(_locks.relay_lock));
mount = c->mounts; mount = c->mounts;
while(mount) { while (mount) {
nextmount = mount->next; nextmount = mount->next;
config_clear_mount (mount); config_clear_mount(mount);
mount = nextmount; mount = nextmount;
} }
alias = c->aliases; alias = c->aliases;
while(alias) { while (alias) {
nextalias = alias->next; nextalias = alias->next;
xmlFree(alias->source); xmlFree(alias->source);
xmlFree(alias->destination); xmlFree(alias->destination);
@ -420,7 +420,7 @@ void config_clear(ice_config_t *c)
} }
dirnode = c->dir_list; dirnode = c->dir_list;
while(dirnode) { while (dirnode) {
nextdirnode = dirnode->next; nextdirnode = dirnode->next;
xmlFree(dirnode->host); xmlFree(dirnode->host);
free(dirnode); free(dirnode);
@ -521,9 +521,9 @@ ice_config_t *config_get_config_unlocked(void)
static void _set_defaults(ice_config_t *configuration) static void _set_defaults(ice_config_t *configuration)
{ {
configuration->location = (char *)xmlCharStrdup (CONFIG_DEFAULT_LOCATION); configuration->location = (char *) xmlCharStrdup(CONFIG_DEFAULT_LOCATION);
configuration->server_id = (char *)xmlCharStrdup (ICECAST_VERSION_STRING); configuration->server_id = (char *) xmlCharStrdup(ICECAST_VERSION_STRING);
configuration->admin = (char *)xmlCharStrdup (CONFIG_DEFAULT_ADMIN); configuration->admin = (char *) xmlCharStrdup(CONFIG_DEFAULT_ADMIN);
configuration->client_limit = CONFIG_DEFAULT_CLIENT_LIMIT; configuration->client_limit = CONFIG_DEFAULT_CLIENT_LIMIT;
configuration->source_limit = CONFIG_DEFAULT_SOURCE_LIMIT; configuration->source_limit = CONFIG_DEFAULT_SOURCE_LIMIT;
configuration->queue_size_limit = CONFIG_DEFAULT_QUEUE_SIZE_LIMIT; configuration->queue_size_limit = CONFIG_DEFAULT_QUEUE_SIZE_LIMIT;
@ -1274,8 +1274,8 @@ static void _parse_relay(xmlDocPtr doc, xmlNodePtr node,
relay->next = NULL; relay->next = NULL;
relay->mp3metadata = 1; relay->mp3metadata = 1;
relay->on_demand = configuration->on_demand; relay->on_demand = configuration->on_demand;
relay->server = (char *)xmlCharStrdup ("127.0.0.1"); relay->server = (char *) xmlCharStrdup("127.0.0.1");
relay->mount = (char *)xmlCharStrdup ("/"); relay->mount = (char *) xmlCharStrdup("/");
do { do {
if (node == NULL) break; if (node == NULL) break;
@ -1418,7 +1418,7 @@ static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node,
if (node == NULL) break; if (node == NULL) break;
if (xmlIsBlankNode(node)) continue; if (xmlIsBlankNode(node)) continue;
if (xmlStrcmp (node->name, XMLSTR("source-password")) == 0) { if (xmlStrcmp(node->name, XMLSTR("source-password")) == 0) {
if (xmlGetProp(node, XMLSTR("mount"))) { if (xmlGetProp(node, XMLSTR("mount"))) {
ICECAST_LOG_ERROR("Mount level source password defined within global <authentication> section."); ICECAST_LOG_ERROR("Mount level source password defined within global <authentication> section.");
} }
@ -1600,7 +1600,7 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
alias->vhost = (char *)xmlGetProp(node, XMLSTR("vhost")); alias->vhost = (char *)xmlGetProp(node, XMLSTR("vhost"));
current = configuration->aliases; current = configuration->aliases;
last = NULL; last = NULL;
while(current) { while (current) {
last = current; last = current;
current = current->next; current = current->next;
} }
@ -1703,12 +1703,12 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node,
if (node == NULL) break; if (node == NULL) break;
if (xmlIsBlankNode(node)) continue; if (xmlIsBlankNode(node)) continue;
if (xmlStrcmp (node->name, XMLSTR("host")) == 0) { if (xmlStrcmp(node->name, XMLSTR("host")) == 0) {
server->host = (char *)xmlNodeListGetString(doc, server->host = (char *) xmlNodeListGetString(doc,
node->xmlChildrenNode, 1); node->xmlChildrenNode, 1);
addnode = 1; addnode = 1;
} else if (xmlStrcmp (node->name, XMLSTR("touch-interval")) == 0) { } else if (xmlStrcmp(node->name, XMLSTR("touch-interval")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *) xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
server->touch_interval = atoi(tmp); server->touch_interval = atoi(tmp);
if (tmp) xmlFree(tmp); if (tmp) xmlFree(tmp);
} }
@ -1858,7 +1858,7 @@ mount_proxy *config_find_mount (ice_config_t *config, const char *mount, mount_t
/* Helper function to locate the configuration details of the listening /* Helper function to locate the configuration details of the listening
* socket * socket
*/ */
listener_t *config_get_listen_sock (ice_config_t *config, connection_t *con) listener_t *config_get_listen_sock(ice_config_t *config, connection_t *con)
{ {
listener_t *listener; listener_t *listener;
int i = 0; int i = 0;

View File

@ -12,10 +12,10 @@
*/ */
/* client.c /* client.c
** **
** client interface implementation ** client interface implementation
** **
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@ -58,16 +58,16 @@ static inline void client_send_500(client_t *client, const char *message);
* client_t is returned just in case a message needs to be returned. Should * client_t is returned just in case a message needs to be returned. Should
* be called with global lock held. * be called with global lock held.
*/ */
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser) int client_create(client_t **c_ptr, connection_t *con, http_parser_t *parser)
{ {
ice_config_t *config; ice_config_t *config;
client_t *client = (client_t *)calloc(1, sizeof(client_t)); client_t *client = (client_t *) calloc(1, sizeof(client_t));
int ret = -1; int ret = -1;
if (client == NULL) if (client == NULL)
abort(); abort();
config = config_get_config (); config = config_get_config();
global.clients++; global.clients++;
if (config->client_limit < global.clients) if (config->client_limit < global.clients)
@ -119,14 +119,14 @@ void client_destroy(client_t *client)
if (client->parser) if (client->parser)
httpp_destroy(client->parser); httpp_destroy(client->parser);
global_lock (); global_lock();
global.clients--; global.clients--;
stats_event_args (NULL, "clients", "%d", global.clients); stats_event_args(NULL, "clients", "%d", global.clients);
global_unlock (); global_unlock();
/* we need to free client specific format data (if any) */ /* we need to free client specific format data (if any) */
if (client->free_client_data) if (client->free_client_data)
client->free_client_data (client); client->free_client_data(client);
free(client->username); free(client->username);
free(client->password); free(client->password);
@ -137,7 +137,7 @@ void client_destroy(client_t *client)
} }
/* helper function for reading data from a client */ /* helper function for reading data from a client */
int client_read_bytes (client_t *client, void *buf, unsigned len) int client_read_bytes(client_t *client, void *buf, unsigned len)
{ {
int bytes; int bytes;
@ -216,9 +216,9 @@ static inline void client_send_500(client_t *client, const char *message) {
} }
/* helper function for sending the data to a client */ /* helper function for sending the data to a client */
int client_send_bytes (client_t *client, const void *buf, unsigned len) int client_send_bytes(client_t *client, const void *buf, unsigned len)
{ {
int ret = client->con->send (client->con, buf, len); int ret = client->con->send(client->con, buf, len);
if (client->con->error) if (client->con->error)
ICECAST_LOG_DEBUG("Client connection died"); ICECAST_LOG_DEBUG("Client connection died");
@ -226,14 +226,14 @@ int client_send_bytes (client_t *client, const void *buf, unsigned len)
return ret; return ret;
} }
void client_set_queue (client_t *client, refbuf_t *refbuf) void client_set_queue(client_t *client, refbuf_t *refbuf)
{ {
refbuf_t *to_release = client->refbuf; refbuf_t *to_release = client->refbuf;
client->refbuf = refbuf; client->refbuf = refbuf;
if (refbuf) if (refbuf)
refbuf_addref (client->refbuf); refbuf_addref(client->refbuf);
client->pos = 0; client->pos = 0;
if (to_release) if (to_release)
refbuf_release (to_release); refbuf_release(to_release);
} }

View File

@ -12,10 +12,10 @@
*/ */
/* client.h /* client.h
** **
** client data structions and function definitions ** client data structions and function definitions
** **
*/ */
#ifndef __CLIENT_H__ #ifndef __CLIENT_H__
#define __CLIENT_H__ #define __CLIENT_H__

View File

@ -181,9 +181,9 @@ static unsigned long _next_connection_id(void)
{ {
unsigned long id; unsigned long id;
thread_spin_lock (&_connection_lock); thread_spin_lock(&_connection_lock);
id = _current_id++; id = _current_id++;
thread_spin_unlock (&_connection_lock); thread_spin_unlock(&_connection_lock);
return id; return id;
} }
@ -281,7 +281,7 @@ static int connection_send_ssl (connection_t *con, const void *buf, size_t len)
#else #else
/* SSL not compiled in, so at least log it */ /* SSL not compiled in, so at least log it */
static void get_ssl_certificate (ice_config_t *config) static void get_ssl_certificate(ice_config_t *config)
{ {
ssl_ok = 0; ssl_ok = 0;
ICECAST_LOG_INFO("No SSL capability"); ICECAST_LOG_INFO("No SSL capability");
@ -319,7 +319,7 @@ static int connection_send (connection_t *con, const void *buf, size_t len)
/* function to handle the re-populating of the avl tree containing IP addresses /* function to handle the re-populating of the avl tree containing IP addresses
* for deciding whether a connection of an incoming request is to be dropped. * for deciding whether a connection of an incoming request is to be dropped.
*/ */
static void recheck_ip_file (cache_file_contents *cache) static void recheck_ip_file(cache_file_contents *cache)
{ {
time_t now = time(NULL); time_t now = time(NULL);
if (now >= cache->file_recheck) if (now >= cache->file_recheck)
@ -379,12 +379,12 @@ static void recheck_ip_file (cache_file_contents *cache)
/* return 0 if the passed ip address is not to be handled by icecast, non-zero otherwise */ /* return 0 if the passed ip address is not to be handled by icecast, non-zero otherwise */
static int accept_ip_address (char *ip) static int accept_ip_address(char *ip)
{ {
void *result; void *result;
recheck_ip_file (&banned_ip); recheck_ip_file(&banned_ip);
recheck_ip_file (&allowed_ip); recheck_ip_file(&allowed_ip);
if (banned_ip.contents) if (banned_ip.contents)
{ {
@ -431,7 +431,7 @@ connection_t *connection_create (sock_t sock, sock_t serversock, char *ip)
/* prepare connection for interacting over a SSL connection /* prepare connection for interacting over a SSL connection
*/ */
void connection_uses_ssl (connection_t *con) void connection_uses_ssl(connection_t *con)
{ {
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
con->read = connection_read_ssl; con->read = connection_read_ssl;
@ -568,12 +568,12 @@ static connection_t *_accept_connection(int duration)
* has been collected, so we now pass it onto the connection thread for * has been collected, so we now pass it onto the connection thread for
* further processing * further processing
*/ */
static void _add_connection (client_queue_t *node) static void _add_connection(client_queue_t *node)
{ {
thread_spin_lock (&_connection_lock); thread_spin_lock(&_connection_lock);
*_con_queue_tail = node; *_con_queue_tail = node;
_con_queue_tail = (volatile client_queue_t **)&node->next; _con_queue_tail = (volatile client_queue_t **) &node->next;
thread_spin_unlock (&_connection_lock); thread_spin_unlock(&_connection_lock);
} }
@ -1564,13 +1564,13 @@ int connection_setup_sockets (ice_config_t *config)
/* setup the banned/allowed IP filenames from the xml */ /* setup the banned/allowed IP filenames from the xml */
if (config->banfile) if (config->banfile)
banned_ip.filename = strdup (config->banfile); banned_ip.filename = strdup(config->banfile);
if (config->allowfile) if (config->allowfile)
allowed_ip.filename = strdup (config->allowfile); allowed_ip.filename = strdup(config->allowfile);
count = 0; count = 0;
global.serversock = calloc (config->listen_sock_count, sizeof (sock_t)); global.serversock = calloc(config->listen_sock_count, sizeof(sock_t));
listener = config->listen_sock; listener = config->listen_sock;
prev = &config->listen_sock; prev = &config->listen_sock;

View File

@ -56,10 +56,10 @@ typedef struct connection_tag
void connection_initialize(void); void connection_initialize(void);
void connection_shutdown(void); void connection_shutdown(void);
void connection_accept_loop(void); void connection_accept_loop(void);
int connection_setup_sockets (struct ice_config_tag *config); int connection_setup_sockets(struct ice_config_tag *config);
void connection_close(connection_t *con); void connection_close(connection_t *con);
connection_t *connection_create (sock_t sock, sock_t serversock, char *ip); connection_t *connection_create(sock_t sock, sock_t serversock, char *ip);
int connection_complete_source (struct source_tag *source, int response); int connection_complete_source(struct source_tag *source, int response);
extern rwlock_t _source_shutdown_rwlock; extern rwlock_t _source_shutdown_rwlock;

View File

@ -12,10 +12,10 @@
/* -*- c-basic-offset: 4; -*- */ /* -*- c-basic-offset: 4; -*- */
/* format.c /* format.c
** **
** format plugin implementation ** format plugin implementation
** **
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@ -88,13 +88,13 @@ int format_get_plugin(format_type_t type, source_t *source)
switch (type) { switch (type) {
case FORMAT_TYPE_OGG: case FORMAT_TYPE_OGG:
ret = format_ogg_get_plugin (source); ret = format_ogg_get_plugin(source);
break; break;
case FORMAT_TYPE_EBML: case FORMAT_TYPE_EBML:
ret = format_ebml_get_plugin (source); ret = format_ebml_get_plugin(source);
break; break;
case FORMAT_TYPE_GENERIC: case FORMAT_TYPE_GENERIC:
ret = format_mp3_get_plugin (source); ret = format_mp3_get_plugin(source);
break; break;
default: default:
break; break;
@ -110,7 +110,7 @@ int format_get_plugin(format_type_t type, source_t *source)
/* clients need to be start from somewhere in the queue so we will look for /* clients need to be start from somewhere in the queue so we will look for
* a refbuf which has been previously marked as a sync point. * a refbuf which has been previously marked as a sync point.
*/ */
static void find_client_start (source_t *source, client_t *client) static void find_client_start(source_t *source, client_t *client)
{ {
refbuf_t *refbuf = source->burst_point; refbuf_t *refbuf = source->burst_point;
@ -146,7 +146,7 @@ static void find_client_start (source_t *source, client_t *client)
} }
static int get_file_data (FILE *intro, client_t *client) static int get_file_data(FILE *intro, client_t *client)
{ {
refbuf_t *refbuf = client->refbuf; refbuf_t *refbuf = client->refbuf;
size_t bytes; size_t bytes;
@ -211,7 +211,7 @@ int format_check_file_buffer (source_t *source, client_t *client)
/* call this to verify that the HTTP data has been sent and if so setup /* call this to verify that the HTTP data has been sent and if so setup
* callbacks to the appropriate format functions * callbacks to the appropriate format functions
*/ */
int format_check_http_buffer (source_t *source, client_t *client) int format_check_http_buffer(source_t *source, client_t *client)
{ {
refbuf_t *refbuf = client->refbuf; refbuf_t *refbuf = client->refbuf;
@ -229,9 +229,9 @@ int format_check_http_buffer (source_t *source, client_t *client)
return -1; return -1;
} }
client->respcode = 200; client->respcode = 200;
stats_event_inc (NULL, "listeners"); stats_event_inc(NULL, "listeners");
stats_event_inc (NULL, "listener_connections"); stats_event_inc(NULL, "listener_connections");
stats_event_inc (source->mount, "listener_connections"); stats_event_inc(source->mount, "listener_connections");
} }
if (client->pos == refbuf->len) if (client->pos == refbuf->len)
@ -246,14 +246,14 @@ int format_check_http_buffer (source_t *source, client_t *client)
} }
int format_generic_write_to_client (client_t *client) int format_generic_write_to_client(client_t *client)
{ {
refbuf_t *refbuf = client->refbuf; refbuf_t *refbuf = client->refbuf;
int ret; int ret;
const char *buf = refbuf->data + client->pos; const char *buf = refbuf->data + client->pos;
unsigned int len = refbuf->len - client->pos; unsigned int len = refbuf->len - client->pos;
ret = client_send_bytes (client, buf, len); ret = client_send_bytes(client, buf, len);
if (ret > 0) if (ret > 0)
client->pos += ret; client->pos += ret;
@ -266,7 +266,7 @@ int format_generic_write_to_client (client_t *client)
* the next buffer in the queue if there is no more left to be written from * the next buffer in the queue if there is no more left to be written from
* the existing buffer. * the existing buffer.
*/ */
int format_advance_queue (source_t *source, client_t *client) int format_advance_queue(source_t *source, client_t *client)
{ {
refbuf_t *refbuf = client->refbuf; refbuf_t *refbuf = client->refbuf;
@ -331,7 +331,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
while (node) while (node)
{ {
int next = 1; int next = 1;
http_var_t *var = (http_var_t *)node->key; http_var_t *var = (http_var_t *) node->key;
bytes = 0; bytes = 0;
if (!strcasecmp(var->name, "ice-audio-info")) if (!strcasecmp(var->name, "ice-audio-info"))
{ {
@ -398,7 +398,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
} }
avl_tree_unlock(source->parser->vars); avl_tree_unlock(source->parser->vars);
bytes = snprintf (ptr, remaining, "\r\n"); bytes = snprintf(ptr, remaining, "\r\n");
remaining -= bytes; remaining -= bytes;
ptr += bytes; ptr += bytes;

View File

@ -11,10 +11,10 @@
*/ */
/* format.h /* format.h
** **
** format plugin header ** format plugin header
** **
*/ */
#ifndef __FORMAT_H__ #ifndef __FORMAT_H__
#define __FORMAT_H__ #define __FORMAT_H__

View File

@ -66,12 +66,12 @@ struct ebml_st {
}; };
static void ebml_free_plugin (format_plugin_t *plugin); static void ebml_free_plugin(format_plugin_t *plugin);
static refbuf_t *ebml_get_buffer (source_t *source); static refbuf_t *ebml_get_buffer(source_t *source);
static int ebml_write_buf_to_client (client_t *client); static int ebml_write_buf_to_client(client_t *client);
static void ebml_write_buf_to_file (source_t *source, refbuf_t *refbuf); static void ebml_write_buf_to_file(source_t *source, refbuf_t *refbuf);
static int ebml_create_client_data (source_t *source, client_t *client); static int ebml_create_client_data(source_t *source, client_t *client);
static void ebml_free_client_data (client_t *client); static void ebml_free_client_data(client_t *client);
static ebml_t *ebml_create(); static ebml_t *ebml_create();
static void ebml_destroy(ebml_t *ebml); static void ebml_destroy(ebml_t *ebml);
@ -81,7 +81,7 @@ static int ebml_last_was_sync(ebml_t *ebml);
static char *ebml_write_buffer(ebml_t *ebml, int len); static char *ebml_write_buffer(ebml_t *ebml, int len);
static int ebml_wrote(ebml_t *ebml, int len); static int ebml_wrote(ebml_t *ebml, int len);
int format_ebml_get_plugin (source_t *source) int format_ebml_get_plugin(source_t *source)
{ {
ebml_source_state_t *ebml_source_state = calloc(1, sizeof(ebml_source_state_t)); ebml_source_state_t *ebml_source_state = calloc(1, sizeof(ebml_source_state_t));
@ -95,7 +95,7 @@ int format_ebml_get_plugin (source_t *source)
plugin->set_tag = NULL; plugin->set_tag = NULL;
plugin->apply_settings = NULL; plugin->apply_settings = NULL;
plugin->contenttype = httpp_getvar (source->parser, "content-type"); plugin->contenttype = httpp_getvar(source->parser, "content-type");
plugin->_state = ebml_source_state; plugin->_state = ebml_source_state;
source->format = plugin; source->format = plugin;
@ -104,19 +104,19 @@ int format_ebml_get_plugin (source_t *source)
return 0; return 0;
} }
static void ebml_free_plugin (format_plugin_t *plugin) static void ebml_free_plugin(format_plugin_t *plugin)
{ {
ebml_source_state_t *ebml_source_state = plugin->_state; ebml_source_state_t *ebml_source_state = plugin->_state;
refbuf_release (ebml_source_state->header); refbuf_release(ebml_source_state->header);
ebml_destroy(ebml_source_state->ebml); ebml_destroy(ebml_source_state->ebml);
free (ebml_source_state); free(ebml_source_state);
free (plugin); free(plugin);
} }
static int send_ebml_header (client_t *client) static int send_ebml_header(client_t *client)
{ {
ebml_client_data_t *ebml_client_data = client->format_data; ebml_client_data_t *ebml_client_data = client->format_data;
@ -157,7 +157,7 @@ static int ebml_write_buf_to_client (client_t *client)
} }
static refbuf_t *ebml_get_buffer (source_t *source) static refbuf_t *ebml_get_buffer(source_t *source)
{ {
ebml_source_state_t *ebml_source_state = source->format->_state; ebml_source_state_t *ebml_source_state = source->format->_state;
@ -209,7 +209,7 @@ static refbuf_t *ebml_get_buffer (source_t *source)
} }
} }
static int ebml_create_client_data (source_t *source, client_t *client) static int ebml_create_client_data(source_t *source, client_t *client)
{ {
ebml_client_data_t *ebml_client_data = calloc(1, sizeof(ebml_client_data_t)); ebml_client_data_t *ebml_client_data = calloc(1, sizeof(ebml_client_data_t));
@ -220,7 +220,7 @@ static int ebml_create_client_data (source_t *source, client_t *client)
if ((ebml_client_data) && (ebml_source_state->header)) if ((ebml_client_data) && (ebml_source_state->header))
{ {
ebml_client_data->header = ebml_source_state->header; ebml_client_data->header = ebml_source_state->header;
refbuf_addref (ebml_client_data->header); refbuf_addref(ebml_client_data->header);
client->format_data = ebml_client_data; client->format_data = ebml_client_data;
client->free_client_data = ebml_free_client_data; client->free_client_data = ebml_free_client_data;
ret = 0; ret = 0;
@ -406,7 +406,7 @@ static int ebml_last_was_sync(ebml_t *ebml)
static char *ebml_write_buffer(ebml_t *ebml, int len) static char *ebml_write_buffer(ebml_t *ebml, int len)
{ {
return (char *)ebml->input_buffer; return (char *) ebml->input_buffer;
} }

View File

@ -103,7 +103,7 @@ ogg_codec_t *initial_flac_page (format_plugin_t *plugin, ogg_page *page)
if (*parse != 0x7F) if (*parse != 0x7F)
break; break;
parse++; parse++;
if (memcmp (parse, "FLAC", 4) != 0) if (memcmp(parse, "FLAC", 4) != 0)
break; break;
ICECAST_LOG_INFO("seen initial FLAC header"); ICECAST_LOG_INFO("seen initial FLAC header");
@ -115,12 +115,12 @@ ogg_codec_t *initial_flac_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1; codec->headers = 1;
codec->name = "FLAC"; codec->name = "FLAC";
format_ogg_attach_header (ogg_info, page); format_ogg_attach_header(ogg_info, page);
return codec; return codec;
} while (0); } while (0);
ogg_stream_clear (&codec->os); ogg_stream_clear(&codec->os);
free (codec); free(codec);
return NULL; return NULL;
} }

View File

@ -16,6 +16,6 @@
#include "format_ogg.h" #include "format_ogg.h"
ogg_codec_t *initial_flac_page (format_plugin_t *plugin, ogg_page *page); ogg_codec_t *initial_flac_page(format_plugin_t *plugin, ogg_page *page);
#endif /* __FORMAT_FLAC_H */ #endif /* __FORMAT_FLAC_H */

View File

@ -87,7 +87,7 @@ static refbuf_t *process_kate_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o
ogg_info->error = 1; ogg_info->error = 1;
return NULL; return NULL;
} }
granulepos = ogg_page_granulepos (page); granulepos = ogg_page_granulepos(page);
while (ogg_stream_packetout (&codec->os, &packet) > 0) while (ogg_stream_packetout (&codec->os, &packet) > 0)
{ {
@ -122,7 +122,7 @@ static refbuf_t *process_kate_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o
} }
continue; continue;
#else #else
header_page = (packet.bytes>0 && (packet.packet[0]&0x80)); header_page = (packet.bytes > 0 && (packet.packet[0] & 0x80));
if (!header_page) if (!header_page)
break; break;
codec->headers++; codec->headers++;
@ -178,23 +178,23 @@ static refbuf_t *process_kate_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o
/* Check if specified BOS page is the start of a kate stream and /* Check if specified BOS page is the start of a kate stream and
* if so, create a codec structure for handling it * if so, create a codec structure for handling it
*/ */
ogg_codec_t *initial_kate_page (format_plugin_t *plugin, ogg_page *page) ogg_codec_t *initial_kate_page(format_plugin_t *plugin, ogg_page *page)
{ {
ogg_state_t *ogg_info = plugin->_state; ogg_state_t *ogg_info = plugin->_state;
ogg_codec_t *codec = calloc (1, sizeof (ogg_codec_t)); ogg_codec_t *codec = calloc(1, sizeof(ogg_codec_t));
ogg_packet packet; ogg_packet packet;
kate_codec_t *kate_codec = calloc (1, sizeof (kate_codec_t)); kate_codec_t *kate_codec = calloc(1, sizeof(kate_codec_t));
ogg_stream_init (&codec->os, ogg_page_serialno (page)); ogg_stream_init(&codec->os, ogg_page_serialno(page));
ogg_stream_pagein (&codec->os, page); ogg_stream_pagein(&codec->os, page);
#ifdef HAVE_KATE #ifdef HAVE_KATE
kate_info_init (&kate_codec->ki); kate_info_init (&kate_codec->ki);
kate_comment_init (&kate_codec->kc); kate_comment_init (&kate_codec->kc);
#endif #endif
ogg_stream_packetout (&codec->os, &packet); ogg_stream_packetout(&codec->os, &packet);
ICECAST_LOG_DEBUG("checking for kate codec"); ICECAST_LOG_DEBUG("checking for kate codec");
#ifdef HAVE_KATE #ifdef HAVE_KATE
@ -225,7 +225,7 @@ ogg_codec_t *initial_kate_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1; codec->headers = 1;
codec->name = "Kate"; codec->name = "Kate";
format_ogg_attach_header (ogg_info, page); format_ogg_attach_header(ogg_info, page);
ogg_info->codec_sync = codec; ogg_info->codec_sync = codec;
return codec; return codec;
} }

View File

@ -16,6 +16,6 @@
#include "format_ogg.h" #include "format_ogg.h"
ogg_codec_t *initial_kate_page (format_plugin_t *plugin, ogg_page *page); ogg_codec_t *initial_kate_page(format_plugin_t *plugin, ogg_page *page);
#endif /* __FORMAT_KATE_H */ #endif /* __FORMAT_KATE_H */

View File

@ -84,12 +84,12 @@ ogg_codec_t *initial_midi_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1; codec->headers = 1;
codec->name = "MIDI"; codec->name = "MIDI";
format_ogg_attach_header (ogg_info, page); format_ogg_attach_header(ogg_info, page);
return codec; return codec;
} while (0); } while (0);
ogg_stream_clear (&codec->os); ogg_stream_clear(&codec->os);
free (codec); free(codec);
return NULL; return NULL;
} }

View File

@ -16,6 +16,6 @@
#include "format_ogg.h" #include "format_ogg.h"
ogg_codec_t *initial_midi_page (format_plugin_t *plugin, ogg_page *page); ogg_codec_t *initial_midi_page(format_plugin_t *plugin, ogg_page *page);
#endif /* __FORMAT_MIDI_H */ #endif /* __FORMAT_MIDI_H */

View File

@ -13,10 +13,10 @@
*/ */
/* format_mp3.c /* format_mp3.c
** **
** format plugin for mp3 ** format plugin for mp3
** **
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@ -74,14 +74,14 @@ typedef struct {
refbuf_t *associated; refbuf_t *associated;
} mp3_client_data; } mp3_client_data;
int format_mp3_get_plugin (source_t *source) int format_mp3_get_plugin(source_t *source)
{ {
const char *metadata; const char *metadata;
format_plugin_t *plugin; format_plugin_t *plugin;
mp3_state *state = calloc(1, sizeof(mp3_state)); mp3_state *state = calloc(1, sizeof(mp3_state));
refbuf_t *meta; refbuf_t *meta;
plugin = (format_plugin_t *)calloc(1, sizeof(format_plugin_t)); plugin = (format_plugin_t *) calloc(1, sizeof(format_plugin_t));
plugin->type = FORMAT_TYPE_GENERIC; plugin->type = FORMAT_TYPE_GENERIC;
plugin->get_buffer = mp3_get_no_meta; plugin->get_buffer = mp3_get_no_meta;
@ -92,7 +92,7 @@ int format_mp3_get_plugin (source_t *source)
plugin->set_tag = mp3_set_tag; plugin->set_tag = mp3_set_tag;
plugin->apply_settings = format_mp3_apply_settings; plugin->apply_settings = format_mp3_apply_settings;
plugin->contenttype = httpp_getvar (source->parser, "content-type"); plugin->contenttype = httpp_getvar(source->parser, "content-type");
if (plugin->contenttype == NULL) { if (plugin->contenttype == NULL) {
/* We default to MP3 audio for old clients without content types */ /* We default to MP3 audio for old clients without content types */
plugin->contenttype = "audio/mpeg"; plugin->contenttype = "audio/mpeg";
@ -119,7 +119,7 @@ int format_mp3_get_plugin (source_t *source)
} }
} }
source->format = plugin; source->format = plugin;
thread_mutex_create (&state->url_lock); thread_mutex_create(&state->url_lock);
return 0; return 0;
} }
@ -235,7 +235,7 @@ static void format_mp3_apply_settings (client_t *client, format_plugin_t *format
/* called from the source thread when the metadata has been updated. /* called from the source thread when the metadata has been updated.
* The artist title are checked and made ready for clients to send * The artist title are checked and made ready for clients to send
*/ */
static void mp3_set_title (source_t *source) static void mp3_set_title(source_t *source)
{ {
const char streamtitle[] = "StreamTitle='"; const char streamtitle[] = "StreamTitle='";
const char streamurl[] = "StreamUrl='"; const char streamurl[] = "StreamUrl='";
@ -345,7 +345,7 @@ static int send_stream_metadata (client_t *client, refbuf_t *associated)
meta_len = 17 - client_mp3->metadata_offset; meta_len = 17 - client_mp3->metadata_offset;
} }
} }
ret = client_send_bytes (client, metadata, meta_len); ret = client_send_bytes(client, metadata, meta_len);
if (ret == meta_len) if (ret == meta_len)
{ {
@ -382,7 +382,7 @@ static int format_mp3_write_buf_to_client(client_t *client)
if (client_mp3->in_metadata) if (client_mp3->in_metadata)
{ {
refbuf_t *associated = refbuf->associated; refbuf_t *associated = refbuf->associated;
ret = send_stream_metadata (client, associated); ret = send_stream_metadata(client, associated);
if (client_mp3->in_metadata) if (client_mp3->in_metadata)
break; break;
@ -449,12 +449,12 @@ static void format_mp3_free_plugin(format_plugin_t *self)
/* free the plugin instance */ /* free the plugin instance */
mp3_state *state = self->_state; mp3_state *state = self->_state;
thread_mutex_destroy (&state->url_lock); thread_mutex_destroy(&state->url_lock);
free (state->url_artist); free(state->url_artist);
free (state->url_title); free(state->url_title);
free (self->charset); free(self->charset);
refbuf_release (state->metadata); refbuf_release(state->metadata);
refbuf_release (state->read_data); refbuf_release(state->read_data);
free(state); free(state);
free(self); free(self);
} }
@ -465,7 +465,7 @@ static void format_mp3_free_plugin(format_plugin_t *self)
* incoming streams come in small packets which could waste a lot of * incoming streams come in small packets which could waste a lot of
* bandwidth with many listeners due to headers and such like. * bandwidth with many listeners due to headers and such like.
*/ */
static int complete_read (source_t *source) static int complete_read(source_t *source)
{ {
int bytes; int bytes;
format_plugin_t *format = source->format; format_plugin_t *format = source->format;
@ -538,7 +538,7 @@ static refbuf_t *mp3_get_no_meta (source_t *source)
* metadata so that the mp3 data itself is store on the queue and the * metadata so that the mp3 data itself is store on the queue and the
* metadata is is associated with it * metadata is is associated with it
*/ */
static refbuf_t *mp3_get_filter_meta (source_t *source) static refbuf_t *mp3_get_filter_meta(source_t *source)
{ {
refbuf_t *refbuf; refbuf_t *refbuf;
format_plugin_t *plugin = source->format; format_plugin_t *plugin = source->format;
@ -658,7 +658,7 @@ static refbuf_t *mp3_get_filter_meta (source_t *source)
static int format_mp3_create_client_data(source_t *source, client_t *client) static int format_mp3_create_client_data(source_t *source, client_t *client)
{ {
mp3_client_data *client_mp3 = calloc(1,sizeof(mp3_client_data)); mp3_client_data *client_mp3 = calloc(1, sizeof(mp3_client_data));
mp3_state *source_mp3 = source->format->_state; mp3_state *source_mp3 = source->format->_state;
const char *metadata; const char *metadata;
/* the +-2 is for overwriting the last set of \r\n */ /* the +-2 is for overwriting the last set of \r\n */

View File

@ -11,10 +11,10 @@
*/ */
/* format_mp3.h /* format_mp3.h
** **
** mp3 format plugin ** mp3 format plugin
** **
*/ */
#ifndef __FORMAT_MP3_H__ #ifndef __FORMAT_MP3_H__
#define __FORMAT_MP3_H__ #define __FORMAT_MP3_H__

View File

@ -55,13 +55,13 @@
struct _ogg_state_tag; struct _ogg_state_tag;
static void format_ogg_free_plugin (format_plugin_t *plugin); static void format_ogg_free_plugin(format_plugin_t *plugin);
static int create_ogg_client_data(source_t *source, client_t *client); static int create_ogg_client_data(source_t *source, client_t *client);
static void free_ogg_client_data (client_t *client); static void free_ogg_client_data(client_t *client);
static void write_ogg_to_file (struct source_tag *source, refbuf_t *refbuf); static void write_ogg_to_file(struct source_tag *source, refbuf_t *refbuf);
static refbuf_t *ogg_get_buffer (source_t *source); static refbuf_t *ogg_get_buffer(source_t *source);
static int write_buf_to_client (client_t *client); static int write_buf_to_client(client_t *client);
struct ogg_client struct ogg_client
@ -110,7 +110,7 @@ void format_ogg_attach_header (ogg_state_t *ogg_info, ogg_page *page)
} }
void format_ogg_free_headers (ogg_state_t *ogg_info) void format_ogg_free_headers(ogg_state_t *ogg_info)
{ {
refbuf_t *header; refbuf_t *header;
@ -121,7 +121,7 @@ void format_ogg_free_headers (ogg_state_t *ogg_info)
{ {
refbuf_t *to_release = header; refbuf_t *to_release = header;
header = header->next; header = header->next;
refbuf_release (to_release); refbuf_release(to_release);
} }
ogg_info->header_pages = NULL; ogg_info->header_pages = NULL;
ogg_info->header_pages_tail = NULL; ogg_info->header_pages_tail = NULL;
@ -130,14 +130,14 @@ void format_ogg_free_headers (ogg_state_t *ogg_info)
/* release the memory used for the codec and header pages from the module */ /* release the memory used for the codec and header pages from the module */
static void free_ogg_codecs (ogg_state_t *ogg_info) static void free_ogg_codecs(ogg_state_t *ogg_info)
{ {
ogg_codec_t *codec; ogg_codec_t *codec;
if (ogg_info == NULL) if (ogg_info == NULL)
return; return;
format_ogg_free_headers (ogg_info); format_ogg_free_headers(ogg_info);
/* now free the codecs */ /* now free the codecs */
codec = ogg_info->codecs; codec = ogg_info->codecs;
@ -146,8 +146,8 @@ static void free_ogg_codecs (ogg_state_t *ogg_info)
{ {
ogg_codec_t *next = codec->next; ogg_codec_t *next = codec->next;
if (codec->possible_start) if (codec->possible_start)
refbuf_release (codec->possible_start); refbuf_release(codec->possible_start);
codec->codec_free (ogg_info, codec); codec->codec_free(ogg_info, codec);
codec = next; codec = next;
} }
ogg_info->codecs = NULL; ogg_info->codecs = NULL;
@ -157,12 +157,12 @@ static void free_ogg_codecs (ogg_state_t *ogg_info)
} }
int format_ogg_get_plugin (source_t *source) int format_ogg_get_plugin(source_t *source)
{ {
format_plugin_t *plugin; format_plugin_t *plugin;
ogg_state_t *state = calloc (1, sizeof (ogg_state_t)); ogg_state_t *state = calloc(1, sizeof(ogg_state_t));
plugin = (format_plugin_t *)calloc(1, sizeof(format_plugin_t)); plugin = (format_plugin_t *) calloc(1, sizeof(format_plugin_t));
plugin->type = FORMAT_TYPE_OGG; plugin->type = FORMAT_TYPE_OGG;
plugin->get_buffer = ogg_get_buffer; plugin->get_buffer = ogg_get_buffer;
@ -213,7 +213,7 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
ogg_info->bitrate = 0; ogg_info->bitrate = 0;
ogg_info->codec_sync = NULL; ogg_info->codec_sync = NULL;
/* need to zap old list of codecs when next group of BOS pages appear */ /* need to zap old list of codecs when next group of BOS pages appear */
free_ogg_codecs (ogg_info); free_ogg_codecs(ogg_info);
} }
do do
{ {
@ -223,7 +223,7 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
ogg_info->error = 1; ogg_info->error = 1;
return -1; return -1;
} }
codec = initial_vorbis_page (plugin, page); codec = initial_vorbis_page(plugin, page);
if (codec) if (codec)
break; break;
#ifdef HAVE_THEORA #ifdef HAVE_THEORA
@ -231,10 +231,10 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
if (codec) if (codec)
break; break;
#endif #endif
codec = initial_midi_page (plugin, page); codec = initial_midi_page(plugin, page);
if (codec) if (codec)
break; break;
codec = initial_flac_page (plugin, page); codec = initial_flac_page(plugin, page);
if (codec) if (codec)
break; break;
#ifdef HAVE_SPEEX #ifdef HAVE_SPEEX
@ -242,13 +242,13 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
if (codec) if (codec)
break; break;
#endif #endif
codec = initial_kate_page (plugin, page); codec = initial_kate_page(plugin, page);
if (codec) if (codec)
break; break;
codec = initial_skeleton_page (plugin, page); codec = initial_skeleton_page(plugin, page);
if (codec) if (codec)
break; break;
codec = initial_opus_page (plugin, page); codec = initial_opus_page(plugin, page);
if (codec) if (codec)
break; break;
@ -274,7 +274,7 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
* artist and title are provided separately so here we update the stats * artist and title are provided separately so here we update the stats
* and write log entry if required. * and write log entry if required.
*/ */
static void update_comments (source_t *source) static void update_comments(source_t *source)
{ {
ogg_state_t *ogg_info = source->format->_state; ogg_state_t *ogg_info = source->format->_state;
char *title = ogg_info->title; char *title = ogg_info->title;
@ -367,7 +367,7 @@ static refbuf_t *complete_buffer (source_t *source, refbuf_t *refbuf)
/* process the incoming page. this requires searching through the /* process the incoming page. this requires searching through the
* currently known codecs that have been seen in the stream * currently known codecs that have been seen in the stream
*/ */
static refbuf_t *process_ogg_page (ogg_state_t *ogg_info, ogg_page *page) static refbuf_t *process_ogg_page(ogg_state_t *ogg_info, ogg_page *page)
{ {
ogg_codec_t *codec = ogg_info->codecs; ogg_codec_t *codec = ogg_info->codecs;
refbuf_t *refbuf = NULL; refbuf_t *refbuf = NULL;
@ -377,7 +377,7 @@ static refbuf_t *process_ogg_page (ogg_state_t *ogg_info, ogg_page *page)
if (ogg_page_serialno (page) == codec->os.serialno) if (ogg_page_serialno (page) == codec->os.serialno)
{ {
if (codec->process_page) if (codec->process_page)
refbuf = codec->process_page (ogg_info, codec, page); refbuf = codec->process_page(ogg_info, codec, page);
break; break;
} }
@ -392,7 +392,7 @@ static refbuf_t *process_ogg_page (ogg_state_t *ogg_info, ogg_page *page)
* just add an incoming page to the codecs and process it until either * just add an incoming page to the codecs and process it until either
* more data is needed or we prodice a buffer for the queue. * more data is needed or we prodice a buffer for the queue.
*/ */
static refbuf_t *ogg_get_buffer (source_t *source) static refbuf_t *ogg_get_buffer(source_t *source)
{ {
ogg_state_t *ogg_info = source->format->_state; ogg_state_t *ogg_info = source->format->_state;
format_plugin_t *format = source->format; format_plugin_t *format = source->format;
@ -501,10 +501,10 @@ static int send_ogg_headers (client_t *client, refbuf_t *headers)
unsigned len = refbuf->len - client_data->pos; unsigned len = refbuf->len - client_data->pos;
int ret; int ret;
ret = client_send_bytes (client, data, len); ret = client_send_bytes(client, data, len);
if (ret > 0) if (ret > 0)
written += ret; written += ret;
if (ret < (int)len) if (ret < (int) len)
return written ? written : -1; return written ? written : -1;
client_data->pos += ret; client_data->pos += ret;
if (client_data->pos == refbuf->len) if (client_data->pos == refbuf->len)
@ -523,7 +523,7 @@ static int send_ogg_headers (client_t *client, refbuf_t *headers)
/* main client write routine for sending ogg data. Each refbuf has a /* main client write routine for sending ogg data. Each refbuf has a
* single page so we only need to determine if there are new headers * single page so we only need to determine if there are new headers
*/ */
static int write_buf_to_client (client_t *client) static int write_buf_to_client(client_t *client)
{ {
refbuf_t *refbuf = client->refbuf; refbuf_t *refbuf = client->refbuf;
char *buf = refbuf->data + client->pos; char *buf = refbuf->data + client->pos;

View File

@ -11,10 +11,10 @@
*/ */
/* format_ogg.h /* format_ogg.h
** **
** vorbis format plugin header ** vorbis format plugin header
** **
*/ */
#ifndef __FORMAT_OGG_H__ #ifndef __FORMAT_OGG_H__
#define __FORMAT_OGG_H__ #define __FORMAT_OGG_H__

View File

@ -15,6 +15,6 @@
#include "format_ogg.h" #include "format_ogg.h"
ogg_codec_t *initial_opus_page (format_plugin_t *plugin, ogg_page *page); ogg_codec_t *initial_opus_page(format_plugin_t *plugin, ogg_page *page);
#endif /* __FORMAT_OPUS_H */ #endif /* __FORMAT_OPUS_H */

View File

@ -94,7 +94,7 @@ ogg_codec_t *initial_skeleton_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1; codec->headers = 1;
codec->name = "Skeleton"; codec->name = "Skeleton";
format_ogg_attach_header (ogg_info, page); format_ogg_attach_header(ogg_info, page);
return codec; return codec;
} }

View File

@ -16,6 +16,6 @@
#include "format_ogg.h" #include "format_ogg.h"
ogg_codec_t *initial_speex_page (format_plugin_t *plugin, ogg_page *page); ogg_codec_t *initial_speex_page(format_plugin_t *plugin, ogg_page *page);
#endif /* __FORMAT_SPEEX_H */ #endif /* __FORMAT_SPEEX_H */

View File

@ -77,7 +77,7 @@ static refbuf_t *process_theora_page (ogg_state_t *ogg_info, ogg_codec_t *codec,
ogg_info->error = 1; ogg_info->error = 1;
return NULL; return NULL;
} }
granulepos = ogg_page_granulepos (page); granulepos = ogg_page_granulepos(page);
while (ogg_stream_packetout (&codec->os, &packet) > 0) while (ogg_stream_packetout (&codec->os, &packet) > 0)
{ {
@ -179,7 +179,7 @@ ogg_codec_t *initial_theora_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1; codec->headers = 1;
codec->name = "Theora"; codec->name = "Theora";
format_ogg_attach_header (ogg_info, page); format_ogg_attach_header(ogg_info, page);
ogg_info->codec_sync = codec; ogg_info->codec_sync = codec;
return codec; return codec;
} }

View File

@ -55,7 +55,7 @@ typedef struct vorbis_codec_tag
int initial_audio_packet; int initial_audio_packet;
ogg_page bos_page; ogg_page bos_page;
ogg_packet *header [3]; ogg_packet *header[3];
ogg_int64_t prev_page_samples; ogg_int64_t prev_page_samples;
int (*process_packet)(ogg_state_t *ogg_info, ogg_codec_t *codec); int (*process_packet)(ogg_state_t *ogg_info, ogg_codec_t *codec);
@ -183,7 +183,7 @@ static refbuf_t *get_buffer_header (ogg_state_t *ogg_info, ogg_codec_t *codec)
} }
static refbuf_t *get_buffer_finished (ogg_state_t *ogg_info, ogg_codec_t *codec) static refbuf_t *get_buffer_finished(ogg_state_t *ogg_info, ogg_codec_t *codec)
{ {
vorbis_codec_t *source_vorbis = codec->specific; vorbis_codec_t *source_vorbis = codec->specific;
ogg_page page; ogg_page page;
@ -235,7 +235,7 @@ static void initiate_flush (vorbis_codec_t *source_vorbis)
* and add them into the new stream, flushing after so many samples. We * and add them into the new stream, flushing after so many samples. We
* also check if an new headers are requested after each processed page * also check if an new headers are requested after each processed page
*/ */
static int process_vorbis_audio (ogg_state_t *ogg_info, ogg_codec_t *codec) static int process_vorbis_audio(ogg_state_t *ogg_info, ogg_codec_t *codec)
{ {
vorbis_codec_t *source_vorbis = codec->specific; vorbis_codec_t *source_vorbis = codec->specific;
@ -389,24 +389,24 @@ ogg_codec_t *initial_vorbis_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1; codec->headers = 1;
codec->name = "Vorbis"; codec->name = "Vorbis";
free_ogg_packet (vorbis->header[0]); free_ogg_packet(vorbis->header[0]);
free_ogg_packet (vorbis->header[1]); free_ogg_packet(vorbis->header[1]);
free_ogg_packet (vorbis->header[2]); free_ogg_packet(vorbis->header[2]);
memset (vorbis->header, 0, sizeof (vorbis->header)); memset(vorbis->header, 0, sizeof(vorbis->header));
vorbis->header [0] = copy_ogg_packet (&packet); vorbis->header[0] = copy_ogg_packet(&packet);
ogg_stream_init (&vorbis->new_os, rand()); ogg_stream_init(&vorbis->new_os, rand());
codec->process_page = process_vorbis_page; codec->process_page = process_vorbis_page;
codec->process = process_vorbis; codec->process = process_vorbis;
plugin->set_tag = vorbis_set_tag; plugin->set_tag = vorbis_set_tag;
vorbis->bos_page.header = malloc (page->header_len + page->body_len); vorbis->bos_page.header = malloc(page->header_len + page->body_len);
memcpy (vorbis->bos_page.header, page->header, page->header_len); memcpy(vorbis->bos_page.header, page->header, page->header_len);
vorbis->bos_page.header_len = page->header_len; vorbis->bos_page.header_len = page->header_len;
vorbis->bos_page.body = vorbis->bos_page.header + page->header_len; vorbis->bos_page.body = vorbis->bos_page.header + page->header_len;
memcpy (vorbis->bos_page.body, page->body, page->body_len); memcpy(vorbis->bos_page.body, page->body, page->body_len);
vorbis->bos_page.body_len = page->body_len; vorbis->bos_page.body_len = page->body_len;
return codec; return codec;
@ -528,7 +528,7 @@ static refbuf_t *process_vorbis_page (ogg_state_t *ogg_info,
if (ogg_stream_packetout (&codec->os, &header) <= 0) if (ogg_stream_packetout (&codec->os, &header) <= 0)
{ {
if (ogg_info->codecs->next) if (ogg_info->codecs->next)
format_ogg_attach_header (ogg_info, page); format_ogg_attach_header(ogg_info, page);
return NULL; return NULL;
} }
@ -540,7 +540,7 @@ static refbuf_t *process_vorbis_page (ogg_state_t *ogg_info,
return NULL; return NULL;
} }
header.granulepos = 0; header.granulepos = 0;
source_vorbis->header [codec->headers] = copy_ogg_packet (&header); source_vorbis->header[codec->headers] = copy_ogg_packet(&header);
codec->headers++; codec->headers++;
} }
ICECAST_LOG_DEBUG("we have the header packets now"); ICECAST_LOG_DEBUG("we have the header packets now");

View File

@ -77,7 +77,7 @@ static avl_tree *mimetypes = NULL;
static volatile int run_fserv = 0; static volatile int run_fserv = 0;
static unsigned int fserve_clients; static unsigned int fserve_clients;
static int client_tree_changed=0; static int client_tree_changed = 0;
#ifdef HAVE_POLL #ifdef HAVE_POLL
static struct pollfd *ufds = NULL; static struct pollfd *ufds = NULL;
@ -180,19 +180,19 @@ int fserve_client_waiting (void)
return 0; return 0;
} }
#else #else
int fserve_client_waiting (void) int fserve_client_waiting(void)
{ {
fserve_t *fclient; fserve_t *fclient;
fd_set realfds; fd_set realfds;
/* only rebuild fds if there are clients added/removed */ /* only rebuild fds if there are clients added/removed */
if(client_tree_changed) { if (client_tree_changed) {
client_tree_changed = 0; client_tree_changed = 0;
FD_ZERO(&fds); FD_ZERO(&fds);
fd_max = SOCK_ERROR; fd_max = SOCK_ERROR;
fclient = active_list; fclient = active_list;
while (fclient) { while (fclient) {
FD_SET (fclient->client->con->sock, &fds); FD_SET(fclient->client->con->sock, &fds);
if (fclient->client->con->sock > fd_max || fd_max == SOCK_ERROR) if (fclient->client->con->sock > fd_max || fd_max == SOCK_ERROR)
fd_max = fclient->client->con->sock; fd_max = fclient->client->con->sock;
fclient = fclient->next; fclient = fclient->next;
@ -254,7 +254,7 @@ static int wait_for_fds(void)
fserve_clients++; fserve_clients++;
} }
pending_list = NULL; pending_list = NULL;
thread_spin_unlock (&pending_lock); thread_spin_unlock(&pending_lock);
} }
/* drop out of here if someone is ready */ /* drop out of here if someone is ready */
ret = fserve_client_waiting(); ret = fserve_client_waiting();
@ -337,7 +337,7 @@ static void *fserv_thread_function(void *arg)
} }
/* string returned needs to be free'd */ /* string returned needs to be free'd */
char *fserve_content_type (const char *path) char *fserve_content_type(const char *path)
{ {
char *ext = util_get_extension(path); char *ext = util_get_extension(path);
mime_type exttype = {ext, NULL}; mime_type exttype = {ext, NULL};
@ -509,7 +509,7 @@ int fserve_client_create (client_t *httpclient, const char *path)
ICECAST_LOG_DEBUG("on demand file \"%H\" refused. Serving static files has been disabled in the config", fullpath); ICECAST_LOG_DEBUG("on demand file \"%H\" refused. Serving static files has been disabled in the config", fullpath);
client_send_error(httpclient, 404, 0, "The file you requested could not be found"); client_send_error(httpclient, 404, 0, "The file you requested could not be found");
config_release_config(); config_release_config();
free (fullpath); free(fullpath);
return -1; return -1;
} }
config_release_config(); config_release_config();
@ -692,7 +692,7 @@ void fserve_add_client_callback (client_t *client, fserve_callback_t callback, v
fclient->callback = callback; fclient->callback = callback;
fclient->arg = arg; fclient->arg = arg;
fserve_add_pending (fclient); fserve_add_pending(fclient);
} }
@ -712,7 +712,7 @@ static int _compare_mappings(void *arg, void *a, void *b)
((mime_type *)b)->ext); ((mime_type *)b)->ext);
} }
void fserve_recheck_mime_types (ice_config_t *config) void fserve_recheck_mime_types(ice_config_t *config)
{ {
FILE *mimefile; FILE *mimefile;
char line[4096]; char line[4096];

View File

@ -104,19 +104,19 @@ int get_clf_time (char *buffer, unsigned len, struct tm *t)
} }
#endif #endif
/* /*
** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME] ** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME]
** **
** ADDR = client->con->ip ** ADDR = client->con->ip
** IDENT = always - , we don't support it because it's useless ** IDENT = always - , we don't support it because it's useless
** USER = client->username ** USER = client->username
** DATE = _make_date(client->con->con_time) ** DATE = _make_date(client->con->con_time)
** REQUEST = build from client->parser ** REQUEST = build from client->parser
** CODE = client->respcode ** CODE = client->respcode
** BYTES = client->con->sent_bytes ** BYTES = client->con->sent_bytes
** REFERER = get from client->parser ** REFERER = get from client->parser
** AGENT = get from client->parser ** AGENT = get from client->parser
** TIME = timing_get_time() - client->con->con_time ** TIME = timing_get_time() - client->con->con_time
*/ */
void logging_access(client_t *client) void logging_access(client_t *client)
{ {
char datebuf[128]; char datebuf[128];

View File

@ -260,9 +260,9 @@ static int _start_logging(void)
if (accesslog < 0) { if (accesslog < 0) {
buf[sizeof(buf)-1] = 0; buf[sizeof(buf)-1] = 0;
snprintf(buf, sizeof(buf)-1, snprintf(buf, sizeof(buf) - 1,
"FATAL: could not open access logging (%s): %s", "FATAL: could not open access logging (%s): %s",
log_to_stderr?"standard error":fn_access, log_to_stderr ? "standard error" : fn_access,
strerror(errno)); strerror(errno));
_fatal_error(buf); _fatal_error(buf);
} }

View File

@ -11,10 +11,10 @@
*/ */
/* refbuf.c /* refbuf.c
** **
** reference counting buffer implementation ** reference counting buffer implementation
** **
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>

View File

@ -109,7 +109,7 @@ relay_server *relay_copy (relay_server *r)
/* force a recheck of the relays. This will recheck the master server if /* force a recheck of the relays. This will recheck the master server if
* this is a slave and rebuild all mountpoints in the stats tree * this is a slave and rebuild all mountpoints in the stats tree
*/ */
void slave_update_all_mounts (void) void slave_update_all_mounts(void)
{ {
thread_mutex_lock(&_slave_mutex); thread_mutex_lock(&_slave_mutex);
max_interval = 0; max_interval = 0;
@ -122,7 +122,7 @@ void slave_update_all_mounts (void)
/* Request slave thread to check the relay list for changes and to /* Request slave thread to check the relay list for changes and to
* update the stats for the current streams. * update the stats for the current streams.
*/ */
void slave_rebuild_mounts (void) void slave_rebuild_mounts(void)
{ {
thread_mutex_lock(&_slave_mutex); thread_mutex_lock(&_slave_mutex);
update_settings = 1; update_settings = 1;
@ -365,15 +365,15 @@ static void *start_relay_stream (void *arg)
ICECAST_LOG_DEBUG("failed relay, fallback to %s", relay->source->fallback_mount); ICECAST_LOG_DEBUG("failed relay, fallback to %s", relay->source->fallback_mount);
avl_tree_rlock(global.source_tree); avl_tree_rlock(global.source_tree);
fallback_source = source_find_mount (relay->source->fallback_mount); fallback_source = source_find_mount(relay->source->fallback_mount);
if (fallback_source != NULL) if (fallback_source != NULL)
source_move_clients (relay->source, fallback_source); source_move_clients(relay->source, fallback_source);
avl_tree_unlock (global.source_tree); avl_tree_unlock(global.source_tree);
} }
source_clear_source (relay->source); source_clear_source(relay->source);
/* cleanup relay, but prevent this relay from starting up again too soon */ /* cleanup relay, but prevent this relay from starting up again too soon */
thread_mutex_lock(&_slave_mutex); thread_mutex_lock(&_slave_mutex);
@ -511,7 +511,7 @@ static int relay_has_changed (relay_server *new, relay_server *old)
* the list of relays to shutdown * the list of relays to shutdown
*/ */
static relay_server * static relay_server *
update_relay_set (relay_server **current, relay_server *updated) update_relay_set(relay_server **current, relay_server *updated)
{ {
relay_server *relay = updated; relay_server *relay = updated;
relay_server *existing_relay, **existing_p; relay_server *existing_relay, **existing_p;
@ -557,7 +557,7 @@ update_relays (relay_server **relay_list, relay_server *new_relay_list)
{ {
relay_server *active_relays, *cleanup_relays; relay_server *active_relays, *cleanup_relays;
active_relays = update_relay_set (relay_list, new_relay_list); active_relays = update_relay_set(relay_list, new_relay_list);
cleanup_relays = *relay_list; cleanup_relays = *relay_list;
/* re-assign new set */ /* re-assign new set */
@ -615,12 +615,12 @@ static int update_from_master(ice_config_t *config)
int len, count = 1; int len, count = 1;
int on_demand; int on_demand;
username = strdup (config->master_username); username = strdup(config->master_username);
if (config->master_password) if (config->master_password)
password = strdup (config->master_password); password = strdup(config->master_password);
if (config->master_server) if (config->master_server)
master = strdup (config->master_server); master = strdup(config->master_server);
port = config->master_server_port; port = config->master_server_port;
@ -629,7 +629,7 @@ static int update_from_master(ice_config_t *config)
on_demand = config->on_demand; on_demand = config->on_demand;
ret = 1; ret = 1;
config_release_config(); config_release_config();
mastersock = sock_connect_wto (master, port, 10); mastersock = sock_connect_wto(master, port, 10);
if (mastersock == SOCK_ERROR) if (mastersock == SOCK_ERROR)
{ {
@ -733,9 +733,9 @@ static void *_slave_thread(void *arg)
thread_mutex_unlock(&_slave_mutex); thread_mutex_unlock(&_slave_mutex);
config = config_get_config(); config = config_get_config();
stats_global (config); stats_global(config);
config_release_config(); config_release_config();
source_recheck_mounts (1); source_recheck_mounts(1);
while (1) while (1)
{ {
@ -747,11 +747,11 @@ static void *_slave_thread(void *arg)
if (global . schedule_config_reread) if (global . schedule_config_reread)
{ {
event_config_read (NULL); event_config_read (NULL);
global . schedule_config_reread = 0; global.schedule_config_reread = 0;
} }
global_unlock(); global_unlock();
thread_sleep (1000000); thread_sleep(1000000);
if (slave_running == 0) if (slave_running == 0)
break; break;

View File

@ -111,15 +111,15 @@ source_t *source_reserve (const char *mount)
src->pending_tree = avl_tree_new(_compare_clients, NULL); src->pending_tree = avl_tree_new(_compare_clients, NULL);
/* make duplicates for strings or similar */ /* make duplicates for strings or similar */
src->mount = strdup (mount); src->mount = strdup(mount);
src->max_listeners = -1; src->max_listeners = -1;
thread_mutex_create(&src->lock); thread_mutex_create(&src->lock);
avl_insert (global.source_tree, src); avl_insert(global.source_tree, src);
} while (0); } while (0);
avl_tree_unlock (global.source_tree); avl_tree_unlock(global.source_tree);
return src; return src;
} }
@ -140,7 +140,7 @@ source_t *source_find_mount_raw(const char *mount)
node = global.source_tree->root->right; node = global.source_tree->root->right;
while (node) { while (node) {
source = (source_t *)node->key; source = (source_t *) node->key;
cmp = strcmp(mount, source->mount); cmp = strcmp(mount, source->mount);
if (cmp < 0) if (cmp < 0)
node = node->left; node = node->left;
@ -159,7 +159,7 @@ source_t *source_find_mount_raw(const char *mount)
* check the fallback, and so on. Must have a global source lock to call * check the fallback, and so on. Must have a global source lock to call
* this function. * this function.
*/ */
source_t *source_find_mount (const char *mount) source_t *source_find_mount(const char *mount)
{ {
source_t *source = NULL; source_t *source = NULL;
ice_config_t *config; ice_config_t *config;
@ -180,7 +180,7 @@ source_t *source_find_mount (const char *mount)
/* we either have a source which is not active (relay) or no source /* we either have a source which is not active (relay) or no source
* at all. Check the mounts list for fallback settings * at all. Check the mounts list for fallback settings
*/ */
mountinfo = config_find_mount (config, mount, MOUNT_TYPE_NORMAL); mountinfo = config_find_mount(config, mount, MOUNT_TYPE_NORMAL);
source = NULL; source = NULL;
if (mountinfo == NULL) if (mountinfo == NULL)
@ -283,7 +283,7 @@ void source_clear_source (source_t *source)
source->hidden = 0; source->hidden = 0;
source->shoutcast_compat = 0; source->shoutcast_compat = 0;
source->client_stats_update = 0; source->client_stats_update = 0;
util_dict_free (source->audio_info); util_dict_free(source->audio_info);
source->audio_info = NULL; source->audio_info = NULL;
free(source->fallback_mount); free(source->fallback_mount);
@ -350,7 +350,7 @@ client_t *source_find_client(source_t *source, int id)
* The only lock that should be held when this is called is the * The only lock that should be held when this is called is the
* source tree lock * source tree lock
*/ */
void source_move_clients (source_t *source, source_t *dest) void source_move_clients(source_t *source, source_t *dest)
{ {
unsigned long count = 0; unsigned long count = 0;
if (strcmp (source->mount, dest->mount) == 0) if (strcmp (source->mount, dest->mount) == 0)
@ -378,8 +378,8 @@ void source_move_clients (source_t *source, source_t *dest)
/* we need to move the client and pending trees - we must take the /* we need to move the client and pending trees - we must take the
* locks in this order to avoid deadlocks */ * locks in this order to avoid deadlocks */
avl_tree_wlock (source->pending_tree); avl_tree_wlock(source->pending_tree);
avl_tree_wlock (source->client_tree); avl_tree_wlock(source->client_tree);
if (source->on_demand == 0 && source->format == NULL) if (source->on_demand == 0 && source->format == NULL)
{ {
@ -567,10 +567,10 @@ static void send_to_listener (source_t *source, client_t *client, int deletion_e
loop--; loop--;
if (client->check_buffer (source, client) < 0) if (client->check_buffer(source, client) < 0)
break; break;
bytes = client->write_to_client (client); bytes = client->write_to_client(client);
if (bytes <= 0) if (bytes <= 0)
break; /* can't write any more */ break; /* can't write any more */
@ -734,7 +734,7 @@ void source_main (source_t *source)
source->stream_data_tail = refbuf; source->stream_data_tail = refbuf;
source->queue_size += refbuf->len; source->queue_size += refbuf->len;
/* new buffer is referenced for burst */ /* new buffer is referenced for burst */
refbuf_addref (refbuf); refbuf_addref(refbuf);
/* new data on queue, so check the burst point */ /* new data on queue, so check the burst point */
source->burst_offset += refbuf->len; source->burst_offset += refbuf->len;
@ -746,7 +746,7 @@ void source_main (source_t *source)
{ {
source->burst_point = to_release->next; source->burst_point = to_release->next;
source->burst_offset -= to_release->len; source->burst_offset -= to_release->len;
refbuf_release (to_release); refbuf_release(to_release);
continue; continue;
} }
break; break;
@ -754,7 +754,7 @@ void source_main (source_t *source)
/* save stream to file */ /* save stream to file */
if (source->dumpfile && source->format->write_buf_to_file) if (source->dumpfile && source->format->write_buf_to_file)
source->format->write_buf_to_file (source, refbuf); source->format->write_buf_to_file(source, refbuf);
} }
/* lets see if we have too much data in the queue, but don't remove it until later */ /* lets see if we have too much data in the queue, but don't remove it until later */
thread_mutex_lock(&source->lock); thread_mutex_lock(&source->lock);
@ -770,15 +770,15 @@ void source_main (source_t *source)
client_node = avl_get_first(source->client_tree); client_node = avl_get_first(source->client_tree);
while (client_node) { while (client_node) {
client = (client_t *)client_node->key; client = (client_t *) client_node->key;
send_to_listener (source, client, remove_from_q); send_to_listener(source, client, remove_from_q);
if (client->con->error) { if (client->con->error) {
client_node = avl_get_next(client_node); client_node = avl_get_next(client_node);
if (client->respcode == 200) if (client->respcode == 200)
stats_event_dec (NULL, "listeners"); stats_event_dec(NULL, "listeners");
avl_delete(source->client_tree, (void *)client, _free_client); avl_delete(source->client_tree, (void *) client, _free_client);
source->listeners--; source->listeners--;
ICECAST_LOG_DEBUG("Client removed"); ICECAST_LOG_DEBUG("Client removed");
continue; continue;
@ -900,12 +900,12 @@ static void source_shutdown (source_t *source)
source_t *fallback_source; source_t *fallback_source;
avl_tree_rlock(global.source_tree); avl_tree_rlock(global.source_tree);
fallback_source = source_find_mount (source->fallback_mount); fallback_source = source_find_mount(source->fallback_mount);
if (fallback_source != NULL) if (fallback_source != NULL)
source_move_clients (source, fallback_source); source_move_clients(source, fallback_source);
avl_tree_unlock (global.source_tree); avl_tree_unlock(global.source_tree);
} }
/* delete this sources stats */ /* delete this sources stats */
@ -913,11 +913,11 @@ static void source_shutdown (source_t *source)
/* we don't remove the source from the tree here, it may be a relay and /* we don't remove the source from the tree here, it may be a relay and
therefore reserved */ therefore reserved */
source_clear_source (source); source_clear_source(source);
global_lock(); global_lock();
global.sources--; global.sources--;
stats_event_args (NULL, "sources", "%d", global.sources); stats_event_args(NULL, "sources", "%d", global.sources);
global_unlock(); global_unlock();
/* release our hold on the lock so the main thread can continue cleaning up */ /* release our hold on the lock so the main thread can continue cleaning up */
@ -927,8 +927,8 @@ static void source_shutdown (source_t *source)
static int _compare_clients(void *compare_arg, void *a, void *b) static int _compare_clients(void *compare_arg, void *a, void *b)
{ {
client_t *clienta = (client_t *)a; client_t *clienta = (client_t *) a;
client_t *clientb = (client_t *)b; client_t *clientb = (client_t *) b;
connection_t *cona = clienta->con; connection_t *cona = clienta->con;
connection_t *conb = clientb->con; connection_t *conb = clientb->con;
@ -1206,12 +1206,12 @@ static void source_apply_mount (ice_config_t *config, source_t *source, mount_pr
source->timeout = mountinfo->source_timeout; source->timeout = mountinfo->source_timeout;
if (mountinfo && mountinfo->burst_size >= 0) if (mountinfo && mountinfo->burst_size >= 0)
source->burst_size = (unsigned int)mountinfo->burst_size; source->burst_size = (unsigned int) mountinfo->burst_size;
if (mountinfo && mountinfo->fallback_when_full) if (mountinfo && mountinfo->fallback_when_full)
source->fallback_when_full = mountinfo->fallback_when_full; source->fallback_when_full = mountinfo->fallback_when_full;
avl_tree_unlock (source->client_tree); avl_tree_unlock(source->client_tree);
} }

View File

@ -94,7 +94,7 @@ static void _add_event_to_queue(stats_event_t *event, event_queue_t *queue);
static stats_node_t *_find_node(avl_tree *tree, const char *name); static stats_node_t *_find_node(avl_tree *tree, const char *name);
static stats_source_t *_find_source(avl_tree *tree, const char *source); static stats_source_t *_find_source(avl_tree *tree, const char *source);
static void _free_event(stats_event_t *event); static void _free_event(stats_event_t *event);
static stats_event_t *_get_event_from_queue (event_queue_t *queue); static stats_event_t *_get_event_from_queue(event_queue_t *queue);
/* simple helper function for creating an event */ /* simple helper function for creating an event */
@ -136,7 +136,7 @@ void stats_initialize(void)
thread_mutex_create(&_stats_mutex); thread_mutex_create(&_stats_mutex);
/* set up stats queues */ /* set up stats queues */
event_queue_init (&_global_event_queue); event_queue_init(&_global_event_queue);
thread_mutex_create(&_global_event_mutex); thread_mutex_create(&_global_event_mutex);
/* fire off the stats thread */ /* fire off the stats thread */
@ -148,7 +148,7 @@ void stats_shutdown(void)
{ {
int n; int n;
if(!_stats_running) /* We can't shutdown if we're not running. */ if (!_stats_running) /* We can't shutdown if we're not running. */
return; return;
/* wait for thread to exit */ /* wait for thread to exit */
@ -210,9 +210,9 @@ void stats_event(const char *source, const char *name, const char *value)
ICECAST_LOG_WARN("seen non-UTF8 data, probably incorrect metadata (%s, %s)", name, value); ICECAST_LOG_WARN("seen non-UTF8 data, probably incorrect metadata (%s, %s)", name, value);
return; return;
} }
event = build_event (source, name, value); event = build_event(source, name, value);
if (event) if (event)
queue_global_event (event); queue_global_event(event);
} }
@ -373,7 +373,7 @@ static stats_node_t *_find_node(avl_tree *stats_tree, const char *name)
node = stats_tree->root->right; node = stats_tree->root->right;
while (node) { while (node) {
stats = (stats_node_t *)node->key; stats = (stats_node_t *) node->key;
cmp = strcmp(name, stats->name); cmp = strcmp(name, stats->name);
if (cmp < 0) if (cmp < 0)
node = node->left; node = node->left;
@ -399,7 +399,7 @@ static stats_source_t *_find_source(avl_tree *source_tree, const char *source)
/* get the root node */ /* get the root node */
node = source_tree->root->right; node = source_tree->root->right;
while (node) { while (node) {
stats = (stats_source_t *)node->key; stats = (stats_source_t *) node->key;
cmp = strcmp(source, stats->source); cmp = strcmp(source, stats->source);
if (cmp < 0) if (cmp < 0)
node = node->left; node = node->left;
@ -434,7 +434,7 @@ static stats_event_t *_copy_event(stats_event_t *event)
/* helper to apply specialised changes to a stats node */ /* helper to apply specialised changes to a stats node */
static void modify_node_event (stats_node_t *node, stats_event_t *event) static void modify_node_event(stats_node_t *node, stats_event_t *event)
{ {
char *str; char *str;
@ -532,7 +532,7 @@ static void process_source_event (stats_event_t *event)
else else
snode->hidden = 0; snode->hidden = 0;
avl_insert(_stats.source_tree, (void *)snode); avl_insert(_stats.source_tree, (void *) snode);
} }
if (event->name) if (event->name)
{ {
@ -875,8 +875,8 @@ static void _register_listener (event_listener_t *listener)
/* start with the global stats */ /* start with the global stats */
node = avl_get_first(_stats.global_tree); node = avl_get_first(_stats.global_tree);
while (node) { while (node) {
event = _make_event_from_node((stats_node_t *)node->key, NULL); event = _make_event_from_node((stats_node_t *) node->key, NULL);
_add_event_to_queue (event, &listener->queue); _add_event_to_queue(event, &listener->queue);
node = avl_get_next(node); node = avl_get_next(node);
} }
@ -974,15 +974,15 @@ typedef struct _source_xml_tag {
void stats_transform_xslt(client_t *client, const char *uri) void stats_transform_xslt(client_t *client, const char *uri)
{ {
xmlDocPtr doc; xmlDocPtr doc;
char *xslpath = util_get_path_from_normalised_uri (uri); char *xslpath = util_get_path_from_normalised_uri(uri);
const char *mount = httpp_get_query_param (client->parser, "mount"); const char *mount = httpp_get_query_param(client->parser, "mount");
doc = stats_get_xml (0, mount); doc = stats_get_xml(0, mount);
xslt_transform(doc, xslpath, client); xslt_transform(doc, xslpath, client);
xmlFreeDoc(doc); xmlFreeDoc(doc);
free (xslpath); free(xslpath);
} }
xmlDocPtr stats_get_xml(int show_hidden, const char *show_mount) xmlDocPtr stats_get_xml(int show_hidden, const char *show_mount)
@ -1088,7 +1088,7 @@ refbuf_t *stats_get_streams (void)
} }
node = avl_get_next(node); node = avl_get_next(node);
} }
thread_mutex_unlock (&_stats_mutex); thread_mutex_unlock(&_stats_mutex);
cur->len = STREAMLIST_BLKSIZE - remaining; cur->len = STREAMLIST_BLKSIZE - remaining;
return start; return start;
} }

View File

@ -396,7 +396,7 @@ char *util_bin_to_hex(unsigned char *data, int len)
char *hex = malloc(len*2 + 1); char *hex = malloc(len*2 + 1);
int i; int i;
for(i = 0; i < len; i++) { for (i = 0; i < len; i++) {
hex[i*2] = hexchars[(data[i]&0xf0) >> 4]; hex[i*2] = hexchars[(data[i]&0xf0) >> 4];
hex[i*2+1] = hexchars[data[i]&0x0f]; hex[i*2+1] = hexchars[data[i]&0x0f];
} }

View File

@ -99,7 +99,7 @@ const char *util_dict_get(util_dict *dict, const char *key);
char *util_dict_urlencode(util_dict *dict, char delim); char *util_dict_urlencode(util_dict *dict, char delim);
#ifndef HAVE_LOCALTIME_R #ifndef HAVE_LOCALTIME_R
struct tm *localtime_r (const time_t *timep, struct tm *result); struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif #endif
char *util_conv_string (const char *string, const char *in_charset, const char *out_charset); char *util_conv_string (const char *string, const char *in_charset, const char *out_charset);

View File

@ -70,12 +70,12 @@ int xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len, xmlDocPtr r
*doc_txt_ptr = NULL; *doc_txt_ptr = NULL;
*doc_txt_len = 0; *doc_txt_len = 0;
if (result->children == NULL) if (result->children == NULL)
return(0); return (0);
buf = xmlAllocOutputBuffer(NULL); buf = xmlAllocOutputBuffer(NULL);
if (buf == NULL) if (buf == NULL)
return(-1); return (-1);
xsltSaveResultTo(buf, result, style); xsltSaveResultTo(buf, result, style);
if (buf->conv != NULL) { if (buf->conv != NULL) {
*doc_txt_len = buf->conv->use; *doc_txt_len = buf->conv->use;
@ -84,7 +84,7 @@ int xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len, xmlDocPtr r
*doc_txt_len = buf->buffer->use; *doc_txt_len = buf->buffer->use;
*doc_txt_ptr = xmlStrndup(buf->buffer->content, *doc_txt_len); *doc_txt_ptr = xmlStrndup(buf->buffer->content, *doc_txt_len);
} }
(void)xmlOutputBufferClose(buf); (void) xmlOutputBufferClose(buf);
return 0; return 0;
} }
#endif #endif
@ -97,7 +97,7 @@ static mutex_t xsltlock;
void xslt_initialize(void) void xslt_initialize(void)
{ {
memset(cache, 0, sizeof(stylesheet_cache_t)*CACHESIZE); memset(cache, 0, sizeof(stylesheet_cache_t) * CACHESIZE);
thread_mutex_create(&xsltlock); thread_mutex_create(&xsltlock);
xmlInitParser(); xmlInitParser();
LIBXML_TEST_VERSION LIBXML_TEST_VERSION
@ -161,7 +161,7 @@ static xsltStylesheetPtr xslt_get_stylesheet(const char *fn) {
xsltFreeStylesheet(cache[i].stylesheet); xsltFreeStylesheet(cache[i].stylesheet);
cache[i].last_modified = file.st_mtime; cache[i].last_modified = file.st_mtime;
cache[i].stylesheet = xsltParseStylesheetFile (XMLSTR(fn)); cache[i].stylesheet = xsltParseStylesheetFile(XMLSTR(fn));
cache[i].cache_age = time(NULL); cache[i].cache_age = time(NULL);
} }
ICECAST_LOG_DEBUG("Using cached sheet %i", i); ICECAST_LOG_DEBUG("Using cached sheet %i", i);
@ -179,7 +179,7 @@ static xsltStylesheetPtr xslt_get_stylesheet(const char *fn) {
cache[i].last_modified = file.st_mtime; cache[i].last_modified = file.st_mtime;
cache[i].filename = strdup(fn); cache[i].filename = strdup(fn);
cache[i].stylesheet = xsltParseStylesheetFile (XMLSTR(fn)); cache[i].stylesheet = xsltParseStylesheetFile(XMLSTR(fn));
cache[i].cache_age = time(NULL); cache[i].cache_age = time(NULL);
return cache[i].stylesheet; return cache[i].stylesheet;
} }
@ -193,8 +193,8 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
const char *mediatype = NULL; const char *mediatype = NULL;
const char *charset = NULL; const char *charset = NULL;
xmlSetGenericErrorFunc ("", log_parse_failure); xmlSetGenericErrorFunc("", log_parse_failure);
xsltSetGenericErrorFunc ("", log_parse_failure); xsltSetGenericErrorFunc("", log_parse_failure);
thread_mutex_lock(&xsltlock); thread_mutex_lock(&xsltlock);
cur = xslt_get_stylesheet(xslfilename); cur = xslt_get_stylesheet(xslfilename);

View File

@ -95,10 +95,10 @@ static volatile unsigned client_limit = 0;
static volatile char *server_version = NULL; static volatile char *server_version = NULL;
static void *yp_update_thread(void *arg); static void *yp_update_thread(void *arg);
static void add_yp_info (ypdata_t *yp, void *info, int type); static void add_yp_info(ypdata_t *yp, void *info, int type);
static int do_yp_remove (ypdata_t *yp, char *s, unsigned len); static int do_yp_remove(ypdata_t *yp, char *s, unsigned len);
static int do_yp_add (ypdata_t *yp, char *s, unsigned len); static int do_yp_add(ypdata_t *yp, char *s, unsigned len);
static int do_yp_touch (ypdata_t *yp, char *s, unsigned len); static int do_yp_touch(ypdata_t *yp, char *s, unsigned len);
static void yp_destroy_ypdata(ypdata_t *ypdata); static void yp_destroy_ypdata(ypdata_t *ypdata);
@ -334,7 +334,7 @@ static int send_to_yp (const char *cmd, ypdata_t *yp, char *post)
ICECAST_LOG_INFO("YP %s on %s failed: %s", cmd, server->url, yp->error_msg); ICECAST_LOG_INFO("YP %s on %s failed: %s", cmd, server->url, yp->error_msg);
} }
yp->process = do_yp_add; yp->process = do_yp_add;
free (yp->sid); free(yp->sid);
yp->sid = NULL; yp->sid = NULL;
return -1; return -1;
} }
@ -491,7 +491,7 @@ static int do_yp_touch (ypdata_t *yp, char *s, unsigned len)
static int process_ypdata (struct yp_server *server, ypdata_t *yp) static int process_ypdata(struct yp_server *server, ypdata_t *yp)
{ {
unsigned len = 1024; unsigned len = 1024;
char *s = NULL, *tmp; char *s = NULL, *tmp;
@ -503,7 +503,7 @@ static int process_ypdata (struct yp_server *server, ypdata_t *yp)
while (1) while (1)
{ {
int ret; int ret;
if ((tmp = realloc (s, len)) == NULL) if ((tmp = realloc(s, len)) == NULL)
return 0; return 0;
s = tmp; s = tmp;
@ -625,7 +625,7 @@ static void check_servers (void)
ICECAST_LOG_DEBUG("YP server \"%s\"removed", server->url); ICECAST_LOG_DEBUG("YP server \"%s\"removed", server->url);
*server_p = server->next; *server_p = server->next;
server = server->next; server = server->next;
destroy_yp_server (to_go); destroy_yp_server(to_go);
continue; continue;
} }
server_p = &server->next; server_p = &server->next;
@ -689,7 +689,7 @@ static void add_pending_yp (struct yp_server *server)
} }
static void delete_marked_yp (struct yp_server *server) static void delete_marked_yp(struct yp_server *server)
{ {
ypdata_t *yp = server->mounts, **prev = &server->mounts; ypdata_t *yp = server->mounts, **prev = &server->mounts;
@ -701,7 +701,7 @@ static void delete_marked_yp (struct yp_server *server)
ICECAST_LOG_DEBUG("removed %s from YP server %s", yp->mount, server->url); ICECAST_LOG_DEBUG("removed %s from YP server %s", yp->mount, server->url);
*prev = yp->next; *prev = yp->next;
yp = yp->next; yp = yp->next;
yp_destroy_ypdata (to_go); yp_destroy_ypdata(to_go);
continue; continue;
} }
prev = &yp->next; prev = &yp->next;
@ -768,10 +768,10 @@ static void yp_destroy_ypdata(ypdata_t *ypdata)
{ {
if (ypdata) { if (ypdata) {
if (ypdata->mount) { if (ypdata->mount) {
free (ypdata->mount); free(ypdata->mount);
} }
if (ypdata->url) { if (ypdata->url) {
free (ypdata->url); free(ypdata->url);
} }
if (ypdata->sid) { if (ypdata->sid) {
free(ypdata->sid); free(ypdata->sid);
@ -803,13 +803,13 @@ static void yp_destroy_ypdata(ypdata_t *ypdata)
if (ypdata->audio_info) { if (ypdata->audio_info) {
free(ypdata->audio_info); free(ypdata->audio_info);
} }
free (ypdata->subtype); free(ypdata->subtype);
free (ypdata->error_msg); free(ypdata->error_msg);
free (ypdata); free(ypdata);
} }
} }
static void add_yp_info (ypdata_t *yp, void *info, int type) static void add_yp_info(ypdata_t *yp, void *info, int type)
{ {
char *escaped; char *escaped;