1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

bot & proxy plugins fixed for GIOChannel changes

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@965 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-12-05 01:01:53 +00:00 committed by cras
parent d1eaeca255
commit 4316840890
6 changed files with 28 additions and 30 deletions

View File

@ -112,7 +112,7 @@ static void botuser_config_save(USER_REC *user)
g_free_not_null(str); g_free_not_null(str);
config_node_set_str(userconfig, node, "password", user->password); 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 */ /* Save masks */
if (user->masks == NULL) if (user->masks == NULL)

View File

@ -56,7 +56,7 @@ static void sig_bot_read(BOT_REC *bot)
botnet = bot->botnet; botnet = bot->botnet;
for (;;) { for (;;) {
recvlen = bot->handle == -1 ? -1 : recvlen = bot->handle == NULL ? -1 :
net_receive(bot->handle, tmpbuf, sizeof(tmpbuf)); net_receive(bot->handle, tmpbuf, sizeof(tmpbuf));
ret = line_split(tmpbuf, recvlen, &str, (LINEBUF_REC **) &bot->buffer); 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) IPADDR *ip, const char *host)
{ {
BOT_DOWNLINK_REC *downlink; BOT_DOWNLINK_REC *downlink;
@ -110,7 +110,7 @@ static void connect_downlink(BOTNET_REC *botnet, int handle,
typedef struct { typedef struct {
char *botnet; char *botnet;
IPADDR ip; IPADDR ip;
int handle; GIOChannel *handle;
} BOT_CONNECT_REC; } BOT_CONNECT_REC;
static void sig_host_got(RESOLVED_NAME_REC *name, BOT_CONNECT_REC *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; BOT_CONNECT_REC *rec;
IPADDR ip; IPADDR ip;
int handle; GIOChannel *handle;
g_return_if_fail(botnet != NULL); g_return_if_fail(botnet != NULL);
/* accept connection */ /* accept connection */
handle = net_accept(botnet->listen_handle, &ip, NULL); handle = net_accept(botnet->listen_handle, &ip, NULL);
if (handle == -1) if (handle == NULL)
return; return;
rec = g_new0(BOT_CONNECT_REC, 1); 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); 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"); g_warning("Couldn't start listening botnet\n");
return FALSE; return FALSE;
} }
@ -184,7 +184,7 @@ static int botnet_listen(BOTNET_REC *botnet)
return TRUE; 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; BOTNET_REC *botnet;
BOT_REC *bot; BOT_REC *bot;
@ -193,7 +193,7 @@ static void sig_botnet_connected(int handle, BOT_UPLINK_REC *uplink)
botnet = uplink->botnet; botnet = uplink->botnet;
if (handle == -1) { if (handle == NULL) {
/* error, try another bot */ /* error, try another bot */
botnet_connect(botnet); botnet_connect(botnet);
return; return;
@ -235,7 +235,6 @@ void botnet_connect(BOTNET_REC *botnet)
bot->connected = TRUE; bot->connected = TRUE;
bot->master = TRUE; bot->master = TRUE;
bot->handle = -1;
bot->read_tag = -1; bot->read_tag = -1;
botnet->connected = TRUE; botnet->connected = TRUE;
@ -244,7 +243,7 @@ void botnet_connect(BOTNET_REC *botnet)
botnet->bots = g_node_new(bot); botnet->bots = g_node_new(bot);
} }
if (botnet->listen_handle == -1) { if (botnet->listen_handle == NULL) {
/* start listening */ /* start listening */
botnet_listen(botnet); 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->botnet = botnet;
rec->nick = g_strdup(nick); rec->nick = g_strdup(nick);
rec->handle = -1;
rec->read_tag = -1; rec->read_tag = -1;
rec->connected = TRUE; rec->connected = TRUE;
@ -527,7 +525,7 @@ static void sig_bot_disconnected(BOT_REC *bot)
if (!bot->botnet->connected) if (!bot->botnet->connected)
return; return;
if (bot->connected && bot->handle != -1) { if (bot->connected && bot->handle != NULL) {
/* send notice to rest of the botnet about quit */ /* send notice to rest of the botnet about quit */
str = g_strdup_printf("BOTQUIT %s", bot->nick); str = g_strdup_printf("BOTQUIT %s", bot->nick);
botnet_broadcast(bot->botnet, bot, NULL, str); botnet_broadcast(bot->botnet, bot, NULL, str);

View File

@ -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) { for (node = botnet->bots->children; node != NULL; node = node->next) {
BOT_REC *rec = node->data; BOT_REC *rec = node->data;
if (rec != except_bot && rec->handle != -1) if (rec != except_bot && rec->handle != NULL)
bot_send_cmd(rec, str); bot_send_cmd(rec, str);
} }
g_free(str); g_free(str);
@ -402,9 +402,9 @@ void bot_disconnect(BOT_REC *bot)
g_source_remove(bot->read_tag); g_source_remove(bot->read_tag);
bot->read_tag = -1; bot->read_tag = -1;
} }
if (bot->handle != -1) { if (bot->handle != NULL) {
net_disconnect(bot->handle); 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); g_source_remove(botnet->listen_tag);
botnet->listen_tag = -1; botnet->listen_tag = -1;
} }
if (botnet->listen_handle != -1) { if (botnet->listen_handle != NULL) {
net_disconnect(botnet->listen_handle); 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->addr = g_strdup(config_node_get_str(node, "listen_addr", NULL));
botnet->port = config_node_get_int(node, "listen_port", DEFAULT_BOTNET_PORT); botnet->port = config_node_get_int(node, "listen_port", DEFAULT_BOTNET_PORT);
botnet->listen_handle = -1;
botnet->listen_tag = -1; botnet->listen_tag = -1;
/* read uplinks */ /* read uplinks */

View File

@ -44,7 +44,7 @@ typedef struct {
char *nick; /* bot's unique nick in botnet */ char *nick; /* bot's unique nick in botnet */
int priority; int priority;
int handle; GIOChannel *handle;
int read_tag; int read_tag;
void *buffer; void *buffer;
@ -82,7 +82,7 @@ struct _botnet_rec {
char *addr; /* in what address we should listen, NULL = all */ char *addr; /* in what address we should listen, NULL = all */
int port; /* what port we should listen, 0 = default, -1 = don't listen */ int port; /* what port we should listen, 0 = default, -1 = don't listen */
int listen_handle; GIOChannel *listen_handle;
int listen_tag; int listen_tag;
GSList *uplinks; GSList *uplinks;

View File

@ -65,7 +65,7 @@ static void proxy_redirect_event(CLIENT_REC *client,
group = 0; group = 0;
while ((event = va_arg(vargs, char *)) != NULL) { while ((event = va_arg(vargs, char *)) != NULL) {
argpos = va_arg(vargs, int); 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 = server_redirect_single_event(SERVER(client->server), args, last > 0,
group, event, str->str, argpos); group, event, str->str, argpos);
last--; 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) static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args)
{ {
int server_handle; GIOChannel *server_handle;
if (!client->connected) { if (!client->connected) {
handle_client_connect_cmd(client, cmd, args); handle_client_connect_cmd(client, cmd, args);
@ -289,14 +289,15 @@ static void sig_listen(LISTEN_REC *listen)
{ {
CLIENT_REC *rec; CLIENT_REC *rec;
IPADDR ip; IPADDR ip;
GIOChannel *handle;
char host[MAX_IP_LEN]; char host[MAX_IP_LEN];
int port, handle; int port;
g_return_if_fail(listen != NULL); g_return_if_fail(listen != NULL);
/* accept connection */ /* accept connection */
handle = net_accept(listen->handle, &ip, &port); handle = net_accept(listen->handle, &ip, &port);
if (handle == -1) if (handle == NULL)
return; return;
net_ip2host(&ip, host); net_ip2host(&ip, host);
@ -342,7 +343,7 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line,
if (list != NULL) { if (list != NULL) {
/* we want to send this to one client (or proxy itself) only */ /* we want to send this to one client (or proxy itself) only */
REDIRECT_REC *rec; REDIRECT_REC *rec;
int handle; void *handle;
rec = list->data; rec = list->data;
if (g_strncasecmp(rec->name, "proxy ", 6) != 0) { 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; return;
} }
if (sscanf(rec->name+6, "%d", &handle) == 1) { if (sscanf(rec->name+6, "%p", &handle) == 1) {
/* send it to specific client only */ /* send it to specific client only */
server_redirect_remove_next(SERVER(server), event, list); server_redirect_remove_next(SERVER(server), event, list);
net_transmit(handle, next_line->str, next_line->len); net_transmit(handle, next_line->str, next_line->len);
@ -478,7 +479,7 @@ static void add_listen(const char *ircnet, int port)
/* start listening */ /* start listening */
rec->handle = net_listen(NULL, &rec->port); rec->handle = net_listen(NULL, &rec->port);
if (rec->handle == -1) { if (rec->handle == NULL) {
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, printtext(NULL, NULL, MSGLEVEL_CLIENTERROR,
"Proxy: Listen in port %d failed: %s", "Proxy: Listen in port %d failed: %s",
rec->port, g_strerror(errno)); rec->port, g_strerror(errno));

View File

@ -11,14 +11,14 @@ typedef struct {
char *ircnet; char *ircnet;
int tag; int tag;
int handle; GIOChannel *handle;
} LISTEN_REC; } LISTEN_REC;
typedef struct { typedef struct {
LINEBUF_REC *buffer; LINEBUF_REC *buffer;
char *nick; char *nick;
int handle; GIOChannel *handle;
int tag; int tag;
char *proxy_address; char *proxy_address;