summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/core/irc-commands.c6
-rw-r--r--src/irc/core/irc-nicklist.c2
-rw-r--r--src/irc/core/irc-servers.c62
-rw-r--r--src/irc/core/sasl.c36
-rw-r--r--src/irc/dcc/dcc-chat.c2
-rw-r--r--src/irc/dcc/dcc-get.c16
-rw-r--r--src/irc/dcc/dcc-resume.c2
-rw-r--r--src/irc/dcc/dcc-server.c2
-rw-r--r--src/irc/dcc/dcc.c10
-rw-r--r--src/irc/proxy/proxy.c3
10 files changed, 77 insertions, 64 deletions
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c
index 6baf2f6d..32ee8845 100644
--- a/src/irc/core/irc-commands.c
+++ b/src/irc/core/irc-commands.c
@@ -1018,11 +1018,15 @@ void irc_commands_init(void)
command_bind_irc("trace", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: VERSION [<server>|<nick>] */
command_bind_irc("version", NULL, (SIGNAL_FUNC) command_self);
+ /* SYNTAX: SERVLIST [<mask> [<type>]] */
+ command_bind_irc("servlist", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: SILENCE [[+|-]<nick!user@host>]
SILENCE [<nick>] */
command_bind_irc("silence", NULL, (SIGNAL_FUNC) command_self);
command_bind_irc("unsilence", NULL, (SIGNAL_FUNC) cmd_unsilence);
command_bind_irc("sconnect", NULL, (SIGNAL_FUNC) cmd_sconnect);
+ /* SYNTAX: SQUERY <service> [<message>] */
+ command_bind_irc("squery", NULL, (SIGNAL_FUNC) command_2self);
/* SYNTAX: DIE */
command_bind_irc("die", NULL, (SIGNAL_FUNC) command_self);
/* SYNTAX: HASH */
@@ -1091,9 +1095,11 @@ void irc_commands_deinit(void)
command_unbind("time", (SIGNAL_FUNC) command_self);
command_unbind("trace", (SIGNAL_FUNC) command_self);
command_unbind("version", (SIGNAL_FUNC) command_self);
+ command_unbind("servlist", (SIGNAL_FUNC) command_self);
command_unbind("silence", (SIGNAL_FUNC) command_self);
command_unbind("unsilence", (SIGNAL_FUNC) cmd_unsilence);
command_unbind("sconnect", (SIGNAL_FUNC) cmd_sconnect);
+ command_unbind("squery", (SIGNAL_FUNC) command_2self);
command_unbind("die", (SIGNAL_FUNC) command_self);
command_unbind("hash", (SIGNAL_FUNC) command_self);
command_unbind("oper", (SIGNAL_FUNC) cmd_oper);
diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c
index bcb9d1f6..b22f3269 100644
--- a/src/irc/core/irc-nicklist.c
+++ b/src/irc/core/irc-nicklist.c
@@ -48,7 +48,7 @@ NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
rec->send_massjoin = send_massjoin;
if (prefixes != NULL) {
- strocpy(rec->prefixes, prefixes, sizeof(rec->prefixes));
+ g_strlcpy(rec->prefixes, prefixes, sizeof(rec->prefixes));
}
nicklist_insert(CHANNEL(channel), rec);
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index 81f0c269..feb7cee8 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -78,17 +78,23 @@ static int ischannel_func(SERVER_REC *server, const char *data)
IRC_SERVER_REC *irc_server = (IRC_SERVER_REC *) server;
char *chantypes, *statusmsg;
+ g_return_val_if_fail(data != NULL, FALSE);
+
+ /* empty string is no channel */
+ if (*data == '\0')
+ return FALSE;
+
chantypes = g_hash_table_lookup(irc_server->isupport, "chantypes");
if (chantypes == NULL)
chantypes = "#&!+"; /* normal, local, secure, modeless */
- statusmsg = g_hash_table_lookup(irc_server->isupport, "statusmsg");
- if (statusmsg == NULL)
- statusmsg = "@+";
- while (strchr(statusmsg, *data) != NULL)
- data++;
+ statusmsg = g_hash_table_lookup(irc_server->isupport, "statusmsg");
+ if (statusmsg != NULL)
+ data += strspn(data, statusmsg);
- return strchr(chantypes, *data) != NULL;
+ /* strchr(3) considers the trailing NUL as part of the string, make sure
+ * we didn't advance too much. */
+ return *data != '\0' && strchr(chantypes, *data) != NULL;
}
static char **split_line(const SERVER_REC *server, const char *line,
@@ -206,7 +212,6 @@ static void server_init(IRC_SERVER_REC *server)
{
IRC_SERVER_CONNECT_REC *conn;
char *address, *ptr, *username, *cmd;
- GTimeVal now;
g_return_if_fail(server != NULL);
@@ -281,9 +286,8 @@ static void server_init(IRC_SERVER_REC *server)
/* prevent the queue from sending too early, we have a max cut off of 120 secs */
/* this will reset to 1 sec after we get the 001 event */
- g_get_current_time(&now);
- memcpy(&((IRC_SERVER_REC *)server)->wait_cmd, &now, sizeof(GTimeVal));
- ((IRC_SERVER_REC *)server)->wait_cmd.tv_sec += 120;
+ g_get_current_time(&server->wait_cmd);
+ g_time_val_add(&server->wait_cmd, 120 * G_USEC_PER_SEC);
}
SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn)
@@ -529,7 +533,7 @@ void irc_server_send_data(IRC_SERVER_REC *server, const char *data, int len)
server->wait_cmd.tv_sec = 0;
else {
memcpy(&server->wait_cmd, &server->last_cmd, sizeof(GTimeVal));
- server->wait_cmd.tv_sec += 2 + len/100;
+ g_time_val_add(&server->wait_cmd, (2 + len/100) * G_USEC_PER_SEC);
}
}
@@ -617,39 +621,25 @@ char *irc_server_get_channels(IRC_SERVER_REC *server)
GString *chans, *keys;
char *ret;
int use_keys;
- char *rejoin_channels_mode;
+ int rejoin_channels_mode;
g_return_val_if_fail(server != NULL, FALSE);
- rejoin_channels_mode = g_strdup(settings_get_str("rejoin_channels_on_reconnect"));
+ rejoin_channels_mode = settings_get_choice("rejoin_channels_on_reconnect");
- if (rejoin_channels_mode == NULL ||
- (g_ascii_strcasecmp(rejoin_channels_mode, "on") != 0 &&
- g_ascii_strcasecmp(rejoin_channels_mode, "off") != 0 &&
- g_ascii_strcasecmp(rejoin_channels_mode, "auto") != 0)) {
- g_warning("Invalid value for 'rejoin_channels_on_reconnect', valid values are 'on', 'off', 'auto', using 'on' as default value.");
- g_free(rejoin_channels_mode);
- rejoin_channels_mode = g_strdup("on");
- }
+ /* do we want to rejoin channels in the first place? */
+ if(rejoin_channels_mode == 0)
+ return g_strdup("");
chans = g_string_new(NULL);
keys = g_string_new(NULL);
use_keys = FALSE;
- /* do we want to rejoin channels in the first place? */
- if(g_ascii_strcasecmp(rejoin_channels_mode, "off") == 0) {
- g_string_free(chans, TRUE);
- g_string_free(keys, TRUE);
- g_free(rejoin_channels_mode);
- return g_strdup("");
- }
-
/* get currently joined channels */
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
CHANNEL_REC *channel = tmp->data;
CHANNEL_SETUP_REC *setup = channel_setup_find(channel->name, channel->server->connrec->chatnet);
- if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) ||
- g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) {
+ if ((setup != NULL && setup->autojoin && rejoin_channels_mode == 2) || rejoin_channels_mode == 1) {
g_string_append_printf(chans, "%s,", channel->name);
g_string_append_printf(keys, "%s,", channel->key == NULL ? "x" : channel->key);
if (channel->key != NULL)
@@ -662,8 +652,7 @@ char *irc_server_get_channels(IRC_SERVER_REC *server)
REJOIN_REC *rec = tmp->data;
CHANNEL_SETUP_REC *setup = channel_setup_find(rec->channel, server->tag);
- if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) ||
- g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) {
+ if ((setup != NULL && setup->autojoin && rejoin_channels_mode == 2) || rejoin_channels_mode == 1) {
g_string_append_printf(chans, "%s,", rec->channel);
g_string_append_printf(keys, "%s,", rec->key == NULL ? "x" :
rec->key);
@@ -681,7 +670,6 @@ char *irc_server_get_channels(IRC_SERVER_REC *server)
ret = chans->str;
g_string_free(chans, FALSE);
g_string_free(keys, TRUE);
- g_free(rejoin_channels_mode);
return ret;
}
@@ -689,7 +677,6 @@ char *irc_server_get_channels(IRC_SERVER_REC *server)
static void event_connected(IRC_SERVER_REC *server, const char *data, const char *from)
{
char *params, *nick;
- GTimeVal now;
g_return_if_fail(server != NULL);
@@ -712,8 +699,7 @@ static void event_connected(IRC_SERVER_REC *server, const char *data, const char
server->real_connect_time = time(NULL);
/* let the queue send now that we are identified */
- g_get_current_time(&now);
- memcpy(&server->wait_cmd, &now, sizeof(GTimeVal));
+ g_get_current_time(&server->wait_cmd);
if (server->connrec->usermode != NULL) {
/* Send the user mode, before the autosendcmd.
@@ -1027,7 +1013,7 @@ void irc_server_init_isupport(IRC_SERVER_REC *server)
void irc_servers_init(void)
{
- settings_add_str("servers", "rejoin_channels_on_reconnect", "on");
+ settings_add_choice("servers", "rejoin_channels_on_reconnect", 1, "off;on;auto");
settings_add_str("misc", "usermode", DEFAULT_USER_MODE);
settings_add_str("misc", "split_line_start", "");
settings_add_str("misc", "split_line_end", "");
diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c
index 8fba9ba2..f080ae59 100644
--- a/src/irc/core/sasl.c
+++ b/src/irc/core/sasl.c
@@ -34,7 +34,7 @@ static gboolean sasl_timeout(IRC_SERVER_REC *server)
irc_send_cmd_now(server, "AUTHENTICATE *");
cap_finish_negotiation(server);
- server->sasl_timeout = -1;
+ server->sasl_timeout = 0;
signal_emit("server sasl failure", 2, server, "The authentication timed out");
@@ -64,14 +64,14 @@ static void sasl_fail(IRC_SERVER_REC *server, const char *data, const char *from
char *params, *error;
/* Stop any pending timeout, if any */
- if (server->sasl_timeout != -1) {
+ if (server->sasl_timeout != 0) {
g_source_remove(server->sasl_timeout);
- server->sasl_timeout = -1;
+ server->sasl_timeout = 0;
}
params = event_get_params(data, 2, NULL, &error);
- signal_emit("server sasl fail", 2, server, error);
+ signal_emit("server sasl failure", 2, server, error);
/* Terminate the negotiation */
cap_finish_negotiation(server);
@@ -81,9 +81,9 @@ static void sasl_fail(IRC_SERVER_REC *server, const char *data, const char *from
static void sasl_already(IRC_SERVER_REC *server, const char *data, const char *from)
{
- if (server->sasl_timeout != -1) {
+ if (server->sasl_timeout != 0) {
g_source_remove(server->sasl_timeout);
- server->sasl_timeout = -1;
+ server->sasl_timeout = 0;
}
signal_emit("server sasl success", 1, server);
@@ -94,9 +94,9 @@ static void sasl_already(IRC_SERVER_REC *server, const char *data, const char *f
static void sasl_success(IRC_SERVER_REC *server, const char *data, const char *from)
{
- if (server->sasl_timeout != -1) {
+ if (server->sasl_timeout != 0) {
g_source_remove(server->sasl_timeout);
- server->sasl_timeout = -1;
+ server->sasl_timeout = 0;
}
signal_emit("server sasl success", 1, server);
@@ -114,9 +114,9 @@ static void sasl_step(IRC_SERVER_REC *server, const char *data, const char *from
conn = server->connrec;
/* Stop the timer */
- if (server->sasl_timeout != -1) {
+ if (server->sasl_timeout != 0) {
g_source_remove(server->sasl_timeout);
- server->sasl_timeout = -1;
+ server->sasl_timeout = 0;
}
switch (conn->sasl_mechanism) {
@@ -153,6 +153,20 @@ static void sasl_step(IRC_SERVER_REC *server, const char *data, const char *from
server->sasl_timeout = g_timeout_add(SASL_TIMEOUT, (GSourceFunc) sasl_timeout, server);
}
+static void sasl_disconnected(IRC_SERVER_REC *server)
+{
+ g_return_if_fail(server != NULL);
+
+ if (!IS_IRC_SERVER(server)) {
+ return;
+ }
+
+ if (server->sasl_timeout != 0) {
+ g_source_remove(server->sasl_timeout);
+ server->sasl_timeout = 0;
+ }
+}
+
void sasl_init(void)
{
signal_add_first("server cap ack sasl", (SIGNAL_FUNC) sasl_start);
@@ -163,6 +177,7 @@ void sasl_init(void)
signal_add_first("event 905", (SIGNAL_FUNC) sasl_fail);
signal_add_first("event 906", (SIGNAL_FUNC) sasl_fail);
signal_add_first("event 907", (SIGNAL_FUNC) sasl_already);
+ signal_add_first("server disconnected", (SIGNAL_FUNC) sasl_disconnected);
}
void sasl_deinit(void)
@@ -175,4 +190,5 @@ void sasl_deinit(void)
signal_remove("event 905", (SIGNAL_FUNC) sasl_fail);
signal_remove("event 906", (SIGNAL_FUNC) sasl_fail);
signal_remove("event 907", (SIGNAL_FUNC) sasl_already);
+ signal_remove("server disconnected", (SIGNAL_FUNC) sasl_disconnected);
}
diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c
index e3dbe72d..ca90b8d8 100644
--- a/src/irc/dcc/dcc-chat.c
+++ b/src/irc/dcc/dcc-chat.c
@@ -619,7 +619,7 @@ static void ctcp_msg_dcc_chat(IRC_SERVER_REC *server, const char *data,
/* CHAT <unused> <address> <port> */
/* CHAT <unused> <address> 0 <id> (DCC CHAT passive protocol) */
params = g_strsplit(data, " ", -1);
- paramcount = strarray_length(params);
+ paramcount = g_strv_length(params);
if (paramcount < 3) {
g_strfreev(params);
diff --git a/src/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c
index a8b1c967..f7a95bb9 100644
--- a/src/irc/dcc/dcc-get.c
+++ b/src/irc/dcc/dcc-get.c
@@ -423,7 +423,7 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
/* SEND <file name> <address> <port> <size> [...] */
/* SEND <file name> <address> 0 <size> <id> (DCC SEND passive protocol) */
params = g_strsplit(data, " ", -1);
- paramcount = strarray_length(params);
+ paramcount = g_strv_length(params);
if (paramcount < 4) {
signal_emit("dcc error ctcp", 5, "SEND", data,
@@ -473,8 +473,8 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
net_ip2host(&temp_dcc->addr, temp_dcc->addrstr);
else {
/* with IPv6, show it to us as it was sent */
- strocpy(temp_dcc->addrstr, address,
- sizeof(temp_dcc->addrstr));
+ g_strlcpy(temp_dcc->addrstr, address,
+ sizeof(temp_dcc->addrstr));
}
/* This new signal is added to let us invoke
@@ -508,7 +508,7 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
net_ip2host(&dcc->addr, dcc->addrstr);
else {
/* with IPv6, show it to us as it was sent */
- strocpy(dcc->addrstr, address, sizeof(dcc->addrstr));
+ g_strlcpy(dcc->addrstr, address, sizeof(dcc->addrstr));
}
dcc->port = port;
dcc->size = size;
@@ -526,14 +526,14 @@ void cmd_dcc_receive(const char *data, DCC_GET_FUNC accept_func,
{
GET_DCC_REC *dcc;
GSList *tmp, *next;
- char *nick, *fname;
+ char *nick, *arg, *fname;
void *free_arg;
int found;
g_return_if_fail(data != NULL);
- if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
- &nick, &fname))
+ if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
+ PARAM_FLAG_STRIP_TRAILING_WS, &nick, &arg))
return;
if (*nick == '\0') {
@@ -548,6 +548,8 @@ void cmd_dcc_receive(const char *data, DCC_GET_FUNC accept_func,
return;
}
+ fname = cmd_get_quoted_param(&arg);
+
found = FALSE;
for (tmp = dcc_conns; tmp != NULL; tmp = next) {
GET_DCC_REC *dcc = tmp->data;
diff --git a/src/irc/dcc/dcc-resume.c b/src/irc/dcc/dcc-resume.c
index 11b28aef..36f84ddf 100644
--- a/src/irc/dcc/dcc-resume.c
+++ b/src/irc/dcc/dcc-resume.c
@@ -88,7 +88,7 @@ static int dcc_ctcp_resume_parse(int type, const char *data, const char *nick,
/* RESUME|ACCEPT <file name> <port> <size> */
/* RESUME|ACCEPT <file name> 0 <size> <id> (passive protocol) */
params = g_strsplit(data, " ", -1);
- paramcount = strarray_length(params);
+ paramcount = g_strv_length(params);
if (paramcount < 3)
return 0;
diff --git a/src/irc/dcc/dcc-server.c b/src/irc/dcc/dcc-server.c
index 30224ff9..7ae572cd 100644
--- a/src/irc/dcc/dcc-server.c
+++ b/src/irc/dcc/dcc-server.c
@@ -245,7 +245,7 @@ static void dcc_server_msg(SERVER_DCC_REC *dcc, const char *msg)
/* 120 clientnickname filesize filename */
params = g_strsplit(msg, " ", -1);
- paramcount = strarray_length(params);
+ paramcount = g_strv_length(params);
if (paramcount < 3) {
g_strfreev(params);
diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c
index 7f35585e..c51f7c7a 100644
--- a/src/irc/dcc/dcc.c
+++ b/src/irc/dcc/dcc.c
@@ -490,14 +490,14 @@ static void event_no_such_nick(IRC_SERVER_REC *server, char *data)
static void cmd_dcc_close(char *data, IRC_SERVER_REC *server)
{
GSList *tmp, *next;
- char *typestr, *nick, *arg;
+ char *typestr, *nick, *arg, *fname;
void *free_arg;
int found, type;
g_return_if_fail(data != NULL);
- if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST |
- PARAM_FLAG_STRIP_TRAILING_WS, &typestr, &nick, &arg))
+ if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
+ &typestr, &nick, &arg))
return;
if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@@ -510,13 +510,15 @@ static void cmd_dcc_close(char *data, IRC_SERVER_REC *server)
return;
}
+ fname = cmd_get_quoted_param(&arg);
+
found = FALSE;
for (tmp = dcc_conns; tmp != NULL; tmp = next) {
DCC_REC *dcc = tmp->data;
next = tmp->next;
if (dcc->type == type && g_ascii_strcasecmp(dcc->nick, nick) == 0 &&
- (*arg == '\0' || g_strcmp0(dcc->arg, arg) == 0)) {
+ (*fname == '\0' || g_strcmp0(dcc->arg, fname) == 0)) {
dcc_reject(dcc, server);
found = TRUE;
}
diff --git a/src/irc/proxy/proxy.c b/src/irc/proxy/proxy.c
index 1a714045..2875d2c2 100644
--- a/src/irc/proxy/proxy.c
+++ b/src/irc/proxy/proxy.c
@@ -28,13 +28,14 @@
/* SYNTAX: IRSSIPROXY STATUS */
static void cmd_irssiproxy_status(const char *data, IRC_SERVER_REC *server)
{
+ GSList *tmp;
+
if (!settings_get_bool("irssiproxy")) {
printtext(server, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy is currently disabled");
return;
}
- GSList *tmp;
printtext(server, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: Currently connected clients: %d",