summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-10-10 21:38:41 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-10-17 21:28:31 +0200
commit69c457287d7122ad7247d7e6dc589c90ef2681ee (patch)
tree75b0f58c33f2a6d0756bed47ea7b6ad3de776a9f /src/plugins/irc
parent5458382bb8969698230b5091fe3e2d3b60ba6637 (diff)
downloadweechat-69c457287d7122ad7247d7e6dc589c90ef2681ee.zip
irc: use parsed command parameters in "account" command callback
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-protocol.c7
-rw-r--r--src/plugins/irc/irc-protocol.h25
2 files changed, 29 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 7d5a09a3b..0499bf336 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -322,14 +322,15 @@ IRC_PROTOCOL_CALLBACK(account)
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_irc_channel_speaking *ptr_nick_speaking;
- char *pos_account, str_account[512];
+ const char *pos_account;
+ char str_account[512];
int cap_account_notify, local_account, smart_filter;
- IRC_PROTOCOL_MIN_ARGS(3);
+ IRC_PROTOCOL_MIN_PARAMS(1);
local_account = (irc_server_strcasecmp (server, nick, server->nick) == 0);
- pos_account = (argv[2][0] == ':') ? argv[2] + 1 : argv[2];
+ pos_account = params[0];
if (strcmp (pos_account, "*") == 0)
pos_account = NULL;
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index 95e0aca3a..c96e10bb8 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -52,6 +52,7 @@
(void) host; \
(void) command; \
(void) ignored; \
+ (void) argc; \
(void) argv; \
(void) argv_eol; \
(void) params; \
@@ -67,6 +68,30 @@
return WEECHAT_RC_ERROR; \
}
+#define IRC_PROTOCOL_MIN_PARAMS(__min_params) \
+ (void) date; \
+ (void) tags; \
+ (void) nick; \
+ (void) address; \
+ (void) host; \
+ (void) command; \
+ (void) ignored; \
+ (void) argc; \
+ (void) argv; \
+ (void) argv_eol; \
+ (void) params; \
+ (void) num_params; \
+ if (num_params < __min_params) \
+ { \
+ weechat_printf (server->buffer, \
+ _("%s%s: too few parameters received in " \
+ "command \"%s\" (received: %d parameters, " \
+ "expected: at least %d)"), \
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, \
+ command, num_params, __min_params); \
+ return WEECHAT_RC_ERROR; \
+ }
+
#define IRC_PROTOCOL_CHECK_HOST \
if (argv[0][0] != ':') \
{ \