mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 01:33:12 +02:00
api: return allocated string in hook_info callback and function info_get
This commit is contained in:
@@ -408,8 +408,7 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
int
|
||||
irc_color_convert_rgb2irc (int rgb)
|
||||
{
|
||||
char str_color[64], *error;
|
||||
const char *info_color;
|
||||
char str_color[64], *error, *info_color;
|
||||
long number;
|
||||
|
||||
snprintf (str_color, sizeof (str_color),
|
||||
@@ -419,16 +418,23 @@ irc_color_convert_rgb2irc (int rgb)
|
||||
|
||||
info_color = weechat_info_get ("color_rgb2term", str_color);
|
||||
if (!info_color || !info_color[0])
|
||||
{
|
||||
if (info_color)
|
||||
free (info_color);
|
||||
return -1;
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
number = strtol (info_color, &error, 10);
|
||||
if (!error || error[0]
|
||||
|| (number < 0) || (number >= IRC_COLOR_TERM2IRC_NUM_COLORS))
|
||||
{
|
||||
free (info_color);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free (info_color);
|
||||
|
||||
return irc_color_term2irc[number];
|
||||
}
|
||||
|
||||
@@ -441,20 +447,28 @@ irc_color_convert_rgb2irc (int rgb)
|
||||
int
|
||||
irc_color_convert_term2irc (int color)
|
||||
{
|
||||
char str_color[64], *error;
|
||||
const char *info_color;
|
||||
char str_color[64], *error, *info_color;
|
||||
long number;
|
||||
|
||||
snprintf (str_color, sizeof (str_color), "%d", color);
|
||||
|
||||
info_color = weechat_info_get ("color_term2rgb", str_color);
|
||||
if (!info_color || !info_color[0])
|
||||
{
|
||||
if (info_color)
|
||||
free (info_color);
|
||||
return -1;
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
number = strtol (info_color, &error, 10);
|
||||
if (!error || error[0] || (number < 0) || (number > 0xFFFFFF))
|
||||
{
|
||||
free (info_color);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free (info_color);
|
||||
|
||||
return irc_color_convert_rgb2irc (number);
|
||||
}
|
||||
@@ -740,6 +754,7 @@ char *
|
||||
irc_color_decode_ansi (const char *string, int keep_colors)
|
||||
{
|
||||
struct t_irc_color_ansi_state ansi_state;
|
||||
char *ansi_regex;
|
||||
|
||||
/* allocate/compile regex if needed (first call) */
|
||||
if (!irc_color_regex_ansi)
|
||||
@@ -747,14 +762,19 @@ irc_color_decode_ansi (const char *string, int keep_colors)
|
||||
irc_color_regex_ansi = malloc (sizeof (*irc_color_regex_ansi));
|
||||
if (!irc_color_regex_ansi)
|
||||
return NULL;
|
||||
ansi_regex = weechat_info_get ("color_ansi_regex", NULL);
|
||||
if (weechat_string_regcomp (irc_color_regex_ansi,
|
||||
weechat_info_get ("color_ansi_regex", NULL),
|
||||
ansi_regex,
|
||||
REG_EXTENDED) != 0)
|
||||
{
|
||||
if (ansi_regex)
|
||||
free (ansi_regex);
|
||||
free (irc_color_regex_ansi);
|
||||
irc_color_regex_ansi = NULL;
|
||||
return NULL;
|
||||
}
|
||||
if (ansi_regex)
|
||||
free (ansi_regex);
|
||||
}
|
||||
|
||||
ansi_state.keep_colors = keep_colors;
|
||||
|
||||
@@ -213,7 +213,7 @@ irc_config_compute_nick_colors ()
|
||||
{
|
||||
if (ptr_nick->color)
|
||||
free (ptr_nick->color);
|
||||
ptr_nick->color = strdup (irc_nick_find_color (ptr_nick->name));
|
||||
ptr_nick->color = irc_nick_find_color (ptr_nick->name);
|
||||
}
|
||||
}
|
||||
if (ptr_channel->pv_remote_nick_color)
|
||||
|
||||
@@ -328,8 +328,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
|
||||
char *
|
||||
irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
{
|
||||
char *res, *temp, *username, *realname;
|
||||
const char *info;
|
||||
char *res, *temp, *username, *realname, *info, *info2;
|
||||
time_t now;
|
||||
struct tm *local_time;
|
||||
char buf[4096];
|
||||
@@ -354,6 +353,8 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
info = weechat_info_get ("version_git", "");
|
||||
temp = weechat_string_replace (res, "$git", info);
|
||||
free (res);
|
||||
if (info)
|
||||
free (info);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
@@ -365,13 +366,18 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
* 0.4.0-dev (git: v0.3.9-104-g7eb5cc4)
|
||||
*/
|
||||
info = weechat_info_get ("version_git", "");
|
||||
info2 = weechat_info_get ("version", "");
|
||||
snprintf (buf, sizeof (buf), "%s%s%s%s",
|
||||
weechat_info_get ("version", ""),
|
||||
info2,
|
||||
(info && info[0]) ? " (git: " : "",
|
||||
(info && info[0]) ? info : "",
|
||||
(info && info[0]) ? ")" : "");
|
||||
temp = weechat_string_replace (res, "$versiongit", buf);
|
||||
free (res);
|
||||
if (info)
|
||||
free (info);
|
||||
if (info2)
|
||||
free (info2);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
@@ -384,6 +390,8 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
info = weechat_info_get ("version", "");
|
||||
temp = weechat_string_replace (res, "$version", info);
|
||||
free (res);
|
||||
if (info)
|
||||
free (info);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
@@ -395,6 +403,8 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
info = weechat_info_get ("date", "");
|
||||
temp = weechat_string_replace (res, "$compilation", info);
|
||||
free (res);
|
||||
if (info)
|
||||
free (info);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
@@ -430,6 +440,8 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
info = weechat_info_get ("weechat_site", "");
|
||||
temp = weechat_string_replace (res, "$site", info);
|
||||
free (res);
|
||||
if (info)
|
||||
free (info);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
@@ -441,6 +453,8 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
info = weechat_info_get ("weechat_site_download", "");
|
||||
temp = weechat_string_replace (res, "$download", info);
|
||||
free (res);
|
||||
if (info)
|
||||
free (info);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
@@ -974,7 +988,7 @@ irc_ctcp_recv (struct t_irc_server *server, time_t date, const char *command,
|
||||
const char *nick, const char *remote_nick, char *arguments,
|
||||
char *message)
|
||||
{
|
||||
char *pos_end, *pos_space, *pos_args;
|
||||
char *pos_end, *pos_space, *pos_args, *nick_color;
|
||||
const char *reply;
|
||||
char *decoded_reply;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
@@ -1014,6 +1028,12 @@ irc_ctcp_recv (struct t_irc_server *server, time_t date, const char *command,
|
||||
irc_channel_nick_speaking_time_remove_old (channel);
|
||||
irc_channel_nick_speaking_time_add (server, channel, nick,
|
||||
time (NULL));
|
||||
if (ptr_nick)
|
||||
nick_color = strdup (ptr_nick->color);
|
||||
else if (nick)
|
||||
nick_color = irc_nick_find_color (nick);
|
||||
else
|
||||
nick_color = strdup (IRC_COLOR_CHAT_NICK);
|
||||
weechat_printf_date_tags (
|
||||
channel->buffer,
|
||||
date,
|
||||
@@ -1026,11 +1046,13 @@ irc_ctcp_recv (struct t_irc_server *server, time_t date, const char *command,
|
||||
"%s%s%s%s%s%s%s",
|
||||
weechat_prefix ("action"),
|
||||
irc_nick_mode_for_display (server, ptr_nick, 0),
|
||||
(ptr_nick) ? ptr_nick->color : ((nick) ? irc_nick_find_color (nick) : IRC_COLOR_CHAT_NICK),
|
||||
nick_color,
|
||||
nick,
|
||||
(pos_args) ? IRC_COLOR_RESET : "",
|
||||
(pos_args) ? " " : "",
|
||||
(pos_args) ? pos_args : "");
|
||||
if (nick_color)
|
||||
free (nick_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+44
-32
@@ -64,14 +64,13 @@ irc_info_create_string_with_pointer (char **string, void *pointer)
|
||||
* Returns IRC info "irc_is_channel".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_is_channel_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
char *pos_comma, *server;
|
||||
const char *pos_channel;
|
||||
static char str_true[2] = "1";
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -92,37 +91,36 @@ irc_info_info_irc_is_channel_cb (const void *pointer, void *data,
|
||||
free (server);
|
||||
}
|
||||
}
|
||||
if (irc_channel_is_channel (ptr_server, pos_channel))
|
||||
return str_true;
|
||||
return NULL;
|
||||
|
||||
return (irc_channel_is_channel (ptr_server, pos_channel)) ?
|
||||
strdup ("1") : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns IRC info "irc_is_nick".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_is_nick_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
static char str_true[2] = "1";
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) info_name;
|
||||
|
||||
if (arguments && arguments[0] && irc_nick_is_nick (arguments))
|
||||
return str_true;
|
||||
return NULL;
|
||||
if (!arguments || !arguments[0])
|
||||
return NULL;
|
||||
|
||||
return (irc_nick_is_nick (arguments)) ? strdup ("1") : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns IRC info "irc_nick".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_nick_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
@@ -138,35 +136,40 @@ irc_info_info_irc_nick_cb (const void *pointer, void *data,
|
||||
return NULL;
|
||||
|
||||
ptr_server = irc_server_search (arguments);
|
||||
if (ptr_server)
|
||||
return ptr_server->nick;
|
||||
|
||||
return NULL;
|
||||
return (ptr_server && ptr_server->nick) ?
|
||||
strdup (ptr_server->nick) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns IRC info "irc_nick_from_host".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_nick_from_host_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
const char *ptr_host;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) info_name;
|
||||
|
||||
return (arguments && arguments[0]) ?
|
||||
irc_message_get_nick_from_host (arguments) : NULL;
|
||||
if (!arguments || !arguments[0])
|
||||
return NULL;
|
||||
|
||||
ptr_host = irc_message_get_nick_from_host (arguments);
|
||||
|
||||
return (ptr_host) ? strdup (ptr_host) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns IRC info "irc_nick_color".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_nick_color_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
@@ -176,15 +179,17 @@ irc_info_info_irc_nick_color_cb (const void *pointer, void *data,
|
||||
(void) data;
|
||||
(void) info_name;
|
||||
|
||||
return (arguments && arguments[0]) ?
|
||||
irc_nick_find_color (arguments) : NULL;
|
||||
if (!arguments || !arguments[0])
|
||||
return NULL;
|
||||
|
||||
return irc_nick_find_color (arguments);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns IRC info "irc_nick_color_name".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_nick_color_name_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
@@ -194,15 +199,17 @@ irc_info_info_irc_nick_color_name_cb (const void *pointer, void *data,
|
||||
(void) data;
|
||||
(void) info_name;
|
||||
|
||||
return (arguments && arguments[0]) ?
|
||||
irc_nick_find_color_name (arguments) : NULL;
|
||||
if (!arguments || !arguments[0])
|
||||
return NULL;
|
||||
|
||||
return irc_nick_find_color_name (arguments);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns IRC info "irc_buffer".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_buffer_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
@@ -281,14 +288,18 @@ irc_info_info_irc_buffer_cb (const void *pointer, void *data,
|
||||
{
|
||||
irc_info_create_string_with_pointer (&ptr_channel->buffer_as_string,
|
||||
ptr_channel->buffer);
|
||||
return ptr_channel->buffer_as_string;
|
||||
return (ptr_channel->buffer_as_string) ?
|
||||
strdup (ptr_channel->buffer_as_string) : NULL;
|
||||
}
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
irc_info_create_string_with_pointer (&ptr_server->buffer_as_string,
|
||||
ptr_server->buffer);
|
||||
return ptr_server->buffer_as_string;
|
||||
return (ptr_server->buffer_as_string) ?
|
||||
strdup (ptr_server->buffer_as_string) : NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -296,14 +307,13 @@ irc_info_info_irc_buffer_cb (const void *pointer, void *data,
|
||||
* Returns IRC info "irc_server_isupport".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_server_isupport_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
char *pos_comma, *server;
|
||||
const char *isupport_value;
|
||||
static char str_true[2] = "1";
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -326,14 +336,15 @@ irc_info_info_irc_server_isupport_cb (const void *pointer, void *data,
|
||||
}
|
||||
}
|
||||
}
|
||||
return (isupport_value) ? str_true : NULL;
|
||||
|
||||
return (isupport_value) ? strdup ("1") : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns IRC info "irc_server_isupport_value".
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_info_info_irc_server_isupport_value_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
@@ -362,7 +373,8 @@ irc_info_info_irc_server_isupport_value_cb (const void *pointer, void *data,
|
||||
}
|
||||
}
|
||||
}
|
||||
return isupport_value;
|
||||
|
||||
return (isupport_value) ? strdup (isupport_value) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+51
-17
@@ -98,7 +98,7 @@ irc_nick_is_nick (const char *string)
|
||||
* Returns a WeeChat color code (that can be used for display).
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_nick_find_color (const char *nickname)
|
||||
{
|
||||
return weechat_info_get ("nick_color", nickname);
|
||||
@@ -110,7 +110,7 @@ irc_nick_find_color (const char *nickname)
|
||||
* Returns the name of a color (for example: "green").
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_nick_find_color_name (const char *nickname)
|
||||
{
|
||||
return weechat_info_get ("nick_color_name", nickname);
|
||||
@@ -309,7 +309,7 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server, char prefix)
|
||||
* Gets nick color for nicklist.
|
||||
*/
|
||||
|
||||
const char *
|
||||
char *
|
||||
irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
@@ -318,17 +318,17 @@ irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
static char *nick_color_away = "weechat.color.nicklist_away";
|
||||
|
||||
if (nick->away)
|
||||
return nick_color_away;
|
||||
return strdup (nick_color_away);
|
||||
|
||||
if (weechat_config_boolean (irc_config_look_color_nicks_in_nicklist))
|
||||
{
|
||||
if (irc_server_strcasecmp (server, nick->name, server->nick) == 0)
|
||||
return nick_color_self;
|
||||
return strdup (nick_color_self);
|
||||
else
|
||||
return irc_nick_find_color_name (nick->name);
|
||||
}
|
||||
|
||||
return nick_color_bar_fg;
|
||||
return strdup (nick_color_bar_fg);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -341,14 +341,18 @@ irc_nick_nicklist_add (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
char *color;
|
||||
|
||||
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
|
||||
color = irc_nick_get_color_for_nicklist (server, nick);
|
||||
weechat_nicklist_add_nick (channel->buffer, ptr_group,
|
||||
nick->name,
|
||||
irc_nick_get_color_for_nicklist (server, nick),
|
||||
color,
|
||||
nick->prefix,
|
||||
irc_nick_get_prefix_color_name (server, nick->prefix[0]),
|
||||
1);
|
||||
if (color)
|
||||
free (color);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -425,6 +429,7 @@ irc_nick_nicklist_set_color_all ()
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *color;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
@@ -435,9 +440,10 @@ irc_nick_nicklist_set_color_all ()
|
||||
for (ptr_nick = ptr_channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
irc_nick_nicklist_set (ptr_channel, ptr_nick, "color",
|
||||
irc_nick_get_color_for_nicklist (ptr_server,
|
||||
ptr_nick));
|
||||
color = irc_nick_get_color_for_nicklist (ptr_server, ptr_nick);
|
||||
irc_nick_nicklist_set (ptr_channel, ptr_nick, "color", color);
|
||||
if (color)
|
||||
free (color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,7 +523,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
if (irc_server_strcasecmp (server, new_nick->name, server->nick) == 0)
|
||||
new_nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
new_nick->color = strdup (irc_nick_find_color (new_nick->name));
|
||||
new_nick->color = irc_nick_find_color (new_nick->name);
|
||||
|
||||
/* add nick to end of list */
|
||||
new_nick->prev_nick = channel->last_nick;
|
||||
@@ -566,7 +572,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
if (nick_is_me)
|
||||
nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
nick->color = strdup (irc_nick_find_color (nick->name));
|
||||
nick->color = irc_nick_find_color (nick->name);
|
||||
|
||||
/* add nick in nicklist */
|
||||
irc_nick_nicklist_add (server, channel, nick);
|
||||
@@ -749,11 +755,15 @@ void
|
||||
irc_nick_set_away (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick, int is_away)
|
||||
{
|
||||
char *color;
|
||||
|
||||
if (is_away != nick->away)
|
||||
{
|
||||
nick->away = is_away;
|
||||
irc_nick_nicklist_set (channel, nick, "color",
|
||||
irc_nick_get_color_for_nicklist (server, nick));
|
||||
color = irc_nick_get_color_for_nicklist (server, nick);
|
||||
irc_nick_nicklist_set (channel, nick, "color", color);
|
||||
if (color)
|
||||
free (color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,12 +830,25 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
const char *nickname, const char *force_color)
|
||||
{
|
||||
static char result[256];
|
||||
char *color;
|
||||
|
||||
if (force_color)
|
||||
color = strdup (force_color);
|
||||
else if (nick)
|
||||
color = strdup (nick->color);
|
||||
else if (nickname)
|
||||
color = irc_nick_find_color (nickname);
|
||||
else
|
||||
color = strdup (IRC_COLOR_CHAT_NICK);
|
||||
|
||||
snprintf (result, sizeof (result), "%s%s%s\t",
|
||||
irc_nick_mode_for_display (server, nick, 1),
|
||||
(force_color) ? force_color : ((nick) ? nick->color : ((nickname) ? irc_nick_find_color (nickname) : IRC_COLOR_CHAT_NICK)),
|
||||
color,
|
||||
(nick) ? nick->name : nickname);
|
||||
|
||||
if (color)
|
||||
free (color);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -837,6 +860,10 @@ const char *
|
||||
irc_nick_color_for_msg (struct t_irc_server *server, int server_message,
|
||||
struct t_irc_nick *nick, const char *nickname)
|
||||
{
|
||||
static char color[16][64];
|
||||
static int index_color = 0;
|
||||
char *color_found;
|
||||
|
||||
if (server_message
|
||||
&& !weechat_config_boolean (irc_config_look_color_nicks_in_server_messages))
|
||||
{
|
||||
@@ -853,7 +880,14 @@ irc_nick_color_for_msg (struct t_irc_server *server, int server_message,
|
||||
{
|
||||
return IRC_COLOR_CHAT_NICK_SELF;
|
||||
}
|
||||
return irc_nick_find_color (nickname);
|
||||
color_found = irc_nick_find_color (nickname);
|
||||
index_color = (index_color + 1) % 16;
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
"%s",
|
||||
color_found);
|
||||
if (color_found)
|
||||
free (color_found);
|
||||
return color[index_color];
|
||||
}
|
||||
|
||||
return IRC_COLOR_CHAT_NICK;
|
||||
@@ -869,7 +903,7 @@ irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname)
|
||||
if (weechat_config_boolean (irc_config_look_color_pv_nick_like_channel))
|
||||
{
|
||||
if (!channel->pv_remote_nick_color)
|
||||
channel->pv_remote_nick_color = strdup (irc_nick_find_color (nickname));
|
||||
channel->pv_remote_nick_color = irc_nick_find_color (nickname);
|
||||
if (channel->pv_remote_nick_color)
|
||||
return channel->pv_remote_nick_color;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ struct t_irc_nick
|
||||
extern int irc_nick_valid (struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick);
|
||||
extern int irc_nick_is_nick (const char *string);
|
||||
extern const char *irc_nick_find_color (const char *nickname);
|
||||
extern const char *irc_nick_find_color_name (const char *nickname);
|
||||
extern char *irc_nick_find_color (const char *nickname);
|
||||
extern char *irc_nick_find_color_name (const char *nickname);
|
||||
extern int irc_nick_is_op (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick);
|
||||
extern int irc_nick_has_prefix_mode (struct t_irc_server *server,
|
||||
|
||||
@@ -2169,6 +2169,7 @@ IRC_PROTOCOL_CALLBACK(pong)
|
||||
IRC_PROTOCOL_CALLBACK(privmsg)
|
||||
{
|
||||
char *pos_args, *pos_target, str_tags[1024], *str_color, status_msg[2];
|
||||
char *color;
|
||||
const char *remote_nick, *pv_tags;
|
||||
int is_channel, nick_is_me;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
@@ -2246,8 +2247,10 @@ IRC_PROTOCOL_CALLBACK(privmsg)
|
||||
else
|
||||
{
|
||||
/* standard message (to "#channel") */
|
||||
str_color = irc_color_for_tags (
|
||||
irc_nick_find_color_name ((ptr_nick) ? ptr_nick->name : nick));
|
||||
color = irc_nick_find_color_name ((ptr_nick) ? ptr_nick->name : nick);
|
||||
str_color = irc_color_for_tags (color);
|
||||
if (color)
|
||||
free (color);
|
||||
snprintf (str_tags, sizeof (str_tags),
|
||||
"notify_message,prefix_nick_%s",
|
||||
(str_color) ? str_color : "default");
|
||||
@@ -2318,8 +2321,10 @@ IRC_PROTOCOL_CALLBACK(privmsg)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_color_pv_nick_like_channel))
|
||||
{
|
||||
str_color = irc_color_for_tags (
|
||||
irc_nick_find_color_name (nick));
|
||||
color = irc_nick_find_color_name (nick);
|
||||
str_color = irc_color_for_tags (color);
|
||||
if (color)
|
||||
free (color);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4667,7 +4672,7 @@ IRC_PROTOCOL_CALLBACK(352)
|
||||
IRC_PROTOCOL_CALLBACK(353)
|
||||
{
|
||||
char *pos_channel, *pos_nick, *pos_nick_orig, *pos_host, *nickname;
|
||||
char *prefixes, *str_nicks;
|
||||
char *prefixes, *str_nicks, *color;
|
||||
int args, i, length;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
@@ -4764,7 +4769,12 @@ IRC_PROTOCOL_CALLBACK(353)
|
||||
if (irc_server_strcasecmp (server, nickname, server->nick) == 0)
|
||||
strcat (str_nicks, IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
strcat (str_nicks, irc_nick_find_color (nickname));
|
||||
{
|
||||
color = irc_nick_find_color (nickname);
|
||||
strcat (str_nicks, color);
|
||||
if (color)
|
||||
free (color);
|
||||
}
|
||||
}
|
||||
else
|
||||
strcat (str_nicks, IRC_COLOR_RESET);
|
||||
@@ -4956,7 +4966,7 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
struct t_infolist *infolist;
|
||||
struct t_config_option *ptr_option;
|
||||
int num_nicks, num_op, num_halfop, num_voice, num_normal, length, i;
|
||||
char *string, str_nicks_count[2048];
|
||||
char *string, str_nicks_count[2048], *color;
|
||||
const char *prefix, *prefix_color, *nickname;
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(5);
|
||||
@@ -5029,7 +5039,12 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
if (irc_server_strcasecmp (server, nickname, server->nick) == 0)
|
||||
strcat (string, IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
strcat (string, irc_nick_find_color (nickname));
|
||||
{
|
||||
color = irc_nick_find_color (nickname);
|
||||
strcat (string, color);
|
||||
if (color)
|
||||
free (color);
|
||||
}
|
||||
}
|
||||
else
|
||||
strcat (string, IRC_COLOR_RESET);
|
||||
|
||||
@@ -96,8 +96,7 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
|
||||
char *
|
||||
irc_sasl_get_key_content (struct t_irc_server *server, const char *sasl_key)
|
||||
{
|
||||
const char *weechat_dir;
|
||||
char *key_path1, *key_path2, *content;
|
||||
char *weechat_dir, *key_path1, *key_path2, *content;
|
||||
|
||||
if (!sasl_key)
|
||||
return NULL;
|
||||
@@ -122,6 +121,8 @@ irc_sasl_get_key_content (struct t_irc_server *server, const char *sasl_key)
|
||||
(key_path2) ? key_path2 : ((key_path1) ? key_path1 : sasl_key));
|
||||
}
|
||||
|
||||
if (weechat_dir)
|
||||
free (weechat_dir);
|
||||
if (key_path1)
|
||||
free (key_path1);
|
||||
if (key_path2)
|
||||
|
||||
@@ -1228,9 +1228,9 @@ irc_server_get_default_msg (const char *default_msg,
|
||||
struct t_irc_server *server,
|
||||
const char *channel_name)
|
||||
{
|
||||
const char *version;
|
||||
char *version;
|
||||
struct t_hashtable *extra_vars;
|
||||
char *msg;
|
||||
char *msg, *res;
|
||||
|
||||
/*
|
||||
* "%v" for version is deprecated since WeeChat 1.6, where
|
||||
@@ -1240,8 +1240,11 @@ irc_server_get_default_msg (const char *default_msg,
|
||||
if (strstr (default_msg, "%v") && !strstr (default_msg, "${"))
|
||||
{
|
||||
version = weechat_info_get ("version", "");
|
||||
return weechat_string_replace (default_msg, "%v",
|
||||
(version) ? version : "");
|
||||
res = weechat_string_replace (default_msg, "%v",
|
||||
(version) ? version : "");
|
||||
if (version)
|
||||
free (version);
|
||||
return res;
|
||||
}
|
||||
|
||||
extra_vars = weechat_hashtable_new (32,
|
||||
@@ -4344,7 +4347,8 @@ irc_server_gnutls_callback (const void *pointer, void *data,
|
||||
unsigned int i, cert_list_len, status;
|
||||
time_t cert_time;
|
||||
char *cert_path0, *cert_path1, *cert_path2, *cert_str, *fingerprint_eval;
|
||||
const char *weechat_dir, *ptr_fingerprint;
|
||||
char *weechat_dir;
|
||||
const char *ptr_fingerprint;
|
||||
int rc, ret, fingerprint_match, hostname_match, cert_temp_init;
|
||||
#if LIBGNUTLS_VERSION_NUMBER >= 0x010706 /* 1.7.6 */
|
||||
gnutls_datum_t cinfo;
|
||||
@@ -4368,6 +4372,7 @@ irc_server_gnutls_callback (const void *pointer, void *data,
|
||||
cert_list = NULL;
|
||||
cert_list_len = 0;
|
||||
fingerprint_eval = NULL;
|
||||
weechat_dir = NULL;
|
||||
|
||||
if (action == WEECHAT_HOOK_CONNECT_GNUTLS_CB_VERIFY_CERT)
|
||||
{
|
||||
@@ -4702,7 +4707,8 @@ end:
|
||||
|
||||
if (cert_temp_init)
|
||||
gnutls_x509_crt_deinit (cert_temp);
|
||||
|
||||
if (weechat_dir)
|
||||
free (weechat_dir);
|
||||
if (fingerprint_eval)
|
||||
free (fingerprint_eval);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user