1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00: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

@ -3,7 +3,7 @@
* 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 <jack@xiph.org,
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
* Michael Smith <msmith@xiph.org>,
* oddsock <oddsock@xiph.org>,
* Karl Heyes <karl@xiph.org>
@ -246,10 +246,10 @@ xmlDocPtr admin_build_sourcelist (const char *mount)
srcnode = xmlNewChild(xmlnode, NULL, XMLSTR("source"), NULL);
xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount));
xmlNewChild(srcnode, NULL, XMLSTR("fallback"),
xmlNewChild(srcnode, NULL, XMLSTR("fallback"),
(source->fallback_mount != NULL)?
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));
config = config_get_config();
@ -297,8 +297,8 @@ void admin_send_response (xmlDocPtr doc, client_t *client,
if (buf_len < 4096)
buf_len = 4096;
client_set_queue (client, NULL);
client->refbuf = refbuf_new (buf_len);
client_set_queue(client, NULL);
client->refbuf = refbuf_new(buf_len);
ret = util_http_build_header(client->refbuf->data, buf_len, 0,
0, 200, NULL,
@ -587,8 +587,8 @@ static void html_success(client_t *client, char *message)
}
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
"<html><head><title>Admin request successful</title></head>"
"<body><p>%s</p></body></html>", message);
"<html><head><title>Admin request successful</title></head>"
"<body><p>%s</p></body></html>", message);
client->respcode = 200;
client->refbuf->len = strlen (client->refbuf->data);
@ -649,7 +649,7 @@ static void command_move_clients(client_t *client, source_t *source,
memset(buf, '\000', sizeof(buf));
snprintf (buf, sizeof(buf), "Clients moved from %s to %s",
source->mount, dest_source);
source->mount, dest_source);
xmlNewChild(node, NULL, XMLSTR("message"), XMLSTR(buf));
xmlNewChild(node, NULL, XMLSTR("return"), XMLSTR("1"));
@ -721,7 +721,7 @@ static void command_show_listeners(client_t *client, source_t *source,
xmlNodePtr node, srcnode;
char buf[22];
doc = xmlNewDoc (XMLSTR("1.0"));
doc = xmlNewDoc(XMLSTR("1.0"));
node = xmlNewDocNode(doc, NULL, XMLSTR("icestats"), NULL);
srcnode = xmlNewChild(node, NULL, XMLSTR("source"), NULL);
xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount));
@ -761,8 +761,8 @@ static void command_buildm3u(client_t *client, const char *mount)
config = config_get_config();
snprintf (client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
"Content-Disposition = attachment; filename=listen.m3u\r\n\r\n"
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
"Content-Disposition = attachment; filename=listen.m3u\r\n\r\n"
"http://%s:%s@%s:%d%s\r\n",
username,
password,
@ -814,7 +814,7 @@ static void command_manageauth(client_t *client, source_t *source,
if (!strcmp(action, "add"))
{
const char *password = NULL;
COMMAND_OPTIONAL (client, "password", password);
COMMAND_OPTIONAL(client, "password", password);
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);
srcnode = xmlNewChild(node, NULL, XMLSTR("source"), NULL);
xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount));
@ -890,7 +890,7 @@ static void command_kill_source(client_t *client, source_t *source,
source->running = 0;
admin_send_response(doc, client, response,
admin_send_response(doc, client, response,
ADMIN_XSL_RESPONSE);
xmlFreeDoc(doc);
}
@ -966,7 +966,7 @@ static void command_metadata(client_t *client, source_t *source,
xmlNodePtr node;
int same_ip = 1;
doc = xmlNewDoc (XMLSTR("1.0"));
doc = xmlNewDoc(XMLSTR("1.0"));
node = xmlNewDocNode (doc, NULL, XMLSTR("iceresponse"), NULL);
xmlDocSetRootElement(doc, node);

View File

@ -3,7 +3,7 @@
* 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 <jack@xiph.org,
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
* Michael Smith <msmith@xiph.org>,
* oddsock <oddsock@xiph.org>,
* Karl Heyes <karl@xiph.org>

View File

@ -268,7 +268,7 @@ static void *auth_run_thread (void *arg)
if (auth->head == NULL)
auth->tailp = &auth->head;
auth->pending_count--;
thread_mutex_unlock (&auth->lock);
thread_mutex_unlock(&auth->lock);
auth_user->next = NULL;
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;
xmlNodePtr option;
char *method;

View File

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

View File

@ -3,7 +3,7 @@
* 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 <jack@xiph.org,
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
* Michael Smith <msmith@xiph.org>,
* oddsock <oddsock@xiph.org>,
* Karl Heyes <karl@xiph.org>
@ -17,7 +17,7 @@
#include <config.h>
#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

View File

@ -3,7 +3,7 @@
* 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 <jack@xiph.org>,
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org>,
* Michael Smith <msmith@xiph.org>,
* oddsock <oddsock@xiph.org>,
* Karl Heyes <karl@xiph.org>
@ -11,7 +11,7 @@
* Copyright 2011-2014, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
*/
/*
/*
* Client authentication via URL functions
*
* authenticate user via a URL, this is done via libcurl so https can also
@ -60,11 +60,11 @@
#include <errno.h>
#include <stdio.h>
#ifndef _WIN32
#include <sys/wait.h>
#include <strings.h>
# include <sys/wait.h>
# include <strings.h>
#else
#define snprintf _snprintf
#define strncasecmp strnicmp
# define snprintf _snprintf
# define strncasecmp strnicmp
#endif
#include <curl/curl.h>
@ -415,7 +415,7 @@ static auth_result auth_url_listuser (auth_t *auth, xmlNodePtr srcnode)
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;
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;
/* default headers */
url_info->auth_header = strdup ("icecast-auth-user: 1\r\n");
url_info->timelimit_header = strdup ("icecast-auth-timelimit:");
url_info->auth_header = strdup("icecast-auth-user: 1\r\n");
url_info->timelimit_header = strdup("icecast-auth-timelimit:");
/* force auth thread to call function. this makes sure the auth_t is attached to client */
authenticator->authenticate_client = url_add_client;

View File

@ -3,7 +3,7 @@
* 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 <jack@xiph.org,
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
* Michael Smith <msmith@xiph.org>,
* oddsock <oddsock@xiph.org>,
* Karl Heyes <karl@xiph.org>
@ -313,7 +313,7 @@ static inline ice_config_http_header_t * config_copy_http_header(ice_config_http
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->dumpfile) xmlFree (mount->dumpfile);
@ -391,7 +391,7 @@ void config_clear(ice_config_t *c)
thread_mutex_lock(&(_locks.relay_lock));
relay = c->relay;
while(relay) {
while (relay) {
nextrelay = relay->next;
xmlFree(relay->server);
xmlFree(relay->mount);
@ -402,14 +402,14 @@ void config_clear(ice_config_t *c)
thread_mutex_unlock(&(_locks.relay_lock));
mount = c->mounts;
while(mount) {
while (mount) {
nextmount = mount->next;
config_clear_mount (mount);
config_clear_mount(mount);
mount = nextmount;
}
alias = c->aliases;
while(alias) {
while (alias) {
nextalias = alias->next;
xmlFree(alias->source);
xmlFree(alias->destination);
@ -420,7 +420,7 @@ void config_clear(ice_config_t *c)
}
dirnode = c->dir_list;
while(dirnode) {
while (dirnode) {
nextdirnode = dirnode->next;
xmlFree(dirnode->host);
free(dirnode);
@ -521,9 +521,9 @@ ice_config_t *config_get_config_unlocked(void)
static void _set_defaults(ice_config_t *configuration)
{
configuration->location = (char *)xmlCharStrdup (CONFIG_DEFAULT_LOCATION);
configuration->server_id = (char *)xmlCharStrdup (ICECAST_VERSION_STRING);
configuration->admin = (char *)xmlCharStrdup (CONFIG_DEFAULT_ADMIN);
configuration->location = (char *) xmlCharStrdup(CONFIG_DEFAULT_LOCATION);
configuration->server_id = (char *) xmlCharStrdup(ICECAST_VERSION_STRING);
configuration->admin = (char *) xmlCharStrdup(CONFIG_DEFAULT_ADMIN);
configuration->client_limit = CONFIG_DEFAULT_CLIENT_LIMIT;
configuration->source_limit = CONFIG_DEFAULT_SOURCE_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->mp3metadata = 1;
relay->on_demand = configuration->on_demand;
relay->server = (char *)xmlCharStrdup ("127.0.0.1");
relay->mount = (char *)xmlCharStrdup ("/");
relay->server = (char *) xmlCharStrdup("127.0.0.1");
relay->mount = (char *) xmlCharStrdup("/");
do {
if (node == NULL) break;
@ -1418,7 +1418,7 @@ static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node,
if (node == NULL) break;
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"))) {
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"));
current = configuration->aliases;
last = NULL;
while(current) {
while (current) {
last = current;
current = current->next;
}
@ -1703,12 +1703,12 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node,
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (xmlStrcmp (node->name, XMLSTR("host")) == 0) {
server->host = (char *)xmlNodeListGetString(doc,
node->xmlChildrenNode, 1);
if (xmlStrcmp(node->name, XMLSTR("host")) == 0) {
server->host = (char *) xmlNodeListGetString(doc,
node->xmlChildrenNode, 1);
addnode = 1;
} else if (xmlStrcmp (node->name, XMLSTR("touch-interval")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (xmlStrcmp(node->name, XMLSTR("touch-interval")) == 0) {
tmp = (char *) xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
server->touch_interval = atoi(tmp);
if (tmp) xmlFree(tmp);
}
@ -1850,7 +1850,7 @@ mount_proxy *config_find_mount (ice_config_t *config, const char *mount, mount_t
/* retry with default mount */
if (!mountinfo && type == MOUNT_TYPE_NORMAL)
mountinfo = config_find_mount(config, mount, MOUNT_TYPE_DEFAULT);
mountinfo = config_find_mount(config, mount, MOUNT_TYPE_DEFAULT);
return mountinfo;
}
@ -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
* 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;
int i = 0;

View File

@ -15,10 +15,10 @@
#ifndef __CFGFILE_H__
#define __CFGFILE_H__
#define CONFIG_EINSANE -1
#define CONFIG_ENOROOT -2
#define CONFIG_EINSANE -1
#define CONFIG_ENOROOT -2
#define CONFIG_EBADROOT -3
#define CONFIG_EPARSE -4
#define CONFIG_EPARSE -4
#define MAX_YP_DIRECTORIES 25
@ -78,7 +78,7 @@ typedef struct _mount_proxy {
char *dumpfile; /* Filename to dump this stream to (will be appended). NULL
to not dump. */
char *intro_filename; /* Send contents of file to client before the stream */
char *intro_filename; /* Send contents of file to client before the stream */
int fallback_when_full; /* switch new listener to fallback source
when max listeners reached */
int max_listeners; /* Max listeners for this mountpoint only. -1 to not
@ -93,8 +93,8 @@ typedef struct _mount_proxy {
* from global setting */
unsigned int queue_size_limit;
int hidden; /* Do we list this on the xsl pages */
unsigned int source_timeout; /* source timeout in seconds */
char *charset; /* character set if not utf8 */
unsigned int source_timeout; /* source timeout in seconds */
char *charset; /* character set if not utf8 */
int mp3_meta_interval; /* outgoing per-stream metadata interval */
ice_config_http_header_t *http_headers; /* additional HTTP headers */
@ -203,8 +203,8 @@ typedef struct ice_config_tag {
char *user;
char *group;
char *yp_url[MAX_YP_DIRECTORIES];
int yp_url_timeout[MAX_YP_DIRECTORIES];
int yp_touch_interval[MAX_YP_DIRECTORIES];
int yp_url_timeout[MAX_YP_DIRECTORIES];
int yp_touch_interval[MAX_YP_DIRECTORIES];
int num_yp_directories;
} ice_config_t;

View File

@ -12,10 +12,10 @@
*/
/* client.c
**
** client interface implementation
**
*/
**
** client interface implementation
**
*/
#ifdef HAVE_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
* 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;
client_t *client = (client_t *)calloc(1, sizeof(client_t));
client_t *client = (client_t *) calloc(1, sizeof(client_t));
int ret = -1;
if (client == NULL)
abort();
config = config_get_config ();
config = config_get_config();
global.clients++;
if (config->client_limit < global.clients)
@ -119,14 +119,14 @@ void client_destroy(client_t *client)
if (client->parser)
httpp_destroy(client->parser);
global_lock ();
global_lock();
global.clients--;
stats_event_args (NULL, "clients", "%d", global.clients);
global_unlock ();
stats_event_args(NULL, "clients", "%d", global.clients);
global_unlock();
/* we need to free client specific format data (if any) */
if (client->free_client_data)
client->free_client_data (client);
client->free_client_data(client);
free(client->username);
free(client->password);
@ -137,7 +137,7 @@ void client_destroy(client_t *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;
@ -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 */
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)
ICECAST_LOG_DEBUG("Client connection died");
@ -226,14 +226,14 @@ int client_send_bytes (client_t *client, const void *buf, unsigned len)
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;
client->refbuf = refbuf;
if (refbuf)
refbuf_addref (client->refbuf);
refbuf_addref(client->refbuf);
client->pos = 0;
if (to_release)
refbuf_release (to_release);
refbuf_release(to_release);
}

View File

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

View File

@ -181,9 +181,9 @@ static unsigned long _next_connection_id(void)
{
unsigned long id;
thread_spin_lock (&_connection_lock);
thread_spin_lock(&_connection_lock);
id = _current_id++;
thread_spin_unlock (&_connection_lock);
thread_spin_unlock(&_connection_lock);
return id;
}
@ -196,8 +196,8 @@ static void get_ssl_certificate (ice_config_t *config)
long ssl_opts;
ssl_ok = 0;
SSL_load_error_strings(); /* readable error messages */
SSL_library_init(); /* initialize library */
SSL_load_error_strings(); /* readable error messages */
SSL_library_init(); /* initialize library */
method = SSLv23_server_method();
ssl_ctx = SSL_CTX_new (method);
@ -253,7 +253,7 @@ static int connection_read_ssl (connection_t *con, void *buf, size_t len)
{
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
return -1;
return -1;
}
con->error = 1;
}
@ -281,7 +281,7 @@ static int connection_send_ssl (connection_t *con, const void *buf, size_t len)
#else
/* 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;
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
* 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);
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 */
static int accept_ip_address (char *ip)
static int accept_ip_address(char *ip)
{
void *result;
recheck_ip_file (&banned_ip);
recheck_ip_file (&allowed_ip);
recheck_ip_file(&banned_ip);
recheck_ip_file(&allowed_ip);
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
*/
void connection_uses_ssl (connection_t *con)
void connection_uses_ssl(connection_t *con)
{
#ifdef HAVE_OPENSSL
con->read = connection_read_ssl;
@ -480,9 +480,9 @@ static sock_t wait_for_serversock(int timeout)
for(i=0, dst=0; i < global.server_sockets; i++)
{
if (global.serversock[i] == SOCK_ERROR)
continue;
continue;
if (i!=dst)
global.serversock[dst] = global.serversock[i];
global.serversock[dst] = global.serversock[i];
dst++;
}
global.server_sockets = dst;
@ -568,12 +568,12 @@ static connection_t *_accept_connection(int duration)
* has been collected, so we now pass it onto the connection thread for
* 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 = (volatile client_queue_t **)&node->next;
thread_spin_unlock (&_connection_lock);
_con_queue_tail = (volatile client_queue_t **) &node->next;
thread_spin_unlock(&_connection_lock);
}
@ -1564,15 +1564,15 @@ int connection_setup_sockets (ice_config_t *config)
/* setup the banned/allowed IP filenames from the xml */
if (config->banfile)
banned_ip.filename = strdup (config->banfile);
banned_ip.filename = strdup(config->banfile);
if (config->allowfile)
allowed_ip.filename = strdup (config->allowfile);
allowed_ip.filename = strdup(config->allowfile);
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;
while (listener)
{

View File

@ -43,7 +43,7 @@ typedef struct connection_tag
int error;
#ifdef HAVE_OPENSSL
SSL *ssl; /* SSL handler */
SSL *ssl; /* SSL handler */
#endif
int (*send)(struct connection_tag *handle, const void *buf, size_t len);
int (*read)(struct connection_tag *handle, void *buf, size_t len);
@ -56,10 +56,10 @@ typedef struct connection_tag
void connection_initialize(void);
void connection_shutdown(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);
connection_t *connection_create (sock_t sock, sock_t serversock, char *ip);
int connection_complete_source (struct source_tag *source, int response);
connection_t *connection_create(sock_t sock, sock_t serversock, char *ip);
int connection_complete_source(struct source_tag *source, int response);
extern rwlock_t _source_shutdown_rwlock;

View File

@ -13,7 +13,7 @@
#ifndef __EVENT_H__
#define __EVENT_H__
#define EVENT_NO_EVENT 0
#define EVENT_NO_EVENT 0
#define EVENT_CONFIG_READ 1
void event_config_read(void *nothing);

View File

@ -12,10 +12,10 @@
/* -*- c-basic-offset: 4; -*- */
/* format.c
**
** format plugin implementation
**
*/
**
** format plugin implementation
**
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -87,16 +87,16 @@ int format_get_plugin(format_type_t type, source_t *source)
int ret = -1;
switch (type) {
case FORMAT_TYPE_OGG:
ret = format_ogg_get_plugin (source);
case FORMAT_TYPE_OGG:
ret = format_ogg_get_plugin(source);
break;
case FORMAT_TYPE_EBML:
ret = format_ebml_get_plugin (source);
case FORMAT_TYPE_EBML:
ret = format_ebml_get_plugin(source);
break;
case FORMAT_TYPE_GENERIC:
ret = format_mp3_get_plugin (source);
case FORMAT_TYPE_GENERIC:
ret = format_mp3_get_plugin(source);
break;
default:
default:
break;
}
if (ret < 0)
@ -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
* 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;
@ -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;
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
* 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;
@ -229,9 +229,9 @@ int format_check_http_buffer (source_t *source, client_t *client)
return -1;
}
client->respcode = 200;
stats_event_inc (NULL, "listeners");
stats_event_inc (NULL, "listener_connections");
stats_event_inc (source->mount, "listener_connections");
stats_event_inc(NULL, "listeners");
stats_event_inc(NULL, "listener_connections");
stats_event_inc(source->mount, "listener_connections");
}
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;
int ret;
const char *buf = refbuf->data + 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)
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 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;
@ -331,7 +331,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
while (node)
{
int next = 1;
http_var_t *var = (http_var_t *)node->key;
http_var_t *var = (http_var_t *) node->key;
bytes = 0;
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);
bytes = snprintf (ptr, remaining, "\r\n");
bytes = snprintf(ptr, remaining, "\r\n");
remaining -= bytes;
ptr += bytes;

View File

@ -11,10 +11,10 @@
*/
/* format.h
**
** format plugin header
**
*/
**
** format plugin header
**
*/
#ifndef __FORMAT_H__
#define __FORMAT_H__
@ -40,10 +40,10 @@ typedef struct _format_plugin_tag
/* we need to know the mount to report statistics */
char *mount;
const char *contenttype;
char *charset;
uint64_t read_bytes;
uint64_t sent_bytes;
const char *contenttype;
char *charset;
uint64_t read_bytes;
uint64_t sent_bytes;
refbuf_t *(*get_buffer)(struct source_tag *);
int (*write_buf_to_client)(client_t *client);

View File

@ -53,7 +53,7 @@ struct ebml_st {
char *cluster_id;
int cluster_start;
int position;
unsigned char *input_buffer;
unsigned char *buffer;
@ -66,12 +66,12 @@ struct ebml_st {
};
static void ebml_free_plugin (format_plugin_t *plugin);
static refbuf_t *ebml_get_buffer (source_t *source);
static int ebml_write_buf_to_client (client_t *client);
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 void ebml_free_client_data (client_t *client);
static void ebml_free_plugin(format_plugin_t *plugin);
static refbuf_t *ebml_get_buffer(source_t *source);
static int ebml_write_buf_to_client(client_t *client);
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 void ebml_free_client_data(client_t *client);
static ebml_t *ebml_create();
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 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));
@ -95,7 +95,7 @@ int format_ebml_get_plugin (source_t *source)
plugin->set_tag = 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;
source->format = plugin;
@ -104,19 +104,19 @@ int format_ebml_get_plugin (source_t *source)
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;
refbuf_release (ebml_source_state->header);
refbuf_release(ebml_source_state->header);
ebml_destroy(ebml_source_state->ebml);
free (ebml_source_state);
free (plugin);
free(ebml_source_state);
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;
@ -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;
@ -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));
@ -220,7 +220,7 @@ static int ebml_create_client_data (source_t *source, client_t *client)
if ((ebml_client_data) && (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->free_client_data = ebml_free_client_data;
ret = 0;
@ -313,7 +313,7 @@ static int ebml_read_space(ebml_t *ebml)
read_space = ebml->cluster_start;
else
read_space = ebml->position - 4;
return read_space;
}
else
@ -353,7 +353,7 @@ static int ebml_read(ebml_t *ebml, char *buffer, int len)
memcpy(buffer, ebml->buffer, to_read);
memmove(ebml->buffer, ebml->buffer + to_read, ebml->position - to_read);
ebml->position -= to_read;
if (ebml->cluster_start > 0)
ebml->cluster_start -= to_read;
}
@ -406,7 +406,7 @@ static int ebml_last_was_sync(ebml_t *ebml)
static char *ebml_write_buffer(ebml_t *ebml, int len)
{
return (char *)ebml->input_buffer;
return (char *) ebml->input_buffer;
}
@ -459,7 +459,7 @@ static int ebml_wrote(ebml_t *ebml, int len)
}
}
}
ebml->position += len;
return len;

View File

@ -103,7 +103,7 @@ ogg_codec_t *initial_flac_page (format_plugin_t *plugin, ogg_page *page)
if (*parse != 0x7F)
break;
parse++;
if (memcmp (parse, "FLAC", 4) != 0)
if (memcmp(parse, "FLAC", 4) != 0)
break;
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->name = "FLAC";
format_ogg_attach_header (ogg_info, page);
format_ogg_attach_header(ogg_info, page);
return codec;
} while (0);
ogg_stream_clear (&codec->os);
free (codec);
ogg_stream_clear(&codec->os);
free(codec);
return NULL;
}

View File

@ -16,6 +16,6 @@
#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 */

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;
return NULL;
}
granulepos = ogg_page_granulepos (page);
granulepos = ogg_page_granulepos(page);
while (ogg_stream_packetout (&codec->os, &packet) > 0)
{
@ -108,21 +108,21 @@ static refbuf_t *process_kate_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o
{
kate->headers_done = 1;
/* TODO: what to replace this with ?
ogg_info->bitrate += theora->ti.target_bitrate;
stats_event_args (ogg_info->mount, "video_bitrate", "%ld",
(long)theora->ti.target_bitrate);
stats_event_args (ogg_info->mount, "video_quality", "%ld",
(long)theora->ti.quality);
stats_event_args (ogg_info->mount, "frame_size", "%ld x %ld",
(long)theora->ti.frame_width,
(long)theora->ti.frame_height);
stats_event_args (ogg_info->mount, "frame_rate", "%.2f",
(float)theora->ti.fps_numerator/theora->ti.fps_denominator);
*/
ogg_info->bitrate += theora->ti.target_bitrate;
stats_event_args (ogg_info->mount, "video_bitrate", "%ld",
(long)theora->ti.target_bitrate);
stats_event_args (ogg_info->mount, "video_quality", "%ld",
(long)theora->ti.quality);
stats_event_args (ogg_info->mount, "frame_size", "%ld x %ld",
(long)theora->ti.frame_width,
(long)theora->ti.frame_height);
stats_event_args (ogg_info->mount, "frame_rate", "%.2f",
(float)theora->ti.fps_numerator/theora->ti.fps_denominator);
*/
}
continue;
#else
header_page = (packet.bytes>0 && (packet.packet[0]&0x80));
header_page = (packet.bytes > 0 && (packet.packet[0] & 0x80));
if (!header_page)
break;
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
* 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_codec_t *codec = calloc (1, sizeof (ogg_codec_t));
ogg_codec_t *codec = calloc(1, sizeof(ogg_codec_t));
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_pagein (&codec->os, page);
ogg_stream_init(&codec->os, ogg_page_serialno(page));
ogg_stream_pagein(&codec->os, page);
#ifdef HAVE_KATE
kate_info_init (&kate_codec->ki);
kate_comment_init (&kate_codec->kc);
#endif
ogg_stream_packetout (&codec->os, &packet);
ogg_stream_packetout(&codec->os, &packet);
ICECAST_LOG_DEBUG("checking for kate codec");
#ifdef HAVE_KATE
@ -225,7 +225,7 @@ ogg_codec_t *initial_kate_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1;
codec->name = "Kate";
format_ogg_attach_header (ogg_info, page);
format_ogg_attach_header(ogg_info, page);
ogg_info->codec_sync = codec;
return codec;
}

View File

@ -16,6 +16,6 @@
#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 */

View File

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

View File

@ -16,6 +16,6 @@
#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 */

View File

@ -13,10 +13,10 @@
*/
/* format_mp3.c
**
** format plugin for mp3
**
*/
**
** format plugin for mp3
**
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -67,21 +67,21 @@ static void format_mp3_apply_settings(client_t *client, format_plugin_t *format,
typedef struct {
unsigned int interval;
int metadata_offset;
unsigned int since_meta_block;
int in_metadata;
refbuf_t *associated;
unsigned int interval;
int metadata_offset;
unsigned int since_meta_block;
int in_metadata;
refbuf_t *associated;
} mp3_client_data;
int format_mp3_get_plugin (source_t *source)
int format_mp3_get_plugin(source_t *source)
{
const char *metadata;
format_plugin_t *plugin;
mp3_state *state = calloc(1, sizeof(mp3_state));
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->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->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) {
/* We default to MP3 audio for old clients without content types */
plugin->contenttype = "audio/mpeg";
@ -119,7 +119,7 @@ int format_mp3_get_plugin (source_t *source)
}
}
source->format = plugin;
thread_mutex_create (&state->url_lock);
thread_mutex_create(&state->url_lock);
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.
* 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 streamurl[] = "StreamUrl='";
@ -345,7 +345,7 @@ static int send_stream_metadata (client_t *client, refbuf_t *associated)
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)
{
@ -382,7 +382,7 @@ static int format_mp3_write_buf_to_client(client_t *client)
if (client_mp3->in_metadata)
{
refbuf_t *associated = refbuf->associated;
ret = send_stream_metadata (client, associated);
ret = send_stream_metadata(client, associated);
if (client_mp3->in_metadata)
break;
@ -449,12 +449,12 @@ static void format_mp3_free_plugin(format_plugin_t *self)
/* free the plugin instance */
mp3_state *state = self->_state;
thread_mutex_destroy (&state->url_lock);
free (state->url_artist);
free (state->url_title);
free (self->charset);
refbuf_release (state->metadata);
refbuf_release (state->read_data);
thread_mutex_destroy(&state->url_lock);
free(state->url_artist);
free(state->url_title);
free(self->charset);
refbuf_release(state->metadata);
refbuf_release(state->read_data);
free(state);
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
* 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;
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 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;
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)
{
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;
const char *metadata;
/* the +-2 is for overwriting the last set of \r\n */

View File

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

View File

@ -55,13 +55,13 @@
struct _ogg_state_tag;
static void format_ogg_free_plugin (format_plugin_t *plugin);
static int create_ogg_client_data(source_t *source, client_t *client);
static void free_ogg_client_data (client_t *client);
static void format_ogg_free_plugin(format_plugin_t *plugin);
static int create_ogg_client_data(source_t *source, 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 refbuf_t *ogg_get_buffer (source_t *source);
static int write_buf_to_client (client_t *client);
static void write_ogg_to_file(struct source_tag *source, refbuf_t *refbuf);
static refbuf_t *ogg_get_buffer(source_t *source);
static int write_buf_to_client(client_t *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;
@ -121,7 +121,7 @@ void format_ogg_free_headers (ogg_state_t *ogg_info)
{
refbuf_t *to_release = header;
header = header->next;
refbuf_release (to_release);
refbuf_release(to_release);
}
ogg_info->header_pages = 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 */
static void free_ogg_codecs (ogg_state_t *ogg_info)
static void free_ogg_codecs(ogg_state_t *ogg_info)
{
ogg_codec_t *codec;
if (ogg_info == NULL)
return;
format_ogg_free_headers (ogg_info);
format_ogg_free_headers(ogg_info);
/* now free the 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;
if (codec->possible_start)
refbuf_release (codec->possible_start);
codec->codec_free (ogg_info, codec);
refbuf_release(codec->possible_start);
codec->codec_free(ogg_info, codec);
codec = next;
}
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;
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->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->codec_sync = NULL;
/* 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
{
@ -223,7 +223,7 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
ogg_info->error = 1;
return -1;
}
codec = initial_vorbis_page (plugin, page);
codec = initial_vorbis_page(plugin, page);
if (codec)
break;
#ifdef HAVE_THEORA
@ -231,10 +231,10 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
if (codec)
break;
#endif
codec = initial_midi_page (plugin, page);
codec = initial_midi_page(plugin, page);
if (codec)
break;
codec = initial_flac_page (plugin, page);
codec = initial_flac_page(plugin, page);
if (codec)
break;
#ifdef HAVE_SPEEX
@ -242,13 +242,13 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
if (codec)
break;
#endif
codec = initial_kate_page (plugin, page);
codec = initial_kate_page(plugin, page);
if (codec)
break;
codec = initial_skeleton_page (plugin, page);
codec = initial_skeleton_page(plugin, page);
if (codec)
break;
codec = initial_opus_page (plugin, page);
codec = initial_opus_page(plugin, page);
if (codec)
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
* 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;
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
* 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;
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 (codec->process_page)
refbuf = codec->process_page (ogg_info, codec, page);
refbuf = codec->process_page(ogg_info, codec, page);
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
* 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;
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;
int ret;
ret = client_send_bytes (client, data, len);
ret = client_send_bytes(client, data, len);
if (ret > 0)
written += ret;
if (ret < (int)len)
written += ret;
if (ret < (int) len)
return written ? written : -1;
client_data->pos += ret;
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
* 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;
char *buf = refbuf->data + client->pos;

View File

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

View File

@ -15,6 +15,6 @@
#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 */

View File

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

View File

@ -16,6 +16,6 @@
#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 */

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;
return NULL;
}
granulepos = ogg_page_granulepos (page);
granulepos = ogg_page_granulepos(page);
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->name = "Theora";
format_ogg_attach_header (ogg_info, page);
format_ogg_attach_header(ogg_info, page);
ogg_info->codec_sync = codec;
return codec;
}

View File

@ -35,27 +35,27 @@
#include "logging.h"
typedef struct vorbis_codec_tag
typedef struct vorbis_codec_tag
{
vorbis_info vi;
vorbis_info vi;
vorbis_comment vc;
int rebuild_comment;
int stream_notify;
int initial_audio_page;
ogg_stream_state new_os;
int page_samples_trigger;
ogg_int64_t prev_granulepos;
ogg_packet *prev_packet;
ogg_int64_t granulepos;
ogg_int64_t initial_page_granulepos;
ogg_int64_t samples_in_page;
int prev_window;
int initial_audio_packet;
ogg_stream_state new_os;
int page_samples_trigger;
ogg_int64_t prev_granulepos;
ogg_packet *prev_packet;
ogg_int64_t granulepos;
ogg_int64_t initial_page_granulepos;
ogg_int64_t samples_in_page;
int prev_window;
int initial_audio_packet;
ogg_page bos_page;
ogg_packet *header [3];
ogg_page bos_page;
ogg_packet *header[3];
ogg_int64_t prev_page_samples;
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;
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
* 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;
@ -389,24 +389,24 @@ ogg_codec_t *initial_vorbis_page (format_plugin_t *plugin, ogg_page *page)
codec->headers = 1;
codec->name = "Vorbis";
free_ogg_packet (vorbis->header[0]);
free_ogg_packet (vorbis->header[1]);
free_ogg_packet (vorbis->header[2]);
memset (vorbis->header, 0, sizeof (vorbis->header));
vorbis->header [0] = copy_ogg_packet (&packet);
ogg_stream_init (&vorbis->new_os, rand());
free_ogg_packet(vorbis->header[0]);
free_ogg_packet(vorbis->header[1]);
free_ogg_packet(vorbis->header[2]);
memset(vorbis->header, 0, sizeof(vorbis->header));
vorbis->header[0] = copy_ogg_packet(&packet);
ogg_stream_init(&vorbis->new_os, rand());
codec->process_page = process_vorbis_page;
codec->process = process_vorbis;
plugin->set_tag = vorbis_set_tag;
vorbis->bos_page.header = malloc (page->header_len + page->body_len);
memcpy (vorbis->bos_page.header, page->header, page->header_len);
vorbis->bos_page.header = malloc(page->header_len + page->body_len);
memcpy(vorbis->bos_page.header, page->header, page->header_len);
vorbis->bos_page.header_len = 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;
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_info->codecs->next)
format_ogg_attach_header (ogg_info, page);
format_ogg_attach_header(ogg_info, page);
return NULL;
}
@ -540,7 +540,7 @@ static refbuf_t *process_vorbis_page (ogg_state_t *ogg_info,
return NULL;
}
header.granulepos = 0;
source_vorbis->header [codec->headers] = copy_ogg_packet (&header);
source_vorbis->header[codec->headers] = copy_ogg_packet(&header);
codec->headers++;
}
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 unsigned int fserve_clients;
static int client_tree_changed=0;
static int client_tree_changed = 0;
#ifdef HAVE_POLL
static struct pollfd *ufds = NULL;
@ -172,7 +172,7 @@ int fserve_client_waiting (void)
for (i=0; i<fserve_clients; i++)
{
if (ufds[i].revents & (POLLOUT|POLLHUP|POLLERR))
fclient->ready = 1;
fclient->ready = 1;
fclient = fclient->next;
}
return 1;
@ -180,19 +180,19 @@ int fserve_client_waiting (void)
return 0;
}
#else
int fserve_client_waiting (void)
int fserve_client_waiting(void)
{
fserve_t *fclient;
fd_set realfds;
/* only rebuild fds if there are clients added/removed */
if(client_tree_changed) {
if (client_tree_changed) {
client_tree_changed = 0;
FD_ZERO(&fds);
fd_max = SOCK_ERROR;
fclient = active_list;
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)
fd_max = fclient->client->con->sock;
fclient = fclient->next;
@ -254,7 +254,7 @@ static int wait_for_fds(void)
fserve_clients++;
}
pending_list = NULL;
thread_spin_unlock (&pending_lock);
thread_spin_unlock(&pending_lock);
}
/* drop out of here if someone is ready */
ret = fserve_client_waiting();
@ -337,7 +337,7 @@ static void *fserv_thread_function(void *arg)
}
/* 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);
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);
client_send_error(httpclient, 404, 0, "The file you requested could not be found");
config_release_config();
free (fullpath);
free(fullpath);
return -1;
}
config_release_config();
@ -692,7 +692,7 @@ void fserve_add_client_callback (client_t *client, fserve_callback_t callback, v
fclient->callback = callback;
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);
}
void fserve_recheck_mime_types (ice_config_t *config)
void fserve_recheck_mime_types(ice_config_t *config)
{
FILE *mimefile;
char line[4096];

View File

@ -43,11 +43,11 @@ int playlistlog = 0;
#ifdef _WIN32
/* Since strftime's %z option on win32 is different, we need
to go through a few loops to get the same info as %z */
to go through a few loops to get the same info as %z */
int get_clf_time (char *buffer, unsigned len, struct tm *t)
{
char sign;
char *timezone_string;
char sign;
char *timezone_string;
struct tm gmt;
time_t time1 = time(NULL);
int time_days, time_hours, time_tz;
@ -99,24 +99,24 @@ int get_clf_time (char *buffer, unsigned len, struct tm *t)
thetime = localtime(&now);
strftime (buffer, len-7, "%d/%b/%Y:%H:%M:%S", thetime);
strcat(buffer, timezone_string);
free(timezone_string);
free(timezone_string);
return 1;
}
#endif
/*
** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME]
**
** ADDR = client->con->ip
** IDENT = always - , we don't support it because it's useless
** USER = client->username
** DATE = _make_date(client->con->con_time)
** REQUEST = build from client->parser
** CODE = client->respcode
** BYTES = client->con->sent_bytes
** REFERER = get from client->parser
** AGENT = get from client->parser
** TIME = timing_get_time() - client->con->con_time
*/
** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME]
**
** ADDR = client->con->ip
** IDENT = always - , we don't support it because it's useless
** USER = client->username
** DATE = _make_date(client->con->con_time)
** REQUEST = build from client->parser
** CODE = client->respcode
** BYTES = client->con->sent_bytes
** REFERER = get from client->parser
** AGENT = get from client->parser
** TIME = timing_get_time() - client->con->con_time
*/
void logging_access(client_t *client)
{
char datebuf[128];

View File

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

View File

@ -11,10 +11,10 @@
*/
/* refbuf.c
**
** reference counting buffer implementation
**
*/
**
** reference counting buffer implementation
**
*/
#ifdef HAVE_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
* 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);
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
* update the stats for the current streams.
*/
void slave_rebuild_mounts (void)
void slave_rebuild_mounts(void)
{
thread_mutex_lock(&_slave_mutex);
update_settings = 1;
@ -357,7 +357,7 @@ static void *start_relay_stream (void *arg)
slave_rebuild_mounts();
return NULL;
} while (0); /* TODO allow looping through multiple servers */
} while (0); /* TODO allow looping through multiple servers */
if (relay->source->fallback_mount)
{
@ -365,15 +365,15 @@ static void *start_relay_stream (void *arg)
ICECAST_LOG_DEBUG("failed relay, fallback to %s", relay->source->fallback_mount);
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)
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 */
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
*/
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 *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;
active_relays = update_relay_set (relay_list, new_relay_list);
active_relays = update_relay_set(relay_list, new_relay_list);
cleanup_relays = *relay_list;
/* re-assign new set */
@ -615,12 +615,12 @@ static int update_from_master(ice_config_t *config)
int len, count = 1;
int on_demand;
username = strdup (config->master_username);
username = strdup(config->master_username);
if (config->master_password)
password = strdup (config->master_password);
password = strdup(config->master_password);
if (config->master_server)
master = strdup (config->master_server);
master = strdup(config->master_server);
port = config->master_server_port;
@ -629,7 +629,7 @@ static int update_from_master(ice_config_t *config)
on_demand = config->on_demand;
ret = 1;
config_release_config();
mastersock = sock_connect_wto (master, port, 10);
mastersock = sock_connect_wto(master, port, 10);
if (mastersock == SOCK_ERROR)
{
@ -733,9 +733,9 @@ static void *_slave_thread(void *arg)
thread_mutex_unlock(&_slave_mutex);
config = config_get_config();
stats_global (config);
stats_global(config);
config_release_config();
source_recheck_mounts (1);
source_recheck_mounts(1);
while (1)
{
@ -747,11 +747,11 @@ static void *_slave_thread(void *arg)
if (global . schedule_config_reread)
{
event_config_read (NULL);
global . schedule_config_reread = 0;
global.schedule_config_reread = 0;
}
global_unlock();
thread_sleep (1000000);
thread_sleep(1000000);
if (slave_running == 0)
break;

View File

@ -111,15 +111,15 @@ source_t *source_reserve (const char *mount)
src->pending_tree = avl_tree_new(_compare_clients, NULL);
/* make duplicates for strings or similar */
src->mount = strdup (mount);
src->mount = strdup(mount);
src->max_listeners = -1;
thread_mutex_create(&src->lock);
avl_insert (global.source_tree, src);
avl_insert(global.source_tree, src);
} while (0);
avl_tree_unlock (global.source_tree);
avl_tree_unlock(global.source_tree);
return src;
}
@ -138,9 +138,9 @@ source_t *source_find_mount_raw(const char *mount)
}
/* get the root node */
node = global.source_tree->root->right;
while (node) {
source = (source_t *)node->key;
source = (source_t *) node->key;
cmp = strcmp(mount, source->mount);
if (cmp < 0)
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
* this function.
*/
source_t *source_find_mount (const char *mount)
source_t *source_find_mount(const char *mount)
{
source_t *source = NULL;
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
* 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;
if (mountinfo == NULL)
@ -283,7 +283,7 @@ void source_clear_source (source_t *source)
source->hidden = 0;
source->shoutcast_compat = 0;
source->client_stats_update = 0;
util_dict_free (source->audio_info);
util_dict_free(source->audio_info);
source->audio_info = NULL;
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
* 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;
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
* locks in this order to avoid deadlocks */
avl_tree_wlock (source->pending_tree);
avl_tree_wlock (source->client_tree);
avl_tree_wlock(source->pending_tree);
avl_tree_wlock(source->client_tree);
if (source->on_demand == 0 && source->format == NULL)
{
@ -567,12 +567,12 @@ static void send_to_listener (source_t *source, client_t *client, int deletion_e
loop--;
if (client->check_buffer (source, client) < 0)
if (client->check_buffer(source, client) < 0)
break;
bytes = client->write_to_client (client);
bytes = client->write_to_client(client);
if (bytes <= 0)
break; /* can't write any more */
break; /* can't write any more */
total_written += bytes;
}
@ -734,7 +734,7 @@ void source_main (source_t *source)
source->stream_data_tail = refbuf;
source->queue_size += refbuf->len;
/* new buffer is referenced for burst */
refbuf_addref (refbuf);
refbuf_addref(refbuf);
/* new data on queue, so check the burst point */
source->burst_offset += refbuf->len;
@ -746,7 +746,7 @@ void source_main (source_t *source)
{
source->burst_point = to_release->next;
source->burst_offset -= to_release->len;
refbuf_release (to_release);
refbuf_release(to_release);
continue;
}
break;
@ -754,7 +754,7 @@ void source_main (source_t *source)
/* save stream 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 */
thread_mutex_lock(&source->lock);
@ -770,15 +770,15 @@ void source_main (source_t *source)
client_node = avl_get_first(source->client_tree);
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) {
client_node = avl_get_next(client_node);
if (client->respcode == 200)
stats_event_dec (NULL, "listeners");
avl_delete(source->client_tree, (void *)client, _free_client);
stats_event_dec(NULL, "listeners");
avl_delete(source->client_tree, (void *) client, _free_client);
source->listeners--;
ICECAST_LOG_DEBUG("Client removed");
continue;
@ -900,24 +900,24 @@ static void source_shutdown (source_t *source)
source_t *fallback_source;
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)
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 */
stats_event(source->mount, NULL, NULL);
/* we don't remove the source from the tree here, it may be a relay and
therefore reserved */
source_clear_source (source);
therefore reserved */
source_clear_source(source);
global_lock();
global.sources--;
stats_event_args (NULL, "sources", "%d", global.sources);
stats_event_args(NULL, "sources", "%d", global.sources);
global_unlock();
/* 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)
{
client_t *clienta = (client_t *)a;
client_t *clientb = (client_t *)b;
client_t *clienta = (client_t *) a;
client_t *clientb = (client_t *) b;
connection_t *cona = clienta->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;
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)
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_source_t *_find_source(avl_tree *tree, const char *source);
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 */
@ -136,7 +136,7 @@ void stats_initialize(void)
thread_mutex_create(&_stats_mutex);
/* set up stats queues */
event_queue_init (&_global_event_queue);
event_queue_init(&_global_event_queue);
thread_mutex_create(&_global_event_mutex);
/* fire off the stats thread */
@ -148,7 +148,7 @@ void stats_shutdown(void)
{
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;
/* wait for thread to exit */
@ -190,7 +190,7 @@ void stats_shutdown(void)
stats_t *stats_get_stats(void)
{
/* lock global stats
copy stats
unlock global stats
@ -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);
return;
}
event = build_event (source, name, value);
event = build_event(source, name, value);
if (event)
queue_global_event (event);
queue_global_event(event);
}
@ -371,9 +371,9 @@ static stats_node_t *_find_node(avl_tree *stats_tree, const char *name)
/* get the root node */
node = stats_tree->root->right;
while (node) {
stats = (stats_node_t *)node->key;
stats = (stats_node_t *) node->key;
cmp = strcmp(name, stats->name);
if (cmp < 0)
node = node->left;
@ -399,7 +399,7 @@ static stats_source_t *_find_source(avl_tree *source_tree, const char *source)
/* get the root node */
node = source_tree->root->right;
while (node) {
stats = (stats_source_t *)node->key;
stats = (stats_source_t *) node->key;
cmp = strcmp(source, stats->source);
if (cmp < 0)
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 */
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;
@ -532,7 +532,7 @@ static void process_source_event (stats_event_t *event)
else
snode->hidden = 0;
avl_insert(_stats.source_tree, (void *)snode);
avl_insert(_stats.source_tree, (void *) snode);
}
if (event->name)
{
@ -871,12 +871,12 @@ static void _register_listener (event_listener_t *listener)
thread_mutex_lock(&_stats_mutex);
/* first we fill our queue with the current stats */
/* start with the global stats */
node = avl_get_first(_stats.global_tree);
while (node) {
event = _make_event_from_node((stats_node_t *)node->key, NULL);
_add_event_to_queue (event, &listener->queue);
event = _make_event_from_node((stats_node_t *) node->key, NULL);
_add_event_to_queue(event, &listener->queue);
node = avl_get_next(node);
}
@ -974,15 +974,15 @@ typedef struct _source_xml_tag {
void stats_transform_xslt(client_t *client, const char *uri)
{
xmlDocPtr doc;
char *xslpath = util_get_path_from_normalised_uri (uri);
const char *mount = httpp_get_query_param (client->parser, "mount");
char *xslpath = util_get_path_from_normalised_uri(uri);
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);
xmlFreeDoc(doc);
free (xslpath);
free(xslpath);
}
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);
}
thread_mutex_unlock (&_stats_mutex);
thread_mutex_unlock(&_stats_mutex);
cur->len = STREAMLIST_BLKSIZE - remaining;
return start;
}

View File

@ -396,7 +396,7 @@ char *util_bin_to_hex(unsigned char *data, int len)
char *hex = malloc(len*2 + 1);
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+1] = hexchars[data[i]&0x0f];
}
@ -422,15 +422,15 @@ char *util_base64_encode(const char *data)
case 3:
*out++ = base64table[((*(data+1) & 0x0F)<<2) | ((*(data+2) & 0xC0)>>6)];
*out++ = base64table[(*(data+2)) & 0x3F];
break;
break;
case 2:
*out++ = base64table[((*(data+1) & 0x0F)<<2)];
*out++ = '=';
break;
break;
case 1:
*out++ = '=';
*out++ = '=';
break;
break;
}
data += chunk;
len -= chunk;

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);
#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
char *util_conv_string (const char *string, const char *in_charset, const char *out_charset);

View File

@ -57,10 +57,10 @@
#include "logging.h"
typedef struct {
char *filename;
time_t last_modified;
time_t cache_age;
xsltStylesheetPtr stylesheet;
char *filename;
time_t last_modified;
time_t cache_age;
xsltStylesheetPtr stylesheet;
} stylesheet_cache_t;
#ifndef HAVE_XSLTSAVERESULTTOSTRING
@ -70,21 +70,21 @@ int xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len, xmlDocPtr r
*doc_txt_ptr = NULL;
*doc_txt_len = 0;
if (result->children == NULL)
return(0);
return (0);
buf = xmlAllocOutputBuffer(NULL);
buf = xmlAllocOutputBuffer(NULL);
if (buf == NULL)
return(-1);
return (-1);
xsltSaveResultTo(buf, result, style);
if (buf->conv != NULL) {
*doc_txt_len = buf->conv->use;
*doc_txt_ptr = xmlStrndup(buf->conv->content, *doc_txt_len);
*doc_txt_len = buf->conv->use;
*doc_txt_ptr = xmlStrndup(buf->conv->content, *doc_txt_len);
} else {
*doc_txt_len = buf->buffer->use;
*doc_txt_ptr = xmlStrndup(buf->buffer->content, *doc_txt_len);
*doc_txt_len = buf->buffer->use;
*doc_txt_ptr = xmlStrndup(buf->buffer->content, *doc_txt_len);
}
(void)xmlOutputBufferClose(buf);
(void) xmlOutputBufferClose(buf);
return 0;
}
#endif
@ -97,7 +97,7 @@ static mutex_t xsltlock;
void xslt_initialize(void)
{
memset(cache, 0, sizeof(stylesheet_cache_t)*CACHESIZE);
memset(cache, 0, sizeof(stylesheet_cache_t) * CACHESIZE);
thread_mutex_create(&xsltlock);
xmlInitParser();
LIBXML_TEST_VERSION
@ -159,9 +159,9 @@ static xsltStylesheetPtr xslt_get_stylesheet(const char *fn) {
if(file.st_mtime > cache[i].last_modified)
{
xsltFreeStylesheet(cache[i].stylesheet);
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);
}
ICECAST_LOG_DEBUG("Using cached sheet %i", i);
@ -179,22 +179,22 @@ static xsltStylesheetPtr xslt_get_stylesheet(const char *fn) {
cache[i].last_modified = file.st_mtime;
cache[i].filename = strdup(fn);
cache[i].stylesheet = xsltParseStylesheetFile (XMLSTR(fn));
cache[i].stylesheet = xsltParseStylesheetFile(XMLSTR(fn));
cache[i].cache_age = time(NULL);
return cache[i].stylesheet;
}
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
{
xmlDocPtr res;
xmlDocPtr res;
xsltStylesheetPtr cur;
xmlChar *string;
int len, problem = 0;
const char *mediatype = NULL;
const char *charset = NULL;
xmlSetGenericErrorFunc ("", log_parse_failure);
xsltSetGenericErrorFunc ("", log_parse_failure);
xmlSetGenericErrorFunc("", log_parse_failure);
xsltSetGenericErrorFunc("", log_parse_failure);
thread_mutex_lock(&xsltlock);
cur = xslt_get_stylesheet(xslfilename);

View File

@ -74,10 +74,10 @@ typedef struct ypdata_tag
char *subtype;
struct yp_server *server;
time_t next_update;
unsigned touch_interval;
char *error_msg;
int (*process)(struct ypdata_tag *yp, char *s, unsigned len);
time_t next_update;
unsigned touch_interval;
char *error_msg;
int (*process)(struct ypdata_tag *yp, char *s, unsigned len);
struct ypdata_tag *next;
} ypdata_t;
@ -95,10 +95,10 @@ static volatile unsigned client_limit = 0;
static volatile char *server_version = NULL;
static void *yp_update_thread(void *arg);
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_add (ypdata_t *yp, char *s, unsigned len);
static int do_yp_touch (ypdata_t *yp, char *s, unsigned len);
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_add(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);
@ -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);
}
yp->process = do_yp_add;
free (yp->sid);
free(yp->sid);
yp->sid = NULL;
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;
char *s = NULL, *tmp;
@ -503,7 +503,7 @@ static int process_ypdata (struct yp_server *server, ypdata_t *yp)
while (1)
{
int ret;
if ((tmp = realloc (s, len)) == NULL)
if ((tmp = realloc(s, len)) == NULL)
return 0;
s = tmp;
@ -625,7 +625,7 @@ static void check_servers (void)
ICECAST_LOG_DEBUG("YP server \"%s\"removed", server->url);
*server_p = server->next;
server = server->next;
destroy_yp_server (to_go);
destroy_yp_server(to_go);
continue;
}
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;
@ -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);
*prev = yp->next;
yp = yp->next;
yp_destroy_ypdata (to_go);
yp_destroy_ypdata(to_go);
continue;
}
prev = &yp->next;
@ -768,10 +768,10 @@ static void yp_destroy_ypdata(ypdata_t *ypdata)
{
if (ypdata) {
if (ypdata->mount) {
free (ypdata->mount);
free(ypdata->mount);
}
if (ypdata->url) {
free (ypdata->url);
free(ypdata->url);
}
if (ypdata->sid) {
free(ypdata->sid);
@ -803,13 +803,13 @@ static void yp_destroy_ypdata(ypdata_t *ypdata)
if (ypdata->audio_info) {
free(ypdata->audio_info);
}
free (ypdata->subtype);
free (ypdata->error_msg);
free (ypdata);
free(ypdata->subtype);
free(ypdata->error_msg);
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;

View File

@ -14,18 +14,18 @@
#ifndef __YP_H__
#define __YP_H__
#define YP_SERVER_NAME 1
#define YP_SERVER_DESC 2
#define YP_SERVER_GENRE 3
#define YP_SERVER_URL 4
#define YP_BITRATE 5
#define YP_AUDIO_INFO 6
#define YP_SERVER_TYPE 7
#define YP_CURRENT_SONG 8
#define YP_CLUSTER_PASSWORD 9
#define YP_SUBTYPE 10
#define YP_SERVER_NAME 1
#define YP_SERVER_DESC 2
#define YP_SERVER_GENRE 3
#define YP_SERVER_URL 4
#define YP_BITRATE 5
#define YP_AUDIO_INFO 6
#define YP_SERVER_TYPE 7
#define YP_CURRENT_SONG 8
#define YP_CLUSTER_PASSWORD 9
#define YP_SUBTYPE 10
#define YP_ADD_ALL -1
#define YP_ADD_ALL -1
#ifdef USE_YP
void yp_add (const char *mount);