summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/irc/irc-protocol.c75
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp26
2 files changed, 59 insertions, 42 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 5338dfe15..f48da7145 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -6633,20 +6633,21 @@ IRC_PROTOCOL_CALLBACK(729)
* (RPL_MONONLINE).
*
* Command looks like:
- * :server 730 mynick :nick1!user1@host1,nick2!user2@host2
+ * 730 mynick :nick1!user1@host1,nick2!user2@host2
*/
IRC_PROTOCOL_CALLBACK(730)
{
struct t_irc_notify *ptr_notify;
const char *monitor_nick, *monitor_host;
- char **nicks;
+ char *str_nicks, **nicks;
int i, num_nicks;
- IRC_PROTOCOL_MIN_ARGS(4);
+ IRC_PROTOCOL_MIN_PARAMS(2);
+
+ str_nicks = irc_protocol_string_params (params, 1, num_params - 1);
- nicks = weechat_string_split ((argv_eol[3][0] == ':') ?
- argv_eol[3] + 1 : argv_eol[3],
+ nicks = weechat_string_split (str_nicks,
",",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -6669,6 +6670,9 @@ IRC_PROTOCOL_CALLBACK(730)
weechat_string_free_split (nicks);
}
+ if (str_nicks)
+ free (str_nicks);
+
return WEECHAT_RC_OK;
}
@@ -6677,20 +6681,21 @@ IRC_PROTOCOL_CALLBACK(730)
* (RPL_MONOFFLINE).
*
* Command looks like:
- * :server 731 mynick :nick1!user1@host1,nick2!user2@host2
+ * 731 mynick :nick1!user1@host1,nick2!user2@host2
*/
IRC_PROTOCOL_CALLBACK(731)
{
struct t_irc_notify *ptr_notify;
const char *monitor_nick, *monitor_host;
- char **nicks;
+ char *str_nicks, **nicks;
int i, num_nicks;
- IRC_PROTOCOL_MIN_ARGS(4);
+ IRC_PROTOCOL_MIN_PARAMS(2);
+
+ str_nicks = irc_protocol_string_params (params, 1, num_params - 1);
- nicks = weechat_string_split ((argv_eol[3][0] == ':') ?
- argv_eol[3] + 1 : argv_eol[3],
+ nicks = weechat_string_split (str_nicks,
",",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -6713,6 +6718,9 @@ IRC_PROTOCOL_CALLBACK(731)
weechat_string_free_split (nicks);
}
+ if (str_nicks)
+ free (str_nicks);
+
return WEECHAT_RC_OK;
}
@@ -6720,17 +6728,17 @@ IRC_PROTOCOL_CALLBACK(731)
* Callback for the IRC command "732": list of monitored nicks (RPL_MONLIST).
*
* Command looks like:
- * :server 732 mynick :nick1!user1@host1,nick2!user2@host2
+ * 732 mynick :nick1!user1@host1,nick2!user2@host2
*/
IRC_PROTOCOL_CALLBACK(732)
{
- char *pos_args;
+ char *str_nicks;
- IRC_PROTOCOL_MIN_ARGS(3);
+ IRC_PROTOCOL_MIN_PARAMS(1);
- pos_args = (argc > 3) ?
- ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;
+ str_nicks = (num_params > 1) ?
+ irc_protocol_string_params (params, 1, num_params - 1) : NULL;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
@@ -6739,7 +6747,10 @@ IRC_PROTOCOL_CALLBACK(732)
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s",
weechat_prefix ("network"),
- (pos_args && pos_args[0]) ? pos_args : "");
+ (str_nicks) ? str_nicks : "");
+
+ if (str_nicks)
+ free (str_nicks);
return WEECHAT_RC_OK;
}
@@ -6748,17 +6759,17 @@ IRC_PROTOCOL_CALLBACK(732)
* Callback for the IRC command "733": end of a monitor list (RPL_ENDOFMONLIST).
*
* Command looks like:
- * :server 733 mynick :End of MONITOR list
+ * 733 mynick :End of MONITOR list
*/
IRC_PROTOCOL_CALLBACK(733)
{
- char *pos_args;
+ char *str_params;
- IRC_PROTOCOL_MIN_ARGS(3);
+ IRC_PROTOCOL_MIN_PARAMS(1);
- pos_args = (argc > 3) ?
- ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;
+ str_params = (num_params > 1) ?
+ irc_protocol_string_params (params, 1, num_params - 1) : NULL;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
@@ -6767,7 +6778,10 @@ IRC_PROTOCOL_CALLBACK(733)
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s",
weechat_prefix ("network"),
- (pos_args && pos_args[0]) ? pos_args : "");
+ (str_params) ? str_params : "");
+
+ if (str_params)
+ free (str_params);
return WEECHAT_RC_OK;
}
@@ -6776,17 +6790,17 @@ IRC_PROTOCOL_CALLBACK(733)
* Callback for the IRC command "734": monitor list is full (ERR_MONLISTFULL)
*
* Command looks like:
- * :server 734 mynick limit nick1,nick2 :Monitor list is full.
+ * 734 mynick limit nick1,nick2 :Monitor list is full.
*/
IRC_PROTOCOL_CALLBACK(734)
{
- char *pos_args;
+ char *str_params;
- IRC_PROTOCOL_MIN_ARGS(5);
+ IRC_PROTOCOL_MIN_PARAMS(3);
- pos_args = (argc > 5) ?
- ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL;
+ str_params = (num_params > 3) ?
+ irc_protocol_string_params (params, 3, num_params - 1) : NULL;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
@@ -6795,8 +6809,11 @@ IRC_PROTOCOL_CALLBACK(734)
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s (%s)",
weechat_prefix ("error"),
- (pos_args && pos_args[0]) ? pos_args : "",
- argv[3]);
+ (str_params) ? str_params : "",
+ params[1]);
+
+ if (str_params)
+ free (str_params);
return WEECHAT_RC_OK;
}
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp
index 73a669ef0..6abbbd043 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -3897,15 +3897,15 @@ TEST(IrcProtocolWithServer, 730)
{
SRV_INIT;
- /* not enough arguments */
+ /* not enough parameters */
RECV(":server 730");
- CHECK_ERROR_ARGS("730", 2, 4);
+ CHECK_ERROR_PARAMS("730", 0, 2);
RECV(":server 730 alice");
- CHECK_ERROR_ARGS("730", 3, 4);
+ CHECK_ERROR_PARAMS("730", 1, 2);
RECV(":server 731");
- CHECK_ERROR_ARGS("731", 2, 4);
+ CHECK_ERROR_PARAMS("731", 0, 2);
RECV(":server 731 alice");
- CHECK_ERROR_ARGS("731", 3, 4);
+ CHECK_ERROR_PARAMS("731", 1, 2);
RECV(":server 730 alice :nick1!user1@host1,nick2!user2@host2");
CHECK_NO_MSG;
@@ -3939,9 +3939,9 @@ TEST(IrcProtocolWithServer, 732)
{
SRV_INIT;
- /* not enough arguments */
+ /* not enough parameters */
RECV(":server 732");
- CHECK_ERROR_ARGS("732", 2, 3);
+ CHECK_ERROR_PARAMS("732", 0, 1);
RECV(":server 732 alice");
CHECK_NO_MSG;
@@ -3958,9 +3958,9 @@ TEST(IrcProtocolWithServer, 733)
{
SRV_INIT;
- /* not enough arguments */
+ /* not enough parameters */
RECV(":server 733");
- CHECK_ERROR_ARGS("733", 2, 3);
+ CHECK_ERROR_PARAMS("733", 0, 1);
RECV(":server 733 alice");
CHECK_NO_MSG;
@@ -3979,13 +3979,13 @@ TEST(IrcProtocolWithServer, 734)
{
SRV_INIT;
- /* not enough arguments */
+ /* not enough parameters */
RECV(":server 734");
- CHECK_ERROR_ARGS("734", 2, 5);
+ CHECK_ERROR_PARAMS("734", 0, 3);
RECV(":server 734 alice");
- CHECK_ERROR_ARGS("734", 3, 5);
+ CHECK_ERROR_PARAMS("734", 1, 3);
RECV(":server 734 alice 10");
- CHECK_ERROR_ARGS("734", 4, 5);
+ CHECK_ERROR_PARAMS("734", 2, 3);
RECV(":server 734 alice 10 nick1,nick2");
CHECK_SRV("=!= (10)");