gcc v2.95 compile fixes.
This commit is contained in:
parent
db32eaeafc
commit
8e7e8c68f5
@ -326,7 +326,7 @@ struct hub_user_access_info* acl_get_access_info(struct acl_handle* handle, cons
|
||||
}
|
||||
|
||||
#define STR_LIST_CONTAINS(LIST, STR) \
|
||||
char* str = (char*) list_get_first(LIST); \
|
||||
str = (char*) list_get_first(LIST); \
|
||||
while (str) \
|
||||
{ \
|
||||
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)
|
||||
{
|
||||
char* str;
|
||||
if (!handle) return 0;
|
||||
STR_LIST_CONTAINS(handle->cids, data);
|
||||
}
|
||||
|
||||
int acl_is_user_banned(struct acl_handle* handle, const char* data)
|
||||
{
|
||||
char* str;
|
||||
if (!handle) return 0;
|
||||
STR_LIST_CONTAINS(handle->users_banned, data);
|
||||
}
|
||||
|
||||
int acl_is_user_denied(struct acl_handle* handle, const char* data)
|
||||
{
|
||||
char* str;
|
||||
if (!handle) return 0;
|
||||
STR_LIST_CONTAINS(handle->users_denied, data);
|
||||
}
|
||||
|
@ -63,20 +63,23 @@ static void command_destroy(struct hub_command* cmd)
|
||||
|
||||
static struct hub_command* command_create(const char* message)
|
||||
{
|
||||
char* prefix;
|
||||
int n;
|
||||
struct hub_command* cmd = hub_malloc_zero(sizeof(struct hub_command));
|
||||
|
||||
if (!cmd) return 0;
|
||||
|
||||
cmd->message = message;
|
||||
cmd->args = list_create();
|
||||
|
||||
int n = split_string(message, "\\s", cmd->args, 0);
|
||||
n = split_string(message, "\\s", cmd->args, 0);
|
||||
if (n <= 0)
|
||||
{
|
||||
command_destroy(cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* prefix = list_get_first(cmd->args);
|
||||
prefix = list_get_first(cmd->args);
|
||||
if (prefix && prefix[0] && 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)
|
||||
{
|
||||
static char args[128];
|
||||
args[0] = 0;
|
||||
size_t n = 0;
|
||||
args[0] = 0;
|
||||
if (handler->args)
|
||||
{
|
||||
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)
|
||||
{
|
||||
char* nick = list_get_first(cmd->args);
|
||||
struct hub_user* target;
|
||||
if (!nick)
|
||||
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)
|
||||
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)
|
||||
{
|
||||
char* nick = list_get_first(cmd->args);
|
||||
struct hub_user* target;
|
||||
if (!nick)
|
||||
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)
|
||||
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)
|
||||
{
|
||||
char* nick = list_get_first(cmd->args);
|
||||
struct hub_user* target;
|
||||
if (!nick)
|
||||
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)
|
||||
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)
|
||||
{
|
||||
char tmp[128];
|
||||
|
||||
char* nick = list_get_first(cmd->args);
|
||||
struct hub_user* target;
|
||||
|
||||
if (!nick);
|
||||
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)
|
||||
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 hub_user* u;
|
||||
int ret = 0;
|
||||
char tmp[128];
|
||||
char* buffer;
|
||||
|
||||
if (!address)
|
||||
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.");
|
||||
}
|
||||
|
||||
char tmp[128];
|
||||
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)
|
||||
{
|
||||
list_destroy(users);
|
||||
@ -413,13 +421,13 @@ static int command_history(struct hub_info* hub, struct hub_user* user, struct h
|
||||
char* message = 0;
|
||||
int ret = (int) list_size(messages);
|
||||
size_t bufsize;
|
||||
char tmp[128];
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
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" : ""));
|
||||
bufsize = strlen(tmp);
|
||||
message = (char*) list_get_first(messages);
|
||||
|
@ -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);
|
||||
int ret = 0;
|
||||
int relay = 1;
|
||||
int offset;
|
||||
|
||||
if (!message || !user_is_logged_in(u))
|
||||
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])
|
||||
{
|
||||
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);
|
||||
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)
|
||||
{
|
||||
struct server_alt_port_data data;
|
||||
|
||||
if (!config->server_alt_ports || !*config->server_alt_ports)
|
||||
return;
|
||||
|
||||
hub->server_alt_ports = (struct linked_list*) list_create();
|
||||
|
||||
struct server_alt_port_data data;
|
||||
data.hub = hub;
|
||||
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 adc_message* cmd = adc_msg_construct(ADC_CMD_ISTA, 6);
|
||||
if (!cmd) return;
|
||||
char code[4];
|
||||
const char* text = 0;
|
||||
const char* flag = 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
|
||||
switch (msg)
|
||||
{
|
||||
|
@ -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 ret;
|
||||
struct adc_message* msg = list_get_first(q->queue);
|
||||
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)
|
||||
{
|
||||
|
@ -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 ret;
|
||||
struct adc_message* cmd = adc_msg_copy(cmd_unmodified);
|
||||
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;
|
||||
}
|
||||
|
||||
int ret = hub_handle_info_login(hub, user, cmd);
|
||||
ret = hub_handle_info_login(hub, user, cmd);
|
||||
if (ret < 0)
|
||||
{
|
||||
on_login_failure(hub, user, ret);
|
||||
|
@ -77,12 +77,14 @@ static int signals[] =
|
||||
void setup_signal_handlers(struct hub_info* hub)
|
||||
{
|
||||
sigset_t sig_set;
|
||||
sigemptyset(&sig_set);
|
||||
struct sigaction act;
|
||||
int i;
|
||||
|
||||
sigemptyset(&sig_set);
|
||||
act.sa_mask = sig_set;
|
||||
act.sa_flags = SA_ONSTACK | SA_RESTART;
|
||||
act.sa_handler = hub_handle_signal;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; signals[i]; i++)
|
||||
{
|
||||
if (sigaction(signals[i], &act, 0) != 0)
|
||||
|
@ -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 ret = 1;
|
||||
struct hub_user* user;
|
||||
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)
|
||||
{
|
||||
if (user_is_logged_in(user))
|
||||
|
@ -107,10 +107,10 @@ void net_backend_shutdown()
|
||||
*/
|
||||
int net_backend_process()
|
||||
{
|
||||
int n;
|
||||
int n, res;
|
||||
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);
|
||||
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);
|
||||
timeout_queue_process(&g_backend->timeout_queue, g_backend->now);
|
||||
|
@ -588,9 +588,10 @@ const char* net_get_peer_address(int fd)
|
||||
struct sockaddr_in6* name6;
|
||||
struct sockaddr_in* name4;
|
||||
struct sockaddr* name;
|
||||
socklen_t namelen;
|
||||
|
||||
memset(address, 0, INET6_ADDRSTRLEN);
|
||||
socklen_t namelen = sizeof(struct sockaddr_storage);
|
||||
namelen = sizeof(struct sockaddr_storage);
|
||||
memset(&storage, 0, namelen);
|
||||
|
||||
name6 = (struct sockaddr_in6*) &storage;
|
||||
@ -626,9 +627,10 @@ const char* net_get_local_address(int fd)
|
||||
struct sockaddr_in6* name6;
|
||||
struct sockaddr_in* name4;
|
||||
struct sockaddr* name;
|
||||
socklen_t namelen;
|
||||
|
||||
memset(address, 0, INET6_ADDRSTRLEN);
|
||||
socklen_t namelen = sizeof(struct sockaddr_storage);
|
||||
namelen = sizeof(struct sockaddr_storage);
|
||||
memset(&storage, 0, namelen);
|
||||
|
||||
name6 = (struct sockaddr_in6*) &storage;
|
||||
|
@ -451,11 +451,12 @@ int ip_convert_address_to_range(const char* address, struct ip_range* range)
|
||||
{
|
||||
int ret = 0;
|
||||
char* addr = 0;
|
||||
const char* split;
|
||||
|
||||
if (!address || !range)
|
||||
return 0;
|
||||
|
||||
const char* split = strrchr(address, '/');
|
||||
split = strrchr(address, '/');
|
||||
if (split)
|
||||
{
|
||||
int mask = uhub_atoi(split+1);
|
||||
|
@ -229,6 +229,7 @@ int file_read_lines(const char* file, void* data, file_line_handler_t handler)
|
||||
int fd;
|
||||
ssize_t ret;
|
||||
char buf[MAX_RECV_BUF];
|
||||
struct file_read_line_data split_data;
|
||||
|
||||
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 */
|
||||
struct file_read_line_data split_data;
|
||||
split_data.handler = handler;
|
||||
split_data.data = data;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user