summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-protocol.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-10-09 13:58:42 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-10-15 18:40:01 +0200
commit3898449dc24d10e29ef086e1d7474fd2eb1f5c9e (patch)
tree57f3a1effba82bdadecc927a32f872f89c05fe8d /src/plugins/irc/irc-protocol.c
parentaed5c543ec00107f22ee8e29774f595b547563c2 (diff)
downloadweechat-3898449dc24d10e29ef086e1d7474fd2eb1f5c9e.zip
irc: add structure with context sent as unique parameter to IRC protocol callbacks (issue #989)
Diffstat (limited to 'src/plugins/irc/irc-protocol.c')
-rw-r--r--src/plugins/irc/irc-protocol.c3124
1 files changed, 1542 insertions, 1582 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 9a9f0189a..6c2ac3626 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -163,9 +163,8 @@ irc_protocol_tags_add_cb (void *data,
*/
const char *
-irc_protocol_tags (struct t_irc_server *server, const char *command,
- struct t_hashtable *irc_msg_tags, const char *extra_tags,
- const char *nick, const char *address)
+irc_protocol_tags (struct t_irc_protocol_ctxt *ctxt,
+ const char *extra_tags, const char *nick, const char *address)
{
static char string[4096];
int log_level, is_numeric, has_irc_tags;
@@ -175,25 +174,25 @@ irc_protocol_tags (struct t_irc_server *server, const char *command,
str_log_level[0] = '\0';
- is_numeric = irc_protocol_is_numeric_command (command);
- has_irc_tags = (irc_msg_tags
- && weechat_hashtable_get_integer (irc_msg_tags,
+ is_numeric = irc_protocol_is_numeric_command (ctxt->command);
+ has_irc_tags = (ctxt->tags
+ && weechat_hashtable_get_integer (ctxt->tags,
"items_count") > 0);
- if (!command && !has_irc_tags && !extra_tags && !nick)
+ if (!ctxt->command && !has_irc_tags && !extra_tags && !nick)
return NULL;
if (has_irc_tags)
{
str_irc_tags = weechat_string_dyn_alloc (256);
- weechat_hashtable_map (irc_msg_tags, irc_protocol_tags_add_cb,
+ weechat_hashtable_map (ctxt->tags, irc_protocol_tags_add_cb,
str_irc_tags);
- if (server)
+ if (ctxt->server)
{
- ptr_tag_batch = weechat_hashtable_get (irc_msg_tags, "batch");
+ ptr_tag_batch = weechat_hashtable_get (ctxt->tags, "batch");
if (ptr_tag_batch && ptr_tag_batch)
{
- ptr_batch = irc_batch_search (server, ptr_tag_batch);
+ ptr_batch = irc_batch_search (ctxt->server, ptr_tag_batch);
if (ptr_batch)
{
if (*str_irc_tags[0])
@@ -211,9 +210,9 @@ irc_protocol_tags (struct t_irc_server *server, const char *command,
str_irc_tags = NULL;
}
- if (command && command[0])
+ if (ctxt->command && ctxt->command[0])
{
- log_level = irc_protocol_log_level_for_command (command);
+ log_level = irc_protocol_log_level_for_command (ctxt->command);
if (log_level > 0)
{
snprintf (str_log_level, sizeof (str_log_level),
@@ -223,8 +222,8 @@ irc_protocol_tags (struct t_irc_server *server, const char *command,
snprintf (string, sizeof (string),
"%s%s%s%s%s%s%s%s%s%s%s%s%s",
- (command && command[0]) ? "irc_" : "",
- (command && command[0]) ? command : "",
+ (ctxt->command && ctxt->command[0]) ? "irc_" : "",
+ (ctxt->command && ctxt->command[0]) ? ctxt->command : "",
(is_numeric) ? "," : "",
(is_numeric) ? "irc_numeric" : "",
(str_irc_tags && *str_irc_tags[0]) ? "," : "",
@@ -359,11 +358,11 @@ irc_protocol_parse_time (const char *time)
*/
char *
-irc_protocol_string_params (const char **params, int arg_start, int arg_end)
+irc_protocol_string_params (char **params, int arg_start, int arg_end)
{
char *result;
- result = weechat_string_rebuild_split_string (params, " ",
+ result = weechat_string_rebuild_split_string ((const char **)params, " ",
arg_start, arg_end);
return (result) ? result : strdup ("");
}
@@ -382,28 +381,23 @@ irc_protocol_string_params (const char **params, int arg_start, int arg_end)
*/
void
-irc_protocol_print_error_warning_msg (struct t_irc_server *server,
- time_t date,
- struct t_hashtable *tags,
- const char *command,
+irc_protocol_print_error_warning_msg (struct t_irc_protocol_ctxt *ctxt,
const char *prefix,
- const char *label,
- const char **params,
- int num_params)
+ const char *label)
{
const char *ptr_command;
char *str_context;
- ptr_command = (strcmp (params[0], "*") != 0) ?
- params[0] : NULL;
+ ptr_command = ((ctxt->num_params > 0) && (strcmp (ctxt->params[0], "*") != 0)) ?
+ ctxt->params[0] : NULL;
- str_context = (num_params > 2) ?
- irc_protocol_string_params (params, 1, num_params - 2) : NULL;
+ str_context = (ctxt->num_params > 2) ?
+ irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 2) : NULL;
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s%s%s%s[%s%s%s]%s %s",
(prefix) ? prefix : "",
(label) ? label : "",
@@ -415,7 +409,7 @@ irc_protocol_print_error_warning_msg (struct t_irc_server *server,
(str_context) ? str_context : "",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- params[num_params - 1]);
+ ctxt->params[ctxt->num_params - 1]);
if (str_context)
free (str_context);
@@ -437,13 +431,11 @@ IRC_PROTOCOL_CALLBACK(account)
struct t_irc_channel_speaking *ptr_nick_speaking;
const char *pos_account;
char str_account[512];
- int cap_account_notify, local_account, smart_filter;
+ int cap_account_notify, smart_filter;
IRC_PROTOCOL_MIN_PARAMS(1);
- local_account = (irc_server_strcasecmp (server, nick, server->nick) == 0);
-
- pos_account = params[0];
+ pos_account = ctxt->params[0];
if (strcmp (pos_account, "*") == 0)
pos_account = NULL;
@@ -452,71 +444,65 @@ IRC_PROTOCOL_CALLBACK(account)
{
snprintf (str_account, sizeof (str_account),
"%s%s",
- irc_nick_color_for_msg (server, 1, NULL, pos_account),
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, pos_account),
pos_account);
}
- cap_account_notify = weechat_hashtable_has_key (server->cap_list,
+ cap_account_notify = weechat_hashtable_has_key (ctxt->server->cap_list,
"account-notify");
- for (ptr_channel = server->channels; ptr_channel;
+ for (ptr_channel = ctxt->server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
switch (ptr_channel->type)
{
case IRC_CHANNEL_TYPE_PRIVATE:
- if (!ignored
+ if (!ctxt->ignored
&& weechat_config_boolean (irc_config_look_display_account_message)
- && (irc_server_strcasecmp (server,
- ptr_channel->name, nick) == 0))
+ && (irc_server_strcasecmp (ctxt->server,
+ ptr_channel->name, ctxt->nick) == 0))
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (
- server,
- command,
- tags,
- NULL,
- nick, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, ctxt->nick, ctxt->address),
(pos_account) ? _("%s%s%s%s has identified as %s") : _("%s%s%s%s has unidentified"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_ACCOUNT,
(pos_account) ? str_account : NULL);
}
break;
case IRC_CHANNEL_TYPE_CHANNEL:
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
if (ptr_nick)
{
- if (!ignored
+ if (!ctxt->ignored
&& weechat_config_boolean (irc_config_look_display_account_message))
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_account))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
- smart_filter = (!local_account
+ irc_channel_nick_speaking_time_search (ctxt->server, ptr_channel, ctxt->nick, 1) : NULL;
+ smart_filter = (!ctxt->nick_is_me
&& weechat_config_boolean (irc_config_look_smart_filter)
&& weechat_config_boolean (irc_config_look_smart_filter_account)
&& !ptr_nick_speaking);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
irc_protocol_tags (
- server,
- command,
- tags,
+ ctxt,
(smart_filter) ? "irc_smart_filter" : NULL,
- nick, address),
+ ctxt->nick,
+ ctxt->address),
(pos_account) ? _("%s%s%s%s has identified as %s") : _("%s%s%s%s has unidentified"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_ACCOUNT,
(pos_account) ? str_account : NULL);
}
@@ -548,14 +534,14 @@ IRC_PROTOCOL_CALLBACK(authenticate)
IRC_PROTOCOL_MIN_PARAMS(1);
- if (!irc_server_sasl_enabled (server))
+ if (!irc_server_sasl_enabled (ctxt->server))
return WEECHAT_RC_OK;
- irc_server_sasl_get_creds (server, &sasl_username, &sasl_password,
+ irc_server_sasl_get_creds (ctxt->server, &sasl_username, &sasl_password,
&sasl_key);
sasl_mechanism = IRC_SERVER_OPTION_ENUM(
- server, IRC_SERVER_OPTION_SASL_MECHANISM);
+ ctxt->server, IRC_SERVER_OPTION_SASL_MECHANISM);
answer = NULL;
sasl_error = NULL;
@@ -566,22 +552,22 @@ IRC_PROTOCOL_CALLBACK(authenticate)
break;
case IRC_SASL_MECHANISM_SCRAM_SHA_1:
answer = irc_sasl_mechanism_scram (
- server, "sha1", params[0],
+ ctxt->server, "sha1", ctxt->params[0],
sasl_username, sasl_password, &sasl_error);
break;
case IRC_SASL_MECHANISM_SCRAM_SHA_256:
answer = irc_sasl_mechanism_scram (
- server, "sha256", params[0],
+ ctxt->server, "sha256", ctxt->params[0],
sasl_username, sasl_password, &sasl_error);
break;
case IRC_SASL_MECHANISM_SCRAM_SHA_512:
answer = irc_sasl_mechanism_scram (
- server, "sha512", params[0],
+ ctxt->server, "sha512", ctxt->params[0],
sasl_username, sasl_password, &sasl_error);
break;
case IRC_SASL_MECHANISM_ECDSA_NIST256P_CHALLENGE:
answer = irc_sasl_mechanism_ecdsa_nist256p_challenge (
- server, params[0],
+ ctxt->server, ctxt->params[0],
sasl_username, sasl_key, &sasl_error);
break;
case IRC_SASL_MECHANISM_EXTERNAL:
@@ -592,7 +578,7 @@ IRC_PROTOCOL_CALLBACK(authenticate)
{
if (sasl_error)
{
- weechat_printf (server->buffer,
+ weechat_printf (ctxt->server->buffer,
_("%s%s: SASL error: %s"),
weechat_prefix ("error"),
IRC_PLUGIN_NAME,
@@ -600,19 +586,19 @@ IRC_PROTOCOL_CALLBACK(authenticate)
}
else
{
- server->sasl_mechanism_used = sasl_mechanism;
+ ctxt->server->sasl_mechanism_used = sasl_mechanism;
}
- irc_server_sendf (server, 0, NULL, "AUTHENTICATE %s", answer);
+ irc_server_sendf (ctxt->server, 0, NULL, "AUTHENTICATE %s", answer);
free (answer);
}
else
{
- weechat_printf (server->buffer,
+ weechat_printf (ctxt->server->buffer,
_("%s%s: SASL error: %s"),
weechat_prefix ("error"),
IRC_PLUGIN_NAME,
(sasl_error) ? sasl_error : _("internal error"));
- irc_server_sendf (server, 0, NULL, "CAP END");
+ irc_server_sendf (ctxt->server, 0, NULL, "CAP END");
}
if (sasl_username)
free (sasl_username);
@@ -643,14 +629,14 @@ IRC_PROTOCOL_CALLBACK(away)
IRC_PROTOCOL_MIN_PARAMS(0);
IRC_PROTOCOL_CHECK_NICK;
- for (ptr_channel = server->channels; ptr_channel;
+ for (ptr_channel = ctxt->server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
if (ptr_nick)
{
- irc_nick_set_away (server, ptr_channel, ptr_nick,
- (num_params > 0));
+ irc_nick_set_away (ctxt->server, ptr_channel, ptr_nick,
+ (ctxt->num_params > 0));
}
}
@@ -673,30 +659,30 @@ IRC_PROTOCOL_CALLBACK(batch)
IRC_PROTOCOL_MIN_PARAMS(1);
/* do nothing (but ignore BATCH) if capability "batch" is not enabled */
- if (!weechat_hashtable_has_key (server->cap_list, "batch"))
+ if (!weechat_hashtable_has_key (ctxt->server->cap_list, "batch"))
return WEECHAT_RC_OK;
- if (params[0][0] == '+')
+ if (ctxt->params[0][0] == '+')
{
/* start batch */
- if (num_params < 2)
+ if (ctxt->num_params < 2)
return WEECHAT_RC_ERROR;
- str_params = (num_params > 2) ?
- irc_protocol_string_params (params, 2, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 2) ?
+ irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1) : NULL;
irc_batch_start_batch (
- server,
- params[0] + 1, /* reference */
- weechat_hashtable_get (tags, "batch"), /* parent ref */
- params[1], /* type */
+ ctxt->server,
+ ctxt->params[0] + 1, /* reference */
+ weechat_hashtable_get (ctxt->tags, "batch"), /* parent ref */
+ ctxt->params[1], /* type */
str_params,
- tags);
+ ctxt->tags);
if (str_params)
free (str_params);
}
- else if (params[0][0] == '-')
+ else if (ctxt->params[0][0] == '-')
{
/* end batch */
- irc_batch_end_batch (server, params[0] + 1);
+ irc_batch_end_batch (ctxt->server, ctxt->params[0] + 1);
}
return WEECHAT_RC_OK;
@@ -969,13 +955,13 @@ IRC_PROTOCOL_CALLBACK(cap)
IRC_PROTOCOL_MIN_PARAMS(2);
- if (strcmp (params[1], "LS") == 0)
+ if (strcmp (ctxt->params[1], "LS") == 0)
{
/* list of capabilities supported by the server */
- if (num_params < 3)
+ if (ctxt->num_params < 3)
return WEECHAT_RC_OK;
- if ((num_params > 3) && (strcmp (params[2], "*") == 0))
+ if ((ctxt->num_params > 3) && (strcmp (ctxt->params[2], "*") == 0))
{
arg_caps = 3;
last_reply = 0;
@@ -986,19 +972,19 @@ IRC_PROTOCOL_CALLBACK(cap)
last_reply = 1;
}
- if (!server->checking_cap_ls)
+ if (!ctxt->server->checking_cap_ls)
{
- weechat_hashtable_remove_all (server->cap_ls);
- server->checking_cap_ls = 1;
+ weechat_hashtable_remove_all (ctxt->server->cap_ls);
+ ctxt->server->checking_cap_ls = 1;
}
if (last_reply)
- server->checking_cap_ls = 0;
+ ctxt->server->checking_cap_ls = 0;
- for (i = arg_caps; i < num_params; i++)
+ for (i = arg_caps; i < ctxt->num_params; i++)
{
caps_supported = weechat_string_split (
- params[i],
+ ctxt->params[i],
" ",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -1017,19 +1003,19 @@ IRC_PROTOCOL_CALLBACK(cap)
pos_value - caps_supported[j]);
if (str_name)
{
- weechat_hashtable_set (server->cap_ls,
+ weechat_hashtable_set (ctxt->server->cap_ls,
str_name, pos_value + 1);
if (strcmp (str_name, "draft/multiline") == 0)
{
irc_message_parse_cap_multiline_value (
- server, pos_value + 1);
+ ctxt->server, pos_value + 1);
}
free (str_name);
}
}
else
{
- weechat_hashtable_set (server->cap_ls,
+ weechat_hashtable_set (ctxt->server->cap_ls,
caps_supported[j], NULL);
}
}
@@ -1039,11 +1025,11 @@ IRC_PROTOCOL_CALLBACK(cap)
if (last_reply)
{
str_caps = weechat_string_dyn_alloc (128);
- weechat_hashtable_map_string (server->cap_ls,
+ weechat_hashtable_map_string (ctxt->server->cap_ls,
irc_protocol_cap_print_cb,
str_caps);
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, server supports: %s"),
weechat_prefix ("network"),
IRC_PLUGIN_NAME,
@@ -1052,16 +1038,16 @@ IRC_PROTOCOL_CALLBACK(cap)
}
/* auto-enable capabilities only when connecting to server */
- if (last_reply && !server->is_connected)
- irc_protocol_cap_sync (server, 1);
+ if (last_reply && !ctxt->server->is_connected)
+ irc_protocol_cap_sync (ctxt->server, 1);
}
- else if (strcmp (params[1], "LIST") == 0)
+ else if (strcmp (ctxt->params[1], "LIST") == 0)
{
/* list of capabilities currently enabled */
- if (num_params < 3)
+ if (ctxt->num_params < 3)
return WEECHAT_RC_OK;
- if ((num_params > 3) && (strcmp (params[2], "*") == 0))
+ if ((ctxt->num_params > 3) && (strcmp (ctxt->params[2], "*") == 0))
{
arg_caps = 3;
last_reply = 0;
@@ -1072,20 +1058,20 @@ IRC_PROTOCOL_CALLBACK(cap)
last_reply = 1;
}
- if (!server->checking_cap_list)
+ if (!ctxt->server->checking_cap_list)
{
- weechat_hashtable_remove_all (server->cap_list);
- irc_server_buffer_set_input_multiline (server, 0);
- server->checking_cap_list = 1;
+ weechat_hashtable_remove_all (ctxt->server->cap_list);
+ irc_server_buffer_set_input_multiline (ctxt->server, 0);
+ ctxt->server->checking_cap_list = 1;
}
if (last_reply)
- server->checking_cap_list = 0;
+ ctxt->server->checking_cap_list = 0;
- for (i = arg_caps; i < num_params; i++)
+ for (i = arg_caps; i < ctxt->num_params; i++)
{
caps_enabled = weechat_string_split (
- params[i],
+ ctxt->params[i],
" ",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -1104,19 +1090,19 @@ IRC_PROTOCOL_CALLBACK(cap)
pos_value - caps_enabled[j]);
if (str_name)
{
- weechat_hashtable_set (server->cap_list,
+ weechat_hashtable_set (ctxt->server->cap_list,
str_name, pos_value + 1);
if (strcmp (str_name, "draft/multiline") == 0)
- irc_server_buffer_set_input_multiline (server, 1);
+ irc_server_buffer_set_input_multiline (ctxt->server, 1);
free (str_name);
}
}
else
{
- weechat_hashtable_set (server->cap_list,
+ weechat_hashtable_set (ctxt->server->cap_list,
caps_enabled[j], NULL);
if (strcmp (caps_enabled[j], "draft/multiline") == 0)
- irc_server_buffer_set_input_multiline (server, 1);
+ irc_server_buffer_set_input_multiline (ctxt->server, 1);
}
}
weechat_string_free_split (caps_enabled);
@@ -1125,11 +1111,11 @@ IRC_PROTOCOL_CALLBACK(cap)
if (last_reply)
{
str_caps = weechat_string_dyn_alloc (128);
- weechat_hashtable_map_string (server->cap_list,
+ weechat_hashtable_map_string (ctxt->server->cap_list,
irc_protocol_cap_print_cb,
str_caps);
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, currently enabled: %s"),
weechat_prefix ("network"),
IRC_PLUGIN_NAME,
@@ -1137,20 +1123,20 @@ IRC_PROTOCOL_CALLBACK(cap)
weechat_string_dyn_free (str_caps, 1);
}
}
- else if (strcmp (params[1], "ACK") == 0)
+ else if (strcmp (ctxt->params[1], "ACK") == 0)
{
/* capabilities acknowledged */
- if (num_params < 3)
+ if (ctxt->num_params < 3)
return WEECHAT_RC_OK;
sasl_to_do = 0;
str_caps_enabled = weechat_string_dyn_alloc (128);
str_caps_disabled = weechat_string_dyn_alloc (128);
- for (i = 2; i < num_params; i++)
+ for (i = 2; i < ctxt->num_params; i++)
{
caps_supported = weechat_string_split (
- params[i],
+ ctxt->params[i],
" ",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -1169,10 +1155,10 @@ IRC_PROTOCOL_CALLBACK(cap)
weechat_string_dyn_concat (str_caps_disabled,
caps_supported[j] + 1,
-1);
- weechat_hashtable_remove (server->cap_list,
+ weechat_hashtable_remove (ctxt->server->cap_list,
caps_supported[j] + 1);
if (strcmp (caps_supported[j] + 1, "draft/multiline") == 0)
- irc_server_buffer_set_input_multiline (server, 0);
+ irc_server_buffer_set_input_multiline (ctxt->server, 0);
}
else
{
@@ -1181,10 +1167,10 @@ IRC_PROTOCOL_CALLBACK(cap)
weechat_string_dyn_concat (str_caps_enabled,
caps_supported[j],
-1);
- weechat_hashtable_set (server->cap_list,
+ weechat_hashtable_set (ctxt->server->cap_list,
caps_supported[j], NULL);
if (strcmp (caps_supported[j], "draft/multiline") == 0)
- irc_server_buffer_set_input_multiline (server, 1);
+ irc_server_buffer_set_input_multiline (ctxt->server, 1);
if (strcmp (caps_supported[j], "sasl") == 0)
sasl_to_do = 1;
}
@@ -1194,7 +1180,7 @@ IRC_PROTOCOL_CALLBACK(cap)
if (*str_caps_enabled[0] && *str_caps_disabled[0])
{
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, enabled: %s, disabled: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME,
*str_caps_enabled, *str_caps_disabled);
@@ -1202,7 +1188,7 @@ IRC_PROTOCOL_CALLBACK(cap)
else if (*str_caps_enabled[0])
{
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, enabled: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME,
*str_caps_enabled);
@@ -1210,7 +1196,7 @@ IRC_PROTOCOL_CALLBACK(cap)
else if (*str_caps_disabled[0])
{
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, disabled: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME,
*str_caps_disabled);
@@ -1221,7 +1207,7 @@ IRC_PROTOCOL_CALLBACK(cap)
if (sasl_to_do)
{
sasl_mechanism = IRC_SERVER_OPTION_ENUM(
- server, IRC_SERVER_OPTION_SASL_MECHANISM);
+ ctxt->server, IRC_SERVER_OPTION_SASL_MECHANISM);
if ((sasl_mechanism >= 0)
&& (sasl_mechanism < IRC_NUM_SASL_MECHANISMS))
{
@@ -1231,54 +1217,54 @@ IRC_PROTOCOL_CALLBACK(cap)
str_msg_auth_upper = weechat_string_toupper (str_msg_auth);
if (str_msg_auth_upper)
{
- irc_server_sendf (server, 0, NULL, str_msg_auth_upper);
+ irc_server_sendf (ctxt->server, 0, NULL, str_msg_auth_upper);
free (str_msg_auth_upper);
}
- if (server->hook_timer_sasl)
- weechat_unhook (server->hook_timer_sasl);
+ if (ctxt->server->hook_timer_sasl)
+ weechat_unhook (ctxt->server->hook_timer_sasl);
timeout = IRC_SERVER_OPTION_INTEGER(
- server, IRC_SERVER_OPTION_SASL_TIMEOUT);
- server->hook_timer_sasl = weechat_hook_timer (
+ ctxt->server, IRC_SERVER_OPTION_SASL_TIMEOUT);
+ ctxt->server->hook_timer_sasl = weechat_hook_timer (
timeout * 1000,
0, 1,
&irc_server_timer_sasl_cb,
- server, NULL);
+ ctxt->server, NULL);
}
}
}
- else if (strcmp (params[1], "NAK") == 0)
+ else if (strcmp (ctxt->params[1], "NAK") == 0)
{
/* capabilities rejected */
- if (num_params < 3)
+ if (ctxt->num_params < 3)
return WEECHAT_RC_OK;
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, refused: %s"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, str_params);
if (str_params)
free (str_params);
- if (!server->is_connected)
- irc_server_sendf (server, 0, NULL, "CAP END");
+ if (!ctxt->server->is_connected)
+ irc_server_sendf (ctxt->server, 0, NULL, "CAP END");
}
- else if (strcmp (params[1], "NEW") == 0)
+ else if (strcmp (ctxt->params[1], "NEW") == 0)
{
/* new capabilities available */
- if (num_params < 3)
+ if (ctxt->num_params < 3)
return WEECHAT_RC_OK;
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, now available: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME, str_params);
if (str_params)
free (str_params);
- for (i = 2; i < num_params; i++)
+ for (i = 2; i < ctxt->num_params; i++)
{
caps_added = weechat_string_split (
- params[i],
+ ctxt->params[i],
" ",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -1297,14 +1283,14 @@ IRC_PROTOCOL_CALLBACK(cap)
pos_value - caps_added[j]);
if (str_name)
{
- weechat_hashtable_set (server->cap_ls,
+ weechat_hashtable_set (ctxt->server->cap_ls,
str_name, pos_value + 1);
free (str_name);
}
}
else
{
- weechat_hashtable_set (server->cap_ls,
+ weechat_hashtable_set (ctxt->server->cap_ls,
caps_added[j], NULL);
}
}
@@ -1312,25 +1298,25 @@ IRC_PROTOCOL_CALLBACK(cap)
}
/* TODO: SASL Reauthentication */
- irc_protocol_cap_sync (server, 0);
+ irc_protocol_cap_sync (ctxt->server, 0);
}
- else if (strcmp (params[1], "DEL") == 0)
+ else if (strcmp (ctxt->params[1], "DEL") == 0)
{
/* capabilities no longer available */
- if (num_params < 3)
+ if (ctxt->num_params < 3)
return WEECHAT_RC_OK;
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
- server->buffer, date, "irc_cap,log3",
+ ctxt->server->buffer, ctxt->date, "irc_cap,log3",
_("%s%s: client capability, removed: %s"),
weechat_prefix ("network"), IRC_PLUGIN_NAME, str_params);
if (str_params)
free (str_params);
- for (i = 2; i < num_params; i++)
+ for (i = 2; i < ctxt->num_params; i++)
{
caps_removed = weechat_string_split (
- params[i],
+ ctxt->params[i],
" ",
NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -1342,10 +1328,10 @@ IRC_PROTOCOL_CALLBACK(cap)
continue;
for (j = 0; j < num_caps_removed; j++)
{
- weechat_hashtable_remove (server->cap_ls, caps_removed[j]);
- weechat_hashtable_remove (server->cap_list, caps_removed[j]);
+ weechat_hashtable_remove (ctxt->server->cap_ls, caps_removed[j]);
+ weechat_hashtable_remove (ctxt->server->cap_list, caps_removed[j]);
if (strcmp (caps_removed[j], "draft/multiline") == 0)
- irc_server_buffer_set_input_multiline (server, 0);
+ irc_server_buffer_set_input_multiline (ctxt->server, 0);
}
weechat_string_free_split (caps_removed);
}
@@ -1367,7 +1353,7 @@ IRC_PROTOCOL_CALLBACK(cap)
IRC_PROTOCOL_CALLBACK(chghost)
{
- int length, local_chghost, smart_filter;
+ int length, smart_filter;
char *str_host, str_tags[512];
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
@@ -1376,48 +1362,46 @@ IRC_PROTOCOL_CALLBACK(chghost)
IRC_PROTOCOL_MIN_PARAMS(2);
IRC_PROTOCOL_CHECK_NICK;
- local_chghost = (irc_server_strcasecmp (server, nick, server->nick) == 0);
-
- length = strlen (params[0]) + 1 + strlen (params[1]) + 1;
+ length = strlen (ctxt->params[0]) + 1 + strlen (ctxt->params[1]) + 1;
str_host = malloc (length);
if (!str_host)
{
weechat_printf (
- server->buffer,
+ ctxt->server->buffer,
_("%s%s: not enough memory for \"%s\" command"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, "chghost");
return WEECHAT_RC_OK;
}
- snprintf (str_host, length, "%s@%s", params[0], params[1]);
+ snprintf (str_host, length, "%s@%s", ctxt->params[0], ctxt->params[1]);
- if (local_chghost)
- irc_server_set_host (server, str_host);
+ if (ctxt->nick_is_me)
+ irc_server_set_host (ctxt->server, str_host);
- for (ptr_channel = server->channels; ptr_channel;
+ for (ptr_channel = ctxt->server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
switch (ptr_channel->type)
{
case IRC_CHANNEL_TYPE_PRIVATE:
- if (!ignored
- && (irc_server_strcasecmp (server,
- ptr_channel->name, nick) == 0))
+ if (!ctxt->ignored
+ && (irc_server_strcasecmp (ctxt->server,
+ ptr_channel->name, ctxt->nick) == 0))
{
snprintf (str_tags, sizeof (str_tags),
"new_host_%s", str_host);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, str_tags,
- nick, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, ctxt->nick,
+ ctxt->address),
_("%s%s%s%s (%s%s%s)%s has changed host to %s%s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- (address) ? address : "",
+ (ctxt->address) ? ctxt->address : "",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_MESSAGE_CHGHOST,
IRC_COLOR_CHAT_HOST,
@@ -1425,15 +1409,15 @@ IRC_PROTOCOL_CALLBACK(chghost)
}
break;
case IRC_CHANNEL_TYPE_CHANNEL:
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
if (ptr_nick)
{
- if (!ignored)
+ if (!ctxt->ignored)
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_chghost))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
- smart_filter = (!local_chghost
+ irc_channel_nick_speaking_time_search (ctxt->server, ptr_channel, ctxt->nick, 1) : NULL;
+ smart_filter = (!ctxt->nick_is_me
&& weechat_config_boolean (irc_config_look_smart_filter)
&& weechat_config_boolean (irc_config_look_smart_filter_chghost)
&& !ptr_nick_speaking);
@@ -1444,17 +1428,17 @@ IRC_PROTOCOL_CALLBACK(chghost)
(smart_filter) ? "irc_smart_filter" : "");
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, str_tags,
- nick, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, ctxt->nick,
+ ctxt->address),
_("%s%s%s%s (%s%s%s)%s has changed host to %s%s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- (address) ? address : "",
+ (ctxt->address) ? ctxt->address : "",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_MESSAGE_CHGHOST,
IRC_COLOR_CHAT_HOST,
@@ -1484,18 +1468,18 @@ IRC_PROTOCOL_CALLBACK(error)
IRC_PROTOCOL_MIN_PARAMS(1);
- str_error = irc_protocol_string_params (params, 0, num_params - 1);
+ str_error = irc_protocol_string_params (ctxt->params, 0, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("error"),
str_error);
if (str_error && (strncmp (str_error, "Closing Link", 12) == 0))
- irc_server_disconnect (server, !server->is_connected, 1);
+ irc_server_disconnect (ctxt->server, !ctxt->server->is_connected, 1);
if (str_error)
free (str_error);
@@ -1523,7 +1507,7 @@ IRC_PROTOCOL_CALLBACK(generic_error)
IRC_PROTOCOL_MIN_PARAMS(2);
- arg_error = (irc_server_strcasecmp (server, params[0], server->nick) == 0) ?
+ arg_error = (irc_server_strcasecmp (ctxt->server, ctxt->params[0], ctxt->server->nick) == 0) ?
1 : 0;
pos_channel = NULL;
@@ -1537,17 +1521,17 @@ IRC_PROTOCOL_CALLBACK(generic_error)
* - 433: nickname already in use
* - 437: nick/channel temporarily unavailable
*/
- force_server_buffer = ((strcmp (command, "432") == 0)
- || (strcmp (command, "433") == 0)
- || (strcmp (command, "437") == 0));
+ force_server_buffer = ((strcmp (ctxt->command, "432") == 0)
+ || (strcmp (ctxt->command, "433") == 0)
+ || (strcmp (ctxt->command, "437") == 0));
- if (params[arg_error + 1])
+ if (ctxt->params[arg_error + 1])
{
if (!force_server_buffer
- && irc_channel_is_channel (server, params[arg_error]))
+ && irc_channel_is_channel (ctxt->server, ctxt->params[arg_error]))
{
- pos_channel = params[arg_error];
- ptr_channel = irc_channel_search (server, pos_channel);
+ pos_channel = ctxt->params[arg_error];
+ ptr_channel = irc_channel_search (ctxt->server, pos_channel);
snprintf (str_target, sizeof (str_target),
"%s%s%s: ",
IRC_COLOR_CHAT_CHANNEL,
@@ -1555,12 +1539,12 @@ IRC_PROTOCOL_CALLBACK(generic_error)
IRC_COLOR_RESET);
arg_error++;
}
- else if (strcmp (params[arg_error], "*") != 0)
+ else if (strcmp (ctxt->params[arg_error], "*") != 0)
{
- pos_nick = params[arg_error];
+ pos_nick = ctxt->params[arg_error];
snprintf (str_target, sizeof (str_target),
"%s%s%s: ",
- irc_nick_color_for_msg (server, 1, NULL, pos_nick),
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, pos_nick),
pos_nick,
IRC_COLOR_RESET);
arg_error++;
@@ -1574,23 +1558,23 @@ IRC_PROTOCOL_CALLBACK(generic_error)
}
else if (!force_server_buffer && pos_nick)
{
- ptr_channel2 = irc_channel_search (server, pos_nick);
+ ptr_channel2 = irc_channel_search (ctxt->server, pos_nick);
if (ptr_channel2)
ptr_buffer = ptr_channel2->buffer;
}
if (!ptr_buffer)
- ptr_buffer = server->buffer;
+ ptr_buffer = ctxt->server->buffer;
- str_error = irc_protocol_string_params (params, arg_error, num_params - 1);
+ str_error = irc_protocol_string_params (ctxt->params, arg_error, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, pos_nick, command,
- ((strcmp (command, "401") == 0)
- || (strcmp (command, "402") == 0)) ? "whois" : NULL,
+ ctxt->server, pos_nick, ctxt->command,
+ ((strcmp (ctxt->command, "401") == 0)
+ || (strcmp (ctxt->command, "402") == 0)) ? "whois" : NULL,
ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s",
weechat_prefix ("network"),
str_target,
@@ -1615,15 +1599,9 @@ IRC_PROTOCOL_CALLBACK(fail)
{
IRC_PROTOCOL_MIN_PARAMS(2);
- irc_protocol_print_error_warning_msg (
- server,
- date,
- tags,
- command,
- weechat_prefix ("error"),
- _("Failure:"),
- params,
- num_params);
+ irc_protocol_print_error_warning_msg (ctxt,
+ weechat_prefix ("error"),
+ _("Failure:"));
return WEECHAT_RC_OK;
}
@@ -1647,23 +1625,23 @@ IRC_PROTOCOL_CALLBACK(invite)
IRC_PROTOCOL_MIN_PARAMS(2);
IRC_PROTOCOL_CHECK_NICK;
- if (ignored)
+ if (ctxt->ignored)
return WEECHAT_RC_OK;
- if (irc_server_strcasecmp (server, params[0], server->nick) == 0)
+ if (irc_server_strcasecmp (ctxt->server, ctxt->params[0], ctxt->server->nick) == 0)
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, "notify_highlight", nick,
- address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->nick, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, "notify_highlight", ctxt->nick,
+ ctxt->address),
_("%sYou have been invited to %s%s%s by %s%s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 1, NULL, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_RESET);
}
else
@@ -1671,19 +1649,19 @@ IRC_PROTOCOL_CALLBACK(invite)
/* CAP invite-notify */
/* imitate numeric 341 output */
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, nick, address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->nick, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, ctxt->nick, ctxt->address),
_("%s%s%s%s has invited %s%s%s to %s%s%s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 1, NULL, params[0]),
- params[0],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[0]),
+ ctxt->params[0],
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET);
}
@@ -1712,16 +1690,14 @@ IRC_PROTOCOL_CALLBACK(join)
struct t_irc_channel_speaking *ptr_nick_speaking;
const char *pos_account, *pos_realname;
char str_account[512], str_realname[512], *channel_name_lower;
- int local_join, display_host, smart_filter;
+ int display_host, smart_filter;
IRC_PROTOCOL_MIN_PARAMS(1);
IRC_PROTOCOL_CHECK_NICK;
- local_join = (irc_server_strcasecmp (server, nick, server->nick) == 0);
-
- pos_account = ((num_params > 1) && (strcmp (params[1], "*") != 0)) ?
- params[1] : NULL;
- pos_realname = (num_params > 2) ? params[2] : NULL;
+ pos_account = ((ctxt->num_params > 1) && (strcmp (ctxt->params[1], "*") != 0)) ?
+ ctxt->params[1] : NULL;
+ pos_realname = (ctxt->num_params > 2) ? ctxt->params[2] : NULL;
str_account[0] = '\0';
if (pos_account
@@ -1747,7 +1723,7 @@ IRC_PROTOCOL_CALLBACK(join)
IRC_COLOR_CHAT_DELIMITERS);
}
- ptr_channel = irc_channel_search (server, params[0]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[0]);
if (ptr_channel)
{
ptr_channel->part = 0;
@@ -1758,17 +1734,17 @@ IRC_PROTOCOL_CALLBACK(join)
* if someone else joins and channel is not opened, then just
* ignore it (we should receive our self join first)
*/
- if (!local_join)
+ if (!ctxt->nick_is_me)
return WEECHAT_RC_OK;
- ptr_channel = irc_channel_new (server, IRC_CHANNEL_TYPE_CHANNEL,
- params[0], 1, 1);
+ ptr_channel = irc_channel_new (ctxt->server, IRC_CHANNEL_TYPE_CHANNEL,
+ ctxt->params[0], 1, 1);
if (!ptr_channel)
{
- weechat_printf (server->buffer,
+ weechat_printf (ctxt->server->buffer,
_("%s%s: cannot create new channel \"%s\""),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
- params[0]);
+ ctxt->params[0]);
return WEECHAT_RC_OK;
}
}
@@ -1778,8 +1754,8 @@ IRC_PROTOCOL_CALLBACK(join)
* reconnection to network, we receive a JOIN for channel with existing
* nicks in irc plugin, so we need to clear the nicklist now)
*/
- if (local_join)
- irc_nick_free_all (server, ptr_channel);
+ if (ctxt->nick_is_me)
+ irc_nick_free_all (ctxt->server, ptr_channel);
/* reset some variables if joining new channel */
if (!ptr_channel->nicks)
@@ -1796,19 +1772,19 @@ IRC_PROTOCOL_CALLBACK(join)
}
/* add nick in channel */
- ptr_nick = irc_nick_new (server, ptr_channel, nick, address, NULL, 0,
+ ptr_nick = irc_nick_new (ctxt->server, ptr_channel, ctxt->nick, ctxt->address, NULL, 0,
(pos_account) ? pos_account : NULL,
(pos_realname) ? pos_realname : NULL);
/* rename the nick if it was in list with a different case */
- irc_channel_nick_speaking_rename_if_present (server, ptr_channel, nick);
+ irc_channel_nick_speaking_rename_if_present (ctxt->server, ptr_channel, ctxt->nick);
- if (!ignored)
+ if (!ctxt->ignored)
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_join))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
- display_host = (local_join) ?
+ irc_channel_nick_speaking_time_search (ctxt->server, ptr_channel, ctxt->nick, 1) : NULL;
+ display_host = (ctxt->nick_is_me) ?
weechat_config_boolean (irc_config_look_display_host_join_local) :
weechat_config_boolean (irc_config_look_display_host_join);
@@ -1816,36 +1792,35 @@ IRC_PROTOCOL_CALLBACK(join)
* "smart" filter the join message if it's not a join from myself, if
* smart filtering is enabled, and if nick was not speaking in channel
*/
- smart_filter = (!local_join
+ smart_filter = (!ctxt->nick_is_me
&& weechat_config_boolean (irc_config_look_smart_filter)
&& weechat_config_boolean (irc_config_look_smart_filter_join)
&& !ptr_nick_speaking);
/* display the join */
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL,
ptr_channel->buffer),
- date,
- irc_protocol_tags (server,
- command,
- tags,
+ ctxt->date,
+ irc_protocol_tags (ctxt,
(smart_filter) ? "irc_smart_filter" : NULL,
- nick, address),
+ ctxt->nick,
+ ctxt->address),
_("%s%s%s%s%s%s%s%s%s%s%s%s has joined %s%s%s"),
weechat_prefix ("join"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
str_account,
str_realname,
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? " (" : "",
IRC_COLOR_CHAT_HOST,
- (display_host) ? address : "",
+ (display_host) ? ctxt->address : "",
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? ")" : "",
IRC_COLOR_MESSAGE_JOIN,
IRC_COLOR_CHAT_CHANNEL,
- params[0],
+ ctxt->params[0],
IRC_COLOR_MESSAGE_JOIN);
/*
@@ -1855,40 +1830,40 @@ IRC_PROTOCOL_CALLBACK(join)
*/
if (smart_filter)
{
- irc_channel_join_smart_filtered_add (ptr_channel, nick,
+ irc_channel_join_smart_filtered_add (ptr_channel, ctxt->nick,
time (NULL));
}
/* display message in private if private has flag "has_quit_server" */
- if (!local_join)
+ if (!ctxt->nick_is_me)
{
- irc_channel_display_nick_back_in_pv (server, ptr_nick, nick);
- irc_channel_set_topic_private_buffers (server, ptr_nick, nick,
- address);
+ irc_channel_display_nick_back_in_pv (ctxt->server, ptr_nick, ctxt->nick);
+ irc_channel_set_topic_private_buffers (ctxt->server, ptr_nick, ctxt->nick,
+ ctxt->address);
}
}
- if (local_join)
+ if (ctxt->nick_is_me)
{
- irc_server_set_host (server, address);
+ irc_server_set_host (ctxt->server, ctxt->address);
irc_bar_item_update_channel ();
/* add channel to autojoin option (on manual join only) */
- channel_name_lower = weechat_string_tolower (params[0]);
+ channel_name_lower = weechat_string_tolower (ctxt->params[0]);
if (channel_name_lower)
{
- if (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOJOIN_DYNAMIC)
- && weechat_hashtable_has_key (server->join_manual,
+ if (IRC_SERVER_OPTION_BOOLEAN(ctxt->server, IRC_SERVER_OPTION_AUTOJOIN_DYNAMIC)
+ && weechat_hashtable_has_key (ctxt->server->join_manual,
channel_name_lower))
{
irc_join_add_channel_to_autojoin (
- server,
- params[0],
- weechat_hashtable_get (server->join_channel_key,
+ ctxt->server,
+ ctxt->params[0],
+ weechat_hashtable_get (ctxt->server->join_channel_key,
channel_name_lower));
}
- weechat_hashtable_remove (server->join_manual, channel_name_lower);
- weechat_hashtable_remove (server->join_channel_key, channel_name_lower);
+ weechat_hashtable_remove (ctxt->server->join_manual, channel_name_lower);
+ weechat_hashtable_remove (ctxt->server->join_channel_key, channel_name_lower);
free (channel_name_lower);
}
}
@@ -1913,29 +1888,29 @@ IRC_PROTOCOL_CALLBACK(kick)
IRC_PROTOCOL_MIN_PARAMS(2);
IRC_PROTOCOL_CHECK_NICK;
- pos_comment = (num_params > 2) ? params[2] : NULL;
+ pos_comment = (ctxt->num_params > 2) ? ctxt->params[2] : NULL;
- ptr_channel = irc_channel_search (server, params[0]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[0]);
if (!ptr_channel)
return WEECHAT_RC_OK;
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
- ptr_nick_kicked = irc_nick_search (server, ptr_channel, params[1]);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
+ ptr_nick_kicked = irc_nick_search (ctxt->server, ptr_channel, ctxt->params[1]);
if (pos_comment)
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL,
ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%s%s%s has kicked %s%s%s %s(%s%s%s)"),
weechat_prefix ("quit"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_KICK,
- irc_nick_color_for_msg (server, 1, ptr_nick_kicked, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick_kicked, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_MESSAGE_KICK,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_REASON_KICK,
@@ -1945,33 +1920,33 @@ IRC_PROTOCOL_CALLBACK(kick)
else
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL,
ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%s%s%s has kicked %s%s%s"),
weechat_prefix ("quit"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_KICK,
- irc_nick_color_for_msg (server, 1, ptr_nick_kicked, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick_kicked, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_MESSAGE_KICK);
}
- if (irc_server_strcasecmp (server, params[1], server->nick) == 0)
+ if (irc_server_strcasecmp (ctxt->server, ctxt->params[1], ctxt->server->nick) == 0)
{
/*
* my nick was kicked => free all nicks, channel is not active any
* more
*/
- irc_nick_free_all (server, ptr_channel);
+ irc_nick_free_all (ctxt->server, ptr_channel);
irc_channel_modelist_set_state (ptr_channel,
IRC_MODELIST_STATE_MODIFIED);
/* read option "autorejoin" in server */
- rejoin = IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOREJOIN);
+ rejoin = IRC_SERVER_OPTION_BOOLEAN(ctxt->server, IRC_SERVER_OPTION_AUTOREJOIN);
/*
* if buffer has a local variable "autorejoin", use it
@@ -1984,18 +1959,18 @@ IRC_PROTOCOL_CALLBACK(kick)
if (rejoin)
{
- if (IRC_SERVER_OPTION_INTEGER(server,
+ if (IRC_SERVER_OPTION_INTEGER(ctxt->server,
IRC_SERVER_OPTION_AUTOREJOIN_DELAY) == 0)
{
/* immediately rejoin if delay is 0 */
- irc_channel_rejoin (server, ptr_channel, 0, 1);
+ irc_channel_rejoin (ctxt->server, ptr_channel, 0, 1);
}
else
{
/* rejoin channel later, according to delay */
ptr_channel->hook_autorejoin =
weechat_hook_timer (
- IRC_SERVER_OPTION_INTEGER(server,
+ IRC_SERVER_OPTION_INTEGER(ctxt->server,
IRC_SERVER_OPTION_AUTOREJOIN_DELAY) * 1000,
0, 1,
&irc_channel_autorejoin_cb,
@@ -2012,7 +1987,7 @@ IRC_PROTOCOL_CALLBACK(kick)
* nick
*/
if (ptr_nick_kicked)
- irc_nick_free (server, ptr_channel, ptr_nick_kicked);
+ irc_nick_free (ctxt->server, ptr_channel, ptr_nick_kicked);
}
return WEECHAT_RC_OK;
@@ -2034,26 +2009,26 @@ IRC_PROTOCOL_CALLBACK(kill)
IRC_PROTOCOL_MIN_PARAMS(1);
IRC_PROTOCOL_CHECK_NICK;
- pos_comment = (num_params > 1) ? params[1] : NULL;
+ pos_comment = (ctxt->num_params > 1) ? ctxt->params[1] : NULL;
- for (ptr_channel = server->channels; ptr_channel;
+ for (ptr_channel = ctxt->server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
- ptr_nick_killed = irc_nick_search (server, ptr_channel, params[0]);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
+ ptr_nick_killed = irc_nick_search (ctxt->server, ptr_channel, ctxt->params[0]);
if (pos_comment)
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL,
ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%sYou were killed by %s%s%s %s(%s%s%s)"),
weechat_prefix ("quit"),
IRC_COLOR_MESSAGE_KICK,
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_KICK,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_REASON_KICK,
@@ -2063,25 +2038,25 @@ IRC_PROTOCOL_CALLBACK(kill)
else
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL,
ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%sYou were killed by %s%s%s"),
weechat_prefix ("quit"),
IRC_COLOR_MESSAGE_KICK,
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_KICK);
}
- if (irc_server_strcasecmp (server, params[0], server->nick) == 0)
+ if (irc_server_strcasecmp (ctxt->server, ctxt->params[0], ctxt->server->nick) == 0)
{
/*
* my nick was killed => free all nicks, channel is not active any
* more
*/
- irc_nick_free_all (server, ptr_channel);
+ irc_nick_free_all (ctxt->server, ptr_channel);
irc_channel_modelist_set_state (ptr_channel,
IRC_MODELIST_STATE_MODIFIED);
@@ -2095,7 +2070,7 @@ IRC_PROTOCOL_CALLBACK(kill)
* nick
*/
if (ptr_nick_killed)
- irc_nick_free (server, ptr_channel, ptr_nick_killed);
+ irc_nick_free (ctxt->server, ptr_channel, ptr_nick_killed);
}
}
@@ -2118,16 +2093,16 @@ IRC_PROTOCOL_CALLBACK(knock_reply)
IRC_PROTOCOL_MIN_PARAMS(3);
- str_message = irc_protocol_string_params (params, 2, num_params - 1);
+ str_message = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->params[0], ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
str_message);
@@ -2149,7 +2124,7 @@ IRC_PROTOCOL_CALLBACK(knock_reply)
IRC_PROTOCOL_CALLBACK(mode)
{
char *msg_modes_args, *modes_args;
- int smart_filter, local_mode;
+ int smart_filter;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_gui_buffer *ptr_buffer;
@@ -2157,64 +2132,62 @@ IRC_PROTOCOL_CALLBACK(mode)
IRC_PROTOCOL_MIN_PARAMS(2);
IRC_PROTOCOL_CHECK_NICK;
- msg_modes_args = (num_params > 2) ?
- irc_protocol_string_params (params, 2, num_params - 1) : NULL;
+ msg_modes_args = (ctxt->num_params > 2) ?
+ irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1) : NULL;
- if (irc_channel_is_channel (server, params[0]))
+ if (irc_channel_is_channel (ctxt->server, ctxt->params[0]))
{
smart_filter = 0;
- ptr_channel = irc_channel_search (server, params[0]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[0]);
if (ptr_channel)
{
- smart_filter = irc_mode_channel_set (server, ptr_channel, host,
- params[1], msg_modes_args);
+ smart_filter = irc_mode_channel_set (ctxt->server, ptr_channel, ctxt->host,
+ ctxt->params[1], msg_modes_args);
}
- local_mode = (irc_server_strcasecmp (server, nick, server->nick) == 0);
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
- ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
+ ptr_buffer = (ptr_channel) ? ptr_channel->buffer : ctxt->server->buffer;
modes_args = irc_mode_get_arguments (msg_modes_args);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL,
ptr_buffer),
- date,
- irc_protocol_tags (server,
- command,
- tags,
- (smart_filter && !local_mode) ?
- "irc_smart_filter" : NULL,
- NULL, address),
+ ctxt->date,
+ irc_protocol_tags (
+ ctxt,
+ (smart_filter && !ctxt->nick_is_me) ? "irc_smart_filter" : NULL,
+ NULL,
+ ctxt->address),
_("%sMode %s%s %s[%s%s%s%s%s]%s by %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- (ptr_channel) ? ptr_channel->name : params[0],
+ (ptr_channel) ? ptr_channel->name : ctxt->params[0],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- params[1],
+ ctxt->params[1],
(modes_args && modes_args[0]) ? " " : "",
(modes_args && modes_args[0]) ? modes_args : "",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick);
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick);
if (modes_args)
free (modes_args);
}
else
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%sUser mode %s[%s%s%s]%s by %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 1, NULL, nick),
- nick);
- irc_mode_user_set (server, params[1], 0);
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->nick),
+ ctxt->nick);
+ irc_mode_user_set (ctxt->server, ctxt->params[1], 0);
}
if (msg_modes_args)
@@ -2235,53 +2208,50 @@ IRC_PROTOCOL_CALLBACK(nick)
struct t_irc_channel *ptr_channel, *ptr_channel_new_nick;
struct t_irc_nick *ptr_nick, *ptr_nick_found;
char *old_color, *new_color, str_tags[512];
- int local_nick, smart_filter;
+ int smart_filter;
struct t_irc_channel_speaking *ptr_nick_speaking;
IRC_PROTOCOL_MIN_PARAMS(1);
IRC_PROTOCOL_CHECK_NICK;
- if (!params[0][0])
+ if (!ctxt->params[0][0])
return WEECHAT_RC_OK;
- local_nick = (irc_server_strcasecmp (server, nick, server->nick) == 0) ?
- 1 : 0;
-
- if (local_nick)
+ if (ctxt->nick_is_me)
{
- irc_server_set_nick (server, params[0]);
- irc_server_set_host (server, address);
+ irc_server_set_nick (ctxt->server, ctxt->params[0]);
+ irc_server_set_host (ctxt->server, ctxt->address);
}
ptr_nick_found = NULL;
/* first display message in server buffer if it's local nick */
- if (local_nick)
+ if (ctxt->nick_is_me)
{
/* temporary disable hotlist */
weechat_buffer_set (NULL, "hotlist", "-");
snprintf (str_tags, sizeof (str_tags),
"irc_nick1_%s,irc_nick2_%s",
- nick,
- params[0]);
+ ctxt->nick,
+ ctxt->params[0]);
weechat_printf_date_tags (
- server->buffer,
- date,
- irc_protocol_tags (server, command, tags, str_tags, NULL, address),
+ ctxt->server->buffer,
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, NULL, ctxt->address),
_("%sYou are now known as %s%s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK_SELF,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET);
/* enable hotlist */
weechat_buffer_set (NULL, "hotlist", "+");
}
- ptr_channel_new_nick = irc_channel_search (server, params[0]);
+ ptr_channel_new_nick = irc_channel_search (ctxt->server, ctxt->params[0]);
- for (ptr_channel = server->channels; ptr_channel;
+ for (ptr_channel = ctxt->server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
switch (ptr_channel->type)
@@ -2294,14 +2264,14 @@ IRC_PROTOCOL_CALLBACK(nick)
*/
if ((!ptr_channel_new_nick
|| (ptr_channel_new_nick == ptr_channel))
- && ((irc_server_strcasecmp (server,
- ptr_channel->name, nick) == 0)
- || ((irc_server_strcasecmp (server,
- ptr_channel->name, params[0]) == 0)
- && (strcmp (ptr_channel->name, params[0]) != 0))))
+ && ((irc_server_strcasecmp (ctxt->server,
+ ptr_channel->name, ctxt->nick) == 0)
+ || ((irc_server_strcasecmp (ctxt->server,
+ ptr_channel->name, ctxt->params[0]) == 0)
+ && (strcmp (ptr_channel->name, ctxt->params[0]) != 0))))
{
/* rename private buffer */
- irc_channel_pv_rename (server, ptr_channel, params[0]);
+ irc_channel_pv_rename (ctxt->server, ptr_channel, ctxt->params[0]);
/* display message */
if (weechat_config_boolean (irc_config_look_display_pv_nick_change))
@@ -2310,8 +2280,8 @@ IRC_PROTOCOL_CALLBACK(nick)
{
if (weechat_config_boolean (irc_config_look_color_pv_nick_like_channel))
{
- old_color = irc_nick_find_color (server, nick);
- new_color = irc_nick_find_color (server, params[0]);
+ old_color = irc_nick_find_color (ctxt->server, ctxt->nick);
+ new_color = irc_nick_find_color (ctxt->server, ctxt->params[0]);
}
else
{
@@ -2326,20 +2296,20 @@ IRC_PROTOCOL_CALLBACK(nick)
}
snprintf (str_tags, sizeof (str_tags),
"irc_nick1_%s,irc_nick2_%s",
- nick,
- params[0]);
+ ctxt->nick,
+ ctxt->params[0]);
weechat_printf_date_tags (
ptr_channel->buffer,
- date,
- irc_protocol_tags (server, command, tags, str_tags,
- NULL, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, NULL,
+ ctxt->address),
_("%s%s%s%s is now known as %s%s%s"),
weechat_prefix ("network"),
old_color,
- nick,
+ ctxt->nick,
IRC_COLOR_RESET,
new_color,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET);
if (old_color)
free (old_color);
@@ -2350,39 +2320,36 @@ IRC_PROTOCOL_CALLBACK(nick)
break;
case IRC_CHANNEL_TYPE_CHANNEL:
/* rename nick in nicklist if found */
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
if (ptr_nick)
{
ptr_nick_found = ptr_nick;
/* set host in nick if needed */
- irc_nick_set_host (ptr_nick, address);
+ irc_nick_set_host (ptr_nick, ctxt->address);
/* change nick and display message on channel */
old_color = strdup (ptr_nick->color);
- irc_nick_change (server, ptr_channel, ptr_nick, params[0]);
- if (local_nick)
+ irc_nick_change (ctxt->server, ptr_channel, ptr_nick, ctxt->params[0]);
+ if (ctxt->nick_is_me)
{
/* temporary disable hotlist */
weechat_buffer_set (NULL, "hotlist", "-");
snprintf (str_tags, sizeof (str_tags),
"irc_nick1_%s,irc_nick2_%s",
- nick,
- params[0]);
+ ctxt->nick,
+ ctxt->params[0]);
weechat_printf_date_tags (ptr_channel->buffer,
- date,
- irc_protocol_tags (server,
- command,
- tags,
- str_tags,
- NULL,
- address),
+ ctxt->date,
+ irc_protocol_tags (
+ ctxt, str_tags, NULL,
+ ctxt->address),
_("%sYou are now known as "
"%s%s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK_SELF,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET);
/* enable hotlist */
@@ -2390,44 +2357,44 @@ IRC_PROTOCOL_CALLBACK(nick)
}
else
{
- if (!irc_ignore_check (server, ptr_channel->name,
- nick, host))
+ if (!irc_ignore_check (ctxt->server, ptr_channel->name,
+ ctxt->nick, ctxt->host))
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_nick))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
+ irc_channel_nick_speaking_time_search (ctxt->server, ptr_channel, ctxt->nick, 1) : NULL;
smart_filter = (weechat_config_boolean (irc_config_look_smart_filter)
&& weechat_config_boolean (irc_config_look_smart_filter_nick)
&& !ptr_nick_speaking);
snprintf (str_tags, sizeof (str_tags),
"%sirc_nick1_%s,irc_nick2_%s",
(smart_filter) ? "irc_smart_filter," : "",
- nick,
- params[0]);
+ ctxt->nick,
+ ctxt->params[0]);
weechat_printf_date_tags (
ptr_channel->buffer,
- date,
- irc_protocol_tags (server, command, tags,
- str_tags, NULL, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, NULL,
+ ctxt->address),
_("%s%s%s%s is now known as %s%s%s"),
weechat_prefix ("network"),
weechat_config_boolean (irc_config_look_color_nicks_in_server_messages) ?
old_color : IRC_COLOR_CHAT_NICK,
- nick,
+ ctxt->nick,
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 1, ptr_nick,
- params[0]),
- params[0],
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick,
+ ctxt->params[0]),
+ ctxt->params[0],
IRC_COLOR_RESET);
}
irc_channel_nick_speaking_rename (ptr_channel,
- nick, params[0]);
- irc_channel_nick_speaking_time_rename (server,
+ ctxt->nick, ctxt->params[0]);
+ irc_channel_nick_speaking_time_rename (ctxt->server,
ptr_channel,
- nick, params[0]);
+ ctxt->nick, ctxt->params[0]);
irc_channel_join_smart_filtered_rename (ptr_channel,
- nick,
- params[0]);
+ ctxt->nick,
+ ctxt->params[0]);
}
if (old_color)
@@ -2437,11 +2404,11 @@ IRC_PROTOCOL_CALLBACK(nick)
}
}
- if (!local_nick)
+ if (!ctxt->nick_is_me)
{
- irc_channel_display_nick_back_in_pv (server, ptr_nick_found, params[0]);
- irc_channel_set_topic_private_buffers (server, ptr_nick_found,
- params[0], address);
+ irc_channel_display_nick_back_in_pv (ctxt->server, ptr_nick_found, ctxt->params[0]);
+ irc_channel_set_topic_private_buffers (ctxt->server, ptr_nick_found,
+ ctxt->params[0], ctxt->address);
}
return WEECHAT_RC_OK;
@@ -2458,15 +2425,9 @@ IRC_PROTOCOL_CALLBACK(note)
{
IRC_PROTOCOL_MIN_PARAMS(2);
- irc_protocol_print_error_warning_msg (
- server,
- date,
- tags,
- command,
- weechat_prefix ("network"),
- _("Note:"),
- params,
- num_params);
+ irc_protocol_print_error_warning_msg (ctxt,
+ weechat_prefix ("network"),
+ _("Note:"));
return WEECHAT_RC_OK;
}
@@ -2486,63 +2447,60 @@ IRC_PROTOCOL_CALLBACK(notice)
const char *pos_target, *pos_args, *nick_address;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
- int notify_private, is_channel, is_channel_orig, nick_is_me, display_host;
+ int notify_private, is_channel, is_channel_orig, display_host;
int cap_echo_message, msg_already_received;
time_t time_now;
struct t_gui_buffer *ptr_buffer;
IRC_PROTOCOL_MIN_PARAMS(2);
- if (ignored)
+ if (ctxt->ignored)
return WEECHAT_RC_OK;
- notice_args = irc_protocol_string_params (params, 1, num_params - 1);
+ notice_args = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
if (!notice_args)
return WEECHAT_RC_ERROR;
- nick_is_me = (irc_server_strcasecmp (server, server->nick, nick) == 0);
-
pos_args = notice_args;
- pos_target = params[0];
- is_channel = irc_channel_is_channel (server, pos_target + 1);
+ pos_target = ctxt->params[0];
+ is_channel = irc_channel_is_channel (ctxt->server, pos_target + 1);
if (is_channel
- && irc_server_prefix_char_statusmsg (server, pos_target[0]))
+ && irc_server_prefix_char_statusmsg (ctxt->server, pos_target[0]))
{
pos_target++;
}
- if (nick && (pos_args[0] == '\01'))
+ if (ctxt->nick && (pos_args[0] == '\01'))
{
- cap_echo_message = weechat_hashtable_has_key (server->cap_list,
+ cap_echo_message = weechat_hashtable_has_key (ctxt->server->cap_list,
"echo-message");
msg_already_received = weechat_hashtable_has_key (
- server->echo_msg_recv, irc_message);
+ ctxt->server->echo_msg_recv, ctxt->irc_message);
if (!msg_already_received && cap_echo_message)
{
time_now = time (NULL);
- weechat_hashtable_set (server->echo_msg_recv,
- irc_message, &time_now);
+ weechat_hashtable_set (ctxt->server->echo_msg_recv,
+ ctxt->irc_message, &time_now);
}
if (!cap_echo_message || !msg_already_received)
{
- irc_ctcp_display_reply_from_nick (server, date, tags, command, nick,
- address, pos_args);
+ irc_ctcp_display_reply_from_nick (ctxt, pos_args);
}
if (msg_already_received)
- weechat_hashtable_remove (server->echo_msg_recv, irc_message);
+ weechat_hashtable_remove (ctxt->server->echo_msg_recv, ctxt->irc_message);
}
else
{
channel = NULL;
- is_channel = irc_channel_is_channel (server, pos_target);
+ is_channel = irc_channel_is_channel (ctxt->server, pos_target);
is_channel_orig = is_channel;
if (is_channel)
{
channel = strdup (pos_target);
}
else if (weechat_config_boolean (irc_config_look_notice_welcome_redirect)
- && (irc_server_strcasecmp (server, server->nick, pos_target) == 0))
+ && (irc_server_strcasecmp (ctxt->server, ctxt->server->nick, pos_target) == 0))
{
end_char = ' ';
switch (pos_args[0])
@@ -2567,7 +2525,7 @@ IRC_PROTOCOL_CALLBACK(notice)
{
channel = weechat_strndup (pos_args + 1,
pos - pos_args - 1);
- if (channel && irc_channel_search (server, channel))
+ if (channel && irc_channel_search (ctxt->server, channel))
{
is_channel = 1;
pos_args = pos + 1;
@@ -2582,24 +2540,24 @@ IRC_PROTOCOL_CALLBACK(notice)
if (is_channel)
{
/* notice for channel */
- ptr_channel = irc_channel_search (server, channel);
+ ptr_channel = irc_channel_search (ctxt->server, channel);
/*
* unmask a smart filtered join if it is in hashtable
* "join_smart_filtered" of channel
*/
if (ptr_channel)
- irc_channel_join_smart_filtered_unmask (ptr_channel, nick);
+ irc_channel_join_smart_filtered_unmask (ptr_channel, ctxt->nick);
if (ptr_channel
&& weechat_config_boolean (irc_config_look_typing_status_nicks))
{
- irc_typing_channel_set_nick (ptr_channel, nick,
+ irc_typing_channel_set_nick (ptr_channel, ctxt->nick,
IRC_CHANNEL_TYPING_STATE_OFF);
}
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
- if (nick_is_me)
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
+ if (ctxt->nick_is_me)
{
snprintf (str_tags, sizeof (str_tags),
"self_msg,notify_none,no_highlight");
@@ -2613,10 +2571,9 @@ IRC_PROTOCOL_CALLBACK(notice)
weechat_config_string (irc_config_look_notice_welcome_tags));
}
weechat_printf_date_tags (
- (ptr_channel) ? ptr_channel->buffer : server->buffer,
- date,
- irc_protocol_tags (server, command, tags, str_tags,
- nick, address),
+ (ptr_channel) ? ptr_channel->buffer : ctxt->server->buffer,
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, ctxt->nick, ctxt->address),
"%s%s%s%s%s(%s%s%s%s)%s%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_NOTICE,
@@ -2624,14 +2581,14 @@ IRC_PROTOCOL_CALLBACK(notice)
/* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */
_("Notice"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_mode_for_display (server, ptr_nick, 0),
- irc_nick_color_for_msg (server, 0, ptr_nick, nick),
- (nick && nick[0]) ? nick : "?",
+ irc_nick_mode_for_display (ctxt->server, ptr_nick, 0),
+ irc_nick_color_for_msg (ctxt->server, 0, ptr_nick, ctxt->nick),
+ (ctxt->nick && ctxt->nick[0]) ? ctxt->nick : "?",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(is_channel_orig) ? " -> " : "",
(is_channel_orig) ? IRC_COLOR_CHAT_CHANNEL : "",
- (is_channel_orig) ? params[0] : "",
+ (is_channel_orig) ? ctxt->params[0] : "",
(is_channel_orig) ? IRC_COLOR_RESET : "",
pos_args);
}
@@ -2639,11 +2596,11 @@ IRC_PROTOCOL_CALLBACK(notice)
{
/* notice for user */
notify_private = 0;
- if (server->is_connected
- && nick
- && (weechat_strcasecmp (nick, "nickserv") != 0)
- && (weechat_strcasecmp (nick, "chanserv") != 0)
- && (weechat_strcasecmp (nick, "memoserv") != 0))
+ if (ctxt->server->is_connected
+ && ctxt->nick
+ && (weechat_strcasecmp (ctxt->nick, "nickserv") != 0)
+ && (weechat_strcasecmp (ctxt->nick, "chanserv") != 0)
+ && (weechat_strcasecmp (ctxt->nick, "memoserv") != 0))
{
/*
* add tag "notify_private" only if:
@@ -2656,23 +2613,23 @@ IRC_PROTOCOL_CALLBACK(notice)
}
ptr_channel = NULL;
- if (nick
+ if (ctxt->nick
&& weechat_config_enum (irc_config_look_notice_as_pv) != IRC_CONFIG_LOOK_NOTICE_AS_PV_NEVER)
{
- ptr_channel = irc_channel_search (server, nick);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->nick);
if (!ptr_channel
&& weechat_config_enum (irc_config_look_notice_as_pv) == IRC_CONFIG_LOOK_NOTICE_AS_PV_ALWAYS)
{
- ptr_channel = irc_channel_new (server,
+ ptr_channel = irc_channel_new (ctxt->server,
IRC_CHANNEL_TYPE_PRIVATE,
- nick, 0, 0);
+ ctxt->nick, 0, 0);
if (!ptr_channel)
{
- weechat_printf (server->buffer,
+ weechat_printf (ctxt->server->buffer,
_("%s%s: cannot create new "
"private buffer \"%s\""),
weechat_prefix ("error"),
- IRC_PLUGIN_NAME, nick);
+ IRC_PLUGIN_NAME, ctxt->nick);
}
}
}
@@ -2680,27 +2637,27 @@ IRC_PROTOCOL_CALLBACK(notice)
if (ptr_channel)
{
/* rename buffer if open with nick case not matching */
- if (strcmp (ptr_channel->name, nick) != 0)
- irc_channel_pv_rename (server, ptr_channel, nick);
+ if (strcmp (ptr_channel->name, ctxt->nick) != 0)
+ irc_channel_pv_rename (ctxt->server, ptr_channel, ctxt->nick);
if (weechat_config_boolean (irc_config_look_typing_status_nicks))
{
- irc_typing_channel_set_nick (ptr_channel, nick,
+ irc_typing_channel_set_nick (ptr_channel, ctxt->nick,
IRC_CHANNEL_TYPING_STATE_OFF);
}
if (!ptr_channel->topic)
- irc_channel_set_topic (ptr_channel, address);
+ irc_channel_set_topic (ptr_channel, ctxt->address);
weechat_printf_date_tags (
ptr_channel->buffer,
- date,
- irc_protocol_tags (server, command, tags, "notify_private",
- nick, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, "notify_private", ctxt->nick,
+ ctxt->address),
"%s%s%s%s: %s",
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 0, NULL, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 0, NULL, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_RESET,
pos_args);
if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
@@ -2711,30 +2668,30 @@ IRC_PROTOCOL_CALLBACK(notice)
}
else
{
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, nick,
- command, NULL,
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->nick,
+ ctxt->command, NULL,
NULL);
/*
* if notice is sent from myself (for example another WeeChat
* via relay), then display message of outgoing notice
*/
- if (nick && (irc_server_strcasecmp (server, server->nick, nick) == 0))
+ if (ctxt->nick && ctxt->nick_is_me)
{
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server,
- command,
- tags,
- (notify_private) ? "notify_private" : NULL,
- server->nick, address),
+ ctxt->date,
+ irc_protocol_tags (
+ ctxt,
+ (notify_private) ? "notify_private" : NULL,
+ ctxt->server->nick,
+ ctxt->address),
"%s%s%s%s -> %s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_NOTICE,
/* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */
_("Notice"),
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 0, NULL, pos_target),
+ irc_nick_color_for_msg (ctxt->server, 0, NULL, pos_target),
pos_target,
IRC_COLOR_RESET,
pos_args);
@@ -2744,19 +2701,19 @@ IRC_PROTOCOL_CALLBACK(notice)
display_host = weechat_config_boolean (
irc_config_look_display_host_notice);
nick_address = irc_protocol_nick_address (
- server,
+ ctxt->server,
0,
NULL,
- nick,
- (display_host) ? address : NULL);
+ ctxt->nick,
+ (display_host) ? ctxt->address : NULL);
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server,
- command,
- tags,
- (notify_private) ? "notify_private" : NULL,
- nick, address),
+ ctxt->date,
+ irc_protocol_tags (
+ ctxt,
+ (notify_private) ? "notify_private" : NULL,
+ ctxt->nick,
+ ctxt->address),
"%s%s%s%s",
weechat_prefix ("network"),
nick_address,
@@ -2788,7 +2745,7 @@ IRC_PROTOCOL_CALLBACK(notice)
IRC_PROTOCOL_CALLBACK(part)
{
char *str_comment;
- int local_part, display_host;
+ int display_host;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_irc_channel_speaking *ptr_nick_speaking;
@@ -2796,52 +2753,50 @@ IRC_PROTOCOL_CALLBACK(part)
IRC_PROTOCOL_MIN_PARAMS(1);
IRC_PROTOCOL_CHECK_NICK;
- ptr_channel = irc_channel_search (server, params[0]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[0]);
if (!ptr_channel)
return WEECHAT_RC_OK;
- str_comment = (num_params > 1) ?
- irc_protocol_string_params (params, 1, num_params - 1) : NULL;
+ str_comment = (ctxt->num_params > 1) ?
+ irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1) : NULL;
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
-
- local_part = (irc_server_strcasecmp (server, nick, server->nick) == 0);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
/* display part message */
- if (!ignored)
+ if (!ctxt->ignored)
{
ptr_nick_speaking = NULL;
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_quit))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
+ irc_channel_nick_speaking_time_search (ctxt->server, ptr_channel, ctxt->nick, 1) : NULL;
}
display_host = weechat_config_boolean (irc_config_look_display_host_quit);
if (str_comment && str_comment[0])
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server,
- command,
- tags,
- (local_part
- || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
- || !weechat_config_boolean (irc_config_look_smart_filter)
- || !weechat_config_boolean (irc_config_look_smart_filter_quit)
- || ptr_nick_speaking) ?
- NULL : "irc_smart_filter",
- nick, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (
+ ctxt,
+ (ctxt->nick_is_me
+ || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
+ || !weechat_config_boolean (irc_config_look_smart_filter)
+ || !weechat_config_boolean (irc_config_look_smart_filter_quit)
+ || ptr_nick_speaking) ?
+ NULL : "irc_smart_filter",
+ ctxt->nick,
+ ctxt->address),
_("%s%s%s%s%s%s%s%s%s%s has left %s%s%s %s(%s%s%s)"),
weechat_prefix ("quit"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? " (" : "",
IRC_COLOR_CHAT_HOST,
- (display_host) ? address : "",
+ (display_host) ? ctxt->address : "",
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? ")" : "",
IRC_COLOR_MESSAGE_QUIT,
@@ -2857,26 +2812,26 @@ IRC_PROTOCOL_CALLBACK(part)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server,
- command,
- tags,
- (local_part
- || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
- || !weechat_config_boolean (irc_config_look_smart_filter)
- || !weechat_config_boolean (irc_config_look_smart_filter_quit)
- || ptr_nick_speaking) ?
- NULL : "irc_smart_filter",
- nick, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (
+ ctxt,
+ (ctxt->nick_is_me
+ || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
+ || !weechat_config_boolean (irc_config_look_smart_filter)
+ || !weechat_config_boolean (irc_config_look_smart_filter_quit)
+ || ptr_nick_speaking) ?
+ NULL : "irc_smart_filter",
+ ctxt->nick,
+ ctxt->address),
_("%s%s%s%s%s%s%s%s%s%s has left %s%s%s"),
weechat_prefix ("quit"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? " (" : "",
IRC_COLOR_CHAT_HOST,
- (display_host) ? address : "",
+ (display_host) ? ctxt->address : "",
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? ")" : "",
IRC_COLOR_MESSAGE_QUIT,
@@ -2887,12 +2842,12 @@ IRC_PROTOCOL_CALLBACK(part)
}
/* part request was issued by local client ? */
- if (local_part)
+ if (ctxt->nick_is_me)
{
if (weechat_config_boolean (irc_config_look_typing_status_nicks))
irc_typing_channel_reset (ptr_channel);
- irc_nick_free_all (server, ptr_channel);
+ irc_nick_free_all (ctxt->server, ptr_channel);
irc_channel_modelist_set_state (ptr_channel,
IRC_MODELIST_STATE_MODIFIED);
@@ -2901,7 +2856,7 @@ IRC_PROTOCOL_CALLBACK(part)
if (ptr_channel->cycle)
{
ptr_channel->cycle = 0;
- irc_channel_rejoin (server, ptr_channel, 1, 1);
+ irc_channel_rejoin (ctxt->server, ptr_channel, 1, 1);
}
else
{
@@ -2917,14 +2872,14 @@ IRC_PROTOCOL_CALLBACK(part)
/* part from another user */
if (weechat_config_boolean (irc_config_look_typing_status_nicks))
{
- irc_typing_channel_set_nick (ptr_channel, nick,
+ irc_typing_channel_set_nick (ptr_channel, ctxt->nick,
IRC_CHANNEL_TYPING_STATE_OFF);
}
if (ptr_nick)
{
irc_channel_join_smart_filtered_remove (ptr_channel,
ptr_nick->name);
- irc_nick_free (server, ptr_channel, ptr_nick);
+ irc_nick_free (ctxt->server, ptr_channel, ptr_nick);
}
}
@@ -2947,9 +2902,9 @@ IRC_PROTOCOL_CALLBACK(ping)
IRC_PROTOCOL_MIN_PARAMS(1);
- str_params = irc_protocol_string_params (params, 0, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 0, ctxt->num_params - 1);
- irc_server_sendf (server, 0, NULL, "PONG :%s", str_params);
+ irc_server_sendf (ctxt->server, 0, NULL, "PONG :%s", str_params);
if (str_params)
free (str_params);
@@ -2971,34 +2926,34 @@ IRC_PROTOCOL_CALLBACK(pong)
IRC_PROTOCOL_MIN_PARAMS(0);
- if (server->lag_check_time.tv_sec != 0)
+ if (ctxt->server->lag_check_time.tv_sec != 0)
{
/* calculate lag (time diff with lag check) */
gettimeofday (&tv, NULL);
- server->lag = (int)(weechat_util_timeval_diff (&(server->lag_check_time),
- &tv) / 1000);
+ ctxt->server->lag = (int)(weechat_util_timeval_diff (&(ctxt->server->lag_check_time),
+ &tv) / 1000);
/* schedule next lag check */
- server->lag_check_time.tv_sec = 0;
- server->lag_check_time.tv_usec = 0;
- server->lag_next_check = time (NULL) +
+ ctxt->server->lag_check_time.tv_sec = 0;
+ ctxt->server->lag_check_time.tv_usec = 0;
+ ctxt->server->lag_next_check = time (NULL) +
weechat_config_integer (irc_config_network_lag_check);
/* refresh lag bar item if needed */
- if (server->lag != server->lag_displayed)
+ if (ctxt->server->lag != ctxt->server->lag_displayed)
{
- server->lag_displayed = server->lag;
- irc_server_set_lag (server);
+ ctxt->server->lag_displayed = ctxt->server->lag;
+ irc_server_set_lag (ctxt->server);
}
}
else
{
- str_params = (num_params > 1) ?
- irc_protocol_string_params (params, 1, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 1) ?
+ irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1) : NULL;
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"PONG%s%s",
(str_params) ? ": " : "",
(str_params) ? str_params : "");
@@ -3020,10 +2975,8 @@ IRC_PROTOCOL_CALLBACK(pong)
*/
void
-irc_protocol_privmsg_display_ctcp_send (struct t_irc_server *server,
- time_t date,
+irc_protocol_privmsg_display_ctcp_send (struct t_irc_protocol_ctxt *ctxt,
const char *target,
- const char *address,
const char *arguments)
{
const char *pos_space, *pos_end;
@@ -3046,10 +2999,10 @@ irc_protocol_privmsg_display_ctcp_send (struct t_irc_server *server,
weechat_strndup (pos_space + 1, pos_end - pos_space - 1) : NULL;
irc_input_user_message_display (
- server,
- date,
+ ctxt->server,
+ ctxt->date,
target,
- address,
+ ctxt->address,
"privmsg",
ctcp_type,
ctcp_args,
@@ -3079,7 +3032,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
{
char *msg_args, *msg_args2, str_tags[1024], *str_color, *color;
const char *pos_target, *remote_nick, *pv_tags;
- int status_msg, is_channel, nick_is_me, cap_echo_message;
+ int status_msg, is_channel, cap_echo_message;
int msg_already_received;
time_t time_now;
struct t_irc_channel *ptr_channel;
@@ -3088,55 +3041,51 @@ IRC_PROTOCOL_CALLBACK(privmsg)
IRC_PROTOCOL_MIN_PARAMS(2);
IRC_PROTOCOL_CHECK_NICK;
- if (ignored)
+ if (ctxt->ignored)
return WEECHAT_RC_OK;
- msg_args = irc_protocol_string_params (params, 1, num_params - 1);
+ msg_args = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
if (!msg_args)
return WEECHAT_RC_ERROR;
- nick_is_me = (irc_server_strcasecmp (server, server->nick, nick) == 0);
-
- pos_target = params[0];
+ pos_target = ctxt->params[0];
status_msg = 0;
- is_channel = irc_channel_is_channel (server, pos_target);
+ is_channel = irc_channel_is_channel (ctxt->server, pos_target);
if (!is_channel
- && irc_channel_is_channel (server, pos_target + 1)
- && irc_server_prefix_char_statusmsg (server, pos_target[0]))
+ && irc_channel_is_channel (ctxt->server, pos_target + 1)
+ && irc_server_prefix_char_statusmsg (ctxt->server, pos_target[0]))
{
is_channel = 1;
status_msg = 1;
pos_target++;
}
- cap_echo_message = weechat_hashtable_has_key (server->cap_list,
+ cap_echo_message = weechat_hashtable_has_key (ctxt->server->cap_list,
"echo-message");
/* receiver is a channel ? */
if (is_channel)
{
- ptr_channel = irc_channel_search (server, pos_target);
+ ptr_channel = irc_channel_search (ctxt->server, pos_target);
if (ptr_channel)
{
/*
* unmask a smart filtered join if it is in hashtable
* "join_smart_filtered" of channel
*/
- irc_channel_join_smart_filtered_unmask (ptr_channel, nick);
+ irc_channel_join_smart_filtered_unmask (ptr_channel, ctxt->nick);
/* CTCP to channel */
if (msg_args[0] == '\01')
{
- if (nick_is_me)
+ if (ctxt->nick_is_me)
{
irc_protocol_privmsg_display_ctcp_send (
- server, date, params[0], address, msg_args);
+ ctxt, ctxt->params[0], msg_args);
}
else
{
- irc_ctcp_recv (server, date, tags, command, ptr_channel,
- params[0], address, nick, NULL, msg_args,
- irc_message);
+ irc_ctcp_recv (ctxt, ptr_channel, NULL, msg_args);
}
goto end;
}
@@ -3144,44 +3093,45 @@ IRC_PROTOCOL_CALLBACK(privmsg)
/* other message */
if (weechat_config_boolean (irc_config_look_typing_status_nicks))
{
- irc_typing_channel_set_nick (ptr_channel, nick,
+ irc_typing_channel_set_nick (ptr_channel, ctxt->nick,
IRC_CHANNEL_TYPING_STATE_OFF);
}
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
if (ptr_nick)
- irc_nick_set_host (ptr_nick, address);
+ irc_nick_set_host (ptr_nick, ctxt->address);
if (status_msg)
{
/* message to channel ops/voiced (to "@#channel" or "+#channel") */
weechat_printf_date_tags (
ptr_channel->buffer,
- date,
+ ctxt->date,
irc_protocol_tags (
- server, command, tags,
- (nick_is_me) ?
+ ctxt,
+ (ctxt->nick_is_me) ?
"self_msg,notify_none,no_highlight" : "notify_message",
- nick, address),
+ ctxt->nick,
+ ctxt->address),
"%s%s%s(%s%s%s%s)%s -> %s%s%s: %s",
weechat_prefix ("network"),
"Msg",
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_mode_for_display (server, ptr_nick, 0),
- irc_nick_color_for_msg (server, 0, ptr_nick, nick),
- (nick && nick[0]) ? nick : "?",
+ irc_nick_mode_for_display (ctxt->server, ptr_nick, 0),
+ irc_nick_color_for_msg (ctxt->server, 0, ptr_nick, ctxt->nick),
+ (ctxt->nick && ctxt->nick[0]) ? ctxt->nick : "?",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET,
msg_args);
}
else
{
/* standard message (to "#channel") */
- if (nick_is_me)
+ if (ctxt->nick_is_me)
{
str_color = irc_color_for_tags (
weechat_config_color (
@@ -3193,8 +3143,8 @@ IRC_PROTOCOL_CALLBACK(privmsg)
else
{
color = irc_nick_find_color_name (
- server,
- (ptr_nick) ? ptr_nick->name : nick);
+ ctxt->server,
+ (ptr_nick) ? ptr_nick->name : ctxt->nick);
str_color = irc_color_for_tags (color);
if (color)
free (color);
@@ -3206,56 +3156,54 @@ IRC_PROTOCOL_CALLBACK(privmsg)
free (str_color);
weechat_printf_date_tags (
ptr_channel->buffer,
- date,
- irc_protocol_tags (server, command, tags, str_tags, nick,
- address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, ctxt->nick, ctxt->address),
"%s%s",
- irc_nick_as_prefix (server, ptr_nick,
- (ptr_nick) ? NULL : nick,
+ irc_nick_as_prefix (ctxt->server, ptr_nick,
+ (ptr_nick) ? NULL : ctxt->nick,
NULL),
msg_args);
}
irc_channel_nick_speaking_add (
ptr_channel,
- nick,
+ ctxt->nick,
weechat_string_has_highlight (msg_args,
- server->nick));
+ ctxt->server->nick));
irc_channel_nick_speaking_time_remove_old (ptr_channel);
- irc_channel_nick_speaking_time_add (server, ptr_channel, nick,
+ irc_channel_nick_speaking_time_add (ctxt->server, ptr_channel, ctxt->nick,
time (NULL));
}
}
else
{
- remote_nick = (nick_is_me) ? pos_target : nick;
+ remote_nick = (ctxt->nick_is_me) ? pos_target : ctxt->nick;
/* private message received => display it */
- ptr_channel = irc_channel_search (server, remote_nick);
+ ptr_channel = irc_channel_search (ctxt->server, remote_nick);
/* CTCP to user */
if (msg_args[0] == '\01')
{
msg_already_received = weechat_hashtable_has_key (
- server->echo_msg_recv, irc_message);
+ ctxt->server->echo_msg_recv, ctxt->irc_message);
if (!msg_already_received && cap_echo_message)
{
time_now = time (NULL);
- weechat_hashtable_set (server->echo_msg_recv,
- irc_message, &time_now);
+ weechat_hashtable_set (ctxt->server->echo_msg_recv,
+ ctxt->irc_message, &time_now);
}
- if (nick_is_me && cap_echo_message && !msg_already_received)
+ if (ctxt->nick_is_me && cap_echo_message && !msg_already_received)
{
irc_protocol_privmsg_display_ctcp_send (
- server, date, remote_nick, address, msg_args);
+ ctxt, remote_nick, msg_args);
}
else
{
- irc_ctcp_recv (server, date, tags, command, NULL, params[0],
- address, nick, remote_nick, msg_args, irc_message);
+ irc_ctcp_recv (ctxt, NULL, remote_nick, msg_args);
}
if (msg_already_received)
- weechat_hashtable_remove (server->echo_msg_recv, irc_message);
+ weechat_hashtable_remove (ctxt->server->echo_msg_recv, ctxt->irc_message);
goto end;
}
@@ -3263,17 +3211,17 @@ IRC_PROTOCOL_CALLBACK(privmsg)
{
/* rename buffer if open with nick case not matching */
if (strcmp (ptr_channel->name, remote_nick) != 0)
- irc_channel_pv_rename (server, ptr_channel, remote_nick);
+ irc_channel_pv_rename (ctxt->server, ptr_channel, remote_nick);
}
- else if (!nick_is_me || !cap_echo_message
+ else if (!ctxt->nick_is_me || !cap_echo_message
|| weechat_config_boolean (irc_config_look_open_pv_buffer_echo_msg))
{
- ptr_channel = irc_channel_new (server,
+ ptr_channel = irc_channel_new (ctxt->server,
IRC_CHANNEL_TYPE_PRIVATE,
remote_nick, 0, 0);
if (!ptr_channel)
{
- weechat_printf (server->buffer,
+ weechat_printf (ctxt->server->buffer,
_("%s%s: cannot create new "
"private buffer \"%s\""),
weechat_prefix ("error"),
@@ -3285,20 +3233,20 @@ IRC_PROTOCOL_CALLBACK(privmsg)
if (ptr_channel
&& weechat_config_boolean (irc_config_look_typing_status_nicks))
{
- irc_typing_channel_set_nick (ptr_channel, nick,
+ irc_typing_channel_set_nick (ptr_channel, ctxt->nick,
IRC_CHANNEL_TYPING_STATE_OFF);
}
if (ptr_channel
- && (!nick_is_me
+ && (!ctxt->nick_is_me
|| !cap_echo_message
- || (irc_server_strcasecmp (server,
- server->nick, remote_nick) == 0)))
+ || (irc_server_strcasecmp (ctxt->server,
+ ctxt->server->nick, remote_nick) == 0)))
{
- irc_channel_set_topic (ptr_channel, address);
+ irc_channel_set_topic (ptr_channel, ctxt->address);
}
- if (nick_is_me)
+ if (ctxt->nick_is_me)
{
str_color = irc_color_for_tags (
weechat_config_color (
@@ -3308,7 +3256,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
{
if (weechat_config_boolean (irc_config_look_color_pv_nick_like_channel))
{
- color = irc_nick_find_color_name (server, nick);
+ color = irc_nick_find_color_name (ctxt->server, ctxt->nick);
str_color = irc_color_for_tags (color);
if (color)
free (color);
@@ -3320,7 +3268,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
weechat_config_get ("weechat.color.chat_nick_other")));
}
}
- if (nick_is_me)
+ if (ctxt->nick_is_me)
{
snprintf (str_tags, sizeof (str_tags),
"self_msg,notify_none,no_highlight,prefix_nick_%s",
@@ -3337,15 +3285,15 @@ IRC_PROTOCOL_CALLBACK(privmsg)
}
if (str_color)
free (str_color);
- msg_args2 = (nick_is_me) ?
- irc_message_hide_password (server, remote_nick, msg_args) : NULL;
- if (nick_is_me && !ptr_channel)
+ msg_args2 = (ctxt->nick_is_me) ?
+ irc_message_hide_password (ctxt->server, remote_nick, msg_args) : NULL;
+ if (ctxt->nick_is_me && !ptr_channel)
{
irc_input_user_message_display (
- server,
- date,
+ ctxt->server,
+ ctxt->date,
remote_nick,
- address,
+ ctxt->address,
"privmsg",
NULL, /* ctcp_type */
(msg_args2) ? msg_args2 : msg_args,
@@ -3354,16 +3302,16 @@ IRC_PROTOCOL_CALLBACK(privmsg)
else
{
weechat_printf_date_tags (
- (ptr_channel) ? ptr_channel->buffer : server->buffer,
- date,
- irc_protocol_tags (server, command, tags, str_tags, nick, address),
+ (ptr_channel) ? ptr_channel->buffer : ctxt->server->buffer,
+ ctxt->date,
+ irc_protocol_tags (ctxt, str_tags, ctxt->nick, ctxt->address),
"%s%s",
irc_nick_as_prefix (
- server, NULL, nick,
- (nick_is_me) ?
- IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (server,
+ ctxt->server, NULL, ctxt->nick,
+ (ctxt->nick_is_me) ?
+ IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ctxt->server,
ptr_channel,
- nick)),
+ ctxt->nick)),
(msg_args2) ? msg_args2 : msg_args);
}
if (msg_args2)
@@ -3374,7 +3322,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
(void) weechat_hook_signal_send ("irc_pv",
WEECHAT_HOOK_SIGNAL_STRING,
- (char *)irc_message);
+ (char *)ctxt->irc_message);
}
end:
@@ -3396,33 +3344,32 @@ IRC_PROTOCOL_CALLBACK(quit)
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_irc_channel_speaking *ptr_nick_speaking;
- int local_quit, display_host;
+ int display_host;
IRC_PROTOCOL_MIN_PARAMS(0);
IRC_PROTOCOL_CHECK_NICK;
- str_quit_msg = (num_params > 0) ?
- irc_protocol_string_params (params, 0, num_params - 1) : NULL;
+ str_quit_msg = (ctxt->num_params > 0) ?
+ irc_protocol_string_params (ctxt->params, 0, ctxt->num_params - 1) : NULL;
- for (ptr_channel = server->channels; ptr_channel;
+ for (ptr_channel = ctxt->server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
if (weechat_config_boolean (irc_config_look_typing_status_nicks))
{
- irc_typing_channel_set_nick (ptr_channel, nick,
+ irc_typing_channel_set_nick (ptr_channel, ctxt->nick,
IRC_CHANNEL_TYPING_STATE_OFF);
}
if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
ptr_nick = NULL;
else
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
if (ptr_nick
- || (irc_server_strcasecmp (server, ptr_channel->name, nick) == 0))
+ || (irc_server_strcasecmp (ctxt->server, ptr_channel->name, ctxt->nick) == 0))
{
- local_quit = (irc_server_strcasecmp (server, nick, server->nick) == 0);
- if (!irc_ignore_check (server, ptr_channel->name, nick, host))
+ if (!irc_ignore_check (ctxt->server, ptr_channel->name, ctxt->nick, ctxt->host))
{
/* display quit message */
ptr_nick_speaking = NULL;
@@ -3430,7 +3377,7 @@ IRC_PROTOCOL_CALLBACK(quit)
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_quit))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
+ irc_channel_nick_speaking_time_search (ctxt->server, ptr_channel, ctxt->nick, 1) : NULL;
}
if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
@@ -3441,29 +3388,28 @@ IRC_PROTOCOL_CALLBACK(quit)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
irc_protocol_tags (
- server,
- command,
- tags,
- (local_quit
+ ctxt,
+ (ctxt->nick_is_me
|| (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
|| !weechat_config_boolean (irc_config_look_smart_filter)
|| !weechat_config_boolean (irc_config_look_smart_filter_quit)
|| ptr_nick_speaking) ?
NULL : "irc_smart_filter",
- nick, address),
+ ctxt->nick,
+ ctxt->address),
_("%s%s%s%s%s%s%s%s%s%s has quit %s(%s%s%s)"),
weechat_prefix ("quit"),
(ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ?
- irc_nick_color_for_pv (server, ptr_channel, nick) :
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_pv (ctxt->server, ptr_channel, ctxt->nick) :
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? " (" : "",
IRC_COLOR_CHAT_HOST,
- (display_host) ? address : "",
+ (display_host) ? ctxt->address : "",
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? ")" : "",
IRC_COLOR_MESSAGE_QUIT,
@@ -3476,41 +3422,40 @@ IRC_PROTOCOL_CALLBACK(quit)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
irc_protocol_tags (
- server,
- command,
- tags,
- (local_quit
+ ctxt,
+ (ctxt->nick_is_me
|| (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
|| !weechat_config_boolean (irc_config_look_smart_filter)
|| !weechat_config_boolean (irc_config_look_smart_filter_quit)
|| ptr_nick_speaking) ?
NULL : "irc_smart_filter",
- nick, address),
+ ctxt->nick,
+ ctxt->address),
_("%s%s%s%s%s%s%s%s%s%s has quit"),
weechat_prefix ("quit"),
(ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ?
- irc_nick_color_for_pv (server, ptr_channel, nick) :
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_pv (ctxt->server, ptr_channel, ctxt->nick) :
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? " (" : "",
IRC_COLOR_CHAT_HOST,
- (display_host) ? address : "",
+ (display_host) ? ctxt->address : "",
IRC_COLOR_CHAT_DELIMITERS,
(display_host) ? ")" : "",
IRC_COLOR_MESSAGE_QUIT);
}
}
- if (!local_quit && ptr_nick)
+ if (!ctxt->nick_is_me && ptr_nick)
{
irc_channel_join_smart_filtered_remove (ptr_channel,
ptr_nick->name);
}
if (ptr_nick)
- irc_nick_free (server, ptr_channel, ptr_nick);
+ irc_nick_free (ctxt->server, ptr_channel, ptr_nick);
}
}
@@ -3530,7 +3475,7 @@ IRC_PROTOCOL_CALLBACK(quit)
IRC_PROTOCOL_CALLBACK(setname)
{
- int local_setname, setname_enabled, smart_filter;
+ int setname_enabled, smart_filter;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_irc_channel_speaking *ptr_nick_speaking;
@@ -3539,9 +3484,7 @@ IRC_PROTOCOL_CALLBACK(setname)
IRC_PROTOCOL_MIN_PARAMS(1);
IRC_PROTOCOL_CHECK_NICK;
- local_setname = (irc_server_strcasecmp (server, nick, server->nick) == 0);
-
- str_realname = irc_protocol_string_params (params, 0, num_params - 1);
+ str_realname = irc_protocol_string_params (ctxt->params, 0, ctxt->num_params - 1);
if (!str_realname)
return WEECHAT_RC_ERROR;
@@ -3549,29 +3492,28 @@ IRC_PROTOCOL_CALLBACK(setname)
str_realname,
weechat_config_boolean (irc_config_network_colors_receive));
- setname_enabled = (weechat_hashtable_has_key (server->cap_list, "setname"));
+ setname_enabled = (weechat_hashtable_has_key (ctxt->server->cap_list, "setname"));
- for (ptr_channel = server->channels; ptr_channel;
+ for (ptr_channel = ctxt->server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
switch (ptr_channel->type)
{
case IRC_CHANNEL_TYPE_PRIVATE:
- if (!ignored
- && !local_setname
- && (irc_server_strcasecmp (server,
- ptr_channel->name, nick) == 0))
+ if (!ctxt->ignored
+ && !ctxt->nick_is_me
+ && (irc_server_strcasecmp (ctxt->server,
+ ptr_channel->name, ctxt->nick) == 0))
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL,
- NULL),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s%s%s has changed real name to %s\"%s%s%s\"%s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_SETNAME,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
@@ -3581,34 +3523,32 @@ IRC_PROTOCOL_CALLBACK(setname)
}
break;
case IRC_CHANNEL_TYPE_CHANNEL:
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
if (ptr_nick)
{
- if (!ignored && !local_setname)
+ if (!ctxt->ignored && !ctxt->nick_is_me)
{
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
&& (weechat_config_boolean (irc_config_look_smart_filter_setname))) ?
- irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
- smart_filter = (!local_setname
+ irc_channel_nick_speaking_time_search (ctxt->server, ptr_channel, ctxt->nick, 1) : NULL;
+ smart_filter = (!ctxt->nick_is_me
&& weechat_config_boolean (irc_config_look_smart_filter)
&& weechat_config_boolean (irc_config_look_smart_filter_setname)
&& !ptr_nick_speaking);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
irc_protocol_tags (
- server,
- command,
- tags,
+ ctxt,
(smart_filter) ? "irc_smart_filter" : NULL,
NULL,
NULL),
_("%s%s%s%s has changed real name to %s\"%s%s%s\"%s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_MESSAGE_SETNAME,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
@@ -3627,12 +3567,12 @@ IRC_PROTOCOL_CALLBACK(setname)
}
}
- if (!ignored && local_setname)
+ if (!ctxt->ignored && ctxt->nick_is_me)
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%sYour real name has been set to %s\"%s%s%s\"%s"),
weechat_prefix ("network"),
IRC_COLOR_MESSAGE_SETNAME,
@@ -3668,27 +3608,27 @@ IRC_PROTOCOL_CALLBACK(tagmsg)
IRC_PROTOCOL_MIN_PARAMS(1);
- if (ignored)
+ if (ctxt->ignored)
return WEECHAT_RC_OK;
- if (!tags)
+ if (!ctxt->tags)
return WEECHAT_RC_OK;
/* ignore if coming from self nick (if echo-message is enabled) */
- if (irc_server_strcasecmp (server, server->nick, nick) == 0)
+ if (ctxt->nick_is_me)
return WEECHAT_RC_OK;
ptr_channel = NULL;
- if (irc_channel_is_channel (server, params[0]))
- ptr_channel = irc_channel_search (server, params[0]);
- else if (irc_server_strcasecmp (server, params[0], server->nick) == 0)
- ptr_channel = irc_channel_search (server, nick);
+ if (irc_channel_is_channel (ctxt->server, ctxt->params[0]))
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[0]);
+ else if (irc_server_strcasecmp (ctxt->server, ctxt->params[0], ctxt->server->nick) == 0)
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->nick);
if (!ptr_channel)
return WEECHAT_RC_OK;
if (weechat_config_boolean (irc_config_look_typing_status_nicks))
{
- ptr_typing_value = weechat_hashtable_get (tags, "+typing");
+ ptr_typing_value = weechat_hashtable_get (ctxt->tags, "+typing");
if (ptr_typing_value && ptr_typing_value[0])
{
if (strcmp (ptr_typing_value, "active") == 0)
@@ -3697,7 +3637,7 @@ IRC_PROTOCOL_CALLBACK(tagmsg)
state = IRC_CHANNEL_TYPING_STATE_PAUSED;
else
state = IRC_CHANNEL_TYPING_STATE_OFF;
- irc_typing_channel_set_nick (ptr_channel, nick, state);
+ irc_typing_channel_set_nick (ptr_channel, ctxt->nick, state);
}
}
@@ -3717,25 +3657,25 @@ IRC_PROTOCOL_CALLBACK(server_mode_reason)
IRC_PROTOCOL_MIN_PARAMS(1);
/* skip nickname if at beginning of server message */
- if (irc_server_strcasecmp (server, server->nick, params[0]) == 0)
+ if (irc_server_strcasecmp (ctxt->server, ctxt->server->nick, ctxt->params[0]) == 0)
{
- if (num_params < 2)
+ if (ctxt->num_params < 2)
return WEECHAT_RC_OK;
- pos_mode = params[1];
+ pos_mode = ctxt->params[1];
arg_text = 2;
}
else
{
- pos_mode = params[0];
+ pos_mode = ctxt->params[0];
arg_text = 1;
}
- str_params = irc_protocol_string_params (params, arg_text, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, arg_text, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s%s",
weechat_prefix ("network"),
pos_mode,
@@ -3759,18 +3699,18 @@ IRC_PROTOCOL_CALLBACK(numeric)
IRC_PROTOCOL_MIN_PARAMS(1);
- arg_text = ((irc_server_strcasecmp (server, server->nick, params[0]) == 0)
- || (strcmp (params[0], "*") == 0)) ?
+ arg_text = ((irc_server_strcasecmp (ctxt->server, ctxt->server->nick, ctxt->params[0]) == 0)
+ || (strcmp (ctxt->params[0], "*") == 0)) ?
1 : 0;
- str_params = irc_protocol_string_params (params, arg_text, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, arg_text, ctxt->num_params - 1);
if (str_params)
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_params);
@@ -3797,27 +3737,27 @@ IRC_PROTOCOL_CALLBACK(topic)
IRC_PROTOCOL_MIN_PARAMS(1);
IRC_PROTOCOL_CHECK_NICK;
- if (!irc_channel_is_channel (server, params[0]))
+ if (!irc_channel_is_channel (ctxt->server, ctxt->params[0]))
{
- weechat_printf (server->buffer,
+ weechat_printf (ctxt->server->buffer,
_("%s%s: \"%s\" command received without channel"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, "topic");
return WEECHAT_RC_OK;
}
- str_topic = (num_params > 1) ?
- irc_protocol_string_params (params, 1, num_params - 1) : NULL;
+ str_topic = (ctxt->num_params > 1) ?
+ irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1) : NULL;
- ptr_channel = irc_channel_search (server, params[0]);
- ptr_nick = irc_nick_search (server, ptr_channel, nick);
- ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[0]);
+ ptr_nick = irc_nick_search (ctxt->server, ptr_channel, ctxt->nick);
+ ptr_buffer = (ptr_channel) ? ptr_channel->buffer : ctxt->server->buffer;
/*
* unmask a smart filtered join if it is in hashtable
* "join_smart_filtered" of channel
*/
if (ptr_channel)
- irc_channel_join_smart_filtered_unmask (ptr_channel, nick);
+ irc_channel_join_smart_filtered_unmask (ptr_channel, ctxt->nick);
if (str_topic && str_topic[0])
{
@@ -3832,17 +3772,17 @@ IRC_PROTOCOL_CALLBACK(topic)
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%s%s%s has changed topic for %s%s%s from \"%s%s%s\" to "
"\"%s%s%s\""),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET,
IRC_COLOR_TOPIC_OLD,
(old_topic_color) ? old_topic_color : ptr_channel->topic,
@@ -3857,16 +3797,16 @@ IRC_PROTOCOL_CALLBACK(topic)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%s%s%s has changed topic for %s%s%s to \"%s%s%s\""),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET,
IRC_COLOR_TOPIC_NEW,
(topic_color) ? topic_color : str_topic,
@@ -3885,17 +3825,17 @@ IRC_PROTOCOL_CALLBACK(topic)
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%s%s%s has unset topic for %s%s%s (old topic: "
"\"%s%s%s\")"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET,
IRC_COLOR_TOPIC_OLD,
(old_topic_color) ? old_topic_color : ptr_channel->topic,
@@ -3907,16 +3847,16 @@ IRC_PROTOCOL_CALLBACK(topic)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%s%s%s has unset topic for %s%s%s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, nick),
- nick,
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, ctxt->nick),
+ ctxt->nick,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
- params[0],
+ ctxt->params[0],
IRC_COLOR_RESET);
}
}
@@ -3947,18 +3887,17 @@ IRC_PROTOCOL_CALLBACK(wallops)
IRC_PROTOCOL_MIN_PARAMS(1);
- if (ignored)
+ if (ctxt->ignored)
return WEECHAT_RC_OK;
- nick_address = irc_protocol_nick_address (server, 0, NULL, nick, address);
+ nick_address = irc_protocol_nick_address (ctxt->server, 0, NULL, ctxt->nick, ctxt->address);
- str_message = irc_protocol_string_params (params, 0, num_params - 1);
+ str_message = irc_protocol_string_params (ctxt->params, 0, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, "notify_private", nick,
- address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->nick, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, "notify_private", ctxt->nick, ctxt->address),
_("%sWallops from %s: %s"),
weechat_prefix ("network"),
(nick_address[0]) ? nick_address : "?",
@@ -3981,15 +3920,9 @@ IRC_PROTOCOL_CALLBACK(warn)
{
IRC_PROTOCOL_MIN_PARAMS(2);
- irc_protocol_print_error_warning_msg (
- server,
- date,
- tags,
- command,
- weechat_prefix ("error"),
- _("Warning:"),
- params,
- num_params);
+ irc_protocol_print_error_warning_msg (ctxt,
+ weechat_prefix ("error"),
+ _("Warning:"));
return WEECHAT_RC_OK;
}
@@ -4010,57 +3943,57 @@ IRC_PROTOCOL_CALLBACK(001)
IRC_PROTOCOL_MIN_PARAMS(1);
- if (irc_server_strcasecmp (server, server->nick, params[0]) != 0)
- irc_server_set_nick (server, params[0]);
+ if (irc_server_strcasecmp (ctxt->server, ctxt->server->nick, ctxt->params[0]) != 0)
+ irc_server_set_nick (ctxt->server, ctxt->params[0]);
- IRC_PROTOCOL_RUN_CALLBACK(numeric);
+ irc_protocol_cb_numeric (ctxt);
/* connection to IRC server is OK! */
- server->is_connected = 1;
- server->reconnect_delay = 0;
- server->monitor_time = time (NULL) + 5;
- irc_server_set_tls_version (server);
+ ctxt->server->is_connected = 1;
+ ctxt->server->reconnect_delay = 0;
+ ctxt->server->monitor_time = time (NULL) + 5;
+ irc_server_set_tls_version (ctxt->server);
- if (server->hook_timer_connection)
+ if (ctxt->server->hook_timer_connection)
{
- weechat_unhook (server->hook_timer_connection);
- server->hook_timer_connection = NULL;
+ weechat_unhook (ctxt->server->hook_timer_connection);
+ ctxt->server->hook_timer_connection = NULL;
}
- server->lag_next_check = time (NULL) +
+ ctxt->server->lag_next_check = time (NULL) +
weechat_config_integer (irc_config_network_lag_check);
- irc_server_set_buffer_title (server);
+ irc_server_set_buffer_title (ctxt->server);
/* set away message if user was away (before disconnection for example) */
- if (server->away_message && server->away_message[0])
+ if (ctxt->server->away_message && ctxt->server->away_message[0])
{
- away_msg = strdup (server->away_message);
+ away_msg = strdup (ctxt->server->away_message);
if (away_msg)
{
- irc_command_away_server (server, away_msg, 0);
+ irc_command_away_server (ctxt->server, away_msg, 0);
free (away_msg);
}
}
/* send signal "irc_server_connected" with server name */
(void) weechat_hook_signal_send ("irc_server_connected",
- WEECHAT_HOOK_SIGNAL_STRING, server->name);
+ WEECHAT_HOOK_SIGNAL_STRING, ctxt->server->name);
/* set usermode when connected */
usermode = irc_server_eval_expression (
- server,
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERMODE));
+ ctxt->server,
+ IRC_SERVER_OPTION_STRING(ctxt->server, IRC_SERVER_OPTION_USERMODE));
if (usermode && usermode[0])
{
- irc_server_sendf (server,
+ irc_server_sendf (ctxt->server,
IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"MODE %s %s",
- server->nick, usermode);
+ ctxt->server->nick, usermode);
}
if (usermode)
free (usermode);
/* execute command when connected */
- ptr_server_command = IRC_SERVER_OPTION_STRING(server,
+ ptr_server_command = IRC_SERVER_OPTION_STRING(ctxt->server,
IRC_SERVER_OPTION_COMMAND);
if (ptr_server_command && ptr_server_command[0])
{
@@ -4070,16 +4003,16 @@ IRC_PROTOCOL_CALLBACK(001)
{
for (ptr_command = commands; *ptr_command; ptr_command++)
{
- command2 = irc_server_eval_expression (server, *ptr_command);
+ command2 = irc_server_eval_expression (ctxt->server, *ptr_command);
if (command2)
{
- command3 = irc_message_replace_vars (server, NULL,
+ command3 = irc_message_replace_vars (ctxt->server, NULL,
command2);
if (command3)
{
if (weechat_string_is_command_char (command3))
{
- weechat_command (server->buffer, command3);
+ weechat_command (ctxt->server->buffer, command3);
}
else
{
@@ -4089,7 +4022,7 @@ IRC_PROTOCOL_CALLBACK(001)
{
snprintf (slash_command, length,
"/%s", command3);
- weechat_command (server->buffer,
+ weechat_command (ctxt->server->buffer,
slash_command);
free (slash_command);
}
@@ -4102,14 +4035,14 @@ IRC_PROTOCOL_CALLBACK(001)
weechat_string_free_split_command (commands);
}
- if (IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY) > 0)
- server->command_time = time (NULL) + 1;
+ if (IRC_SERVER_OPTION_INTEGER(ctxt->server, IRC_SERVER_OPTION_COMMAND_DELAY) > 0)
+ ctxt->server->command_time = time (NULL) + 1;
else
- irc_server_autojoin_channels (server);
+ irc_server_autojoin_channels (ctxt->server);
}
else
{
- irc_server_autojoin_channels (server);
+ irc_server_autojoin_channels (ctxt->server);
}
return WEECHAT_RC_OK;
@@ -4133,120 +4066,120 @@ IRC_PROTOCOL_CALLBACK(005)
IRC_PROTOCOL_MIN_PARAMS(2);
- IRC_PROTOCOL_RUN_CALLBACK(numeric);
+ irc_protocol_cb_numeric (ctxt);
- arg_last = (strstr (irc_message, " :")) ? num_params - 2 : num_params - 1;
+ arg_last = (strstr (ctxt->irc_message, " :")) ? ctxt->num_params - 2 : ctxt->num_params - 1;
for (i = 1; i <= arg_last; i++)
{
- if (strncmp (params[i], "PREFIX=", 7) == 0)
+ if (strncmp (ctxt->params[i], "PREFIX=", 7) == 0)
{
/* save prefix */
- irc_server_set_prefix_modes_chars (server, params[i] + 7);
+ irc_server_set_prefix_modes_chars (ctxt->server, ctxt->params[i] + 7);
}
- else if (strncmp (params[i], "LINELEN=", 8) == 0)
+ else if (strncmp (ctxt->params[i], "LINELEN=", 8) == 0)
{
/* save max message length */
error = NULL;
- value = strtol (params[i] + 8, &error, 10);
+ value = strtol (ctxt->params[i] + 8, &error, 10);
if (error && !error[0] && (value > 0))
- server->msg_max_length = (int)value;
+ ctxt->server->msg_max_length = (int)value;
}
- else if (strncmp (params[i], "NICKLEN=", 8) == 0)
+ else if (strncmp (ctxt->params[i], "NICKLEN=", 8) == 0)
{
/* save max nick length */
error = NULL;
- value = strtol (params[i] + 8, &error, 10);
+ value = strtol (ctxt->params[i] + 8, &error, 10);
if (error && !error[0] && (value > 0))
- server->nick_max_length = (int)value;
+ ctxt->server->nick_max_length = (int)value;
}
- else if (strncmp (params[i], "USERLEN=", 8) == 0)
+ else if (strncmp (ctxt->params[i], "USERLEN=", 8) == 0)
{
/* save max user length */
error = NULL;
- value = strtol (params[i] + 8, &error, 10);
+ value = strtol (ctxt->params[i] + 8, &error, 10);
if (error && !error[0] && (value > 0))
- server->user_max_length = (int)value;
+ ctxt->server->user_max_length = (int)value;
}
- else if (strncmp (params[i], "HOSTLEN=", 8) == 0)
+ else if (strncmp (ctxt->params[i], "HOSTLEN=", 8) == 0)
{
/* save max host length */
error = NULL;
- value = strtol (params[i] + 8, &error, 10);
+ value = strtol (ctxt->params[i] + 8, &error, 10);
if (error && !error[0] && (value > 0))
- server->host_max_length = (int)value;
+ ctxt->server->host_max_length = (int)value;
}
- else if (strncmp (params[i], "CASEMAPPING=", 12) == 0)
+ else if (strncmp (ctxt->params[i], "CASEMAPPING=", 12) == 0)
{
/* save casemapping */
- casemapping = irc_server_search_casemapping (params[i] + 12);
+ casemapping = irc_server_search_casemapping (ctxt->params[i] + 12);
if (casemapping >= 0)
- server->casemapping = casemapping;
+ ctxt->server->casemapping = casemapping;
}
- else if (strncmp (params[i], "UTF8MAPPING=", 12) == 0)
+ else if (strncmp (ctxt->params[i], "UTF8MAPPING=", 12) == 0)
{
/* save utf8mapping */
- utf8mapping = irc_server_search_utf8mapping (params[i] + 12);
+ utf8mapping = irc_server_search_utf8mapping (ctxt->params[i] + 12);
if (utf8mapping >= 0)
- server->utf8mapping = utf8mapping;
+ ctxt->server->utf8mapping = utf8mapping;
}
- else if (strcmp (params[i], "UTF8ONLY") == 0)
+ else if (strcmp (ctxt->params[i], "UTF8ONLY") == 0)
{
/* save utf8only */
- server->utf8only = 1;
+ ctxt->server->utf8only = 1;
}
- else if (strncmp (params[i], "CHANTYPES=", 10) == 0)
+ else if (strncmp (ctxt->params[i], "CHANTYPES=", 10) == 0)
{
/* save chantypes */
- if (server->chantypes)
- free (server->chantypes);
- server->chantypes = strdup (params[i] + 10);
+ if (ctxt->server->chantypes)
+ free (ctxt->server->chantypes);
+ ctxt->server->chantypes = strdup (ctxt->params[i] + 10);
}
- else if (strncmp (params[i], "CHANMODES=", 10) == 0)
+ else if (strncmp (ctxt->params[i], "CHANMODES=", 10) == 0)
{
/* save chanmodes */
- if (server->chanmodes)
- free (server->chanmodes);
- server->chanmodes = strdup (params[i] + 10);
+ if (ctxt->server->chanmodes)
+ free (ctxt->server->chanmodes);
+ ctxt->server->chanmodes = strdup (ctxt->params[i] + 10);
}
- else if (strncmp (params[i], "MONITOR=", 8) == 0)
+ else if (strncmp (ctxt->params[i], "MONITOR=", 8) == 0)
{
/* save monitor (limit) */
error = NULL;
- value = strtol (params[i] + 8, &error, 10);
+ value = strtol (ctxt->params[i] + 8, &error, 10);
if (error && !error[0] && (value > 0))
- server->monitor = (int)value;
+ ctxt->server->monitor = (int)value;
}
- else if (strncmp (params[i], "CLIENTTAGDENY=", 14) == 0)
+ else if (strncmp (ctxt->params[i], "CLIENTTAGDENY=", 14) == 0)
{
/* save client tag deny */
- irc_server_set_clienttagdeny (server, params[i] + 14);
+ irc_server_set_clienttagdeny (ctxt->server, ctxt->params[i] + 14);
}
}
/* save whole message (concatenate to existing isupport, if any) */
- str_info = irc_protocol_string_params (params, 1, arg_last);
+ str_info = irc_protocol_string_params (ctxt->params, 1, arg_last);
if (str_info && str_info[0])
{
length = strlen (str_info);
- if (server->isupport)
+ if (ctxt->server->isupport)
{
- length_isupport = strlen (server->isupport);
- isupport2 = realloc (server->isupport,
+ length_isupport = strlen (ctxt->server->isupport);
+ isupport2 = realloc (ctxt->server->isupport,
length_isupport + /* existing */
1 + /* space */
length + /* new */
1);
if (isupport2)
{
- server->isupport = isupport2;
- strcat (server->isupport, " ");
- strcat (server->isupport, str_info);
+ ctxt->server->isupport = isupport2;
+ strcat (ctxt->server->isupport, " ");
+ strcat (ctxt->server->isupport, str_info);
}
}
else
{
- server->isupport = strdup (str_info);
+ ctxt->server->isupport = strdup (str_info);
}
}
if (str_info)
@@ -4268,16 +4201,16 @@ IRC_PROTOCOL_CALLBACK(008)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_params = irc_protocol_string_params (params, 1, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->params[0], ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%sServer notice mask for %s%s%s: %s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, params[0]),
- params[0],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[0]),
+ ctxt->params[0],
IRC_COLOR_RESET,
str_params);
@@ -4300,24 +4233,24 @@ IRC_PROTOCOL_CALLBACK(221)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_modes = irc_protocol_string_params (params, 1, num_params - 1);
+ str_modes = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->params[0], ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%sUser mode for %s%s%s is %s[%s%s%s]"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, params[0]),
- params[0],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[0]),
+ ctxt->params[0],
IRC_COLOR_RESET,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_modes,
IRC_COLOR_CHAT_DELIMITERS);
- if (irc_server_strcasecmp (server, params[0], server->nick) == 0)
- irc_mode_user_set (server, str_modes, 1);
+ if (irc_server_strcasecmp (ctxt->server, ctxt->params[0], ctxt->server->nick) == 0)
+ irc_mode_user_set (ctxt->server, str_modes, 1);
if (str_modes)
free (str_modes);
@@ -4343,31 +4276,31 @@ IRC_PROTOCOL_CALLBACK(301)
IRC_PROTOCOL_MIN_PARAMS(1);
- if (num_params < 3)
+ if (ctxt->num_params < 3)
return WEECHAT_RC_OK;
- str_away_msg = irc_protocol_string_params (params, 2, num_params - 1);
+ str_away_msg = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
if (!str_away_msg)
return WEECHAT_RC_ERROR;
/* look for private buffer to display message */
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
if (!weechat_config_boolean (irc_config_look_display_pv_away_once)
|| !ptr_channel
|| !(ptr_channel->away_message)
|| (strcmp (ptr_channel->away_message, str_away_msg) != 0))
{
- ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
+ ptr_buffer = (ptr_channel) ? ptr_channel->buffer : ctxt->server->buffer;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%s%s[%s%s%s]%s is away: %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_away_msg);
@@ -4397,12 +4330,12 @@ IRC_PROTOCOL_CALLBACK(303)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_nicks = irc_protocol_string_params (params, 1, num_params - 1);
+ str_nicks = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sUsers online: %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
@@ -4427,14 +4360,14 @@ IRC_PROTOCOL_CALLBACK(305)
IRC_PROTOCOL_MIN_PARAMS(1);
- if (num_params > 1)
+ if (ctxt->num_params > 1)
{
- str_away_msg = irc_protocol_string_params (params, 1, num_params - 1);
+ str_away_msg = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "unaway", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "unaway", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_away_msg);
@@ -4442,8 +4375,8 @@ IRC_PROTOCOL_CALLBACK(305)
free (str_away_msg);
}
- server->is_away = 0;
- server->away_time = 0;
+ ctxt->server->is_away = 0;
+ ctxt->server->away_time = 0;
weechat_bar_item_update ("away");
@@ -4463,14 +4396,14 @@ IRC_PROTOCOL_CALLBACK(306)
IRC_PROTOCOL_MIN_PARAMS(1);
- if (num_params > 1)
+ if (ctxt->num_params > 1)
{
- str_away_msg = irc_protocol_string_params (params, 1, num_params - 1);
+ str_away_msg = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "away", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "away", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_away_msg);
@@ -4478,8 +4411,8 @@ IRC_PROTOCOL_CALLBACK(306)
free (str_away_msg);
}
- server->is_away = 1;
- server->away_time = time (NULL);
+ ctxt->server->is_away = 1;
+ ctxt->server->away_time = time (NULL);
weechat_bar_item_update ("away");
@@ -4502,19 +4435,19 @@ IRC_PROTOCOL_CALLBACK(whois_nick_msg)
IRC_PROTOCOL_MIN_PARAMS(2);
- if (num_params >= 3)
+ if (ctxt->num_params >= 3)
{
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_params);
@@ -4527,7 +4460,7 @@ IRC_PROTOCOL_CALLBACK(whois_nick_msg)
* not enough parameters: this should not be a whois command so we
* display the arguments as-is
*/
- IRC_PROTOCOL_RUN_CALLBACK(numeric);
+ irc_protocol_cb_numeric (ctxt);
}
return WEECHAT_RC_OK;
@@ -4546,19 +4479,19 @@ IRC_PROTOCOL_CALLBACK(whowas_nick_msg)
IRC_PROTOCOL_MIN_PARAMS(2);
- if (num_params >= 3)
+ if (ctxt->num_params >= 3)
{
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whowas", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whowas", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_params);
@@ -4571,7 +4504,7 @@ IRC_PROTOCOL_CALLBACK(whowas_nick_msg)
* not enough parameters: this should not be a whowas command so we
* display the arguments as-is
*/
- IRC_PROTOCOL_RUN_CALLBACK(numeric);
+ irc_protocol_cb_numeric (ctxt);
}
return WEECHAT_RC_OK;
@@ -4590,27 +4523,27 @@ IRC_PROTOCOL_CALLBACK(311)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (num_params < 6)
+ if (ctxt->num_params < 6)
{
- IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
+ irc_protocol_cb_whois_nick_msg (ctxt);
}
else
{
- str_realname = irc_protocol_string_params (params, 5, num_params - 1);
+ str_realname = irc_protocol_string_params (ctxt->params, 5, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] (%s%s@%s%s)%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- params[2],
- params[3],
+ ctxt->params[2],
+ ctxt->params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname);
@@ -4634,26 +4567,26 @@ IRC_PROTOCOL_CALLBACK(312)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (num_params < 4)
+ if (ctxt->num_params < 4)
{
- IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
+ irc_protocol_cb_whois_nick_msg (ctxt);
}
else
{
- str_server = irc_protocol_string_params (params, 3, num_params - 1);
+ str_server = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- params[2],
+ ctxt->params[2],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_server,
@@ -4678,27 +4611,27 @@ IRC_PROTOCOL_CALLBACK(314)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (num_params < 6)
+ if (ctxt->num_params < 6)
{
- IRC_PROTOCOL_RUN_CALLBACK(whowas_nick_msg);
+ irc_protocol_cb_whowas_nick_msg (ctxt);
}
else
{
- str_realname = irc_protocol_string_params (params, 5, num_params - 1);
+ str_realname = irc_protocol_string_params (ctxt->params, 5, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whowas", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whowas", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- params[2],
- params[3],
+ ctxt->params[2],
+ ctxt->params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname);
@@ -4723,24 +4656,24 @@ IRC_PROTOCOL_CALLBACK(315)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
if (ptr_channel && (ptr_channel->checking_whox > 0))
{
ptr_channel->checking_whox--;
}
else
{
- str_text = irc_protocol_string_params (params, 2, num_params - 1);
+ str_text = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "who", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "who", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s]%s %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_text);
@@ -4766,29 +4699,29 @@ IRC_PROTOCOL_CALLBACK(317)
IRC_PROTOCOL_MIN_PARAMS(4);
- idle_time = atoi (params[2]);
+ idle_time = atoi (ctxt->params[2]);
day = idle_time / (60 * 60 * 24);
hour = (idle_time % (60 * 60 * 24)) / (60 * 60);
min = ((idle_time % (60 * 60 * 24)) % (60 * 60)) / 60;
sec = ((idle_time % (60 * 60 * 24)) % (60 * 60)) % 60;
- datetime = (time_t)(atol (params[3]));
+ datetime = (time_t)(atol (ctxt->params[3]));
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, params[1],
- command, "whois", NULL);
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->params[1],
+ ctxt->command, "whois", NULL);
if (day > 0)
{
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s idle: %s%d %s%s, %s%02d %s%s %s%02d %s%s %s%02d "
"%s%s, signon at: %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
@@ -4814,14 +4747,14 @@ IRC_PROTOCOL_CALLBACK(317)
{
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s idle: %s%02d %s%s %s%02d %s%s %s%02d %s%s, "
"signon at: %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
@@ -4856,16 +4789,16 @@ IRC_PROTOCOL_CALLBACK(321)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "list", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "list", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s%s",
weechat_prefix ("network"),
- params[1],
+ ctxt->params[1],
(str_params && str_params[0]) ? " " : "",
(str_params && str_params[0]) ? str_params : "");
@@ -4888,22 +4821,22 @@ IRC_PROTOCOL_CALLBACK(322)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (!server->cmd_list_regexp ||
- (regexec (server->cmd_list_regexp, params[1], 0, NULL, 0) == 0))
+ if (!ctxt->server->cmd_list_regexp ||
+ (regexec (ctxt->server->cmd_list_regexp, ctxt->params[1], 0, NULL, 0) == 0))
{
- str_topic = irc_protocol_string_params (params, 3, num_params - 1);
+ str_topic = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "list", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "list", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s%s(%s%s%s)%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- params[2],
+ ctxt->params[2],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(str_topic && str_topic[0]) ? ": " : "",
@@ -4928,12 +4861,12 @@ IRC_PROTOCOL_CALLBACK(323)
IRC_PROTOCOL_MIN_PARAMS(1);
- str_params = irc_protocol_string_params (params, 1, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, "list", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, "list", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_params);
@@ -4958,35 +4891,35 @@ IRC_PROTOCOL_CALLBACK(324)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_modes = (num_params > 2) ?
- irc_protocol_string_params (params, 2, num_params - 1) : NULL;
- str_modes_args = (num_params > 3) ?
- irc_protocol_string_params (params, 3, num_params - 1) : NULL;
+ str_modes = (ctxt->num_params > 2) ?
+ irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1) : NULL;
+ str_modes_args = (ctxt->num_params > 3) ?
+ irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1) : NULL;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
if (ptr_channel)
{
irc_channel_set_modes (ptr_channel, str_modes);
- if (num_params > 2)
+ if (ctxt->num_params > 2)
{
- (void) irc_mode_channel_set (server, ptr_channel, host,
+ (void) irc_mode_channel_set (ctxt->server, ptr_channel, ctxt->host,
str_modes, str_modes_args);
}
}
if (!ptr_channel
- || (weechat_hashtable_has_key (ptr_channel->join_msg_received, command)
- || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, command)))
+ || (weechat_hashtable_has_key (ptr_channel->join_msg_received, ctxt->command)
+ || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, ctxt->command)))
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL,
+ ctxt->server, NULL, ctxt->command, NULL,
(ptr_channel) ? ptr_channel->buffer : NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, address),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, ctxt->address),
_("%sMode %s%s %s[%s%s%s]"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(str_modes) ? str_modes : "",
@@ -4994,7 +4927,7 @@ IRC_PROTOCOL_CALLBACK(324)
}
if (ptr_channel)
- weechat_hashtable_set (ptr_channel->join_msg_received, command, "1");
+ weechat_hashtable_set (ptr_channel->join_msg_received, ctxt->command, "1");
if (str_modes)
free (str_modes);
@@ -5018,33 +4951,33 @@ IRC_PROTOCOL_CALLBACK(327)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (num_params < 4)
+ if (ctxt->num_params < 4)
{
- IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
+ irc_protocol_cb_whois_nick_msg (ctxt);
}
else
{
- str_realname = (num_params > 4) ?
- irc_protocol_string_params (params, 4, num_params - 1) : NULL;
+ str_realname = (ctxt->num_params > 4) ?
+ irc_protocol_string_params (ctxt->params, 4, ctxt->num_params - 1) : NULL;
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, params[1],
- command, "whois", NULL);
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->params[1],
+ ctxt->command, "whois", NULL);
if (str_realname && str_realname[0])
{
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- params[2],
- params[3],
+ ctxt->params[2],
+ ctxt->params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname,
@@ -5054,17 +4987,17 @@ IRC_PROTOCOL_CALLBACK(327)
{
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- params[2],
- params[3]);
+ ctxt->params[2],
+ ctxt->params[3]);
}
if (str_realname)
@@ -5088,19 +5021,19 @@ IRC_PROTOCOL_CALLBACK(328)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
if (ptr_channel)
{
- str_url = irc_protocol_string_params (params, 2, num_params - 1);
+ str_url = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sURL for %s%s%s: %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
str_url);
if (str_url)
@@ -5124,21 +5057,20 @@ IRC_PROTOCOL_CALLBACK(329)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
- datetime = (time_t)(atol (params[2]));
+ datetime = (time_t)(atol (ctxt->params[2]));
if (ptr_channel)
{
- if (weechat_hashtable_has_key (ptr_channel->join_msg_received, command)
- || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, command))
+ if (weechat_hashtable_has_key (ptr_channel->join_msg_received, ctxt->command)
+ || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, ctxt->command))
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL,
- NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "created on" is a date */
_("%sChannel created on %s"),
weechat_prefix ("network"),
@@ -5148,20 +5080,20 @@ IRC_PROTOCOL_CALLBACK(329)
else
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "created on" is a date */
_("%sChannel %s%s%s created on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
weechat_util_get_time_string (&datetime));
}
if (ptr_channel)
- weechat_hashtable_set (ptr_channel->join_msg_received, command, "1");
+ weechat_hashtable_set (ptr_channel->join_msg_received, ctxt->command, "1");
return WEECHAT_RC_OK;
}
@@ -5184,43 +5116,43 @@ IRC_PROTOCOL_CALLBACK(330_343)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (num_params >= 4)
+ if (ctxt->num_params >= 4)
{
- str_text = irc_protocol_string_params (params, 3, num_params - 1);
+ str_text = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_text,
- irc_nick_color_for_msg (server, 1, NULL, params[2]),
- params[2]);
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[2]),
+ ctxt->params[2]);
if (str_text)
free (str_text);
}
else
{
- ptr_channel = (irc_channel_is_channel (server, params[1])) ?
- irc_channel_search (server, params[1]) : NULL;
- ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
- str_text = irc_protocol_string_params (params, 2, num_params - 1);
+ ptr_channel = (irc_channel_is_channel (ctxt->server, ctxt->params[1])) ?
+ irc_channel_search (ctxt->server, ctxt->params[1]) : NULL;
+ ptr_buffer = (ptr_channel) ? ptr_channel->buffer : ctxt->server->buffer;
+ str_text = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_text);
@@ -5245,17 +5177,17 @@ IRC_PROTOCOL_CALLBACK(331)
IRC_PROTOCOL_MIN_PARAMS(2);
- ptr_channel = irc_channel_search (server, params[1]);
- ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
+ ptr_buffer = (ptr_channel) ? ptr_channel->buffer : ctxt->server->buffer;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, NULL, ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, NULL, ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sNo topic set for channel %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1]);
+ ctxt->params[1]);
return WEECHAT_RC_OK;
}
@@ -5275,10 +5207,10 @@ IRC_PROTOCOL_CALLBACK(332)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_topic = (num_params >= 3) ?
- irc_protocol_string_params (params, 2, num_params - 1) : NULL;
+ str_topic = (ctxt->num_params >= 3) ?
+ irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1) : NULL;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
if (ptr_channel && ptr_channel->nicks)
{
@@ -5294,7 +5226,7 @@ IRC_PROTOCOL_CALLBACK(332)
ptr_buffer = ptr_channel->buffer;
}
else
- ptr_buffer = server->buffer;
+ ptr_buffer = ctxt->server->buffer;
topic_color = NULL;
if (str_topic)
@@ -5305,18 +5237,18 @@ IRC_PROTOCOL_CALLBACK(332)
}
if (!ptr_channel
- || (weechat_hashtable_has_key (ptr_channel->join_msg_received, command))
- || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, command))
+ || (weechat_hashtable_has_key (ptr_channel->join_msg_received, ctxt->command))
+ || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, ctxt->command))
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sTopic for %s%s%s is \"%s%s%s\""),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
IRC_COLOR_TOPIC_CURRENT,
(topic_color) ? topic_color : ((str_topic) ? str_topic : ""),
@@ -5327,7 +5259,7 @@ IRC_PROTOCOL_CALLBACK(332)
free (topic_color);
if (ptr_channel)
- weechat_hashtable_set (ptr_channel->join_msg_received, command, "1");
+ weechat_hashtable_set (ptr_channel->join_msg_received, ctxt->command, "1");
if (str_topic)
free (str_topic);
@@ -5352,36 +5284,36 @@ IRC_PROTOCOL_CALLBACK(333)
IRC_PROTOCOL_MIN_PARAMS(3);
- topic_nick = (num_params > 3) ? irc_message_get_nick_from_host (params[2]) : NULL;
- topic_address = (num_params > 3) ? irc_message_get_address_from_host (params[2]) : NULL;
+ topic_nick = (ctxt->num_params > 3) ? irc_message_get_nick_from_host (ctxt->params[2]) : NULL;
+ topic_address = (ctxt->num_params > 3) ? irc_message_get_address_from_host (ctxt->params[2]) : NULL;
if (topic_nick && topic_address && strcmp (topic_nick, topic_address) == 0)
topic_address = NULL;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_nick = (ptr_channel) ?
- irc_nick_search (server, ptr_channel, topic_nick) : NULL;
- datetime = (num_params > 3) ?
- (time_t)(atol (params[3])) : (time_t)(atol (params[2]));
+ irc_nick_search (ctxt->server, ptr_channel, topic_nick) : NULL;
+ datetime = (ctxt->num_params > 3) ?
+ (time_t)(atol (ctxt->params[3])) : (time_t)(atol (ctxt->params[2]));
if (!topic_nick && (datetime == 0))
return WEECHAT_RC_OK;
if (ptr_channel && ptr_channel->nicks)
{
- if (weechat_hashtable_has_key (ptr_channel->join_msg_received, command)
- || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, command))
+ if (weechat_hashtable_has_key (ptr_channel->join_msg_received, ctxt->command)
+ || weechat_hashtable_has_key (irc_config_hashtable_display_join_message, ctxt->command))
{
if (topic_nick)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic set by %s%s%s%s%s%s%s%s%s on %s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, ptr_nick, topic_nick),
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, topic_nick),
topic_nick,
IRC_COLOR_CHAT_DELIMITERS,
(topic_address && topic_address[0]) ? " (" : "",
@@ -5396,9 +5328,9 @@ IRC_PROTOCOL_CALLBACK(333)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic set on %s"),
weechat_prefix ("network"),
@@ -5412,16 +5344,16 @@ IRC_PROTOCOL_CALLBACK(333)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic for %s%s%s set by %s%s%s%s%s%s%s%s%s on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 1, ptr_nick, topic_nick),
+ irc_nick_color_for_msg (ctxt->server, 1, ptr_nick, topic_nick),
topic_nick,
IRC_COLOR_CHAT_DELIMITERS,
(topic_address && topic_address[0]) ? " (" : "",
@@ -5436,21 +5368,21 @@ IRC_PROTOCOL_CALLBACK(333)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic for %s%s%s set on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
weechat_util_get_time_string (&datetime));
}
}
if (ptr_channel)
- weechat_hashtable_set (ptr_channel->join_msg_received, command, "1");
+ weechat_hashtable_set (ptr_channel->join_msg_received, ctxt->command, "1");
return WEECHAT_RC_OK;
}
@@ -5471,28 +5403,28 @@ IRC_PROTOCOL_CALLBACK(338)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (num_params < 4)
+ if (ctxt->num_params < 4)
{
- IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
+ irc_protocol_cb_whois_nick_msg (ctxt);
}
else
{
- str_text = irc_protocol_string_params (params, 3, num_params - 1);
+ str_text = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s]%s %s %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_text,
IRC_COLOR_CHAT_HOST,
- params[2]);
+ ctxt->params[2]);
if (str_text)
free (str_text);
}
@@ -5513,19 +5445,19 @@ IRC_PROTOCOL_CALLBACK(341)
IRC_PROTOCOL_MIN_PARAMS(3);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, params[0], address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->params[0], ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, ctxt->params[0], ctxt->address),
_("%s%s%s%s has invited %s%s%s to %s%s%s"),
weechat_prefix ("network"),
- irc_nick_color_for_msg (server, 1, NULL, params[0]),
- params[0],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[0]),
+ ctxt->params[0],
IRC_COLOR_RESET,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET);
return WEECHAT_RC_OK;
@@ -5547,18 +5479,18 @@ IRC_PROTOCOL_CALLBACK(344)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (irc_channel_is_channel (server, params[1]))
+ if (irc_channel_is_channel (ctxt->server, ctxt->params[1]))
{
/* channel reop (IRCnet) */
- str_host = irc_protocol_string_params (params, 2, num_params - 1);
+ str_host = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, "reop", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, "reop", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sChannel reop %s%s%s: %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
IRC_COLOR_CHAT_HOST,
str_host);
@@ -5568,35 +5500,35 @@ IRC_PROTOCOL_CALLBACK(344)
else
{
/* whois, geo info (UnrealIRCd) */
- if (num_params >= 3)
+ if (ctxt->num_params >= 3)
{
str_params = irc_protocol_string_params (
- params,
- (num_params >= 4) ? 3 : 2,
- num_params - 1);
+ ctxt->params,
+ (ctxt->num_params >= 4) ? 3 : 2,
+ ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_params,
- (num_params >= 4) ? " (" : "",
- (num_params >= 4) ? params[2] : "",
- (num_params >= 4) ? ")" : "");
+ (ctxt->num_params >= 4) ? " (" : "",
+ (ctxt->num_params >= 4) ? ctxt->params[2] : "",
+ (ctxt->num_params >= 4) ? ")" : "");
if (str_params)
free (str_params);
}
else
{
/* not enough arguments: use the default whois callback */
- IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
+ irc_protocol_cb_whois_nick_msg (ctxt);
}
}
@@ -5616,16 +5548,16 @@ IRC_PROTOCOL_CALLBACK(345)
IRC_PROTOCOL_MIN_PARAMS(3);
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, "reop", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, "reop", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
str_params);
@@ -5654,9 +5586,9 @@ IRC_PROTOCOL_CALLBACK(346)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = irc_modelist_search (ptr_channel, 'I');
if (ptr_modelist)
@@ -5678,31 +5610,31 @@ IRC_PROTOCOL_CALLBACK(346)
else
str_number[0] = '\0';
- if (num_params >= 4)
+ if (ctxt->num_params >= 4)
{
nick_address = irc_protocol_nick_address (
- server, 1, NULL, irc_message_get_nick_from_host (params[3]),
- irc_message_get_address_from_host (params[3]));
- if (num_params >= 5)
+ ctxt->server, 1, NULL, irc_message_get_nick_from_host (ctxt->params[3]),
+ irc_message_get_address_from_host (ctxt->params[3]));
+ if (ctxt->num_params >= 5)
{
- datetime = (time_t)(atol (params[4]));
+ datetime = (time_t)(atol (ctxt->params[4]));
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], params[3], datetime);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], ctxt->params[3], datetime);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "invitelist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "invitelist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s] %s%s%s%s invited by %s on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?",
weechat_util_get_time_string (&datetime));
@@ -5710,21 +5642,21 @@ IRC_PROTOCOL_CALLBACK(346)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], params[3], 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], ctxt->params[3], 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "invitelist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "invitelist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s invited by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?");
}
@@ -5732,21 +5664,21 @@ IRC_PROTOCOL_CALLBACK(346)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], NULL, 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], NULL, 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "invitelist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "invitelist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s invited"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET);
}
@@ -5769,12 +5701,12 @@ IRC_PROTOCOL_CALLBACK(347)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_params = (num_params > 2) ?
- irc_protocol_string_params (params, 2, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 2) ?
+ irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1) : NULL;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = irc_modelist_search (ptr_channel, 'I');
if (ptr_modelist)
{
@@ -5790,14 +5722,14 @@ IRC_PROTOCOL_CALLBACK(347)
}
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "invitelist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "invitelist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(str_params) ? " " : "",
@@ -5827,9 +5759,9 @@ IRC_PROTOCOL_CALLBACK(348)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = irc_modelist_search (ptr_channel, 'e');
if (ptr_modelist)
@@ -5851,32 +5783,32 @@ IRC_PROTOCOL_CALLBACK(348)
else
str_number[0] = '\0';
- if (num_params >= 4)
+ if (ctxt->num_params >= 4)
{
nick_address = irc_protocol_nick_address (
- server, 1, NULL, irc_message_get_nick_from_host (params[3]),
- irc_message_get_address_from_host (params[3]));
- if (num_params >= 5)
+ ctxt->server, 1, NULL, irc_message_get_nick_from_host (ctxt->params[3]),
+ irc_message_get_address_from_host (ctxt->params[3]));
+ if (ctxt->num_params >= 5)
{
- datetime = (time_t)(atol (params[4]));
+ datetime = (time_t)(atol (ctxt->params[4]));
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], params[3], datetime);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], ctxt->params[3], datetime);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "exceptionlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "exceptionlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s]%s%s exception %s%s%s by %s on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?",
weechat_util_get_time_string (&datetime));
@@ -5884,22 +5816,22 @@ IRC_PROTOCOL_CALLBACK(348)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], params[3], 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], ctxt->params[3], 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "exceptionlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "exceptionlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s%s exception %s%s%s by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?");
}
@@ -5907,22 +5839,22 @@ IRC_PROTOCOL_CALLBACK(348)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], NULL, 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], NULL, 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "exceptionlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "exceptionlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s%s exception %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_RESET,
IRC_COLOR_CHAT_HOST,
- params[2]);
+ ctxt->params[2]);
}
return WEECHAT_RC_OK;
@@ -5944,12 +5876,12 @@ IRC_PROTOCOL_CALLBACK(349)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_params = (num_params > 2) ?
- irc_protocol_string_params (params, 2, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 2) ?
+ irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1) : NULL;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = irc_modelist_search (ptr_channel, 'e');
if (ptr_modelist)
{
@@ -5965,14 +5897,14 @@ IRC_PROTOCOL_CALLBACK(349)
}
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "exceptionlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "exceptionlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(str_params) ? " " : "",
@@ -5999,35 +5931,35 @@ IRC_PROTOCOL_CALLBACK(350)
IRC_PROTOCOL_MIN_PARAMS(2);
- if (num_params >= 5)
+ if (ctxt->num_params >= 5)
{
str_host[0] = '\0';
- has_real_hostmask = (strcmp (params[2], "*") != 0);
- has_real_ip = (strcmp (params[3], "*") != 0);
+ has_real_hostmask = (strcmp (ctxt->params[2], "*") != 0);
+ has_real_ip = (strcmp (ctxt->params[3], "*") != 0);
if (has_real_hostmask || has_real_ip)
{
snprintf (str_host, sizeof (str_host),
"%s(%s%s%s%s%s%s%s) ",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- (has_real_hostmask) ? params[2] : "",
+ (has_real_hostmask) ? ctxt->params[2] : "",
(has_real_hostmask && has_real_ip) ? IRC_COLOR_CHAT_DELIMITERS : "",
(has_real_hostmask && has_real_ip) ? ", " : "",
(has_real_hostmask && has_real_ip) ? IRC_COLOR_CHAT_HOST : "",
- (has_real_ip) ? params[3] : "",
+ (has_real_ip) ? ctxt->params[3] : "",
IRC_COLOR_CHAT_DELIMITERS);
}
- str_params = irc_protocol_string_params (params, 4, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 4, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, params[1], command, "whois", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, ctxt->params[1], ctxt->command, "whois", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[1]),
- params[1],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[1]),
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_host,
IRC_COLOR_RESET,
@@ -6039,7 +5971,7 @@ IRC_PROTOCOL_CALLBACK(350)
else
{
/* not enough parameters: display with the default whois callback */
- IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
+ irc_protocol_cb_whois_nick_msg (ctxt);
}
return WEECHAT_RC_OK;
@@ -6059,20 +5991,20 @@ IRC_PROTOCOL_CALLBACK(351)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL,
NULL);
- if (num_params > 3)
+ if (ctxt->num_params > 3)
{
- str_params = irc_protocol_string_params (params, 3, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s %s (%s)",
weechat_prefix ("network"),
- params[1],
- params[2],
+ ctxt->params[1],
+ ctxt->params[2],
str_params);
if (str_params)
free (str_params);
@@ -6081,12 +6013,12 @@ IRC_PROTOCOL_CALLBACK(351)
{
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s %s",
weechat_prefix ("network"),
- params[1],
- params[2]);
+ ctxt->params[1],
+ ctxt->params[2]);
}
return WEECHAT_RC_OK;
@@ -6110,18 +6042,18 @@ IRC_PROTOCOL_CALLBACK(352)
IRC_PROTOCOL_MIN_PARAMS(3);
/* silently ignore malformed 352 message (missing infos) */
- if (num_params < 6)
+ if (ctxt->num_params < 6)
return WEECHAT_RC_OK;
str_hopcount = NULL;
str_realname = NULL;
- if (num_params >= 8)
+ if (ctxt->num_params >= 8)
{
- pos = strchr (params[num_params - 1], ' ');
+ pos = strchr (ctxt->params[ctxt->num_params - 1], ' ');
if (pos)
{
- str_hopcount = weechat_strndup (params[num_params - 1],
- pos - params[num_params - 1]);
+ str_hopcount = weechat_strndup (ctxt->params[ctxt->num_params - 1],
+ pos - ctxt->params[ctxt->num_params - 1]);
while (pos[0] == ' ')
{
pos++;
@@ -6131,32 +6063,32 @@ IRC_PROTOCOL_CALLBACK(352)
}
else
{
- str_hopcount = strdup (params[num_params - 1]);
+ str_hopcount = strdup (ctxt->params[ctxt->num_params - 1]);
}
}
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_nick = (ptr_channel) ?
- irc_nick_search (server, ptr_channel, params[5]) : NULL;
+ irc_nick_search (ctxt->server, ptr_channel, ctxt->params[5]) : NULL;
/* update host in nick */
if (ptr_nick)
{
- length = strlen (params[2]) + 1 + strlen (params[3]) + 1;
+ length = strlen (ctxt->params[2]) + 1 + strlen (ctxt->params[3]) + 1;
str_host = malloc (length);
if (str_host)
{
- snprintf (str_host, length, "%s@%s", params[2], params[3]);
+ snprintf (str_host, length, "%s@%s", ctxt->params[2], ctxt->params[3]);
irc_nick_set_host (ptr_nick, str_host);
free (str_host);
}
}
/* update away flag in nick */
- if (ptr_channel && ptr_nick && (num_params >= 7) && (params[6][0] != '*'))
+ if (ptr_channel && ptr_nick && (ctxt->num_params >= 7) && (ctxt->params[6][0] != '*'))
{
- irc_nick_set_away (server, ptr_channel, ptr_nick,
- (params[6][0] == 'G') ? 1 : 0);
+ irc_nick_set_away (ctxt->server, ptr_channel, ptr_nick,
+ (ctxt->params[6][0] == 'G') ? 1 : 0);
}
/* update realname in nick */
@@ -6172,25 +6104,25 @@ IRC_PROTOCOL_CALLBACK(352)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "who", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "who", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s %s%s%s%s%s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[5]),
- params[5],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[5]),
+ ctxt->params[5],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- params[2],
- params[3],
+ ctxt->params[2],
+ ctxt->params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- (num_params >= 7) ? params[6] : "",
- (num_params >= 7) ? " " : "",
+ (ctxt->num_params >= 7) ? ctxt->params[6] : "",
+ (ctxt->num_params >= 7) ? " " : "",
(str_hopcount) ? str_hopcount : "",
(str_hopcount) ? " " : "",
IRC_COLOR_CHAT_DELIMITERS,
@@ -6225,20 +6157,20 @@ IRC_PROTOCOL_CALLBACK(353)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (irc_channel_is_channel (server, params[1]))
+ if (irc_channel_is_channel (ctxt->server, ctxt->params[1]))
{
- pos_channel = params[1];
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ pos_channel = ctxt->params[1];
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
}
else
{
- if (num_params < 4)
+ if (ctxt->num_params < 4)
return WEECHAT_RC_ERROR;
- pos_channel = params[2];
- str_params = irc_protocol_string_params (params, 3, num_params - 1);
+ pos_channel = ctxt->params[2];
+ str_params = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
}
- ptr_channel = irc_channel_search (server, pos_channel);
+ ptr_channel = irc_channel_search (ctxt->server, pos_channel);
nicks = weechat_string_split (
str_params,
@@ -6261,7 +6193,7 @@ IRC_PROTOCOL_CALLBACK(353)
/* skip and save prefix(es) */
pos_nick = nicks[i];
while (pos_nick[0]
- && (irc_server_get_prefix_char_index (server, pos_nick[0]) >= 0))
+ && (irc_server_get_prefix_char_index (ctxt->server, pos_nick[0]) >= 0))
{
pos_nick++;
}
@@ -6285,11 +6217,11 @@ IRC_PROTOCOL_CALLBACK(353)
{
if (ptr_channel && ptr_channel->nicks)
{
- if (!irc_nick_new (server, ptr_channel, nickname, pos_host,
+ if (!irc_nick_new (ctxt->server, ptr_channel, nickname, pos_host,
prefixes, 0, NULL, NULL))
{
weechat_printf (
- server->buffer,
+ ctxt->server->buffer,
_("%s%s: cannot create nick \"%s\" for channel \"%s\""),
weechat_prefix ("error"), IRC_PLUGIN_NAME, nickname,
ptr_channel->name);
@@ -6307,14 +6239,14 @@ IRC_PROTOCOL_CALLBACK(353)
weechat_string_dyn_concat (
str_nicks,
weechat_color (
- irc_nick_get_prefix_color_name (server,
+ irc_nick_get_prefix_color_name (ctxt->server,
prefixes[0])),
-1);
weechat_string_dyn_concat (str_nicks, prefixes, -1);
}
if (weechat_config_boolean (irc_config_look_color_nicks_in_names))
{
- if (irc_server_strcasecmp (server, nickname, server->nick) == 0)
+ if (irc_server_strcasecmp (ctxt->server, nickname, ctxt->server->nick) == 0)
{
weechat_string_dyn_concat (str_nicks,
IRC_COLOR_CHAT_NICK_SELF,
@@ -6322,7 +6254,7 @@ IRC_PROTOCOL_CALLBACK(353)
}
else
{
- color = irc_nick_find_color (server, nickname);
+ color = irc_nick_find_color (ctxt->server, nickname);
weechat_string_dyn_concat (str_nicks, color, -1);
if (color)
free (color);
@@ -6344,9 +6276,9 @@ IRC_PROTOCOL_CALLBACK(353)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "names", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "names", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sNicks %s%s%s: %s[%s%s%s]"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -6384,28 +6316,28 @@ IRC_PROTOCOL_CALLBACK(354)
IRC_PROTOCOL_MIN_PARAMS(2);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
/*
* if there are less than 9 arguments, we are unable to parse the message,
* some infos are missing but we don't know which ones; in this case we
* just display the message as-is
*/
- if (num_params < 9)
+ if (ctxt->num_params < 9)
{
if (!ptr_channel || (ptr_channel->checking_whox <= 0))
{
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "who", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "who", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(str_params && str_params[0]) ? " " : "",
@@ -6417,26 +6349,26 @@ IRC_PROTOCOL_CALLBACK(354)
}
ptr_nick = (ptr_channel) ?
- irc_nick_search (server, ptr_channel, params[5]) : NULL;
+ irc_nick_search (ctxt->server, ptr_channel, ctxt->params[5]) : NULL;
/* update host in nick */
if (ptr_nick)
{
- length = strlen (params[2]) + 1 + strlen (params[3]) + 1;
+ length = strlen (ctxt->params[2]) + 1 + strlen (ctxt->params[3]) + 1;
str_host = malloc (length);
if (str_host)
{
- snprintf (str_host, length, "%s@%s", params[2], params[3]);
+ snprintf (str_host, length, "%s@%s", ctxt->params[2], ctxt->params[3]);
irc_nick_set_host (ptr_nick, str_host);
free (str_host);
}
}
/* update away flag in nick */
- if (ptr_channel && ptr_nick && (params[6][0] != '*'))
+ if (ptr_channel && ptr_nick && (ctxt->params[6][0] != '*'))
{
- irc_nick_set_away (server, ptr_channel, ptr_nick,
- (params[6][0] == 'G') ? 1 : 0);
+ irc_nick_set_away (ctxt->server, ptr_channel, ptr_nick,
+ (ctxt->params[6][0] == 'G') ? 1 : 0);
}
/* update account in nick */
@@ -6445,9 +6377,9 @@ IRC_PROTOCOL_CALLBACK(354)
if (ptr_nick->account)
free (ptr_nick->account);
if (ptr_channel
- && weechat_hashtable_has_key (server->cap_list, "account-notify"))
+ && weechat_hashtable_has_key (ctxt->server->cap_list, "account-notify"))
{
- ptr_nick->account = strdup (params[8]);
+ ptr_nick->account = strdup (ctxt->params[8]);
}
else
{
@@ -6460,8 +6392,8 @@ IRC_PROTOCOL_CALLBACK(354)
{
if (ptr_nick->realname)
free (ptr_nick->realname);
- ptr_nick->realname = (ptr_channel && (num_params >= 10)) ?
- strdup (params[9]) : NULL;
+ ptr_nick->realname = (ptr_channel && (ctxt->num_params >= 10)) ?
+ strdup (ctxt->params[9]) : NULL;
}
/* display output of who (manual who from user) */
@@ -6469,31 +6401,31 @@ IRC_PROTOCOL_CALLBACK(354)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "who", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "who", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s[%s%s%s] (%s%s@%s%s)%s %s %s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
- irc_nick_color_for_msg (server, 1, NULL, params[5]),
- params[5],
+ irc_nick_color_for_msg (ctxt->server, 1, NULL, ctxt->params[5]),
+ ctxt->params[5],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- params[8],
+ ctxt->params[8],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- params[2],
- params[3],
+ ctxt->params[2],
+ ctxt->params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- params[6],
- params[7],
+ ctxt->params[6],
+ ctxt->params[7],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
- (num_params >= 10) ? params[9] : "",
+ (ctxt->num_params >= 10) ? ctxt->params[9] : "",
IRC_COLOR_CHAT_DELIMITERS);
}
@@ -6729,7 +6661,7 @@ IRC_PROTOCOL_CALLBACK(366)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
if (ptr_channel && ptr_channel->nicks)
{
@@ -6738,7 +6670,7 @@ IRC_PROTOCOL_CALLBACK(366)
channel_name_lower = weechat_string_tolower (ptr_channel->name);
if (channel_name_lower)
{
- ptr_filter = weechat_hashtable_get (server->names_channel_filter,
+ ptr_filter = weechat_hashtable_get (ctxt->server->names_channel_filter,
channel_name_lower);
}
@@ -6747,7 +6679,7 @@ IRC_PROTOCOL_CALLBACK(366)
&& (weechat_hashtable_has_key (ptr_channel->join_msg_received, "353")
|| weechat_hashtable_has_key (irc_config_hashtable_display_join_message, "353")))
{
- string = irc_protocol_get_string_channel_nicks (server, ptr_channel,
+ string = irc_protocol_get_string_channel_nicks (ctxt->server, ptr_channel,
ptr_filter);
if (string)
{
@@ -6762,9 +6694,9 @@ IRC_PROTOCOL_CALLBACK(366)
}
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "names", ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "names", ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sNicks %s%s%s%s: %s[%s%s]"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -6782,15 +6714,15 @@ IRC_PROTOCOL_CALLBACK(366)
if (weechat_hashtable_has_key (ptr_channel->join_msg_received, "366")
|| weechat_hashtable_has_key (irc_config_hashtable_display_join_message, "366"))
{
- string = irc_protocol_get_string_channel_nicks_count (server,
+ string = irc_protocol_get_string_channel_nicks_count (ctxt->server,
ptr_channel);
if (string)
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "names", ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "names", ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%sChannel %s%s%s: %s%d%s %s %s(%s%s)"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -6810,30 +6742,30 @@ IRC_PROTOCOL_CALLBACK(366)
if (channel_name_lower)
{
/* remove filter */
- weechat_hashtable_remove (server->names_channel_filter,
+ weechat_hashtable_remove (ctxt->server->names_channel_filter,
channel_name_lower);
free (channel_name_lower);
}
- if (!weechat_hashtable_has_key (ptr_channel->join_msg_received, command))
+ if (!weechat_hashtable_has_key (ptr_channel->join_msg_received, ctxt->command))
{
- irc_command_mode_server (server, "MODE", ptr_channel, NULL,
+ irc_command_mode_server (ctxt->server, "MODE", ptr_channel, NULL,
IRC_SERVER_SEND_OUTQ_PRIO_LOW);
- irc_channel_check_whox (server, ptr_channel);
+ irc_channel_check_whox (ctxt->server, ptr_channel);
}
}
else
{
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "names", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "names", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_RESET,
str_params);
if (str_params)
@@ -6869,9 +6801,9 @@ IRC_PROTOCOL_CALLBACK(367)
IRC_PROTOCOL_MIN_PARAMS(3);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = (ptr_channel) ?
irc_modelist_search (ptr_channel, 'b') : NULL;
@@ -6893,34 +6825,34 @@ IRC_PROTOCOL_CALLBACK(367)
IRC_COLOR_CHAT_DELIMITERS);
}
- if (num_params >= 4)
+ if (ctxt->num_params >= 4)
{
nick_address = irc_protocol_nick_address (
- server, 1, NULL, irc_message_get_nick_from_host (params[3]),
- irc_message_get_address_from_host (params[3]));
- if (num_params >= 5)
+ ctxt->server, 1, NULL, irc_message_get_nick_from_host (ctxt->params[3]),
+ irc_message_get_address_from_host (ctxt->params[3]));
+ if (ctxt->num_params >= 5)
{
- datetime = (time_t)(atol (params[4]));
+ datetime = (time_t)(atol (ctxt->params[4]));
if (ptr_modelist)
{
- irc_modelist_item_new (ptr_modelist, params[2], params[3],
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], ctxt->params[3],
datetime);
}
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "banlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "banlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s] %s%s%s%s banned by %s on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?",
weechat_util_get_time_string (&datetime));
@@ -6928,21 +6860,21 @@ IRC_PROTOCOL_CALLBACK(367)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], params[3], 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], ctxt->params[3], 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "banlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "banlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s banned by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?");
}
@@ -6950,21 +6882,21 @@ IRC_PROTOCOL_CALLBACK(367)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[2], NULL, 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[2], NULL, 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "banlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "banlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s banned"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[2],
+ ctxt->params[2],
IRC_COLOR_RESET);
}
@@ -6987,12 +6919,12 @@ IRC_PROTOCOL_CALLBACK(368)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_params = (num_params > 2) ?
- irc_protocol_string_params (params, 2, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 2) ?
+ irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1) : NULL;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = (ptr_channel) ?
irc_modelist_search (ptr_channel, 'b') : NULL;
@@ -7011,14 +6943,14 @@ IRC_PROTOCOL_CALLBACK(368)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "banlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "banlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(str_params) ? " " : "",
@@ -7045,38 +6977,38 @@ IRC_PROTOCOL_CALLBACK(432)
const char *alternate_nick;
struct t_gui_buffer *ptr_buffer;
- IRC_PROTOCOL_RUN_CALLBACK(generic_error);
+ irc_protocol_cb_generic_error (ctxt);
- if (!server->is_connected)
+ if (!ctxt->server->is_connected)
{
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,
- command, NULL, NULL);
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, NULL,
+ ctxt->command, NULL, NULL);
- alternate_nick = irc_server_get_alternate_nick (server);
+ alternate_nick = irc_server_get_alternate_nick (ctxt->server);
if (!alternate_nick)
{
weechat_printf_date_tags (
- ptr_buffer, date, NULL,
+ ptr_buffer, ctxt->date, NULL,
_("%s%s: all declared nicknames are already in use or "
"invalid, closing connection with server"),
weechat_prefix ("error"), IRC_PLUGIN_NAME);
- irc_server_disconnect (server, 0, 1);
+ irc_server_disconnect (ctxt->server, 0, 1);
return WEECHAT_RC_OK;
}
weechat_printf_date_tags (
- ptr_buffer, date, NULL,
+ ptr_buffer, ctxt->date, NULL,
_("%s%s: nickname \"%s\" is invalid, trying nickname \"%s\""),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
- server->nick, alternate_nick);
+ ctxt->server->nick, alternate_nick);
- irc_server_set_nick (server, alternate_nick);
+ irc_server_set_nick (ctxt->server, alternate_nick);
irc_server_sendf (
- server, 0, NULL,
+ ctxt->server, 0, NULL,
"NICK %s%s",
- (server->nick && strchr (server->nick, ':')) ? ":" : "",
- server->nick);
+ (ctxt->server->nick && strchr (ctxt->server->nick, ':')) ? ":" : "",
+ ctxt->server->nick);
}
return WEECHAT_RC_OK;
@@ -7097,41 +7029,41 @@ IRC_PROTOCOL_CALLBACK(433)
const char *alternate_nick;
struct t_gui_buffer *ptr_buffer;
- if (!server->is_connected)
+ if (!ctxt->server->is_connected)
{
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,
- command, NULL, NULL);
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, NULL,
+ ctxt->command, NULL, NULL);
- alternate_nick = irc_server_get_alternate_nick (server);
+ alternate_nick = irc_server_get_alternate_nick (ctxt->server);
if (!alternate_nick)
{
weechat_printf_date_tags (
- ptr_buffer, date, NULL,
+ ptr_buffer, ctxt->date, NULL,
_("%s%s: all declared nicknames are already in use, closing "
"connection with server"),
weechat_prefix ("error"), IRC_PLUGIN_NAME);
- irc_server_disconnect (server, 0, 1);
+ irc_server_disconnect (ctxt->server, 0, 1);
return WEECHAT_RC_OK;
}
weechat_printf_date_tags (
- ptr_buffer, date, NULL,
+ ptr_buffer, ctxt->date, NULL,
_("%s%s: nickname \"%s\" is already in use, trying nickname "
"\"%s\""),
weechat_prefix ("network"), IRC_PLUGIN_NAME,
- server->nick, alternate_nick);
+ ctxt->server->nick, alternate_nick);
- irc_server_set_nick (server, alternate_nick);
+ irc_server_set_nick (ctxt->server, alternate_nick);
irc_server_sendf (
- server, 0, NULL,
+ ctxt->server, 0, NULL,
"NICK %s%s",
- (server->nick && strchr (server->nick, ':')) ? ":" : "",
- server->nick);
+ (ctxt->server->nick && strchr (ctxt->server->nick, ':')) ? ":" : "",
+ ctxt->server->nick);
}
else
{
- IRC_PROTOCOL_RUN_CALLBACK(generic_error);
+ irc_protocol_cb_generic_error (ctxt);
}
return WEECHAT_RC_OK;
@@ -7149,42 +7081,42 @@ IRC_PROTOCOL_CALLBACK(437)
const char *alternate_nick;
struct t_gui_buffer *ptr_buffer;
- IRC_PROTOCOL_RUN_CALLBACK(generic_error);
+ irc_protocol_cb_generic_error (ctxt);
- if (!server->is_connected)
+ if (!ctxt->server->is_connected)
{
- if ((num_params >= 2)
- && (irc_server_strcasecmp (server, server->nick, params[1]) == 0))
+ if ((ctxt->num_params >= 2)
+ && (irc_server_strcasecmp (ctxt->server, ctxt->server->nick, ctxt->params[1]) == 0))
{
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,
- command, NULL, NULL);
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, NULL,
+ ctxt->command, NULL, NULL);
- alternate_nick = irc_server_get_alternate_nick (server);
+ alternate_nick = irc_server_get_alternate_nick (ctxt->server);
if (!alternate_nick)
{
weechat_printf_date_tags (
- ptr_buffer, date, NULL,
+ ptr_buffer, ctxt->date, NULL,
_("%s%s: all declared nicknames are already in use or "
"invalid, closing connection with server"),
weechat_prefix ("error"), IRC_PLUGIN_NAME);
- irc_server_disconnect (server, 0, 1);
+ irc_server_disconnect (ctxt->server, 0, 1);
return WEECHAT_RC_OK;
}
weechat_printf_date_tags (
- ptr_buffer, date, NULL,
+ ptr_buffer, ctxt->date, NULL,
_("%s%s: nickname \"%s\" is unavailable, trying nickname "
"\"%s\""),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
- server->nick, alternate_nick);
+ ctxt->server->nick, alternate_nick);
- irc_server_set_nick (server, alternate_nick);
+ irc_server_set_nick (ctxt->server, alternate_nick);
irc_server_sendf (
- server, 0, NULL,
+ ctxt->server, 0, NULL,
"NICK %s%s",
- (server->nick && strchr (server->nick, ':')) ? ":" : "",
- server->nick);
+ (ctxt->server->nick && strchr (ctxt->server->nick, ':')) ? ":" : "",
+ ctxt->server->nick);
}
}
@@ -7205,21 +7137,21 @@ IRC_PROTOCOL_CALLBACK(438)
IRC_PROTOCOL_MIN_PARAMS(2);
- ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,
- command, NULL, NULL);
+ ptr_buffer = irc_msgbuffer_get_target_buffer (ctxt->server, NULL,
+ ctxt->command, NULL, NULL);
- if (num_params >= 3)
+ if (ctxt->num_params >= 3)
{
- str_params = irc_protocol_string_params (params, 2, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s (%s => %s)",
weechat_prefix ("network"),
str_params,
- params[0],
- params[1]);
+ ctxt->params[0],
+ ctxt->params[1]);
if (str_params)
free (str_params);
}
@@ -7227,12 +7159,12 @@ IRC_PROTOCOL_CALLBACK(438)
{
weechat_printf_date_tags (
ptr_buffer,
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s %s",
weechat_prefix ("network"),
- params[0],
- params[1]);
+ ctxt->params[0],
+ ctxt->params[1]);
}
return WEECHAT_RC_OK;
@@ -7253,13 +7185,13 @@ IRC_PROTOCOL_CALLBACK(470)
char *old_channel_lower, *new_channel_lower, *buffer_name;
int lines_count;
- IRC_PROTOCOL_RUN_CALLBACK(generic_error);
+ irc_protocol_cb_generic_error (ctxt);
- if ((num_params >= 3) && !irc_channel_search (server, params[1]))
+ if ((ctxt->num_params >= 3) && !irc_channel_search (ctxt->server, ctxt->params[1]))
{
- ptr_buffer = irc_channel_search_buffer (server,
+ ptr_buffer = irc_channel_search_buffer (ctxt->server,
IRC_CHANNEL_TYPE_CHANNEL,
- params[1]);
+ ctxt->params[1]);
if (ptr_buffer)
{
short_name = weechat_buffer_get_string (ptr_buffer, "short_name");
@@ -7273,11 +7205,11 @@ IRC_PROTOCOL_CALLBACK(470)
* update the short_name only if it was not changed by the
* user
*/
- weechat_buffer_set (ptr_buffer, "short_name", params[2]);
+ weechat_buffer_set (ptr_buffer, "short_name", ctxt->params[2]);
}
- buffer_name = irc_buffer_build_name (server->name, params[2]);
+ buffer_name = irc_buffer_build_name (ctxt->server->name, ctxt->params[2]);
weechat_buffer_set (ptr_buffer, "name", buffer_name);
- weechat_buffer_set (ptr_buffer, "localvar_set_channel", params[2]);
+ weechat_buffer_set (ptr_buffer, "localvar_set_channel", ctxt->params[2]);
if (buffer_name)
free (buffer_name);
@@ -7301,40 +7233,40 @@ IRC_PROTOCOL_CALLBACK(470)
WEECHAT_HOOK_SIGNAL_POINTER,
ptr_buffer);
}
- if (IRC_SERVER_OPTION_BOOLEAN(server,
+ if (IRC_SERVER_OPTION_BOOLEAN(ctxt->server,
IRC_SERVER_OPTION_AUTOJOIN_DYNAMIC))
{
- irc_join_rename_channel_in_autojoin (server, params[1],
- params[2]);
+ irc_join_rename_channel_in_autojoin (ctxt->server, ctxt->params[1],
+ ctxt->params[2]);
}
}
- old_channel_lower = weechat_string_tolower (params[1]);
+ old_channel_lower = weechat_string_tolower (ctxt->params[1]);
if (old_channel_lower)
{
- new_channel_lower = weechat_string_tolower (params[2]);
+ new_channel_lower = weechat_string_tolower (ctxt->params[2]);
if (new_channel_lower)
{
- if (weechat_hashtable_has_key (server->join_manual,
+ if (weechat_hashtable_has_key (ctxt->server->join_manual,
old_channel_lower))
{
- weechat_hashtable_set (server->join_manual,
+ weechat_hashtable_set (ctxt->server->join_manual,
new_channel_lower,
weechat_hashtable_get (
- server->join_manual,
+ ctxt->server->join_manual,
old_channel_lower));
- weechat_hashtable_remove (server->join_manual,
+ weechat_hashtable_remove (ctxt->server->join_manual,
old_channel_lower);
}
- if (weechat_hashtable_has_key (server->join_noswitch,
+ if (weechat_hashtable_has_key (ctxt->server->join_noswitch,
old_channel_lower))
{
- weechat_hashtable_set (server->join_noswitch,
+ weechat_hashtable_set (ctxt->server->join_noswitch,
new_channel_lower,
weechat_hashtable_get (
- server->join_noswitch,
+ ctxt->server->join_noswitch,
old_channel_lower));
- weechat_hashtable_remove (server->join_noswitch,
+ weechat_hashtable_remove (ctxt->server->join_noswitch,
old_channel_lower);
}
free (new_channel_lower);
@@ -7366,16 +7298,15 @@ IRC_PROTOCOL_CALLBACK(help)
IRC_PROTOCOL_MIN_PARAMS(2);
- if (ignored)
+ if (ctxt->ignored)
return WEECHAT_RC_OK;
- str_message = irc_protocol_string_params (params, 2, num_params - 1);
+ str_message = irc_protocol_string_params (ctxt->params, 2, ctxt->num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, "notify_private", nick,
- address),
+ irc_msgbuffer_get_target_buffer (ctxt->server, ctxt->nick, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, "notify_private", ctxt->nick, ctxt->address),
"%s%s",
weechat_prefix ("network"),
str_message);
@@ -7401,24 +7332,24 @@ IRC_PROTOCOL_CALLBACK(710)
IRC_PROTOCOL_MIN_PARAMS(3);
- if (ignored)
+ if (ctxt->ignored)
return WEECHAT_RC_OK;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
if (!ptr_channel)
return WEECHAT_RC_ERROR;
nick_address = irc_protocol_nick_address (
- server, 1, NULL, irc_message_get_nick_from_host (params[2]),
- irc_message_get_address_from_host (params[2]));
+ ctxt->server, 1, NULL, irc_message_get_nick_from_host (ctxt->params[2]),
+ irc_message_get_address_from_host (ctxt->params[2]));
- str_message = irc_protocol_string_params (params, 3, num_params - 1);
+ str_message = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, NULL, ptr_channel->buffer),
- date,
- irc_protocol_tags (server, command, tags, "notify_message", NULL, NULL),
+ ctxt->server, NULL, ctxt->command, NULL, ptr_channel->buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, "notify_message", NULL, NULL),
"%s%s %s",
weechat_prefix ("network"),
(nick_address[0]) ? nick_address : "?",
@@ -7449,11 +7380,11 @@ IRC_PROTOCOL_CALLBACK(728)
IRC_PROTOCOL_MIN_PARAMS(4);
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = (ptr_channel) ?
- irc_modelist_search (ptr_channel, params[2][0]) : NULL;
+ irc_modelist_search (ptr_channel, ctxt->params[2][0]) : NULL;
str_number[0] = '\0';
if (ptr_modelist)
@@ -7473,34 +7404,34 @@ IRC_PROTOCOL_CALLBACK(728)
IRC_COLOR_CHAT_DELIMITERS);
}
- if (num_params >= 5)
+ if (ctxt->num_params >= 5)
{
nick_address = irc_protocol_nick_address (
- server, 1, NULL, irc_message_get_nick_from_host (params[4]),
- irc_message_get_address_from_host (params[4]));
- if (num_params >= 6)
+ ctxt->server, 1, NULL, irc_message_get_nick_from_host (ctxt->params[4]),
+ irc_message_get_address_from_host (ctxt->params[4]));
+ if (ctxt->num_params >= 6)
{
- datetime = (time_t)(atol (params[5]));
+ datetime = (time_t)(atol (ctxt->params[5]));
if (ptr_modelist)
{
- irc_modelist_item_new (ptr_modelist, params[3], params[4],
+ irc_modelist_item_new (ptr_modelist, ctxt->params[3], ctxt->params[4],
datetime);
}
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "quietlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "quietlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s] %s%s%s%s quieted by %s on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[3],
+ ctxt->params[3],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?",
weechat_util_get_time_string (&datetime));
@@ -7508,21 +7439,21 @@ IRC_PROTOCOL_CALLBACK(728)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[3], params[4], 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[3], ctxt->params[4], 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "quietlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "quietlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s quieted by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[3],
+ ctxt->params[3],
IRC_COLOR_RESET,
(nick_address[0]) ? nick_address : "?");
}
@@ -7530,21 +7461,21 @@ IRC_PROTOCOL_CALLBACK(728)
else
{
if (ptr_modelist)
- irc_modelist_item_new (ptr_modelist, params[3], NULL, 0);
+ irc_modelist_item_new (ptr_modelist, ctxt->params[3], NULL, 0);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "quietlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "quietlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s quieted"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
str_number,
IRC_COLOR_CHAT_HOST,
- params[3],
+ ctxt->params[3],
IRC_COLOR_RESET);
}
@@ -7567,14 +7498,14 @@ IRC_PROTOCOL_CALLBACK(729)
IRC_PROTOCOL_MIN_PARAMS(3);
- str_params = (num_params > 3) ?
- irc_protocol_string_params (params, 3, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 3) ?
+ irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1) : NULL;
- ptr_channel = irc_channel_search (server, params[1]);
+ ptr_channel = irc_channel_search (ctxt->server, ctxt->params[1]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
- ptr_channel->buffer : server->buffer;
+ ptr_channel->buffer : ctxt->server->buffer;
ptr_modelist = (ptr_channel) ?
- irc_modelist_search (ptr_channel, params[2][0]) : NULL;
+ irc_modelist_search (ptr_channel, ctxt->params[2][0]) : NULL;
if (ptr_modelist)
{
@@ -7591,14 +7522,14 @@ IRC_PROTOCOL_CALLBACK(729)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "quietlist", ptr_buffer),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "quietlist", ptr_buffer),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
- params[1],
+ ctxt->params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(str_params) ? " " : "",
@@ -7627,7 +7558,7 @@ IRC_PROTOCOL_CALLBACK(730)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_nicks = irc_protocol_string_params (params, 1, num_params - 1);
+ str_nicks = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
nicks = weechat_string_split (str_nicks,
",",
@@ -7645,7 +7576,7 @@ IRC_PROTOCOL_CALLBACK(730)
monitor_host = strchr (nicks[i], '!');
if (monitor_host)
monitor_host++;
- ptr_notify = irc_notify_search (server, monitor_nick);
+ ptr_notify = irc_notify_search (ctxt->server, monitor_nick);
if (ptr_notify)
irc_notify_set_is_on_server (ptr_notify, monitor_host, 1);
}
@@ -7675,7 +7606,7 @@ IRC_PROTOCOL_CALLBACK(731)
IRC_PROTOCOL_MIN_PARAMS(2);
- str_nicks = irc_protocol_string_params (params, 1, num_params - 1);
+ str_nicks = irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1);
nicks = weechat_string_split (str_nicks,
",",
@@ -7693,7 +7624,7 @@ IRC_PROTOCOL_CALLBACK(731)
monitor_host = strchr (nicks[i], '!');
if (monitor_host)
monitor_host++;
- ptr_notify = irc_notify_search (server, monitor_nick);
+ ptr_notify = irc_notify_search (ctxt->server, monitor_nick);
if (ptr_notify)
irc_notify_set_is_on_server (ptr_notify, monitor_host, 0);
}
@@ -7719,14 +7650,14 @@ IRC_PROTOCOL_CALLBACK(732)
IRC_PROTOCOL_MIN_PARAMS(1);
- str_nicks = (num_params > 1) ?
- irc_protocol_string_params (params, 1, num_params - 1) : NULL;
+ str_nicks = (ctxt->num_params > 1) ?
+ irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1) : NULL;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "monitor", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "monitor", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
(str_nicks) ? str_nicks : "");
@@ -7750,14 +7681,14 @@ IRC_PROTOCOL_CALLBACK(733)
IRC_PROTOCOL_MIN_PARAMS(1);
- str_params = (num_params > 1) ?
- irc_protocol_string_params (params, 1, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 1) ?
+ irc_protocol_string_params (ctxt->params, 1, ctxt->num_params - 1) : NULL;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "monitor", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "monitor", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
(str_params) ? str_params : "");
@@ -7781,18 +7712,18 @@ IRC_PROTOCOL_CALLBACK(734)
IRC_PROTOCOL_MIN_PARAMS(3);
- str_params = (num_params > 3) ?
- irc_protocol_string_params (params, 3, num_params - 1) : NULL;
+ str_params = (ctxt->num_params > 3) ?
+ irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1) : NULL;
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
- server, NULL, command, "monitor", NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ ctxt->server, NULL, ctxt->command, "monitor", NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s (%s)",
weechat_prefix ("error"),
(str_params) ? str_params : "",
- params[1]);
+ ctxt->params[1]);
if (str_params)
free (str_params);
@@ -7815,16 +7746,16 @@ IRC_PROTOCOL_CALLBACK(900)
IRC_PROTOCOL_MIN_PARAMS(4);
- pos_nick_host = (strcmp (params[1], "*") != 0) ? params[1] : NULL;
+ pos_nick_host = (strcmp (ctxt->params[1], "*") != 0) ? ctxt->params[1] : NULL;
- str_params = irc_protocol_string_params (params, 3, num_params - 1);
+ str_params = irc_protocol_string_params (ctxt->params, 3, ctxt->num_params - 1);
if (pos_nick_host)
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s %s(%s%s%s)",
weechat_prefix ("network"),
str_params,
@@ -7836,15 +7767,15 @@ IRC_PROTOCOL_CALLBACK(900)
else
{
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_params);
}
- irc_server_free_sasl_data (server);
+ irc_server_free_sasl_data (ctxt->server);
if (str_params)
free (str_params);
@@ -7864,12 +7795,12 @@ IRC_PROTOCOL_CALLBACK(901)
IRC_PROTOCOL_MIN_PARAMS(3);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
- date,
- irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
+ irc_msgbuffer_get_target_buffer (ctxt->server, NULL, ctxt->command, NULL, NULL),
+ ctxt->date,
+ irc_protocol_tags (ctxt, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
- params[2]);
+ ctxt->params[2]);
return WEECHAT_RC_OK;
}
@@ -7884,20 +7815,20 @@ IRC_PROTOCOL_CALLBACK(901)
IRC_PROTOCOL_CALLBACK(sasl_end_ok)
{
- if (server->hook_timer_sasl)
+ if (ctxt->server->hook_timer_sasl)
{
- weechat_unhook (server->hook_timer_sasl);
- server->hook_timer_sasl = NULL;
+ weechat_unhook (ctxt->server->hook_timer_sasl);
+ ctxt->server->hook_timer_sasl = NULL;
}
- IRC_PROTOCOL_RUN_CALLBACK(numeric);
+ irc_protocol_cb_numeric (ctxt);
- server->authentication_method = IRC_SERVER_AUTH_METHOD_SASL;
+ ctxt->server->authentication_method = IRC_SERVER_AUTH_METHOD_SASL;
- if (!server->is_connected)
- irc_server_sendf (server, 0, NULL, "CAP END");
+ if (!ctxt->server->is_connected)
+ irc_server_sendf (ctxt->server, 0, NULL, "CAP END");
- irc_server_free_sasl_data (server);
+ irc_server_free_sasl_data (ctxt->server);
return WEECHAT_RC_OK;
}
@@ -7913,37 +7844,82 @@ IRC_PROTOCOL_CALLBACK(sasl_end_fail)
{
int sasl_fail;
- if (server->hook_timer_sasl)
+ if (ctxt->server->hook_timer_sasl)
{
- weechat_unhook (server->hook_timer_sasl);
- server->hook_timer_sasl = NULL;
+ weechat_unhook (ctxt->server->hook_timer_sasl);
+ ctxt->server->hook_timer_sasl = NULL;
}
- server->authentication_method = IRC_SERVER_AUTH_METHOD_NONE;
- server->sasl_mechanism_used = -1;
+ ctxt->server->authentication_method = IRC_SERVER_AUTH_METHOD_NONE;
+ ctxt->server->sasl_mechanism_used = -1;
- IRC_PROTOCOL_RUN_CALLBACK(numeric);
+ irc_protocol_cb_numeric (ctxt);
- sasl_fail = IRC_SERVER_OPTION_ENUM(server, IRC_SERVER_OPTION_SASL_FAIL);
- if (!server->is_connected
+ sasl_fail = IRC_SERVER_OPTION_ENUM(ctxt->server, IRC_SERVER_OPTION_SASL_FAIL);
+ if (!ctxt->server->is_connected
&& ((sasl_fail == IRC_SERVER_SASL_FAIL_RECONNECT)
|| (sasl_fail == IRC_SERVER_SASL_FAIL_DISCONNECT)))
{
irc_server_disconnect (
- server, 0,
+ ctxt->server, 0,
(sasl_fail == IRC_SERVER_SASL_FAIL_RECONNECT) ? 1 : 0);
return WEECHAT_RC_OK;
}
- if (!server->is_connected)
- irc_server_sendf (server, 0, NULL, "CAP END");
+ if (!ctxt->server->is_connected)
+ irc_server_sendf (ctxt->server, 0, NULL, "CAP END");
- irc_server_free_sasl_data (server);
+ irc_server_free_sasl_data (ctxt->server);
return WEECHAT_RC_OK;
}
/*
+ * Frees data in structure t_irc_protocol_ctxt.
+ */
+
+void
+irc_protocol_ctxt_free_data (struct t_irc_protocol_ctxt *ctxt)
+{
+ if (ctxt->irc_message)
+ {
+ free (ctxt->irc_message);
+ ctxt->irc_message = NULL;
+ }
+ if (ctxt->tags)
+ {
+ weechat_hashtable_free (ctxt->tags);
+ ctxt->tags = NULL;
+ }
+ if (ctxt->nick)
+ {
+ free (ctxt->nick);
+ ctxt->nick = NULL;
+ }
+ if (ctxt->address)
+ {
+ free (ctxt->address);
+ ctxt->address = NULL;
+ }
+ if (ctxt->host)
+ {
+ free (ctxt->host);
+ ctxt->host = NULL;
+ }
+ if (ctxt->command)
+ {
+ free (ctxt->command);
+ ctxt->command = NULL;
+ }
+ if (ctxt->params)
+ {
+ weechat_string_free_split (ctxt->params);
+ ctxt->params = NULL;
+ }
+ ctxt->num_params = 0;
+}
+
+/*
* Executes action when an IRC command is received.
*
* Argument "irc_message" is the full message without optional tags.
@@ -7963,15 +7939,13 @@ irc_protocol_recv_command (struct t_irc_server *server,
int ignore_batch_tag)
{
int i, cmd_found, return_code, decode_color, keep_trailing_spaces;
- int message_ignored, num_params;
- char *message_colors_decoded, *msg_to_parse, *pos_space, *tags, **params;
+ char *message_colors_decoded, *pos_space, *tags;
struct t_irc_channel *ptr_channel;
t_irc_recv_func *cmd_recv_func;
- const char *cmd_name, *ptr_msg_after_tags, *ptr_batch_ref;
- time_t date;
+ const char *ptr_msg_after_tags, *ptr_batch_ref;
const char *nick1, *address1, *host1;
- char *nick, *address, *address_color, *host, *host_no_color, *host_color;
- struct t_hashtable *hash_tags;
+ char *address, *host, *host_no_color;
+ struct t_irc_protocol_ctxt ctxt;
struct t_irc_protocol_msg irc_protocol_messages[] = {
/* format: "command", decode_color, keep_trailing_spaces, func_cb */
@@ -8149,16 +8123,22 @@ irc_protocol_recv_command (struct t_irc_server *server,
if (!msg_command)
return;
- nick = NULL;
address = NULL;
- address_color = NULL;
host = NULL;
host_no_color = NULL;
- host_color = NULL;
message_colors_decoded = NULL;
- msg_to_parse = NULL;
- date = 0;
- hash_tags = NULL;
+
+ ctxt.server = server;
+ ctxt.date = 0;
+ ctxt.irc_message = NULL;
+ ctxt.tags = NULL;
+ ctxt.nick = NULL;
+ ctxt.address = NULL;
+ ctxt.host = NULL;
+ ctxt.command = NULL;
+ ctxt.ignored = 0;
+ ctxt.params = NULL;
+ ctxt.num_params = 0;
ptr_msg_after_tags = irc_message;
@@ -8172,15 +8152,16 @@ irc_protocol_recv_command (struct t_irc_server *server,
pos_space - (irc_message + 1));
if (tags)
{
- hash_tags = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
- NULL, NULL);
- if (hash_tags)
+ ctxt.tags = weechat_hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL, NULL);
+ if (ctxt.tags)
{
- irc_tag_parse (tags, hash_tags, NULL);
- date = irc_protocol_parse_time (
- weechat_hashtable_get (hash_tags, "time"));
+ irc_tag_parse (tags, ctxt.tags, NULL);
+ ctxt.date = irc_protocol_parse_time (
+ weechat_hashtable_get (ctxt.tags, "time"));
}
free (tags);
}
@@ -8196,11 +8177,11 @@ irc_protocol_recv_command (struct t_irc_server *server,
/* if message is not BATCH but has a batch tag, just store it for later */
if (!ignore_batch_tag
- && hash_tags
+ && ctxt.tags
&& (weechat_strcasecmp (msg_command, "batch") != 0)
&& weechat_hashtable_has_key (server->cap_list, "batch"))
{
- ptr_batch_ref = weechat_hashtable_get (hash_tags, "batch");
+ ptr_batch_ref = weechat_hashtable_get (ctxt.tags, "batch");
if (ptr_batch_ref)
{
if (irc_batch_add_message (server, ptr_batch_ref, irc_message))
@@ -8218,9 +8199,10 @@ irc_protocol_recv_command (struct t_irc_server *server,
address1 = irc_message_get_address_from_host (ptr_msg_after_tags);
host1 = ptr_msg_after_tags + 1;
}
- nick = (nick1) ? strdup (nick1) : NULL;
+ ctxt.nick = (nick1) ? strdup (nick1) : NULL;
+ ctxt.nick_is_me = (irc_server_strcasecmp (server, ctxt.nick, server->nick) == 0);
address = (address1) ? strdup (address1) : NULL;
- address_color = (address) ?
+ ctxt.address = (address) ?
irc_color_decode (
address,
weechat_config_boolean (irc_config_network_colors_receive)) :
@@ -8233,7 +8215,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
pos_space[0] = '\0';
}
host_no_color = (host) ? irc_color_decode (host, 0) : NULL;
- host_color = (host) ?
+ ctxt.host = (host) ?
irc_color_decode (
host,
weechat_config_boolean (irc_config_network_colors_receive)) :
@@ -8243,10 +8225,10 @@ irc_protocol_recv_command (struct t_irc_server *server,
ptr_channel = NULL;
if (msg_channel)
ptr_channel = irc_channel_search (server, msg_channel);
- message_ignored = irc_ignore_check (
+ ctxt.ignored = irc_ignore_check (
server,
(ptr_channel) ? ptr_channel->name : msg_channel,
- nick,
+ ctxt.nick,
host_no_color);
/* send signal with received command, even if command is ignored */
@@ -8256,7 +8238,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
goto end;
/* send signal with received command, only if message is not ignored */
- if (!message_ignored)
+ if (!ctxt.ignored)
{
return_code = irc_server_send_signal (server, "irc_in", msg_command,
irc_message, NULL);
@@ -8282,7 +8264,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
/* for numeric commands, we use default recv function */
if (irc_protocol_is_numeric_command (msg_command))
{
- cmd_name = msg_command;
+ ctxt.command = (msg_command) ? strdup (msg_command) : NULL;
decode_color = 1;
keep_trailing_spaces = 0;
cmd_recv_func = irc_protocol_cb_numeric;
@@ -8298,7 +8280,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
}
else
{
- cmd_name = irc_protocol_messages[cmd_found].name;
+ ctxt.command = strdup (irc_protocol_messages[cmd_found].name);
decode_color = irc_protocol_messages[cmd_found].decode_color;
keep_trailing_spaces = irc_protocol_messages[cmd_found].keep_trailing_spaces;
cmd_recv_func = irc_protocol_messages[cmd_found].recv_function;
@@ -8316,12 +8298,12 @@ irc_protocol_recv_command (struct t_irc_server *server,
{
message_colors_decoded = strdup (ptr_msg_after_tags);
}
- msg_to_parse = (keep_trailing_spaces) ?
+ ctxt.irc_message = (keep_trailing_spaces) ?
strdup (message_colors_decoded) :
weechat_string_strip (message_colors_decoded, 0, 1, " ");
irc_message_parse (server,
- msg_to_parse,
+ ctxt.irc_message,
NULL, /* tags */
NULL, /* message_without_tags */
NULL, /* nick */
@@ -8331,27 +8313,14 @@ irc_protocol_recv_command (struct t_irc_server *server,
NULL, /* channel */
NULL, /* arguments */
NULL, /* text */
- &params,
- &num_params,
+ &(ctxt.params),
+ &(ctxt.num_params),
NULL, /* pos_command */
NULL, /* pos_arguments */
NULL, /* pos_channel */
NULL); /* pos_text */
- return_code = (int) (cmd_recv_func) (server,
- date,
- msg_to_parse,
- hash_tags,
- nick,
- address_color,
- host_color,
- cmd_name,
- message_ignored,
- (const char **)params,
- num_params);
-
- if (params)
- weechat_string_free_split (params);
+ return_code = (int) (cmd_recv_func) (&ctxt);
if (return_code == WEECHAT_RC_ERROR)
{
@@ -8359,11 +8328,11 @@ irc_protocol_recv_command (struct t_irc_server *server,
_("%s%s: failed to parse command \"%s\" (please "
"report to developers): \"%s\""),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
- cmd_name, irc_message);
+ ctxt.command, irc_message);
}
/* send signal with received command (if message is not ignored) */
- if (!message_ignored)
+ if (!ctxt.ignored)
{
(void) irc_server_send_signal (server, "irc_in2", msg_command,
irc_message, NULL);
@@ -8375,22 +8344,13 @@ irc_protocol_recv_command (struct t_irc_server *server,
irc_message, NULL);
end:
- if (nick)
- free (nick);
if (address)
free (address);
- if (address_color)
- free (address_color);
if (host)
free (host);
if (host_no_color)
free (host_no_color);
- if (host_color)
- free (host_color);
if (message_colors_decoded)
free (message_colors_decoded);
- if (msg_to_parse)
- free (msg_to_parse);
- if (hash_tags)
- weechat_hashtable_free (hash_tags);
+ irc_protocol_ctxt_free_data (&ctxt);
}