summaryrefslogtreecommitdiff
path: root/src/irc/core/irc-channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc/core/irc-channels.c')
-rw-r--r--src/irc/core/irc-channels.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/irc/core/irc-channels.c b/src/irc/core/irc-channels.c
index dd6e29ce..e775f530 100644
--- a/src/irc/core/irc-channels.c
+++ b/src/irc/core/irc-channels.c
@@ -99,7 +99,7 @@ static void irc_channels_join(IRC_SERVER_REC *server, const char *data,
tmp = chanlist;
for (;; tmp++) {
if (*tmp != NULL) {
- channel = ischannel(**tmp) ? g_strdup(*tmp) :
+ channel = server_ischannel(SERVER(server), *tmp) ? g_strdup(*tmp) :
g_strdup_printf("#%s", *tmp);
chanrec = irc_channel_find(server, channel);
@@ -114,7 +114,7 @@ static void irc_channels_join(IRC_SERVER_REC *server, const char *data,
use_keys = TRUE;
key = schannel->password;
} else key = NULL;
-
+
g_string_append_printf(outkeys, "%s,", get_join_key(key));
channame = channel + (channel[0] == '!' &&
channel[1] == '!');
@@ -126,31 +126,33 @@ static void irc_channels_join(IRC_SERVER_REC *server, const char *data,
if (*tmpkey != NULL)
tmpkey++;
-
+
tmpstr = tmp;
tmpstr++;
cmdlen = outchans->len-1;
-
+
if (use_keys)
cmdlen += outkeys->len;
if (*tmpstr != NULL)
- cmdlen += ischannel(**tmpstr) ? strlen(*tmpstr) :
+ cmdlen += server_ischannel(SERVER(server), *tmpstr) ? strlen(*tmpstr) :
strlen(*tmpstr)+1;
if (*tmpkey != NULL)
cmdlen += strlen(*tmpkey);
-
- /* don't try to send too long lines
+
+ /* don't try to send too long lines
make sure it's not longer than 510
so 510 - strlen("JOIN ") = 505 */
if (cmdlen < 505)
continue;
}
if (outchans->len > 0) {
- g_string_truncate(outchans, outchans->len-1);
- g_string_truncate(outkeys, outkeys->len-1);
- irc_send_cmdv(IRC_SERVER(server),
- use_keys ? "JOIN %s %s" : "JOIN %s",
- outchans->str, outkeys->str);
+ g_string_truncate(outchans, outchans->len - 1);
+ g_string_truncate(outkeys, outkeys->len - 1);
+
+ if (use_keys)
+ irc_send_cmdv(IRC_SERVER(server), "JOIN %s %s", outchans->str, outkeys->str);
+ else
+ irc_send_cmdv(IRC_SERVER(server), "JOIN %s", outchans->str);
}
cmdlen = 0;
g_string_truncate(outchans,0);
@@ -172,6 +174,13 @@ static CHANNEL_REC *irc_channel_find_server(SERVER_REC *server,
const char *channel)
{
GSList *tmp;
+ char *fmt_channel;
+
+ /* if 'channel' has no leading # this lookup is going to fail, add a
+ * octothorpe in front of it to handle this case. */
+ fmt_channel = server_ischannel(SERVER(server), channel) ?
+ g_strdup(channel) :
+ g_strdup_printf("#%s", channel);
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
CHANNEL_REC *rec = tmp->data;
@@ -180,13 +189,19 @@ static CHANNEL_REC *irc_channel_find_server(SERVER_REC *server,
continue;
/* check both !ABCDEchannel and !channel */
- if (IRC_SERVER(server)->nick_comp_func(channel, rec->name) == 0)
+ if (IRC_SERVER(server)->nick_comp_func(fmt_channel, rec->name) == 0) {
+ g_free(fmt_channel);
return rec;
+ }
- if (IRC_SERVER(server)->nick_comp_func(channel, rec->visible_name) == 0)
+ if (IRC_SERVER(server)->nick_comp_func(fmt_channel, rec->visible_name) == 0) {
+ g_free(fmt_channel);
return rec;
+ }
}
+ g_free(fmt_channel);
+
return NULL;
}