From 4316840890b7b14b1fe05f5548f333fe0ff8ec62 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 5 Dec 2000 01:01:53 +0000 Subject: bot & proxy plugins fixed for GIOChannel changes git-svn-id: http://svn.irssi.org/repos/irssi/trunk@965 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/bot/bot-users.c | 2 +- src/irc/bot/botnet-connection.c | 22 ++++++++++------------ src/irc/bot/botnet.c | 11 +++++------ src/irc/bot/botnet.h | 4 ++-- src/irc/proxy/listen.c | 15 ++++++++------- src/irc/proxy/module.h | 4 ++-- 6 files changed, 28 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/irc/bot/bot-users.c b/src/irc/bot/bot-users.c index d8e9b9fc..b6305b51 100644 --- a/src/irc/bot/bot-users.c +++ b/src/irc/bot/bot-users.c @@ -112,7 +112,7 @@ static void botuser_config_save(USER_REC *user) g_free_not_null(str); config_node_set_str(userconfig, node, "password", user->password); - iconfig_node_set_int(node, "last_modify", (int) user->last_modify); + config_node_set_int(userconfig, node, "last_modify", (int) user->last_modify); /* Save masks */ if (user->masks == NULL) diff --git a/src/irc/bot/botnet-connection.c b/src/irc/bot/botnet-connection.c index 988a9b5c..bd25d30b 100644 --- a/src/irc/bot/botnet-connection.c +++ b/src/irc/bot/botnet-connection.c @@ -56,7 +56,7 @@ static void sig_bot_read(BOT_REC *bot) botnet = bot->botnet; for (;;) { - recvlen = bot->handle == -1 ? -1 : + recvlen = bot->handle == NULL ? -1 : net_receive(bot->handle, tmpbuf, sizeof(tmpbuf)); ret = line_split(tmpbuf, recvlen, &str, (LINEBUF_REC **) &bot->buffer); @@ -80,7 +80,7 @@ static void sig_bot_read(BOT_REC *bot) } } -static void connect_downlink(BOTNET_REC *botnet, int handle, +static void connect_downlink(BOTNET_REC *botnet, GIOChannel *handle, IPADDR *ip, const char *host) { BOT_DOWNLINK_REC *downlink; @@ -110,7 +110,7 @@ static void connect_downlink(BOTNET_REC *botnet, int handle, typedef struct { char *botnet; IPADDR ip; - int handle; + GIOChannel *handle; } BOT_CONNECT_REC; static void sig_host_got(RESOLVED_NAME_REC *name, BOT_CONNECT_REC *rec) @@ -133,13 +133,13 @@ static void sig_botnet_listen(BOTNET_REC *botnet) { BOT_CONNECT_REC *rec; IPADDR ip; - int handle; + GIOChannel *handle; g_return_if_fail(botnet != NULL); /* accept connection */ handle = net_accept(botnet->listen_handle, &ip, NULL); - if (handle == -1) + if (handle == NULL) return; rec = g_new0(BOT_CONNECT_REC, 1); @@ -173,7 +173,7 @@ static int botnet_listen(BOTNET_REC *botnet) botnet->listen_handle = net_listen(&addr, &port); } - if (botnet->listen_handle == -1) { + if (botnet->listen_handle == NULL) { g_warning("Couldn't start listening botnet\n"); return FALSE; } @@ -184,7 +184,7 @@ static int botnet_listen(BOTNET_REC *botnet) return TRUE; } -static void sig_botnet_connected(int handle, BOT_UPLINK_REC *uplink) +static void sig_botnet_connected(GIOChannel *handle, BOT_UPLINK_REC *uplink) { BOTNET_REC *botnet; BOT_REC *bot; @@ -193,7 +193,7 @@ static void sig_botnet_connected(int handle, BOT_UPLINK_REC *uplink) botnet = uplink->botnet; - if (handle == -1) { + if (handle == NULL) { /* error, try another bot */ botnet_connect(botnet); return; @@ -235,7 +235,6 @@ void botnet_connect(BOTNET_REC *botnet) bot->connected = TRUE; bot->master = TRUE; - bot->handle = -1; bot->read_tag = -1; botnet->connected = TRUE; @@ -244,7 +243,7 @@ void botnet_connect(BOTNET_REC *botnet) botnet->bots = g_node_new(bot); } - if (botnet->listen_handle == -1) { + if (botnet->listen_handle == NULL) { /* start listening */ botnet_listen(botnet); } @@ -470,7 +469,6 @@ static BOT_REC *bot_add(BOTNET_REC *botnet, const char *nick, const char *parent rec->botnet = botnet; rec->nick = g_strdup(nick); - rec->handle = -1; rec->read_tag = -1; rec->connected = TRUE; @@ -527,7 +525,7 @@ static void sig_bot_disconnected(BOT_REC *bot) if (!bot->botnet->connected) return; - if (bot->connected && bot->handle != -1) { + if (bot->connected && bot->handle != NULL) { /* send notice to rest of the botnet about quit */ str = g_strdup_printf("BOTQUIT %s", bot->nick); botnet_broadcast(bot->botnet, bot, NULL, str); diff --git a/src/irc/bot/botnet.c b/src/irc/bot/botnet.c index e1f00bb7..935b337e 100644 --- a/src/irc/bot/botnet.c +++ b/src/irc/bot/botnet.c @@ -74,7 +74,7 @@ static void botnet_broadcast_single(BOTNET_REC *botnet, BOT_REC *except_bot, for (node = botnet->bots->children; node != NULL; node = node->next) { BOT_REC *rec = node->data; - if (rec != except_bot && rec->handle != -1) + if (rec != except_bot && rec->handle != NULL) bot_send_cmd(rec, str); } g_free(str); @@ -402,9 +402,9 @@ void bot_disconnect(BOT_REC *bot) g_source_remove(bot->read_tag); bot->read_tag = -1; } - if (bot->handle != -1) { + if (bot->handle != NULL) { net_disconnect(bot->handle); - bot->handle = -1; + bot->handle = NULL; } } @@ -483,9 +483,9 @@ void botnet_disconnect(BOTNET_REC *botnet) g_source_remove(botnet->listen_tag); botnet->listen_tag = -1; } - if (botnet->listen_handle != -1) { + if (botnet->listen_handle != NULL) { net_disconnect(botnet->listen_handle); - botnet->listen_handle = -1; + botnet->listen_handle = NULL; } } @@ -730,7 +730,6 @@ static void botnet_config_read_botnet(CONFIG_NODE *node) botnet->addr = g_strdup(config_node_get_str(node, "listen_addr", NULL)); botnet->port = config_node_get_int(node, "listen_port", DEFAULT_BOTNET_PORT); - botnet->listen_handle = -1; botnet->listen_tag = -1; /* read uplinks */ diff --git a/src/irc/bot/botnet.h b/src/irc/bot/botnet.h index 46489099..44b09bf7 100644 --- a/src/irc/bot/botnet.h +++ b/src/irc/bot/botnet.h @@ -44,7 +44,7 @@ typedef struct { char *nick; /* bot's unique nick in botnet */ int priority; - int handle; + GIOChannel *handle; int read_tag; void *buffer; @@ -82,7 +82,7 @@ struct _botnet_rec { char *addr; /* in what address we should listen, NULL = all */ int port; /* what port we should listen, 0 = default, -1 = don't listen */ - int listen_handle; + GIOChannel *listen_handle; int listen_tag; GSList *uplinks; diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c index b5710a40..0be32b81 100644 --- a/src/irc/proxy/listen.c +++ b/src/irc/proxy/listen.c @@ -65,7 +65,7 @@ static void proxy_redirect_event(CLIENT_REC *client, group = 0; while ((event = va_arg(vargs, char *)) != NULL) { argpos = va_arg(vargs, int); - g_string_sprintf(str, "proxy %d", client->handle); + g_string_sprintf(str, "proxy %p", client->handle); group = server_redirect_single_event(SERVER(client->server), args, last > 0, group, event, str->str, argpos); last--; @@ -132,7 +132,7 @@ static void handle_client_connect_cmd(CLIENT_REC *client, static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args) { - int server_handle; + GIOChannel *server_handle; if (!client->connected) { handle_client_connect_cmd(client, cmd, args); @@ -289,14 +289,15 @@ static void sig_listen(LISTEN_REC *listen) { CLIENT_REC *rec; IPADDR ip; + GIOChannel *handle; char host[MAX_IP_LEN]; - int port, handle; + int port; g_return_if_fail(listen != NULL); /* accept connection */ handle = net_accept(listen->handle, &ip, &port); - if (handle == -1) + if (handle == NULL) return; net_ip2host(&ip, host); @@ -342,7 +343,7 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line, if (list != NULL) { /* we want to send this to one client (or proxy itself) only */ REDIRECT_REC *rec; - int handle; + void *handle; rec = list->data; if (g_strncasecmp(rec->name, "proxy ", 6) != 0) { @@ -351,7 +352,7 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line, return; } - if (sscanf(rec->name+6, "%d", &handle) == 1) { + if (sscanf(rec->name+6, "%p", &handle) == 1) { /* send it to specific client only */ server_redirect_remove_next(SERVER(server), event, list); net_transmit(handle, next_line->str, next_line->len); @@ -478,7 +479,7 @@ static void add_listen(const char *ircnet, int port) /* start listening */ rec->handle = net_listen(NULL, &rec->port); - if (rec->handle == -1) { + if (rec->handle == NULL) { printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Proxy: Listen in port %d failed: %s", rec->port, g_strerror(errno)); diff --git a/src/irc/proxy/module.h b/src/irc/proxy/module.h index 1defd0ce..8eecfc5c 100644 --- a/src/irc/proxy/module.h +++ b/src/irc/proxy/module.h @@ -11,14 +11,14 @@ typedef struct { char *ircnet; int tag; - int handle; + GIOChannel *handle; } LISTEN_REC; typedef struct { LINEBUF_REC *buffer; char *nick; - int handle; + GIOChannel *handle; int tag; char *proxy_address; -- cgit v1.2.3