mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -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:
parent
d1eaeca255
commit
4316840890
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user