gcc v2.95 compile fixes.

This commit is contained in:
Jan Vidar Krey 2010-01-28 01:06:41 +01:00
parent db32eaeafc
commit 8e7e8c68f5
11 changed files with 49 additions and 27 deletions

View File

@ -326,7 +326,7 @@ struct hub_user_access_info* acl_get_access_info(struct acl_handle* handle, cons
} }
#define STR_LIST_CONTAINS(LIST, STR) \ #define STR_LIST_CONTAINS(LIST, STR) \
char* str = (char*) list_get_first(LIST); \ str = (char*) list_get_first(LIST); \
while (str) \ while (str) \
{ \ { \
if (strcasecmp(str, STR) == 0) \ if (strcasecmp(str, STR) == 0) \
@ -337,18 +337,21 @@ struct hub_user_access_info* acl_get_access_info(struct acl_handle* handle, cons
int acl_is_cid_banned(struct acl_handle* handle, const char* data) int acl_is_cid_banned(struct acl_handle* handle, const char* data)
{ {
char* str;
if (!handle) return 0; if (!handle) return 0;
STR_LIST_CONTAINS(handle->cids, data); STR_LIST_CONTAINS(handle->cids, data);
} }
int acl_is_user_banned(struct acl_handle* handle, const char* data) int acl_is_user_banned(struct acl_handle* handle, const char* data)
{ {
char* str;
if (!handle) return 0; if (!handle) return 0;
STR_LIST_CONTAINS(handle->users_banned, data); STR_LIST_CONTAINS(handle->users_banned, data);
} }
int acl_is_user_denied(struct acl_handle* handle, const char* data) int acl_is_user_denied(struct acl_handle* handle, const char* data)
{ {
char* str;
if (!handle) return 0; if (!handle) return 0;
STR_LIST_CONTAINS(handle->users_denied, data); STR_LIST_CONTAINS(handle->users_denied, data);
} }

View File

@ -63,20 +63,23 @@ static void command_destroy(struct hub_command* cmd)
static struct hub_command* command_create(const char* message) static struct hub_command* command_create(const char* message)
{ {
char* prefix;
int n;
struct hub_command* cmd = hub_malloc_zero(sizeof(struct hub_command)); struct hub_command* cmd = hub_malloc_zero(sizeof(struct hub_command));
if (!cmd) return 0; if (!cmd) return 0;
cmd->message = message; cmd->message = message;
cmd->args = list_create(); cmd->args = list_create();
int n = split_string(message, "\\s", cmd->args, 0); n = split_string(message, "\\s", cmd->args, 0);
if (n <= 0) if (n <= 0)
{ {
command_destroy(cmd); command_destroy(cmd);
return 0; return 0;
} }
char* prefix = list_get_first(cmd->args); prefix = list_get_first(cmd->args);
if (prefix && prefix[0] && prefix[1]) if (prefix && prefix[0] && prefix[1])
{ {
cmd->prefix = hub_strdup(&prefix[1]); cmd->prefix = hub_strdup(&prefix[1]);
@ -129,8 +132,8 @@ static int command_status_user_not_found(struct hub_info* hub, struct hub_user*
const char* command_get_syntax(struct commands_handler* handler) const char* command_get_syntax(struct commands_handler* handler)
{ {
static char args[128]; static char args[128];
args[0] = 0;
size_t n = 0; size_t n = 0;
args[0] = 0;
if (handler->args) if (handler->args)
{ {
for (n = 0; n < strlen(handler->args); n++) for (n = 0; n < strlen(handler->args); n++)
@ -235,10 +238,11 @@ static int command_uptime(struct hub_info* hub, struct hub_user* user, struct hu
static int command_kick(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd) static int command_kick(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
{ {
char* nick = list_get_first(cmd->args); char* nick = list_get_first(cmd->args);
struct hub_user* target;
if (!nick) if (!nick)
return -1; // FIXME: bad syntax. return -1; // FIXME: bad syntax.
struct hub_user* target = uman_get_user_by_nick(hub, nick); target = uman_get_user_by_nick(hub, nick);
if (!target) if (!target)
return command_status_user_not_found(hub, user, cmd, nick); return command_status_user_not_found(hub, user, cmd, nick);
@ -253,10 +257,11 @@ static int command_kick(struct hub_info* hub, struct hub_user* user, struct hub_
static int command_ban(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd) static int command_ban(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
{ {
char* nick = list_get_first(cmd->args); char* nick = list_get_first(cmd->args);
struct hub_user* target;
if (!nick) if (!nick)
return -1; // FIXME: bad syntax. return -1; // FIXME: bad syntax.
struct hub_user* target = uman_get_user_by_nick(hub, nick); target = uman_get_user_by_nick(hub, nick);
if (!target) if (!target)
return command_status_user_not_found(hub, user, cmd, nick); return command_status_user_not_found(hub, user, cmd, nick);
@ -279,10 +284,11 @@ static int command_unban(struct hub_info* hub, struct hub_user* user, struct hub
static int command_mute(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd) static int command_mute(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
{ {
char* nick = list_get_first(cmd->args); char* nick = list_get_first(cmd->args);
struct hub_user* target;
if (!nick) if (!nick)
return -1; // FIXME: bad syntax. return -1; // FIXME: bad syntax.
struct hub_user* target = uman_get_user_by_nick(hub, nick); target = uman_get_user_by_nick(hub, nick);
if (!target) if (!target)
return command_status_user_not_found(hub, user, cmd, nick); return command_status_user_not_found(hub, user, cmd, nick);
@ -325,12 +331,13 @@ static int command_myip(struct hub_info* hub, struct hub_user* user, struct hub_
static int command_getip(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd) static int command_getip(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
{ {
char tmp[128]; char tmp[128];
char* nick = list_get_first(cmd->args); char* nick = list_get_first(cmd->args);
struct hub_user* target;
if (!nick); if (!nick);
return -1; // FIXME: bad syntax/OOM return -1; // FIXME: bad syntax/OOM
struct hub_user* target = uman_get_user_by_nick(hub, nick); target = uman_get_user_by_nick(hub, nick);
if (!target) if (!target)
return command_status_user_not_found(hub, user, cmd, nick); return command_status_user_not_found(hub, user, cmd, nick);
@ -346,6 +353,8 @@ static int command_whoip(struct hub_info* hub, struct hub_user* user, struct hub
struct linked_list* users; struct linked_list* users;
struct hub_user* u; struct hub_user* u;
int ret = 0; int ret = 0;
char tmp[128];
char* buffer;
if (!address) if (!address)
return -1; // FIXME: bad syntax. return -1; // FIXME: bad syntax.
@ -366,10 +375,9 @@ static int command_whoip(struct hub_info* hub, struct hub_user* user, struct hub
return command_status(hub, user, cmd, "No users found."); return command_status(hub, user, cmd, "No users found.");
} }
char tmp[128];
snprintf(tmp, 128, "*** %s: Found %d match%s:", cmd->prefix, ret, ((ret != 1) ? "es" : "")); snprintf(tmp, 128, "*** %s: Found %d match%s:", cmd->prefix, ret, ((ret != 1) ? "es" : ""));
char* buffer = hub_malloc(((MAX_NICK_LEN + INET6_ADDRSTRLEN + 5) * ret) + strlen(tmp) + 3); buffer = hub_malloc(((MAX_NICK_LEN + INET6_ADDRSTRLEN + 5) * ret) + strlen(tmp) + 3);
if (!buffer) if (!buffer)
{ {
list_destroy(users); list_destroy(users);
@ -413,13 +421,13 @@ static int command_history(struct hub_info* hub, struct hub_user* user, struct h
char* message = 0; char* message = 0;
int ret = (int) list_size(messages); int ret = (int) list_size(messages);
size_t bufsize; size_t bufsize;
char tmp[128];
if (!ret) if (!ret)
{ {
return command_status(hub, user, cmd, "No messages."); return command_status(hub, user, cmd, "No messages.");
} }
char tmp[128];
snprintf(tmp, 128, "*** %s: Found %d message%s:", cmd->prefix, ret, ((ret != 1) ? "s" : "")); snprintf(tmp, 128, "*** %s: Found %d message%s:", cmd->prefix, ret, ((ret != 1) ? "s" : ""));
bufsize = strlen(tmp); bufsize = strlen(tmp);
message = (char*) list_get_first(messages); message = (char*) list_get_first(messages);

View File

@ -183,6 +183,7 @@ int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc
char* message = adc_msg_get_argument(cmd, 0); char* message = adc_msg_get_argument(cmd, 0);
int ret = 0; int ret = 0;
int relay = 1; int relay = 1;
int offset;
if (!message || !user_is_logged_in(u)) if (!message || !user_is_logged_in(u))
return 0; return 0;
@ -196,7 +197,7 @@ int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc
if (message[1] == message[0]) if (message[1] == message[0])
{ {
relay = 1; relay = 1;
int offset = adc_msg_get_arg_offset(cmd); offset = adc_msg_get_arg_offset(cmd);
memmove(cmd->cache+offset+1, cmd->cache+offset+2, cmd->length - offset); memmove(cmd->cache+offset+1, cmd->cache+offset+2, cmd->length - offset);
cmd->length--; cmd->length--;
} }
@ -519,12 +520,13 @@ static int server_alt_port_start_one(char* line, int count, void* ptr)
static void server_alt_port_start(struct hub_info* hub, struct hub_config* config) static void server_alt_port_start(struct hub_info* hub, struct hub_config* config)
{ {
struct server_alt_port_data data;
if (!config->server_alt_ports || !*config->server_alt_ports) if (!config->server_alt_ports || !*config->server_alt_ports)
return; return;
hub->server_alt_ports = (struct linked_list*) list_create(); hub->server_alt_ports = (struct linked_list*) list_create();
struct server_alt_port_data data;
data.hub = hub; data.hub = hub;
data.config = config; data.config = config;
@ -823,12 +825,13 @@ void hub_send_status(struct hub_info* hub, struct hub_user* user, enum status_me
{ {
struct hub_config* cfg = hub->config; struct hub_config* cfg = hub->config;
struct adc_message* cmd = adc_msg_construct(ADC_CMD_ISTA, 6); struct adc_message* cmd = adc_msg_construct(ADC_CMD_ISTA, 6);
if (!cmd) return;
char code[4]; char code[4];
const char* text = 0; const char* text = 0;
const char* flag = 0; const char* flag = 0;
char* escaped_text = 0; char* escaped_text = 0;
if (!cmd) return;
#define STATUS(CODE, MSG, FLAG) case status_ ## MSG : set_status_code(level, CODE, code); text = cfg->MSG; flag = FLAG; break #define STATUS(CODE, MSG, FLAG) case status_ ## MSG : set_status_code(level, CODE, code); text = cfg->MSG; flag = FLAG; break
switch (msg) switch (msg)
{ {

View File

@ -143,10 +143,11 @@ void hub_sendq_remove(struct hub_sendq* q, struct adc_message* msg)
int hub_sendq_send(struct hub_sendq* q, struct hub_user* user) int hub_sendq_send(struct hub_sendq* q, struct hub_user* user)
{ {
int ret;
struct adc_message* msg = list_get_first(q->queue); struct adc_message* msg = list_get_first(q->queue);
if (!msg) return 0; if (!msg) return 0;
int ret = net_con_send(user->connection, msg->cache + q->offset, msg->length - q->offset); ret = net_con_send(user->connection, msg->cache + q->offset, msg->length - q->offset);
if (ret > 0) if (ret > 0)
{ {

View File

@ -715,6 +715,7 @@ int hub_handle_info_login(struct hub_info* hub, struct hub_user* user, struct ad
*/ */
int hub_handle_info(struct hub_info* hub, struct hub_user* user, const struct adc_message* cmd_unmodified) int hub_handle_info(struct hub_info* hub, struct hub_user* user, const struct adc_message* cmd_unmodified)
{ {
int ret;
struct adc_message* cmd = adc_msg_copy(cmd_unmodified); struct adc_message* cmd = adc_msg_copy(cmd_unmodified);
if (!cmd) return -1; /* OOM */ if (!cmd) return -1; /* OOM */
@ -737,7 +738,7 @@ int hub_handle_info(struct hub_info* hub, struct hub_user* user, const struct ad
return 0; return 0;
} }
int ret = hub_handle_info_login(hub, user, cmd); ret = hub_handle_info_login(hub, user, cmd);
if (ret < 0) if (ret < 0)
{ {
on_login_failure(hub, user, ret); on_login_failure(hub, user, ret);

View File

@ -77,12 +77,14 @@ static int signals[] =
void setup_signal_handlers(struct hub_info* hub) void setup_signal_handlers(struct hub_info* hub)
{ {
sigset_t sig_set; sigset_t sig_set;
sigemptyset(&sig_set);
struct sigaction act; struct sigaction act;
int i;
sigemptyset(&sig_set);
act.sa_mask = sig_set; act.sa_mask = sig_set;
act.sa_flags = SA_ONSTACK | SA_RESTART; act.sa_flags = SA_ONSTACK | SA_RESTART;
act.sa_handler = hub_handle_signal; act.sa_handler = hub_handle_signal;
int i = 0;
for (i = 0; signals[i]; i++) for (i = 0; signals[i]; i++)
{ {
if (sigaction(signals[i], &act, 0) != 0) if (sigaction(signals[i], &act, 0) != 0)

View File

@ -224,8 +224,9 @@ size_t uman_get_user_by_addr(struct hub_info* hub, struct linked_list* users, st
int uman_send_user_list(struct hub_info* hub, struct hub_user* target) int uman_send_user_list(struct hub_info* hub, struct hub_user* target)
{ {
int ret = 1; int ret = 1;
struct hub_user* user;
user_flag_set(target, flag_user_list); user_flag_set(target, flag_user_list);
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list); /* iterate users - only on INF or PAS msg */ user = (struct hub_user*) list_get_first(hub->users->list); /* iterate users - only on INF or PAS msg */
while (user) while (user)
{ {
if (user_is_logged_in(user)) if (user_is_logged_in(user))

View File

@ -107,10 +107,10 @@ void net_backend_shutdown()
*/ */
int net_backend_process() int net_backend_process()
{ {
int n; int n, res;
size_t secs = timeout_queue_get_next_timeout(&g_backend->timeout_queue, g_backend->now); size_t secs = timeout_queue_get_next_timeout(&g_backend->timeout_queue, g_backend->now);
LOG_TRACE("epoll_wait: fd=%d, events=%x, max=%zu, seconds=%d", g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), (int) secs); LOG_TRACE("epoll_wait: fd=%d, events=%x, max=%zu, seconds=%d", g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), (int) secs);
int res = epoll_wait(g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), secs * 1000); res = epoll_wait(g_backend->epfd, g_backend->events, MIN(g_backend->num, EPOLL_EVBUFFER), secs * 1000);
g_backend->now = time(0); g_backend->now = time(0);
timeout_queue_process(&g_backend->timeout_queue, g_backend->now); timeout_queue_process(&g_backend->timeout_queue, g_backend->now);

View File

@ -588,9 +588,10 @@ const char* net_get_peer_address(int fd)
struct sockaddr_in6* name6; struct sockaddr_in6* name6;
struct sockaddr_in* name4; struct sockaddr_in* name4;
struct sockaddr* name; struct sockaddr* name;
socklen_t namelen;
memset(address, 0, INET6_ADDRSTRLEN); memset(address, 0, INET6_ADDRSTRLEN);
socklen_t namelen = sizeof(struct sockaddr_storage); namelen = sizeof(struct sockaddr_storage);
memset(&storage, 0, namelen); memset(&storage, 0, namelen);
name6 = (struct sockaddr_in6*) &storage; name6 = (struct sockaddr_in6*) &storage;
@ -626,9 +627,10 @@ const char* net_get_local_address(int fd)
struct sockaddr_in6* name6; struct sockaddr_in6* name6;
struct sockaddr_in* name4; struct sockaddr_in* name4;
struct sockaddr* name; struct sockaddr* name;
socklen_t namelen;
memset(address, 0, INET6_ADDRSTRLEN); memset(address, 0, INET6_ADDRSTRLEN);
socklen_t namelen = sizeof(struct sockaddr_storage); namelen = sizeof(struct sockaddr_storage);
memset(&storage, 0, namelen); memset(&storage, 0, namelen);
name6 = (struct sockaddr_in6*) &storage; name6 = (struct sockaddr_in6*) &storage;

View File

@ -451,11 +451,12 @@ int ip_convert_address_to_range(const char* address, struct ip_range* range)
{ {
int ret = 0; int ret = 0;
char* addr = 0; char* addr = 0;
const char* split;
if (!address || !range) if (!address || !range)
return 0; return 0;
const char* split = strrchr(address, '/'); split = strrchr(address, '/');
if (split) if (split)
{ {
int mask = uhub_atoi(split+1); int mask = uhub_atoi(split+1);

View File

@ -229,6 +229,7 @@ int file_read_lines(const char* file, void* data, file_line_handler_t handler)
int fd; int fd;
ssize_t ret; ssize_t ret;
char buf[MAX_RECV_BUF]; char buf[MAX_RECV_BUF];
struct file_read_line_data split_data;
memset(buf, 0, MAX_RECV_BUF); memset(buf, 0, MAX_RECV_BUF);
@ -256,7 +257,6 @@ int file_read_lines(const char* file, void* data, file_line_handler_t handler)
} }
/* Parse configuaration */ /* Parse configuaration */
struct file_read_line_data split_data;
split_data.handler = handler; split_data.handler = handler;
split_data.data = data; split_data.data = data;