Commit 3b2df1d0 authored by Michael Smith's avatar Michael Smith

Brendan was getting pissed off about inconsistent indentation styles.

Convert all tabs to 4 spaces. All code must now use 4 space indents.

svn path=/trunk/avl/; revision=4492
parent bd9c2383
......@@ -96,7 +96,7 @@ void admin_handle_request(client_t *client, char *uri)
/* This is a mount request, handle it as such */
if(!connection_check_admin_pass(client->parser)) {
if(!connection_check_source_pass(client->parser, mount)) {
INFO1("Bad or missing password on mount modification admin "
INFO1("Bad or missing password on mount modification admin "
"request (command: %s)", command_string);
client_send_401(client);
return;
......@@ -122,7 +122,7 @@ void admin_handle_request(client_t *client, char *uri)
else {
if(!connection_check_admin_pass(client->parser)) {
INFO1("Bad or missing password on admin command "
INFO1("Bad or missing password on admin command "
"request (command: %s)", command_string);
client_send_401(client);
return;
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 by Sam Rushing <rushing@nightmare.com>
*/
/* $Id: avl.h,v 1.5 2003/03/09 22:56:46 karl Exp $ */
/* $Id: avl.h,v 1.6 2003/03/15 02:10:18 msmith Exp $ */
#ifndef __AVL_H
#define __AVL_H
......@@ -22,24 +22,24 @@ extern "C" {
#endif
typedef struct avl_node_tag {
void * key;
struct avl_node_tag * left;
struct avl_node_tag * right;
struct avl_node_tag * parent;
void * key;
struct avl_node_tag * left;
struct avl_node_tag * right;
struct avl_node_tag * parent;
/*
* The lower 2 bits of <rank_and_balance> specify the balance
* factor: 00==-1, 01==0, 10==+1.
* The rest of the bits are used for <rank>
*/
unsigned long rank_and_balance;
unsigned long rank_and_balance;
#ifndef NO_THREAD
rwlock_t rwlock;
#endif
} avl_node;
#define AVL_GET_BALANCE(n) ((int)(((n)->rank_and_balance & 3) - 1))
#define AVL_GET_BALANCE(n) ((int)(((n)->rank_and_balance & 3) - 1))
#define AVL_GET_RANK(n) (((n)->rank_and_balance >> 2))
#define AVL_GET_RANK(n) (((n)->rank_and_balance >> 2))
#define AVL_SET_BALANCE(n,b) \
((n)->rank_and_balance) = \
......@@ -51,11 +51,11 @@ typedef struct avl_node_tag {
struct _avl_tree;
typedef int (*avl_key_compare_fun_type) (void * compare_arg, void * a, void * b);
typedef int (*avl_iter_fun_type) (void * key, void * iter_arg);
typedef int (*avl_iter_index_fun_type) (unsigned long index, void * key, void * iter_arg);
typedef int (*avl_free_key_fun_type) (void * key);
typedef int (*avl_key_printer_fun_type) (char *, void *);
typedef int (*avl_key_compare_fun_type) (void * compare_arg, void * a, void * b);
typedef int (*avl_iter_fun_type) (void * key, void * iter_arg);
typedef int (*avl_iter_index_fun_type) (unsigned long index, void * key, void * iter_arg);
typedef int (*avl_free_key_fun_type) (void * key);
typedef int (*avl_key_printer_fun_type) (char *, void *);
/*
* <compare_fun> and <compare_arg> let us associate a particular compare
......@@ -63,11 +63,11 @@ typedef int (*avl_key_printer_fun_type) (char *, void *);
*/
typedef struct _avl_tree {
avl_node * root;
unsigned long height;
unsigned long length;
avl_key_compare_fun_type compare_fun;
void * compare_arg;
avl_node * root;
unsigned long height;
unsigned long length;
avl_key_compare_fun_type compare_fun;
void * compare_arg;
#ifndef NO_THREAD
rwlock_t rwlock;
#endif
......@@ -77,66 +77,66 @@ avl_tree * avl_tree_new (avl_key_compare_fun_type compare_fun, void * compare_ar
avl_node * avl_node_new (void * key, avl_node * parent);
void avl_tree_free (
avl_tree * tree,
avl_free_key_fun_type free_key_fun
avl_tree * tree,
avl_free_key_fun_type free_key_fun
);
int avl_insert (
avl_tree * ob,
void * key
avl_tree * ob,
void * key
);
int avl_delete (
avl_tree * tree,
void * key,
avl_free_key_fun_type free_key_fun
avl_tree * tree,
void * key,
avl_free_key_fun_type free_key_fun
);
int avl_get_by_index (
avl_tree * tree,
unsigned long index,
void ** value_address
avl_tree * tree,
unsigned long index,
void ** value_address
);
int avl_get_by_key (
avl_tree * tree,
void * key,
void ** value_address
avl_tree * tree,
void * key,
void ** value_address
);
int avl_iterate_inorder (
avl_tree * tree,
avl_iter_fun_type iter_fun,
void * iter_arg
avl_tree * tree,
avl_iter_fun_type iter_fun,
void * iter_arg
);
int avl_iterate_index_range (
avl_tree * tree,
avl_tree * tree,
avl_iter_index_fun_type iter_fun,
unsigned long low,
unsigned long high,
void * iter_arg
unsigned long low,
unsigned long high,
void * iter_arg
);
int avl_get_span_by_key (
avl_tree * tree,
void * key,
unsigned long * low,
unsigned long * high
avl_tree * tree,
void * key,
unsigned long * low,
unsigned long * high
);
int avl_get_span_by_two_keys (
avl_tree * tree,
void * key_a,
void * key_b,
unsigned long * low,
unsigned long * high
avl_tree * tree,
void * key_a,
void * key_b,
unsigned long * low,
unsigned long * high
);
int avl_verify (avl_tree * tree);
void avl_print_tree (
avl_tree * tree,
avl_tree * tree,
avl_key_printer_fun_type key_printer
);
......@@ -149,15 +149,15 @@ avl_node *avl_get_next(avl_node * node);
/* These two are from David Ascher <david_ascher@brown.edu> */
int avl_get_item_by_key_most (
avl_tree * tree,
void * key,
void ** value_address
avl_tree * tree,
void * key,
void ** value_address
);
int avl_get_item_by_key_least (
avl_tree * tree,
void * key,
void ** value_address
avl_tree * tree,
void * key,
void ** value_address
);
/* optional locking stuff */
......
......@@ -11,75 +11,75 @@ int _printer(char *buff, void *key);
int main(int argc, char **argv)
{
int i, max_nodes;
avl_tree *tree;
avl_node *node;
max_nodes = 25;
if (argc == 2) {
max_nodes = atoi(argv[1]);
if (max_nodes == 0)
max_nodes = 10;
}
printf("avl test... max_nodes = %d...\n", max_nodes);
tree = avl_tree_new(_compare, NULL);
printf("Filling tree...\n");
for (i = 0; i < max_nodes; i++) {
avl_insert(tree, (void *)rand());
}
printf("Traversing tree...\n");
node = avl_get_first(tree);
while (node) {
i = (int)node->key;
printf("...%5d\n", i);
node = avl_get_next(node);
}
printf("Trying to go backwards...\n");
node = tree->root->right;
while (node) {
i = (int)node->key;
printf("...%5d\n", i);
node = avl_get_prev(node);
}
printf("Printing tree...\n");
avl_print_tree(tree, _printer);
avl_tree_free(tree, _free);
return 0;
int i, max_nodes;
avl_tree *tree;
avl_node *node;
max_nodes = 25;
if (argc == 2) {
max_nodes = atoi(argv[1]);
if (max_nodes == 0)
max_nodes = 10;
}
printf("avl test... max_nodes = %d...\n", max_nodes);
tree = avl_tree_new(_compare, NULL);
printf("Filling tree...\n");
for (i = 0; i < max_nodes; i++) {
avl_insert(tree, (void *)rand());
}
printf("Traversing tree...\n");
node = avl_get_first(tree);
while (node) {
i = (int)node->key;
printf("...%5d\n", i);
node = avl_get_next(node);
}
printf("Trying to go backwards...\n");
node = tree->root->right;
while (node) {
i = (int)node->key;
printf("...%5d\n", i);
node = avl_get_prev(node);
}
printf("Printing tree...\n");
avl_print_tree(tree, _printer);
avl_tree_free(tree, _free);
return 0;
}
int _compare(void *compare_arg, void *a, void *b)
{
int i, j;
int i, j;
i = (int)a;
j = (int)b;
i = (int)a;
j = (int)b;
if (i > j)
return 1;
if (j > i)
return -1;
return 0;
if (i > j)
return 1;
if (j > i)
return -1;
return 0;
}
int _free(void *key)
{
return 1;
return 1;
}
int _printer(char *buff, void *key)
{
return snprintf(buff, 25, "%d", (int)key);
return snprintf(buff, 25, "%d", (int)key);
}
......
......@@ -19,33 +19,33 @@
client_t *client_create(connection_t *con, http_parser_t *parser)
{
client_t *client = (client_t *)calloc(1, sizeof(client_t));
client_t *client = (client_t *)calloc(1, sizeof(client_t));
client->con = con;
client->parser = parser;
client->queue = NULL;
client->pos = 0;
client->con = con;
client->parser = parser;
client->queue = NULL;
client->pos = 0;
return client;
return client;
}
void client_destroy(client_t *client)
{
refbuf_t *refbuf;
refbuf_t *refbuf;
/* write log entry if ip is set (some things don't set it, like outgoing
/* write log entry if ip is set (some things don't set it, like outgoing
* slave requests
*/
if(client->con->ip)
logging_access(client);
connection_close(client->con);
httpp_destroy(client->parser);
logging_access(client);
connection_close(client->con);
httpp_destroy(client->parser);
while ((refbuf = refbuf_queue_remove(&client->queue)))
refbuf_release(refbuf);
while ((refbuf = refbuf_queue_remove(&client->queue)))
refbuf_release(refbuf);
free(client);
free(client);
}
void client_send_400(client_t *client, char *message) {
......@@ -72,12 +72,12 @@ void client_send_404(client_t *client, char *message) {
void client_send_504(client_t *client, char *message) {
int bytes;
client->respcode = 504;
bytes = sock_write(client->con->sock,
bytes = sock_write(client->con->sock,
"HTTP/1.0 504 Server Full\r\n"
"Content-Type: text/html\r\n\r\n"
"<b>%s</b>\r\n", message);
if (bytes > 0) client->con->sent_bytes = bytes;
client_destroy(client);
if (bytes > 0) client->con->sent_bytes = bytes;
client_destroy(client);
}
void client_send_401(client_t *client) {
......
......@@ -10,18 +10,18 @@
typedef struct _client_tag
{
/* the clients connection */
connection_t *con;
/* the clients http headers */
http_parser_t *parser;
/* the clients connection */
connection_t *con;
/* the clients http headers */
http_parser_t *parser;
/* http response code for this client */
int respcode;
/* http response code for this client */
int respcode;
/* buffer queue */
refbuf_queue_t *queue;
/* position in first buffer */
unsigned long pos;
/* buffer queue */
refbuf_queue_t *queue;
/* position in first buffer */
unsigned long pos;
/* Format-handler-specific data for this client */
void *format_data;
......
This diff is collapsed.
......@@ -15,9 +15,9 @@
typedef struct ice_config_dir_tag
{
char *host;
int touch_interval;
struct ice_config_dir_tag *next;
char *host;
int touch_interval;
struct ice_config_dir_tag *next;
} ice_config_dir_t;
typedef struct _relay_server {
......@@ -52,33 +52,33 @@ typedef struct ice_config_tag
{
char *config_filename;
char *location;
char *admin;
char *location;
char *admin;
int client_limit;
int source_limit;
int client_limit;
int source_limit;
long queue_size_limit;
int threadpool_size;
int client_timeout;
int header_timeout;
int source_timeout;
int threadpool_size;
int client_timeout;
int header_timeout;
int source_timeout;
int ice_login;
int fileserve;
char *source_password;
char *source_password;
char *admin_username;
char *admin_password;
int touch_interval;
ice_config_dir_t *dir_list;
int touch_interval;
ice_config_dir_t *dir_list;
char *hostname;
char *hostname;
int port;
listener_t listeners[MAX_LISTEN_SOCKETS];
char *master_server;
int master_server_port;
char *master_server;
int master_server_port;
int master_update_interval;
char *master_password;
......@@ -86,12 +86,12 @@ typedef struct ice_config_tag
mount_proxy *mounts;
char *base_dir;
char *log_dir;
char *webroot_dir;
char *base_dir;
char *log_dir;
char *webroot_dir;
char *access_log;
char *error_log;
char *access_log;
char *error_log;
int loglevel;
int chroot;
......@@ -99,7 +99,7 @@ typedef struct ice_config_tag
char *user;
char *group;
char *yp_url[MAX_YP_DIRECTORIES];
int yp_url_timeout[MAX_YP_DIRECTORIES];
int yp_url_timeout[MAX_YP_DIRECTORIES];
int num_yp_directories;
} ice_config_t;
......
......@@ -5,52 +5,52 @@ void _dump_config(ice_config_t *config);
int main(void)
{
ice_config_t *config;
ice_config_t *config;
config_initialize();
config_parse_file("icecast.xml");
config_initialize();
config_parse_file("icecast.xml");
config = config_get_config_unlocked();
config = config_get_config_unlocked();
_dump_config(config);
_dump_config(config);
config_shutdown();
config_shutdown();
return 0;
return 0;
}
void _dump_config(ice_config_t *config)
{
ice_config_dir_t *node;
printf("-----\n");
printf("location = %s\n", config->location);
printf("admin = %s\n", config->admin);
printf("client_limit = %d\n", config->client_limit);
printf("source_limit = %d\n", config->source_limit);
printf("threadpool_size = %d\n", config->threadpool_size);
printf("client_timeout = %d\n", config->client_timeout);
printf("source_password = %s\n", config->source_password);
printf("touch_interval = %d\n", config->touch_interval);
node = config->dir_list;
while (node) {
printf("directory.touch_interval = %d\n", node->touch_interval);
printf("directory.host = %s\n", node->host);
node = node->next;
}
printf("hostname = %s\n", config->hostname);
printf("port = %d\n", config->port);
printf("bind_address = %s\n", config->bind_address);
printf("base_dir = %s\n", config->base_dir);
printf("log_dir = %s\n", config->log_dir);
printf("access_log = %s\n", config->access_log);
printf("error_log = %s\n", config->error_log);
printf("loglevel = %d\n", config->loglevel);
printf("-----\n");
ice_config_dir_t *node;
printf("-----\n");
printf("location = %s\n", config->location);
printf("admin = %s\n", config->admin);
printf("client_limit = %d\n", config->client_limit);
printf("source_limit = %d\n", config->source_limit);
printf("threadpool_size = %d\n", config->threadpool_size);
printf("client_timeout = %d\n", config->client_timeout);
printf("source_password = %s\n", config->source_password);
printf("touch_interval = %d\n", config->touch_interval);
node = config->dir_list;
while (node) {
printf("directory.touch_interval = %d\n", node->touch_interval);
printf("directory.host = %s\n", node->host);
node = node->next;
}
printf("hostname = %s\n", config->hostname);
printf("port = %d\n", config->port);
printf("bind_address = %s\n", config->bind_address);
printf("base_dir = %s\n", config->base_dir);
printf("log_dir = %s\n", config->log_dir);
printf("access_log = %s\n", config->access_log);
printf("error_log = %s\n", config->error_log);
printf("loglevel = %d\n", config->loglevel);
printf("-----\n");
}
......
This diff is collapsed.
......@@ -11,16 +11,16 @@ struct _client_tag;
typedef struct connection_tag
{
unsigned long id;
unsigned long id;
time_t con_time;
uint64_t sent_bytes;
time_t con_time;
uint64_t sent_bytes;
int sock;
int error;
int sock;
int error;
char *ip;
char *host;
char *ip;
char *host;
/* For 'fake' connections */
int event_number;
......
......@@ -12,7 +12,7 @@ void event_config_read(void *arg)
int ret;
ice_config_t *config;
ice_config_t new_config;
/* reread config file */
/* reread config file */
config = config_get_config(); /* Both to get the lock, and to be able
to find out the config filename */
......
......@@ -57,23 +57,23 @@ char *format_get_mimetype(format_type_t type)
format_plugin_t *format_get_plugin(format_type_t type, char *mount,
http_parser_t *parser)
{
format_plugin_t *plugin;
format_plugin_t *plugin;
switch (type) {
case FORMAT_TYPE_VORBIS:
plugin = format_vorbis_get_plugin();
if (plugin) plugin->mount = mount;
break;
switch (type) {
case FORMAT_TYPE_VORBIS:
plugin = format_vorbis_get_plugin();
if (plugin) plugin->mount = mount;
break;
case FORMAT_TYPE_MP3:
plugin = format_mp3_get_plugin(parser);
if (plugin) plugin->mount = mount;
break;
default:
plugin = NULL;
break;
}
default:
plugin = NULL;
break;
}
return plugin;
return plugin;
}
int format_generic_write_buf_to_client(format_plugin_t *format,
......@@ -102,21 +102,21 @@ void format_send_general_headers(format_plugin_t *format,
avl_node *node;
int bytes;
/* iterate through source http headers and send to client */
avl_tree_rlock(source->parser->vars);
node = avl_get_first(source->parser->vars);
while (node) {
var = (http_var_t *)node->key;
if (strcasecmp(var->name, "ice-password") &&
/* iterate through source http headers and send to client */
avl_tree_rlock(source->parser->vars);
node = avl_get_first(source->parser->vars);
while (node) {
var = (http_var_t *)node->key;
if (strcasecmp(var->name, "ice-password") &&
(!strncasecmp("ice-", var->name, 4) ||
!strncasecmp("icy-", var->name, 4))) {
bytes = sock_write(client->con->sock,
"%s: %s\r\n", var->name, var->value);
if(bytes > 0) client->con->sent_bytes += bytes;
}
node = avl_get_next(node);
}
avl_tree_unlock(source->parser->vars);
}
node = avl_get_next(node);
}
avl_tree_unlock(source->parser->vars);
bytes = sock_write(client->con->sock,
"Server: %s\r\n", ICECAST_VERSION_STRING);
if(bytes > 0) client->con->sent_bytes += bytes;
......
......@@ -14,28 +14,28 @@ struct source_tag;
typedef enum _format_type_tag
{
FORMAT_TYPE_VORBIS,
FORMAT_TYPE_MP3,
FORMAT_TYPE_VORBIS,
FORMAT_TYPE_MP3,
FORMAT_ERROR /* No format, source not processable */
} format_type_t;
typedef struct _format_plugin_tag