OSUOSL/Nero are experiencing Internet connectivity problems. This affects us as we're hosted with OSUOSL. We apologize for the inconvenience.

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) ...@@ -96,7 +96,7 @@ void admin_handle_request(client_t *client, char *uri)
/* This is a mount request, handle it as such */ /* This is a mount request, handle it as such */
if(!connection_check_admin_pass(client->parser)) { if(!connection_check_admin_pass(client->parser)) {
if(!connection_check_source_pass(client->parser, mount)) { 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); "request (command: %s)", command_string);
client_send_401(client); client_send_401(client);
return; return;
...@@ -122,7 +122,7 @@ void admin_handle_request(client_t *client, char *uri) ...@@ -122,7 +122,7 @@ void admin_handle_request(client_t *client, char *uri)
else { else {
if(!connection_check_admin_pass(client->parser)) { 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); "request (command: %s)", command_string);
client_send_401(client); client_send_401(client);
return; return;
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 1995 by Sam Rushing <rushing@nightmare.com> * 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 #ifndef __AVL_H
#define __AVL_H #define __AVL_H
...@@ -22,24 +22,24 @@ extern "C" { ...@@ -22,24 +22,24 @@ extern "C" {
#endif #endif
typedef struct avl_node_tag { typedef struct avl_node_tag {
void * key; void * key;
struct avl_node_tag * left; struct avl_node_tag * left;
struct avl_node_tag * right; struct avl_node_tag * right;
struct avl_node_tag * parent; struct avl_node_tag * parent;
/* /*
* The lower 2 bits of <rank_and_balance> specify the balance * The lower 2 bits of <rank_and_balance> specify the balance
* factor: 00==-1, 01==0, 10==+1. * factor: 00==-1, 01==0, 10==+1.
* The rest of the bits are used for <rank> * The rest of the bits are used for <rank>
*/ */
unsigned long rank_and_balance; unsigned long rank_and_balance;
#ifndef NO_THREAD #ifndef NO_THREAD
rwlock_t rwlock; rwlock_t rwlock;
#endif #endif
} avl_node; } 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) \ #define AVL_SET_BALANCE(n,b) \
((n)->rank_and_balance) = \ ((n)->rank_and_balance) = \
...@@ -51,11 +51,11 @@ typedef struct avl_node_tag { ...@@ -51,11 +51,11 @@ typedef struct avl_node_tag {
struct _avl_tree; struct _avl_tree;
typedef int (*avl_key_compare_fun_type) (void * compare_arg, void * a, void * b); 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_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_iter_index_fun_type) (unsigned long index, void * key, void * iter_arg);
typedef int (*avl_free_key_fun_type) (void * key); typedef int (*avl_free_key_fun_type) (void * key);
typedef int (*avl_key_printer_fun_type) (char *, void *); typedef int (*avl_key_printer_fun_type) (char *, void *);
/* /*
* <compare_fun> and <compare_arg> let us associate a particular compare * <compare_fun> and <compare_arg> let us associate a particular compare
...@@ -63,11 +63,11 @@ typedef int (*avl_key_printer_fun_type) (char *, void *); ...@@ -63,11 +63,11 @@ typedef int (*avl_key_printer_fun_type) (char *, void *);
*/ */
typedef struct _avl_tree { typedef struct _avl_tree {
avl_node * root; avl_node * root;
unsigned long height; unsigned long height;
unsigned long length; unsigned long length;
avl_key_compare_fun_type compare_fun; avl_key_compare_fun_type compare_fun;
void * compare_arg; void * compare_arg;
#ifndef NO_THREAD #ifndef NO_THREAD
rwlock_t rwlock; rwlock_t rwlock;
#endif #endif
...@@ -77,66 +77,66 @@ avl_tree * avl_tree_new (avl_key_compare_fun_type compare_fun, void * compare_ar ...@@ -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); avl_node * avl_node_new (void * key, avl_node * parent);
void avl_tree_free ( void avl_tree_free (
avl_tree * tree, avl_tree * tree,
avl_free_key_fun_type free_key_fun avl_free_key_fun_type free_key_fun
); );
int avl_insert ( int avl_insert (
avl_tree * ob, avl_tree * ob,
void * key void * key
); );
int avl_delete ( int avl_delete (
avl_tree * tree, avl_tree * tree,
void * key, void * key,
avl_free_key_fun_type free_key_fun avl_free_key_fun_type free_key_fun
); );
int avl_get_by_index ( int avl_get_by_index (
avl_tree * tree, avl_tree * tree,
unsigned long index, unsigned long index,
void ** value_address void ** value_address
); );
int avl_get_by_key ( int avl_get_by_key (
avl_tree * tree, avl_tree * tree,
void * key, void * key,
void ** value_address void ** value_address
); );
int avl_iterate_inorder ( int avl_iterate_inorder (
avl_tree * tree, avl_tree * tree,
avl_iter_fun_type iter_fun, avl_iter_fun_type iter_fun,
void * iter_arg void * iter_arg
); );
int avl_iterate_index_range ( int avl_iterate_index_range (
avl_tree * tree, avl_tree * tree,
avl_iter_index_fun_type iter_fun, avl_iter_index_fun_type iter_fun,
unsigned long low, unsigned long low,
unsigned long high, unsigned long high,
void * iter_arg void * iter_arg
); );
int avl_get_span_by_key ( int avl_get_span_by_key (
avl_tree * tree, avl_tree * tree,
void * key, void * key,
unsigned long * low, unsigned long * low,
unsigned long * high unsigned long * high
); );
int avl_get_span_by_two_keys ( int avl_get_span_by_two_keys (
avl_tree * tree, avl_tree * tree,
void * key_a, void * key_a,
void * key_b, void * key_b,
unsigned long * low, unsigned long * low,
unsigned long * high unsigned long * high
); );
int avl_verify (avl_tree * tree); int avl_verify (avl_tree * tree);
void avl_print_tree ( void avl_print_tree (
avl_tree * tree, avl_tree * tree,
avl_key_printer_fun_type key_printer avl_key_printer_fun_type key_printer
); );
...@@ -149,15 +149,15 @@ avl_node *avl_get_next(avl_node * node); ...@@ -149,15 +149,15 @@ avl_node *avl_get_next(avl_node * node);
/* These two are from David Ascher <david_ascher@brown.edu> */ /* These two are from David Ascher <david_ascher@brown.edu> */
int avl_get_item_by_key_most ( int avl_get_item_by_key_most (
avl_tree * tree, avl_tree * tree,
void * key, void * key,
void ** value_address void ** value_address
); );
int avl_get_item_by_key_least ( int avl_get_item_by_key_least (
avl_tree * tree, avl_tree * tree,
void * key, void * key,
void ** value_address void ** value_address
); );
/* optional locking stuff */ /* optional locking stuff */
......
...@@ -11,75 +11,75 @@ int _printer(char *buff, void *key); ...@@ -11,75 +11,75 @@ int _printer(char *buff, void *key);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i, max_nodes; int i, max_nodes;
avl_tree *tree; avl_tree *tree;
avl_node *node; avl_node *node;
max_nodes = 25; max_nodes = 25;
if (argc == 2) { if (argc == 2) {
max_nodes = atoi(argv[1]); max_nodes = atoi(argv[1]);
if (max_nodes == 0) if (max_nodes == 0)
max_nodes = 10; max_nodes = 10;
} }
printf("avl test... max_nodes = %d...\n", max_nodes); printf("avl test... max_nodes = %d...\n", max_nodes);
tree = avl_tree_new(_compare, NULL); tree = avl_tree_new(_compare, NULL);
printf("Filling tree...\n"); printf("Filling tree...\n");
for (i = 0; i < max_nodes; i++) { for (i = 0; i < max_nodes; i++) {
avl_insert(tree, (void *)rand()); avl_insert(tree, (void *)rand());
} }
printf("Traversing tree...\n"); printf("Traversing tree...\n");
node = avl_get_first(tree); node = avl_get_first(tree);
while (node) { while (node) {
i = (int)node->key; i = (int)node->key;
printf("...%5d\n", i); printf("...%5d\n", i);
node = avl_get_next(node); node = avl_get_next(node);
} }
printf("Trying to go backwards...\n"); printf("Trying to go backwards...\n");
node = tree->root->right; node = tree->root->right;
while (node) { while (node) {
i = (int)node->key; i = (int)node->key;
printf("...%5d\n", i); printf("...%5d\n", i);
node = avl_get_prev(node); node = avl_get_prev(node);
} }
printf("Printing tree...\n"); printf("Printing tree...\n");
avl_print_tree(tree, _printer); avl_print_tree(tree, _printer);
avl_tree_free(tree, _free); avl_tree_free(tree, _free);
return 0; return 0;
} }
int _compare(void *compare_arg, void *a, void *b) int _compare(void *compare_arg, void *a, void *b)
{ {
int i, j; int i, j;
i = (int)a; i = (int)a;
j = (int)b; j = (int)b;
if (i > j) if (i > j)
return 1; return 1;
if (j > i) if (j > i)
return -1; return -1;
return 0; return 0;
} }
int _free(void *key) int _free(void *key)
{ {
return 1; return 1;
} }
int _printer(char *buff, void *key) int _printer(char *buff, void *key)
{ {
return snprintf(buff, 25, "%d", (int)key); return snprintf(buff, 25, "%d", (int)key);
} }
......
...@@ -19,33 +19,33 @@ ...@@ -19,33 +19,33 @@
client_t *client_create(connection_t *con, http_parser_t *parser) 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->con = con;
client->parser = parser; client->parser = parser;
client->queue = NULL; client->queue = NULL;
client->pos = 0; client->pos = 0;
return client; return client;
} }
void client_destroy(client_t *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 * slave requests
*/ */
if(client->con->ip) if(client->con->ip)
logging_access(client); logging_access(client);
connection_close(client->con); connection_close(client->con);
httpp_destroy(client->parser); httpp_destroy(client->parser);
while ((refbuf = refbuf_queue_remove(&client->queue))) while ((refbuf = refbuf_queue_remove(&client->queue)))
refbuf_release(refbuf); refbuf_release(refbuf);
free(client); free(client);
} }
void client_send_400(client_t *client, char *message) { void client_send_400(client_t *client, char *message) {
...@@ -72,12 +72,12 @@ void client_send_404(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) { void client_send_504(client_t *client, char *message) {
int bytes; int bytes;
client->respcode = 504; client->respcode = 504;
bytes = sock_write(client->con->sock, bytes = sock_write(client->con->sock,
"HTTP/1.0 504 Server Full\r\n" "HTTP/1.0 504 Server Full\r\n"
"Content-Type: text/html\r\n\r\n" "Content-Type: text/html\r\n\r\n"
"<b>%s</b>\r\n", message); "<b>%s</b>\r\n", message);
if (bytes > 0) client->con->sent_bytes = bytes; if (bytes > 0) client->con->sent_bytes = bytes;
client_destroy(client); client_destroy(client);
} }
void client_send_401(client_t *client) { void client_send_401(client_t *client) {
......
...@@ -10,18 +10,18 @@ ...@@ -10,18 +10,18 @@
typedef struct _client_tag typedef struct _client_tag
{ {
/* the clients connection */ /* the clients connection */
connection_t *con; connection_t *con;
/* the clients http headers */ /* the clients http headers */
http_parser_t *parser; http_parser_t *parser;
/* http response code for this client */ /* http response code for this client */
int respcode; int respcode;
/* buffer queue */ /* buffer queue */
refbuf_queue_t *queue; refbuf_queue_t *queue;
/* position in first buffer */ /* position in first buffer */
unsigned long pos; unsigned long pos;
/* Format-handler-specific data for this client */ /* Format-handler-specific data for this client */
void *format_data; void *format_data;
......
This diff is collapsed.
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
typedef struct ice_config_dir_tag typedef struct ice_config_dir_tag
{ {
char *host; char *host;
int touch_interval; int touch_interval;
struct ice_config_dir_tag *next; struct ice_config_dir_tag *next;
} ice_config_dir_t; } ice_config_dir_t;
typedef struct _relay_server { typedef struct _relay_server {
...@@ -52,33 +52,33 @@ typedef struct ice_config_tag ...@@ -52,33 +52,33 @@ typedef struct ice_config_tag
{ {
char *config_filename; char *config_filename;
char *location; char *location;
char *admin; char *admin;
int client_limit; int client_limit;
int source_limit; int source_limit;
long queue_size_limit; long queue_size_limit;
int threadpool_size; int threadpool_size;
int client_timeout; int client_timeout;
int header_timeout; int header_timeout;
int source_timeout; int source_timeout;
int ice_login; int ice_login;
int fileserve; int fileserve;
char *source_password; char *source_password;
char *admin_username; char *admin_username;
char *admin_password; char *admin_password;
int touch_interval; int touch_interval;
ice_config_dir_t *dir_list; ice_config_dir_t *dir_list;
char *hostname; char *hostname;
int port; int port;
listener_t listeners[MAX_LISTEN_SOCKETS]; listener_t listeners[MAX_LISTEN_SOCKETS];
char *master_server; char *master_server;
int master_server_port; int master_server_port;
int master_update_interval; int master_update_interval;
char *master_password; char *master_password;
...@@ -86,12 +86,12 @@ typedef struct ice_config_tag ...@@ -86,12 +86,12 @@ typedef struct ice_config_tag
mount_proxy *mounts; mount_proxy *mounts;
char *base_dir; char *base_dir;
char *log_dir; char *log_dir;
char *webroot_dir; char *webroot_dir;
char *access_log; char *access_log;
char *error_log; char *error_log;
int loglevel; int loglevel;
int chroot; int chroot;
...@@ -99,7 +99,7 @@ typedef struct ice_config_tag ...@@ -99,7 +99,7 @@ typedef struct ice_config_tag
char *user; char *user;
char *group; char *group;
char *yp_url[MAX_YP_DIRECTORIES]; char *yp_url[MAX_YP_DIRECTORIES];
int yp_url_timeout[MAX_YP_DIRECTORIES]; int yp_url_timeout[MAX_YP_DIRECTORIES];
int num_yp_directories; int num_yp_directories;
} ice_config_t; } ice_config_t;
......
...@@ -5,52 +5,52 @@ void _dump_config(ice_config_t *config); ...@@ -5,52 +5,52 @@ void _dump_config(ice_config_t *config);
int main(void) int main(void)
{ {
ice_config_t *config; ice_config_t *config;
config_initialize(); config_initialize();
config_parse_file("icecast.xml"); 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) void _dump_config(ice_config_t *config)
{ {
ice_config_dir_t *node; ice_config_dir_t *node;
printf("-----\n"); printf("-----\n");
printf("location = %s\n", config->location); printf("location = %s\n", config->location);
printf("admin = %s\n", config->admin); printf("admin = %s\n", config->admin);
printf("client_limit = %d\n", config->client_limit); printf("client_limit = %d\n", config->client_limit);
printf("source_limit = %d\n", config->source_limit); printf("source_limit = %d\n", config->source_limit);
printf("threadpool_size = %d\n", config->threadpool_size); printf("threadpool_size = %d\n", config->threadpool_size);
printf("client_timeout = %d\n", config->client_timeout); printf("client_timeout = %d\n", config->client_timeout);
printf("source_password = %s\n", config->source_password); printf("source_password = %s\n", config->source_password);
printf("touch_interval = %d\n", config->touch_interval); printf("touch_interval = %d\n", config->touch_interval);
node = config->dir_list; node = config->dir_list;
while (node) { while (node) {
printf("directory.touch_interval = %d\n", node->touch_interval); printf("directory.touch_interval = %d\n", node->touch_interval);
printf("directory.host = %s\n", node->host); printf("directory.host = %s\n", node->host);
node = node->next; node = node->next;
} }
printf("hostname = %s\n", config->hostname); printf("hostname = %s\n", config->hostname);
printf("port = %d\n", config->port); printf("port = %d\n", config->port);
printf("bind_address = %s\n", config->bind_address); printf("bind_address = %s\n", config->bind_address);
printf("base_dir = %s\n", config->base_dir); printf("base_dir = %s\n", config->base_dir);
printf("log_dir = %s\n", config->log_dir); printf("log_dir = %s\n", config->log_dir);
printf("access_log = %s\n", config->access_log); printf("access_log = %s\n", config->access_log);
printf("error_log = %s\n", config->error_log);