summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/irc/irc-protocol.c43
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp8
2 files changed, 27 insertions, 24 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 74772f791..112cf0e53 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -5953,7 +5953,7 @@ IRC_PROTOCOL_CALLBACK(366)
* Callback for the IRC command "367": banlist.
*
* Command looks like:
- * :server 367 mynick #channel banmask nick!user@host 1205590879
+ * 367 mynick #channel banmask nick!user@host 1205590879
*/
IRC_PROTOCOL_CALLBACK(367)
@@ -5965,13 +5965,15 @@ IRC_PROTOCOL_CALLBACK(367)
const char *nick_address;
char str_number[64];
- IRC_PROTOCOL_MIN_ARGS(5);
+ IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, argv[3]);
+ ptr_channel = irc_channel_search (server, params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
ptr_channel->buffer : server->buffer;
- ptr_modelist = irc_modelist_search (ptr_channel, 'b');
+ ptr_modelist = (ptr_channel) ?
+ irc_modelist_search (ptr_channel, 'b') : NULL;
+ str_number[0] = '\0';
if (ptr_modelist)
{
/* start receiving new list */
@@ -5988,19 +5990,20 @@ IRC_PROTOCOL_CALLBACK(367)
((ptr_modelist->last_item) ? ptr_modelist->last_item->number + 1 : 0) + 1,
IRC_COLOR_CHAT_DELIMITERS);
}
- else
- str_number[0] = '\0';
- if (argc >= 6)
+ if (num_params >= 4)
{
nick_address = irc_protocol_nick_address (
- server, 1, NULL, irc_message_get_nick_from_host (argv[5]),
- irc_message_get_address_from_host (argv[5]));
- if (argc >= 7)
+ server, 1, NULL, irc_message_get_nick_from_host (params[3]),
+ irc_message_get_address_from_host (params[3]));
+ if (num_params >= 5)
{
- datetime = (time_t)(atol ((argv[6][0] == ':') ? argv[6] + 1 : argv[6]));
+ datetime = (time_t)(atol (params[4]));
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, argv[4], argv[5], datetime);
+ {
+ irc_modelist_item_new (ptr_modelist, params[2], params[3],
+ datetime);
+ }
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
@@ -6011,11 +6014,11 @@ IRC_PROTOCOL_CALLBACK(367)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- argv[3],
+ params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- argv[4],
+ params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?",
weechat_util_get_time_string (&datetime));
@@ -6023,7 +6026,7 @@ IRC_PROTOCOL_CALLBACK(367)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, argv[4], argv[5], 0);
+ irc_modelist_item_new (ptr_modelist, params[2], params[3], 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
@@ -6033,11 +6036,11 @@ IRC_PROTOCOL_CALLBACK(367)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- argv[3],
+ params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- argv[4],
+ params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?");
}
@@ -6045,7 +6048,7 @@ IRC_PROTOCOL_CALLBACK(367)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, argv[4], NULL, 0);
+ irc_modelist_item_new (ptr_modelist, params[2], NULL, 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
@@ -6055,11 +6058,11 @@ IRC_PROTOCOL_CALLBACK(367)
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- argv[3],
+ params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- argv[4],
+ params[2],
IRC_COLOR_RESET);
}
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp
index 8216108eb..7974627a7 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -3573,13 +3573,13 @@ TEST(IrcProtocolWithServer, 367)
{
SRV_INIT_JOIN;
- /* not enough arguments */
+ /* not enough parameters */
RECV(":server 367");
- CHECK_ERROR_ARGS("367", 2, 5);
+ CHECK_ERROR_PARAMS("367", 0, 3);
RECV(":server 367 alice");
- CHECK_ERROR_ARGS("367", 3, 5);
+ CHECK_ERROR_PARAMS("367", 1, 3);
RECV(":server 367 alice #test");
- CHECK_ERROR_ARGS("367", 4, 5);
+ CHECK_ERROR_PARAMS("367", 2, 3);
RECV(":server 367 alice #test nick1!user1@host1");
CHECK_CHAN("-- [#test] [1] nick1!user1@host1 banned");