summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-10-10 22:31:19 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-10-17 21:28:31 +0200
commiteda8ad9de54a645b979d5b1fdd46638876a4c578 (patch)
tree17e2f1d8f1da432639ec892ea187bacda29687bb /src
parentdf6f32a7bb1e097af20eded11f0f5c7a6837740b (diff)
downloadweechat-eda8ad9de54a645b979d5b1fdd46638876a4c578.zip
irc: use parsed command parameters in "generic_error" command callback
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-protocol.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 03879b982..4030f3821 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1255,39 +1255,38 @@ IRC_PROTOCOL_CALLBACK(error)
* command "ERROR").
*
* Command looks like:
- * :server 404 nick #channel :Cannot send to channel
+ * 404 nick #channel :Cannot send to channel
*/
IRC_PROTOCOL_CALLBACK(generic_error)
{
- int first_arg;
- char *chan_nick, *args;
+ int arg_error;
+ char *str_params;
+ const char *pos_chan_nick;
struct t_irc_channel *ptr_channel;
struct t_gui_buffer *ptr_buffer;
- IRC_PROTOCOL_MIN_ARGS(4);
+ IRC_PROTOCOL_MIN_PARAMS(1);
- first_arg = (irc_server_strcasecmp (server, argv[2], server->nick) == 0) ? 3 : 2;
+ arg_error = (irc_server_strcasecmp (server, params[0], server->nick) == 0) ?
+ 1 : 0;
- if ((argv[first_arg][0] != ':') && argv[first_arg + 1])
- {
- chan_nick = argv[first_arg];
- args = argv_eol[first_arg + 1];
- }
- else
+ pos_chan_nick = NULL;
+ if (params[arg_error + 1]
+ && irc_channel_is_channel (server, params[arg_error]))
{
- chan_nick = NULL;
- args = argv_eol[first_arg];
+ pos_chan_nick = params[arg_error];
+ arg_error++;
}
- if (args[0] == ':')
- args++;
ptr_channel = NULL;
- if (chan_nick)
- ptr_channel = irc_channel_search (server, chan_nick);
+ if (pos_chan_nick)
+ ptr_channel = irc_channel_search (server, pos_chan_nick);
ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
+ str_params = irc_protocol_string_params (params, arg_error);
+
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command,
@@ -1298,14 +1297,17 @@ IRC_PROTOCOL_CALLBACK(generic_error)
irc_protocol_tags (command, NULL, NULL, NULL),
"%s%s%s%s%s%s",
weechat_prefix ("network"),
- (ptr_channel && chan_nick
- && (irc_server_strcasecmp (server, chan_nick,
+ (ptr_channel && pos_chan_nick
+ && (irc_server_strcasecmp (server, pos_chan_nick,
ptr_channel->name) == 0)) ?
IRC_COLOR_CHAT_CHANNEL : "",
- (chan_nick) ? chan_nick : "",
+ (pos_chan_nick) ? pos_chan_nick : "",
IRC_COLOR_RESET,
- (chan_nick) ? ": " : "",
- args);
+ (pos_chan_nick) ? ": " : "",
+ str_params);
+
+ if (str_params)
+ free (str_params);
return WEECHAT_RC_OK;
}