1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

core: remove unneeded whitespace

This commit is contained in:
Sebastien Helleu
2011-10-26 20:37:03 +02:00
parent 2a83aae85e
commit dfdf42e27b
176 changed files with 13151 additions and 13151 deletions
+58 -58
View File
@@ -47,22 +47,22 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
struct t_irc_server *server;
char *buf, *message;
int length;
/* make C compiler happy */
(void) data;
(void) item;
buf = NULL;
if (!window)
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
irc_buffer_get_server_and_channel (buffer, &server, NULL);
if (server && server->is_away)
{
if (weechat_config_boolean (irc_config_look_item_away_message)
@@ -88,7 +88,7 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
}
}
}
return buf;
}
@@ -103,29 +103,29 @@ irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
struct t_gui_buffer *buffer;
const char *title;
char *title_color;
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
title = weechat_buffer_get_string (buffer, "title");
if (!title)
return NULL;
title_color = irc_color_decode (title,
(weechat_config_boolean (irc_config_look_topic_strip_colors)) ?
0 : 1);
return (title_color) ? title_color : strdup (title);
}
return NULL;
}
@@ -143,16 +143,16 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
const char *name;
struct t_irc_server *server;
struct t_irc_channel *channel;
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
ptr_plugin = weechat_buffer_get_pointer (buffer, "plugin");
@@ -180,7 +180,7 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
}
return strdup (buf);
}
return NULL;
}
@@ -198,21 +198,21 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
struct t_gui_buffer *buffer;
struct t_irc_server *server;
struct t_irc_channel *channel;
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = weechat_current_window ();
buf_name[0] = '\0';
modes[0] = '\0';
display_server = (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME);
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
irc_buffer_get_server_and_channel (buffer, &server, &channel);
@@ -282,14 +282,14 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
if (name)
snprintf (buf_name, sizeof (buf_name), "%s", name);
}
snprintf (buf, sizeof (buf), "%s%s%s",
(server && server->ssl_connected) ? IRC_COLOR_STATUS_NAME_SSL : IRC_COLOR_STATUS_NAME,
buf_name,
modes);
return strdup (buf);
}
return NULL;
}
@@ -307,21 +307,21 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
struct t_gui_buffer *buffer;
struct t_irc_server *server;
struct t_irc_channel *channel;
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = weechat_current_window ();
buf_name[0] = '\0';
modes[0] = '\0';
display_server = (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME);
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
irc_buffer_get_server_and_channel (buffer, &server, &channel);
@@ -363,14 +363,14 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
if (name)
snprintf (buf_name, sizeof (buf_name), "%s", name);
}
snprintf (buf, sizeof (buf), "%s%s%s",
IRC_COLOR_STATUS_NAME,
buf_name,
modes);
return strdup (buf);
}
return NULL;
}
@@ -385,20 +385,20 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
char buf[128];
struct t_gui_buffer *buffer;
struct t_irc_server *server;
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
irc_buffer_get_server_and_channel (buffer, &server, NULL);
if (server
&& (server->lag >= weechat_config_integer (irc_config_network_lag_min_show)))
{
@@ -430,22 +430,22 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
struct t_irc_nick *ptr_nick;
char *buf, str_prefix[64];
int length;
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
irc_buffer_get_server_and_channel (buffer, &server, &channel);
if (!server || !server->nick)
return NULL;
/* build prefix */
str_prefix[0] = '\0';
if (weechat_config_boolean (irc_config_look_item_nick_prefix)
@@ -463,11 +463,11 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
}
}
}
/* build bar item */
length = 64 + strlen (server->nick) + 64 +
((server->nick_modes) ? strlen (server->nick_modes) : 0) + 64 + 1;
buf = malloc (length);
if (buf)
{
@@ -491,10 +491,10 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
server->nick);
}
}
return buf;
}
return NULL;
}
@@ -511,22 +511,22 @@ irc_bar_item_focus_buffer_nicklist (void *data,
struct t_gui_buffer *buffer;
struct t_irc_nick *ptr_nick;
const char *str_buffer, *nick;
str_buffer = weechat_hashtable_get (info, "_buffer");
if (!str_buffer || !str_buffer[0])
return NULL;
rc = sscanf (str_buffer, "%lx", &value);
if ((rc == EOF) || (rc == 0))
return NULL;
buffer = (struct t_gui_buffer *)value;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
if (ptr_server && ptr_channel)
{
nick = weechat_hashtable_get (info, "nick");
@@ -540,7 +540,7 @@ irc_bar_item_focus_buffer_nicklist (void *data,
}
}
}
return NULL;
}
@@ -558,14 +558,14 @@ irc_bar_item_buffer_switch (void *data, const char *signal,
(void) signal;
(void) type_data;
(void) signal_data;
weechat_bar_item_update ("away");
weechat_bar_item_update ("buffer_title");
weechat_bar_item_update ("buffer_name");
weechat_bar_item_update ("irc_channel");
weechat_bar_item_update ("lag");
weechat_bar_item_update ("input_prompt");
return WEECHAT_RC_OK;
}
+15 -15
View File
@@ -49,15 +49,15 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
if (server)
*server = NULL;
if (channel)
*channel = NULL;
if (!buffer)
return;
/* look for a server or channel using this buffer */
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -68,7 +68,7 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
*server = ptr_server;
return;
}
for (ptr_channel = ptr_server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -82,7 +82,7 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
}
}
}
/* no server or channel found */
}
@@ -94,18 +94,18 @@ char *
irc_buffer_build_name (const char *server, const char *channel)
{
static char buffer[128];
buffer[0] = '\0';
if (!server && !channel)
return buffer;
if (server && channel)
snprintf (buffer, sizeof (buffer), "%s.%s", server, channel);
else
snprintf (buffer, sizeof (buffer), "%s",
(server) ? server : channel);
return buffer;
}
@@ -117,12 +117,12 @@ int
irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
struct t_irc_channel *next_channel;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
if (buffer == irc_raw_buffer)
{
irc_raw_buffer = NULL;
@@ -156,7 +156,7 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
}
}
}
return WEECHAT_RC_OK;
}
@@ -172,10 +172,10 @@ irc_buffer_search_first_for_all_servers ()
struct t_gui_buffer *ptr_buffer;
struct t_irc_server *ptr_server;
int number, number_found;
ptr_buffer = NULL;
number_found = INT_MAX;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
+67 -67
View File
@@ -50,17 +50,17 @@ int
irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel)
{
struct t_irc_channel *ptr_channel;
if (!server)
return 0;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel == channel)
return 1;
}
/* channel not found */
return 0;
}
@@ -77,12 +77,12 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
int number_found;
char str_number[32];
struct t_irc_channel *ptr_channel;
number = weechat_buffer_get_integer (buffer, "number");
number_last_channel = 0;
number_last_private = 0;
number_found = 0;
if (server->channels)
{
/* search last channel/pv number for server */
@@ -106,7 +106,7 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
}
}
}
/* use last channel/pv number + 1 */
switch (channel_type)
{
@@ -130,7 +130,7 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
number_found = weechat_buffer_get_integer (server->buffer, "number") + 1;
}
}
/* switch to number found */
if ((number_found >= 1) && (number_found != number))
{
@@ -154,7 +154,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
int i, buffer_created, current_buffer_number, buffer_position, manual_join;
char *buffer_name, str_number[32], str_group[32], *channel_name_lower;
const char *prefix_modes;
/* alloc memory for new channel */
if ((new_channel = malloc (sizeof (*new_channel))) == NULL)
{
@@ -163,7 +163,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
weechat_prefix ("error"), IRC_PLUGIN_NAME);
return NULL;
}
/* create buffer for channel (or use existing one) */
buffer_created = 0;
buffer_name = irc_buffer_build_name (server->name, channel_name);
@@ -206,7 +206,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
}
buffer_created = 1;
}
if (buffer_created)
{
if (!weechat_buffer_get_integer (new_buffer, "short_name_is_set"))
@@ -227,7 +227,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
weechat_buffer_set (new_buffer, "nicklist", "1");
weechat_buffer_set (new_buffer, "nicklist_display_groups", "0");
}
/* set highlights settings on channel buffer */
weechat_buffer_set(new_buffer, "highlight_words_add", "$nick");
if (weechat_config_string (irc_config_look_highlight_tags)
@@ -237,7 +237,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
weechat_config_string (irc_config_look_highlight_tags));
}
}
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
{
prefix_modes = irc_server_get_prefix_modes (server);
@@ -253,7 +253,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
weechat_nicklist_add_group (new_buffer, NULL, str_group,
"weechat.color.nicklist_group", 1);
}
/* initialize new channel */
new_channel->type = channel_type;
new_channel->name = strdup (channel_name);
@@ -279,7 +279,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
new_channel->last_nick_speaking_time = NULL;
new_channel->buffer = new_buffer;
new_channel->buffer_as_string = NULL;
/* add new channel to channels list */
new_channel->prev_channel = server->last_channel;
new_channel->next_channel = NULL;
@@ -288,7 +288,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
else
server->channels = new_channel;
server->last_channel = new_channel;
manual_join = 0;
channel_name_lower = NULL;
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
@@ -301,7 +301,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
channel_name_lower);
}
}
if (switch_to_channel)
{
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
@@ -310,23 +310,23 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|| (!manual_join && !weechat_config_boolean (irc_config_look_buffer_switch_autojoin)))
switch_to_channel = 0;
}
if (switch_to_channel)
{
weechat_buffer_set (new_buffer, "display",
(auto_switch) ? "auto" : "1");
}
}
if (manual_join)
weechat_hashtable_remove (server->manual_joins, channel_name_lower);
if (channel_name_lower)
free (channel_name_lower);
weechat_hook_signal_send ((channel_type == IRC_CHANNEL_TYPE_CHANNEL) ?
"irc_channel_opened" : "irc_pv_opened",
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
/* all is ok, return address of new channel */
return new_channel;
}
@@ -340,7 +340,7 @@ irc_channel_set_topic (struct t_irc_channel *channel, const char *topic)
{
if (channel->topic)
free (channel->topic);
channel->topic = (topic) ? strdup (topic) : NULL;
weechat_buffer_set (channel->buffer, "title",
(channel->topic) ? channel->topic : "");
@@ -354,10 +354,10 @@ struct t_irc_channel *
irc_channel_search (struct t_irc_server *server, const char *channel_name)
{
struct t_irc_channel *ptr_channel;
if (!server || !channel_name)
return NULL;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -375,10 +375,10 @@ int
irc_channel_is_channel (const char *string)
{
char first_char[2];
if (!string)
return 0;
first_char[0] = string[0];
first_char[1] = '\0';
return (strpbrk (first_char, IRC_CHANNEL_PREFIX)) ? 1 : 0;
@@ -393,7 +393,7 @@ irc_channel_remove_away (struct t_irc_server *server,
struct t_irc_channel *channel)
{
struct t_irc_nick *ptr_nick;
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
@@ -436,7 +436,7 @@ irc_channel_set_away (struct t_irc_server *server,
int is_away)
{
struct t_irc_nick *ptr_nick;
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
ptr_nick = irc_nick_search (channel, nick_name);
@@ -456,21 +456,21 @@ irc_channel_nick_speaking_add_to_list (struct t_irc_channel *channel,
{
int size, to_remove, i;
struct t_weelist_item *ptr_item;
/* create list if it does not exist */
if (!channel->nicks_speaking[highlight])
channel->nicks_speaking[highlight] = weechat_list_new ();
/* remove item if it was already in list */
ptr_item = weechat_list_casesearch (channel->nicks_speaking[highlight],
nick_name);
if (ptr_item)
weechat_list_remove (channel->nicks_speaking[highlight], ptr_item);
/* add nick in list */
weechat_list_add (channel->nicks_speaking[highlight], nick_name,
WEECHAT_LIST_POS_END, NULL);
/* reduce list size if it's too big */
size = weechat_list_size (channel->nicks_speaking[highlight]);
if (size > IRC_CHANNEL_NICKS_SPEAKING_LIMIT)
@@ -498,7 +498,7 @@ irc_channel_nick_speaking_add (struct t_irc_channel *channel,
highlight = 1;
if (highlight)
irc_channel_nick_speaking_add_to_list (channel, nick_name, 1);
irc_channel_nick_speaking_add_to_list (channel, nick_name, 0);
}
@@ -537,10 +537,10 @@ irc_channel_nick_speaking_time_search (struct t_irc_channel *channel,
{
struct t_irc_channel_speaking *ptr_nick;
time_t time_limit;
time_limit = time (NULL) -
(weechat_config_integer (irc_config_look_smart_filter_delay) * 60);
for (ptr_nick = channel->nicks_speaking_time; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
@@ -551,7 +551,7 @@ irc_channel_nick_speaking_time_search (struct t_irc_channel *channel,
return ptr_nick;
}
}
/* nick speaking time not found */
return NULL;
}
@@ -567,7 +567,7 @@ irc_channel_nick_speaking_time_free (struct t_irc_channel *channel,
/* free data */
if (nick_speaking->nick)
free (nick_speaking->nick);
/* remove nick from list */
if (nick_speaking->prev_nick)
(nick_speaking->prev_nick)->next_nick = nick_speaking->next_nick;
@@ -577,7 +577,7 @@ irc_channel_nick_speaking_time_free (struct t_irc_channel *channel,
channel->nicks_speaking_time = nick_speaking->next_nick;
if (channel->last_nick_speaking_time == nick_speaking)
channel->last_nick_speaking_time = nick_speaking->prev_nick;
free (nick_speaking);
}
@@ -603,7 +603,7 @@ void
irc_channel_nick_speaking_time_remove_old (struct t_irc_channel *channel)
{
time_t time_limit;
time_limit = time (NULL) -
(weechat_config_integer (irc_config_look_smart_filter_delay) * 60);
@@ -611,7 +611,7 @@ irc_channel_nick_speaking_time_remove_old (struct t_irc_channel *channel)
{
if (channel->last_nick_speaking_time->time_last_message >= time_limit)
break;
irc_channel_nick_speaking_time_free (channel,
channel->last_nick_speaking_time);
}
@@ -627,17 +627,17 @@ irc_channel_nick_speaking_time_add (struct t_irc_channel *channel,
time_t time_last_message)
{
struct t_irc_channel_speaking *ptr_nick, *new_nick;
ptr_nick = irc_channel_nick_speaking_time_search (channel, nick_name, 0);
if (ptr_nick)
irc_channel_nick_speaking_time_free (channel, ptr_nick);
new_nick = malloc (sizeof (*new_nick));
if (new_nick)
{
new_nick->nick = strdup (nick_name);
new_nick->time_last_message = time_last_message;
/* insert nick at beginning of list */
new_nick->prev_nick = NULL;
new_nick->next_nick = channel->nicks_speaking_time;
@@ -660,7 +660,7 @@ irc_channel_nick_speaking_time_rename (struct t_irc_channel *channel,
const char *new_nick)
{
struct t_irc_channel_speaking *ptr_nick;
if (channel->nicks_speaking_time)
{
ptr_nick = irc_channel_nick_speaking_time_search (channel, old_nick, 0);
@@ -680,12 +680,12 @@ void
irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel)
{
char join_args[256];
snprintf (join_args, sizeof (join_args), "%s%s%s",
channel->name,
(channel->key) ? " " : "",
(channel->key) ? channel->key : "");
irc_command_join_server (server, join_args, 0);
}
@@ -698,12 +698,12 @@ irc_channel_autorejoin_cb (void *data, int remaining_calls)
{
struct t_irc_server *ptr_server, *ptr_server_found;
struct t_irc_channel *ptr_channel_arg, *ptr_channel;
/* make C compiler happy */
(void) remaining_calls;
ptr_channel_arg = (struct t_irc_channel *)data;
ptr_server_found = NULL;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -718,13 +718,13 @@ irc_channel_autorejoin_cb (void *data, int remaining_calls)
}
}
}
if (ptr_server_found && (ptr_channel_arg->hook_autorejoin))
{
irc_channel_rejoin (ptr_server_found, ptr_channel_arg);
ptr_channel_arg->hook_autorejoin = NULL;
}
return WEECHAT_RC_OK;
}
@@ -740,10 +740,10 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
const char *nickname)
{
struct t_irc_channel *ptr_channel;
if (!server || (!nick && !nickname))
return;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -777,10 +777,10 @@ void
irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
{
struct t_irc_channel *new_channels;
if (!server || !channel)
return;
/* remove channel from channels list */
if (server->last_channel == channel)
server->last_channel = channel->prev_channel;
@@ -791,10 +791,10 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
}
else
new_channels = channel->next_channel;
if (channel->next_channel)
(channel->next_channel)->prev_channel = channel->prev_channel;
/* free data */
if (channel->name)
free (channel->name);
@@ -818,9 +818,9 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
irc_channel_nick_speaking_time_free_all (channel);
if (channel->buffer_as_string)
free (channel->buffer_as_string);
free (channel);
server->channels = new_channels;
}
@@ -845,10 +845,10 @@ struct t_hdata *
irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_channel", "next_channel");
if (hdata)
{
@@ -889,10 +889,10 @@ struct t_hdata *
irc_channel_hdata_channel_speaking_cb (void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
if (hdata)
{
@@ -918,14 +918,14 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
struct t_irc_channel_speaking *ptr_nick;
char option_name[64];
int i, index;
if (!infolist || !channel)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", channel->buffer))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "buffer_name",
@@ -1003,7 +1003,7 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
i++;
}
}
return 1;
}
@@ -1018,7 +1018,7 @@ irc_channel_print_log (struct t_irc_channel *channel)
struct t_irc_channel_speaking *ptr_nick_speaking;
int i, index;
struct t_irc_nick *ptr_nick;
weechat_log_printf ("");
weechat_log_printf (" => channel %s (addr:0x%lx):", channel->name, channel);
weechat_log_printf (" type . . . . . . . . . . : %d", channel->type);
+17 -17
View File
@@ -66,17 +66,17 @@ irc_color_decode (const char *string, int keep_colors)
int out_length, length, out_pos;
char str_fg[3], str_bg[3], str_color[128];
int fg, bg, bold, reverse, italic, underline, rc;
out_length = (strlen (string) * 2) + 1;
out = malloc (out_length);
if (!out)
return NULL;
bold = 0;
reverse = 0;
italic = 0;
underline = 0;
ptr_string = (unsigned char *)string;
out[0] = '\0';
while (ptr_string && ptr_string[0])
@@ -197,7 +197,7 @@ irc_color_decode (const char *string, int keep_colors)
break;
}
}
return (char *)out;
}
@@ -212,12 +212,12 @@ irc_color_decode_for_user_entry (const char *string)
{
unsigned char *out, *ptr_string;
int out_length, out_pos, length;
out_length = (strlen (string) * 2) + 1;
out = malloc (out_length);
if (!out)
return NULL;
ptr_string = (unsigned char *)string;
out_pos = 0;
while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
@@ -261,9 +261,9 @@ irc_color_decode_for_user_entry (const char *string)
ptr_string += length;
}
}
out[out_pos] = '\0';
return (char *)out;
}
@@ -280,12 +280,12 @@ irc_color_encode (const char *string, int keep_colors)
{
unsigned char *out, *ptr_string;
int out_length, out_pos, length;
out_length = (strlen (string) * 2) + 1;
out = malloc (out_length);
if (!out)
return NULL;
ptr_string = (unsigned char *)string;
out_pos = 0;
while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
@@ -356,9 +356,9 @@ irc_color_encode (const char *string, int keep_colors)
ptr_string += length;
}
}
out[out_pos] = '\0';
return (char *)out;
}
@@ -374,18 +374,18 @@ irc_color_modifier_cb (void *data, const char *modifier,
const char *modifier_data, const char *string)
{
int keep_colors;
/* make C compiler happy */
(void) data;
keep_colors = (modifier_data && (strcmp (modifier_data, "1") == 0)) ? 1 : 0;
if (strcmp (modifier, "irc_color_decode") == 0)
return irc_color_decode (string, keep_colors);
if (strcmp (modifier, "irc_color_encode") == 0)
return irc_color_encode (string, keep_colors);
/* unknown modifier */
return NULL;
}
File diff suppressed because it is too large Load Diff
+56 -56
View File
@@ -48,17 +48,17 @@ irc_completion_server_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_server)
{
weechat_hook_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -73,17 +73,17 @@ irc_completion_server_nick_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_server && ptr_server->nick)
{
weechat_hook_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -98,14 +98,14 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_irc_channel *ptr_channel;
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
if (ptr_server)
{
for (ptr_channel = ptr_server->channels; ptr_channel;
@@ -118,7 +118,7 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
}
}
}
return WEECHAT_RC_OK;
}
@@ -133,14 +133,14 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_irc_channel *ptr_channel;
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
if (ptr_server)
{
for (ptr_channel = ptr_server->channels; ptr_channel;
@@ -153,7 +153,7 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
}
}
}
return WEECHAT_RC_OK;
}
@@ -169,13 +169,13 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
{
struct t_irc_channel *ptr_channel2;
struct t_irc_nick *ptr_nick;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_server)
{
for (ptr_channel2 = ptr_server->channels; ptr_channel2;
@@ -191,12 +191,12 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
}
}
}
/* add self nick at the end */
weechat_hook_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
}
@@ -210,19 +210,19 @@ irc_completion_servers_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
weechat_hook_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -236,17 +236,17 @@ irc_completion_channel_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_channel)
{
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -262,7 +262,7 @@ irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion,
{
int list_size, i;
const char *nick;
if (channel->nicks_speaking[highlight])
{
list_size = weechat_list_size (channel->nicks_speaking[highlight]);
@@ -291,13 +291,13 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_irc_nick *ptr_nick;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_channel)
{
switch (ptr_channel->type)
@@ -342,7 +342,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
}
ptr_channel->nick_completion_reset = 0;
}
return WEECHAT_RC_OK;
}
@@ -359,13 +359,13 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
struct t_irc_nick *ptr_nick;
char *buf;
int length;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_channel)
{
switch (ptr_channel->type)
@@ -404,7 +404,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
break;
}
}
return WEECHAT_RC_OK;
}
@@ -420,13 +420,13 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
{
char *topic, *topic_color;
int length;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0])
{
if (weechat_strncasecmp (ptr_channel->topic, ptr_channel->name,
@@ -449,7 +449,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
}
else
topic = strdup (ptr_channel->topic);
topic_color = irc_color_decode_for_user_entry ((topic) ? topic : ptr_channel->topic);
weechat_hook_completion_list_add (completion,
(topic_color) ? topic_color : ((topic) ? topic : ptr_channel->topic),
@@ -459,7 +459,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
if (topic)
free (topic);
}
return WEECHAT_RC_OK;
}
@@ -475,12 +475,12 @@ irc_completion_channels_cb (void *data, const char *completion_item,
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -494,7 +494,7 @@ irc_completion_channels_cb (void *data, const char *completion_item,
}
}
}
return WEECHAT_RC_OK;
}
@@ -510,12 +510,12 @@ irc_completion_privates_cb (void *data, const char *completion_item,
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -529,7 +529,7 @@ irc_completion_privates_cb (void *data, const char *completion_item,
}
}
}
return WEECHAT_RC_OK;
}
@@ -543,13 +543,13 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
const char *msg_part;
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_server)
{
msg_part = IRC_SERVER_OPTION_STRING(ptr_server,
@@ -560,7 +560,7 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
0, WEECHAT_LIST_POS_SORT);
}
}
return WEECHAT_RC_OK;
}
@@ -576,12 +576,12 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
{
struct t_irc_ignore *ptr_ignore;
char str_number[32];
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
@@ -589,7 +589,7 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
weechat_hook_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
}
@@ -604,13 +604,13 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_irc_notify *ptr_notify;
IRC_BUFFER_GET_SERVER(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
if (ptr_server)
{
for (ptr_notify = ptr_server->notify_list; ptr_notify;
@@ -633,7 +633,7 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item,
}
}
}
return WEECHAT_RC_OK;
}
+118 -118
View File
@@ -144,9 +144,9 @@ irc_config_get_server_from_option_name (const char *name)
{
struct t_irc_server *ptr_server;
char *pos_option, *server_name;
ptr_server = NULL;
if (name)
{
pos_option = strrchr (name, '.');
@@ -160,7 +160,7 @@ irc_config_get_server_from_option_name (const char *name)
}
}
}
return ptr_server;
}
@@ -175,7 +175,7 @@ irc_config_compute_nick_colors ()
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -199,7 +199,7 @@ irc_config_compute_nick_colors ()
}
}
}
/* if colors are displayed for nicks in nicklist, refresh them */
if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist))
irc_nick_nicklist_set_color_all ();
@@ -219,7 +219,7 @@ irc_config_set_nick_colors ()
irc_config_nick_colors = NULL;
irc_config_num_nick_colors = 0;
}
irc_config_nick_colors =
weechat_string_split (weechat_config_string (weechat_config_get ("weechat.color.chat_nick_colors")),
",", 0, 0,
@@ -239,10 +239,10 @@ irc_config_change_nick_colors_cb (void *data, const char *option,
(void) data;
(void) option;
(void) value;
irc_config_set_nick_colors ();
irc_config_compute_nick_colors ();
return WEECHAT_RC_OK;
}
@@ -259,7 +259,7 @@ irc_config_change_look_color_nicks_in_nicklist (void *data,
/* make C compiler happy */
(void) data;
(void) option;
irc_nick_nicklist_set_color_all ();
}
@@ -274,7 +274,7 @@ irc_config_change_look_server_buffer (void *data,
{
struct t_irc_server *ptr_server;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
(void) option;
@@ -297,7 +297,7 @@ irc_config_change_look_server_buffer (void *data,
(weechat_config_integer (irc_config_look_server_buffer) ==
IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE) ?
weechat_buffer_search_main () : irc_buffer_search_first_for_all_servers ();
if (ptr_buffer)
{
for (ptr_server = irc_servers; ptr_server;
@@ -322,7 +322,7 @@ irc_config_change_look_item_away_message (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("away");
}
@@ -338,7 +338,7 @@ irc_config_change_look_item_channel_modes (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_name");
}
@@ -356,7 +356,7 @@ irc_config_change_look_item_channel_modes_hide_key (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_name");
}
@@ -372,7 +372,7 @@ irc_config_change_look_item_nick_modes (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("input_prompt");
}
@@ -388,7 +388,7 @@ irc_config_change_look_item_nick_prefix (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("input_prompt");
}
@@ -403,11 +403,11 @@ irc_config_change_look_highlight_tags (void *data,
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) data;
(void) option;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -439,7 +439,7 @@ irc_config_change_look_nick_color_force (void *data,
{
char **items, *pos;
int num_items, i;
/* make C compiler happy */
(void) data;
(void) option;
@@ -454,7 +454,7 @@ irc_config_change_look_nick_color_force (void *data,
}
else
weechat_hashtable_remove_all (irc_config_hashtable_nick_color_force);
items = weechat_string_split (weechat_config_string (irc_config_look_nick_color_force),
";", 0, 0, &num_items);
if (items)
@@ -472,7 +472,7 @@ irc_config_change_look_nick_color_force (void *data,
}
weechat_string_free_split (items);
}
irc_config_compute_nick_colors ();
}
@@ -488,7 +488,7 @@ irc_config_change_look_nick_color_stop_chars (void *data,
/* make C compiler happy */
(void) data;
(void) option;
irc_config_compute_nick_colors ();
}
@@ -522,7 +522,7 @@ irc_config_change_look_topic_strip_colors (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_title");
}
@@ -538,7 +538,7 @@ irc_config_change_color_input_nick (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("input_prompt");
}
@@ -554,7 +554,7 @@ irc_config_change_color_item_away (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("away");
}
@@ -570,7 +570,7 @@ irc_config_change_color_item_buffer_name (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("buffer_name");
}
@@ -586,7 +586,7 @@ irc_config_change_color_item_lag (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("lag");
}
@@ -601,11 +601,11 @@ irc_config_change_color_nick_prefixes (void *data,
{
char **items, *pos;
int num_items, i;
/* make C compiler happy */
(void) data;
(void) option;
if (!irc_config_hashtable_nick_prefixes)
{
irc_config_hashtable_nick_prefixes = weechat_hashtable_new (8,
@@ -616,7 +616,7 @@ irc_config_change_color_nick_prefixes (void *data,
}
else
weechat_hashtable_remove_all (irc_config_hashtable_nick_prefixes);
items = weechat_string_split (weechat_config_string (irc_config_color_nick_prefixes),
";", 0, 0, &num_items);
if (items)
@@ -634,9 +634,9 @@ irc_config_change_color_nick_prefixes (void *data,
}
weechat_string_free_split (items);
}
irc_nick_nicklist_set_prefix_color_all ();
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("nicklist");
}
@@ -651,14 +651,14 @@ irc_config_change_network_lag_check (void *data,
{
time_t time_next_check;
struct t_irc_server *ptr_server;
/* make C compiler happy */
(void) data;
(void) option;
time_next_check = (weechat_config_integer (irc_config_network_lag_check) > 0) ?
time (NULL) : 0;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -678,7 +678,7 @@ irc_config_change_network_lag_min_show (void *data,
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("lag");
}
@@ -694,7 +694,7 @@ irc_config_change_network_notify_check_ison (void *data,
/* make C compiler happy */
(void) data;
(void) option;
irc_notify_hook_timer_ison ();
}
@@ -710,7 +710,7 @@ irc_config_change_network_notify_check_whois (void *data,
/* make C compiler happy */
(void) data;
(void) option;
irc_notify_hook_timer_whois ();
}
@@ -726,15 +726,15 @@ irc_config_change_network_send_unknown_commands (void *data,
char value[2];
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) data;
(void) option;
strcpy (value,
(weechat_config_boolean (irc_config_network_send_unknown_commands)) ?
"1" : "0");
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -744,7 +744,7 @@ irc_config_change_network_send_unknown_commands (void *data,
"input_get_unknown_commands", value);
}
}
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -770,7 +770,7 @@ irc_config_server_default_change_cb (void *data, struct t_config_option *option)
{
int index_option;
struct t_irc_server *ptr_server;
index_option = irc_server_search_option (data);
if (index_option >= 0)
{
@@ -820,7 +820,7 @@ irc_config_check_gnutls_priorities (const char *priorities)
gnutls_priority_t priority_cache;
const char *pos_error;
int rc;
if (!priorities || !priorities[0])
return NULL;
@@ -850,10 +850,10 @@ irc_config_server_check_value_cb (void *data,
{
int index_option;
const char *pos_error;
/* make C compiler happy */
(void) option;
index_option = irc_server_search_option (data);
if (index_option >= 0)
{
@@ -873,7 +873,7 @@ irc_config_server_check_value_cb (void *data,
break;
}
}
return 1;
}
@@ -887,7 +887,7 @@ irc_config_server_change_cb (void *data, struct t_config_option *option)
int index_option;
char *name;
struct t_irc_server *ptr_server;
index_option = irc_server_search_option (data);
if (index_option >= 0)
{
@@ -938,10 +938,10 @@ irc_config_server_default_check_notify (void *data,
/* make C compiler happy */
(void) data;
(void) option;
if (value && value[0])
return 0;
return 1;
}
@@ -954,26 +954,26 @@ irc_config_reload (void *data, struct t_config_file *config_file)
{
int rc;
struct t_irc_server *ptr_server, *next_server;
/* make C compiler happy */
(void) data;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
ptr_server->reloading_from_config = 1;
ptr_server->reloaded_from_config = 0;
}
irc_ignore_free_all ();
rc = weechat_config_reload (config_file);
ptr_server = irc_servers;
while (ptr_server)
{
next_server = ptr_server->next_server;
if (!ptr_server->reloaded_from_config)
{
if (ptr_server->is_connected)
@@ -988,10 +988,10 @@ irc_config_reload (void *data, struct t_config_file *config_file)
else
irc_server_free (ptr_server);
}
ptr_server = next_server;
}
return rc;
}
@@ -1007,12 +1007,12 @@ irc_config_msgbuffer_create_option (void *data,
{
struct t_config_option *ptr_option;
int rc;
/* make C compiler happy */
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (option_name)
{
ptr_option = weechat_config_search_option (config_file, section,
@@ -1045,7 +1045,7 @@ irc_config_msgbuffer_create_option (void *data,
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
@@ -1053,7 +1053,7 @@ irc_config_msgbuffer_create_option (void *data,
weechat_prefix ("error"), IRC_PLUGIN_NAME,
option_name, value);
}
return rc;
}
@@ -1071,12 +1071,12 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
const char *default_value;
static char empty_value[1] = { '\0' };
const char *pos_name;
/* make C compiler happy */
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (option_name)
{
ptr_option = weechat_config_search_option (config_file, section,
@@ -1097,11 +1097,11 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
{
pos_name = strchr (option_name, '.');
pos_name = (pos_name) ? pos_name + 1 : option_name;
default_value = irc_ctcp_get_default_reply (pos_name);
if (!default_value)
default_value = empty_value;
ptr_option = weechat_config_new_option (
config_file, section,
option_name, "string",
@@ -1124,7 +1124,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
@@ -1132,7 +1132,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
weechat_prefix ("error"), IRC_PLUGIN_NAME,
option_name, value);
}
return rc;
}
@@ -1149,12 +1149,12 @@ irc_config_ignore_read_cb (void *data,
{
char **argv, **argv_eol;
int argc;
/* make C compiler happy */
(void) data;
(void) config_file;
(void) section;
if (option_name)
{
if (value && value[0])
@@ -1171,7 +1171,7 @@ irc_config_ignore_read_cb (void *data,
weechat_string_free_split (argv_eol);
}
}
return 1;
}
@@ -1184,13 +1184,13 @@ irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
const char *section_name)
{
struct t_irc_ignore *ptr_ignore;
/* make C compiler happy */
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
@@ -1202,7 +1202,7 @@ irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
ptr_ignore->mask))
return WEECHAT_CONFIG_WRITE_ERROR;
}
return WEECHAT_CONFIG_WRITE_OK;
}
@@ -1218,13 +1218,13 @@ irc_config_server_write_default_cb (void *data,
{
int i;
char option_name[128];
/* make C compiler happy */
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
{
snprintf (option_name, sizeof (option_name),
@@ -1246,7 +1246,7 @@ irc_config_server_write_default_cb (void *data,
break;
}
}
return WEECHAT_CONFIG_WRITE_OK;
}
@@ -1271,9 +1271,9 @@ irc_config_server_new_option (struct t_config_file *config_file,
void *callback_change_data)
{
struct t_config_option *new_option;
new_option = NULL;
switch (index_option)
{
case IRC_SERVER_OPTION_ADDRESSES:
@@ -1701,7 +1701,7 @@ irc_config_server_new_option (struct t_config_file *config_file,
case IRC_SERVER_NUM_OPTIONS:
break;
}
return new_option;
}
@@ -1717,14 +1717,14 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
struct t_irc_server *ptr_server;
int index_option, rc, i;
char *pos_option, *server_name;
/* make C compiler happy */
(void) data;
(void) config_file;
(void) section;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (option_name)
{
pos_option = strrchr (option_name, '.');
@@ -1769,7 +1769,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
}
}
}
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
@@ -1777,7 +1777,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
weechat_prefix ("error"), IRC_PLUGIN_NAME,
option_name);
}
return rc;
}
@@ -1791,13 +1791,13 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
{
struct t_irc_server *ptr_server;
int i;
/* make C compiler happy */
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -1811,7 +1811,7 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
}
}
}
return WEECHAT_CONFIG_WRITE_OK;
}
@@ -1825,11 +1825,11 @@ irc_config_server_create_default_options (struct t_config_section *section)
int i, length;
char *nicks, *username, *realname, *default_value;
struct passwd *my_passwd;
nicks = NULL;
username = NULL;
realname = strdup ("");
/* Get the user's name from /etc/passwd */
if ((my_passwd = getpwuid (geteuid ())) != NULL)
{
@@ -1852,7 +1852,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
nicks = strdup (IRC_SERVER_DEFAULT_NICKS);
username = strdup ("weechat");
}
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
{
default_value = NULL;
@@ -1870,7 +1870,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
}
if (!default_value)
default_value = irc_server_option_default[i];
irc_config_server_default[i] = irc_config_server_new_option (
irc_config_file,
section,
@@ -1884,7 +1884,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
&irc_config_server_default_change_cb,
irc_server_option_string[i]);
}
if (nicks)
free (nicks);
if (username)
@@ -1902,7 +1902,7 @@ int
irc_config_init ()
{
struct t_config_section *ptr_section;
irc_config_hashtable_nick_color_force = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -1913,12 +1913,12 @@ irc_config_init ()
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
irc_config_file = weechat_config_new (IRC_CONFIG_NAME,
&irc_config_reload, NULL);
if (!irc_config_file)
return 0;
/* look */
ptr_section = weechat_config_new_section (irc_config_file, "look",
0, 0,
@@ -2216,7 +2216,7 @@ irc_config_init ()
N_("strip colors in topic (used only when displaying buffer title)"),
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
&irc_config_change_look_topic_strip_colors, NULL, NULL, NULL);
/* color */
ptr_section = weechat_config_new_section (irc_config_file, "color",
0, 0,
@@ -2228,7 +2228,7 @@ irc_config_init ()
weechat_config_free (irc_config_file);
return 0;
}
irc_config_color_message_join = weechat_config_new_option (
irc_config_file, ptr_section,
"message_join", "color",
@@ -2321,7 +2321,7 @@ irc_config_init ()
N_("color for new channel topic (when topic is changed)"),
NULL, -1, 0, "white", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
/* network */
ptr_section = weechat_config_new_section (irc_config_file, "network",
0, 0,
@@ -2333,7 +2333,7 @@ irc_config_init ()
weechat_config_free (irc_config_file);
return 0;
}
irc_config_network_autoreconnect_delay_growing = weechat_config_new_option (
irc_config_file, ptr_section,
"autoreconnect_delay_growing", "integer",
@@ -2404,7 +2404,7 @@ irc_config_init ()
"(in minutes)"),
NULL, 1, 60 * 24 * 7, "5", NULL, 0, NULL, NULL,
&irc_config_change_network_notify_check_whois, NULL, NULL, NULL);
/* msgbuffer */
ptr_section = weechat_config_new_section (irc_config_file, "msgbuffer",
1, 1,
@@ -2418,7 +2418,7 @@ irc_config_init ()
return 0;
}
irc_config_section_msgbuffer = ptr_section;
/* CTCP */
ptr_section = weechat_config_new_section (irc_config_file, "ctcp",
1, 1,
@@ -2432,7 +2432,7 @@ irc_config_init ()
return 0;
}
irc_config_section_ctcp = ptr_section;
/* ignore */
ptr_section = weechat_config_new_section (irc_config_file, "ignore",
0, 0,
@@ -2445,7 +2445,7 @@ irc_config_init ()
weechat_config_free (irc_config_file);
return 0;
}
/* server_default */
ptr_section = weechat_config_new_section (irc_config_file, "server_default",
0, 0,
@@ -2458,9 +2458,9 @@ irc_config_init ()
return 0;
}
irc_config_section_server_default = ptr_section;
irc_config_server_create_default_options (ptr_section);
/* server */
ptr_section = weechat_config_new_section (irc_config_file, "server",
0, 0,
@@ -2475,10 +2475,10 @@ irc_config_init ()
return 0;
}
irc_config_section_server = ptr_section;
irc_config_hook_config_nick_colors = weechat_hook_config ("weechat.color.chat_nick_colors",
&irc_config_change_nick_colors_cb, NULL);
return 1;
}
@@ -2490,7 +2490,7 @@ int
irc_config_read ()
{
int rc;
rc = weechat_config_read (irc_config_file);
if (rc == WEECHAT_CONFIG_READ_OK)
{
@@ -2511,7 +2511,7 @@ int
irc_config_write (int write_temp_servers)
{
irc_config_write_temp_servers = write_temp_servers;
return weechat_config_write (irc_config_file);
}
@@ -2523,7 +2523,7 @@ void
irc_config_free ()
{
weechat_config_free (irc_config_file);
if (irc_config_hook_config_nick_colors)
{
weechat_unhook (irc_config_hook_config_nick_colors);
@@ -2535,13 +2535,13 @@ irc_config_free ()
irc_config_nick_colors = NULL;
irc_config_num_nick_colors = 0;
}
if (irc_config_hashtable_nick_color_force)
{
weechat_hashtable_free (irc_config_hashtable_nick_color_force);
irc_config_hashtable_nick_color_force = NULL;
}
if (irc_config_hashtable_nick_prefixes)
{
weechat_hashtable_free (irc_config_hashtable_nick_prefixes);
+78 -78
View File
@@ -59,13 +59,13 @@ const char *
irc_ctcp_get_default_reply (const char *ctcp)
{
int i;
for (i = 0; irc_ctcp_default_reply[i].name; i++)
{
if (weechat_strcasecmp (irc_ctcp_default_reply[i].name, ctcp) == 0)
return irc_ctcp_default_reply[i].reply;
}
/* unknown CTCP */
return NULL;
}
@@ -81,21 +81,21 @@ irc_ctcp_get_reply (struct t_irc_server *server, const char *ctcp)
char option_name[512];
snprintf (option_name, sizeof (option_name), "%s.%s", server->name, ctcp);
/* search for CTCP in config file, for server */
ptr_option = weechat_config_search_option (irc_config_file,
irc_config_section_ctcp,
option_name);
if (ptr_option)
return weechat_config_string (ptr_option);
/* search for CTCP in config file */
ptr_option = weechat_config_search_option (irc_config_file,
irc_config_section_ctcp,
ctcp);
if (ptr_option)
return weechat_config_string (ptr_option);
/*
* no CTCP reply found in config, then return default reply, or NULL
* for unknown CTCP
@@ -119,7 +119,7 @@ irc_ctcp_display_request (struct t_irc_server *server,
if (reply && !reply[0]
&& !weechat_config_boolean (irc_config_look_display_ctcp_blocked))
return;
weechat_printf_tags ((channel) ? channel->buffer : server->buffer,
irc_protocol_tags (command, "irc_ctcp", NULL),
_("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"),
@@ -147,13 +147,13 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
char *pos_end, *pos_space, *pos_args, *pos_usec;
struct timeval tv;
long sec1, usec1, sec2, usec2, difftime;
while (arguments && arguments[0])
{
pos_end = strchr (arguments + 1, '\01');
if (pos_end)
pos_end[0] = '\0';
pos_space = strchr (arguments + 1, ' ');
if (pos_space)
{
@@ -169,16 +169,16 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
if (pos_usec)
{
pos_usec[0] = '\0';
gettimeofday (&tv, NULL);
sec1 = atol (pos_args);
usec1 = atol (pos_usec + 1);
sec2 = tv.tv_sec;
usec2 = tv.tv_usec;
difftime = ((sec2 * 1000000) + usec2) -
((sec1 * 1000000) + usec1);
weechat_printf_tags (server->buffer,
irc_protocol_tags (command,
"irc_ctcp",
@@ -196,7 +196,7 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
(difftime % 1000000) / 1000,
(NG_("second", "seconds",
(difftime / 1000000))));
pos_usec[0] = ' ';
}
}
@@ -234,10 +234,10 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
"",
"");
}
if (pos_end)
pos_end[0] = '\01';
arguments = (pos_end) ? pos_end + 1 : NULL;
}
}
@@ -257,7 +257,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
int number;
char hash_key[32];
const char *str_args;
hashtable = irc_server_sendf (server,
IRC_SERVER_SEND_OUTQ_PRIO_LOW | IRC_SERVER_SEND_RETURN_HASHTABLE,
NULL,
@@ -265,7 +265,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
nick, ctcp,
(arguments) ? " " : "",
(arguments) ? arguments : "");
if (hashtable)
{
if (weechat_config_boolean (irc_config_look_display_ctcp_reply))
@@ -311,7 +311,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
time_t now;
char buf[1024];
struct utsname *buf_uname;
/* clientinfo */
temp = weechat_string_replace (format, "$clientinfo",
"ACTION DCC CLIENTINFO FINGER PING SOURCE "
@@ -319,7 +319,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* version */
info = weechat_info_get ("version", "");
temp = weechat_string_replace (res, "$version", info);
@@ -327,7 +327,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* compilation date */
info = weechat_info_get ("date", "");
temp = weechat_string_replace (res, "$compilation", info);
@@ -335,7 +335,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* info about OS */
buf_uname = (struct utsname *)malloc (sizeof (struct utsname));
if (buf_uname && (uname (buf_uname) >= 0))
@@ -350,7 +350,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
return NULL;
res = temp;
}
/* site */
info = weechat_info_get ("weechat_site", "");
temp = weechat_string_replace (res, "$site", info);
@@ -358,7 +358,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* site (download page) */
info = weechat_info_get ("weechat_site_download", "");
temp = weechat_string_replace (res, "$download", info);
@@ -366,7 +366,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* time */
now = time (NULL);
snprintf (buf, sizeof (buf), "%s", ctime (&now));
@@ -376,7 +376,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* username */
temp = weechat_string_replace (res, "$username",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME));
@@ -384,7 +384,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* realname */
temp = weechat_string_replace (res, "$realname",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME));
@@ -392,7 +392,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
if (!temp)
return NULL;
res = temp;
/* return result */
return res;
}
@@ -429,10 +429,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
struct t_infolist *infolist;
struct t_infolist_item *item;
char charset_modifier[256];
if (!arguments || !arguments[0])
return;
if (strncmp (arguments, "SEND ", 5) == 0)
{
arguments += 5;
@@ -441,7 +441,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
arguments++;
}
dcc_args = strdup (arguments);
if (!dcc_args)
{
weechat_printf (server->buffer,
@@ -451,14 +451,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
IRC_PLUGIN_NAME, "privmsg");
return;
}
/* DCC filename */
pos_file = dcc_args;
while (pos_file[0] == ' ')
{
pos_file++;
}
/* look for file size */
pos_size = strrchr (pos_file, ' ');
if (!pos_size)
@@ -470,7 +470,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
free (dcc_args);
return;
}
pos = pos_size;
pos_size++;
while (pos[0] == ' ')
@@ -478,7 +478,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
pos--;
}
pos[1] = '\0';
/* look for DCC port */
pos_port = strrchr (pos_file, ' ');
if (!pos_port)
@@ -490,7 +490,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
free (dcc_args);
return;
}
pos = pos_port;
pos_port++;
while (pos[0] == ' ')
@@ -498,7 +498,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
pos--;
}
pos[1] = '\0';
/* look for DCC IP address */
pos_addr = strrchr (pos_file, ' ');
if (!pos_addr)
@@ -510,7 +510,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
free (dcc_args);
return;
}
pos = pos_addr;
pos_addr++;
while (pos[0] == ' ')
@@ -518,10 +518,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
pos--;
}
pos[1] = '\0';
/* remove double quotes around filename */
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
/* add DCC file via xfer plugin */
infolist = weechat_infolist_new ();
if (infolist)
@@ -548,14 +548,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
}
weechat_infolist_free (infolist);
}
weechat_hook_signal_send ("irc_dcc",
WEECHAT_HOOK_SIGNAL_STRING,
message);
if (filename)
free (filename);
free (dcc_args);
}
else if (strncmp (arguments, "RESUME ", 7) == 0)
@@ -566,7 +566,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
arguments++;
}
dcc_args = strdup (arguments);
if (!dcc_args)
{
weechat_printf (server->buffer,
@@ -576,14 +576,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
IRC_PLUGIN_NAME, "privmsg");
return;
}
/* DCC filename */
pos_file = dcc_args;
while (pos_file[0] == ' ')
{
pos_file++;
}
/* look for resume start position */
pos_start_resume = strrchr (pos_file, ' ');
if (!pos_start_resume)
@@ -602,7 +602,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
pos--;
}
pos[1] = '\0';
/* look for DCC port */
pos_port = strrchr (pos_file, ' ');
if (!pos_port)
@@ -621,10 +621,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
pos--;
}
pos[1] = '\0';
/* remove double quotes around filename */
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
/* accept resume via xfer plugin */
infolist = weechat_infolist_new ();
if (infolist)
@@ -645,14 +645,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
}
weechat_infolist_free (infolist);
}
weechat_hook_signal_send ("irc_dcc",
WEECHAT_HOOK_SIGNAL_STRING,
message);
if (filename)
free (filename);
free (dcc_args);
}
else if (strncmp (arguments, "ACCEPT ", 7) == 0)
@@ -663,7 +663,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
arguments++;
}
dcc_args = strdup (arguments);
if (!dcc_args)
{
weechat_printf (server->buffer,
@@ -673,14 +673,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
"privmsg");
return;
}
/* DCC filename */
pos_file = dcc_args;
while (pos_file[0] == ' ')
{
pos_file++;
}
/* look for resume start position */
pos_start_resume = strrchr (pos_file, ' ');
if (!pos_start_resume)
@@ -699,7 +699,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
pos--;
}
pos[1] = '\0';
/* look for DCC port */
pos_port = strrchr (pos_file, ' ');
if (!pos_port)
@@ -718,10 +718,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
pos--;
}
pos[1] = '\0';
/* remove double quotes around filename */
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
/* resume file via xfer plugin */
infolist = weechat_infolist_new ();
if (infolist)
@@ -742,14 +742,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
}
weechat_infolist_free (infolist);
}
weechat_hook_signal_send ("irc_dcc",
WEECHAT_HOOK_SIGNAL_STRING,
message);
if (filename)
free (filename);
free (dcc_args);
}
else if (strncmp (arguments, "CHAT ", 5) == 0)
@@ -760,7 +760,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
arguments++;
}
dcc_args = strdup (arguments);
if (!dcc_args)
{
weechat_printf (server->buffer,
@@ -770,14 +770,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
"privmsg");
return;
}
/* CHAT type */
pos_file = dcc_args;
while (pos_file[0] == ' ')
{
pos_file++;
}
/* DCC IP address */
pos_addr = strchr (pos_file, ' ');
if (!pos_addr)
@@ -795,7 +795,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
{
pos_addr++;
}
/* look for DCC port */
pos_port = strchr (pos_addr, ' ');
if (!pos_port)
@@ -813,7 +813,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
{
pos_port++;
}
if (weechat_strcasecmp (pos_file, "chat") != 0)
{
weechat_printf (server->buffer,
@@ -828,7 +828,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
free (dcc_args);
return;
}
/* add DCC chat via xfer plugin */
infolist = weechat_infolist_new ();
if (infolist)
@@ -854,11 +854,11 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
}
weechat_infolist_free (infolist);
}
weechat_hook_signal_send ("irc_dcc",
WEECHAT_HOOK_SIGNAL_STRING,
message);
free (dcc_args);
}
}
@@ -879,13 +879,13 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
int nick_is_me;
while (arguments && arguments[0])
{
pos_end = strrchr (arguments + 1, '\01');
if (pos_end)
pos_end[0] = '\0';
pos_args = NULL;
pos_space = strchr (arguments + 1, ' ');
if (pos_space)
@@ -897,14 +897,14 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
pos_args++;
}
}
/* CTCP ACTION */
if (strcmp (arguments + 1, "ACTION") == 0)
{
if (channel)
{
ptr_nick = irc_nick_search (channel, nick);
irc_channel_nick_speaking_add (channel,
nick,
(pos_args) ?
@@ -913,7 +913,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
irc_channel_nick_speaking_time_remove_old (channel);
irc_channel_nick_speaking_time_add (channel, nick,
time (NULL));
weechat_printf_tags (channel->buffer,
irc_protocol_tags (command,
"irc_action,notify_message",
@@ -948,7 +948,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
{
if (!ptr_channel->topic)
irc_channel_set_topic (ptr_channel, address);
weechat_printf_tags (ptr_channel->buffer,
irc_protocol_tags (command,
(nick_is_me) ?
@@ -994,7 +994,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
{
irc_ctcp_display_request (server, command, channel, nick,
arguments + 1, pos_args, reply);
if (reply[0])
{
decoded_reply = irc_ctcp_replace_variables (server, reply);
@@ -1028,17 +1028,17 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
}
}
}
weechat_hook_signal_send ("irc_ctcp",
WEECHAT_HOOK_SIGNAL_STRING,
message);
if (pos_space)
pos_space[0] = ' ';
if (pos_end)
pos_end[0] = '\01';
arguments = (pos_end) ? pos_end + 1 : NULL;
}
}
+4 -4
View File
@@ -44,23 +44,23 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data
|| (weechat_strcasecmp ((char *)signal_data, IRC_PLUGIN_NAME) == 0))
{
weechat_log_printf ("");
weechat_log_printf ("***** \"%s\" plugin dump *****",
weechat_plugin->name);
irc_server_print_log ();
irc_ignore_print_log ();
irc_redirect_pattern_print_log ();
weechat_log_printf ("");
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
weechat_plugin->name);
}
return WEECHAT_RC_OK;
}
+3 -3
View File
@@ -46,7 +46,7 @@ irc_display_hide_password (char *string, int look_for_nickserv)
{
char *pos_nickserv, *pos, *pos_pwd, *pos_space;
int char_size;
pos = string;
while (pos)
{
@@ -110,7 +110,7 @@ irc_display_hide_password (char *string, int look_for_nickserv)
{
pos_pwd++;
}
while (pos_pwd && pos_pwd[0] && (pos_pwd[0] != ' '))
{
char_size = weechat_utf8_char_size (pos_pwd);
@@ -132,7 +132,7 @@ irc_display_away (struct t_irc_server *server, const char *string1,
const char *string2)
{
struct t_irc_channel *ptr_channel;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
+36 -36
View File
@@ -46,17 +46,17 @@ int
irc_ignore_valid (struct t_irc_ignore *ignore)
{
struct t_irc_ignore *ptr_ignore;
if (!ignore)
return 0;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
if (ptr_ignore == ignore)
return 1;
}
/* ignore not found */
return 0;
}
@@ -70,12 +70,12 @@ irc_ignore_search (const char *mask, const char *server, const char *channel)
{
struct t_irc_ignore *ptr_ignore;
char any[2] = "*";
if (!server)
server = any;
if (!channel)
channel = any;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
@@ -86,7 +86,7 @@ irc_ignore_search (const char *mask, const char *server, const char *channel)
return ptr_ignore;
}
}
/* ignore not found */
return NULL;
}
@@ -99,14 +99,14 @@ struct t_irc_ignore *
irc_ignore_search_by_number (int number)
{
struct t_irc_ignore *ptr_ignore;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
if (ptr_ignore->number == number)
return ptr_ignore;
}
/* ignore not found */
return NULL;
}
@@ -121,14 +121,14 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
struct t_irc_ignore *new_ignore;
regex_t *regex;
char *complete_mask;
if (!mask || !mask[0])
return NULL;
complete_mask = malloc (1 + strlen (mask) + 1 + 1);
if (!complete_mask)
return NULL;
if (mask[0] == '^')
strcpy (complete_mask, mask);
else
@@ -145,14 +145,14 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
free (complete_mask);
return NULL;
}
if (regcomp (regex, complete_mask, REG_NOSUB | REG_ICASE) != 0)
{
free (regex);
free (complete_mask);
return NULL;
}
new_ignore = malloc (sizeof (*new_ignore));
if (new_ignore)
{
@@ -161,7 +161,7 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
new_ignore->regex_mask = regex;
new_ignore->server = (server) ? strdup (server) : strdup ("*");
new_ignore->channel = (channel) ? strdup (channel) : strdup ("*");
/* add ignore to ignore list */
new_ignore->prev_ignore = last_irc_ignore;
if (irc_ignore_list)
@@ -171,9 +171,9 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
last_irc_ignore = new_ignore;
new_ignore->next_ignore = NULL;
}
free (complete_mask);
return new_ignore;
}
@@ -190,29 +190,29 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
{
struct t_irc_ignore *ptr_ignore;
int server_match, channel_match;
if (!server)
return 0;
/*
* if nick is the same as server, then we will not ignore
* (it is possible when connected to an irc proxy)
*/
if (nick && server->nick && (strcmp (server->nick, nick) == 0))
return 0;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
server_match = 0;
channel_match = 0;
if (!server || (strcmp (ptr_ignore->server, "*") == 0))
server_match = 1;
else
server_match = (weechat_strcasecmp (ptr_ignore->server,
server->name) == 0);
if (!channel || (strcmp (ptr_ignore->channel, "*") == 0))
channel_match = 1;
else
@@ -228,7 +228,7 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
nick) == 0);
}
}
if (server_match && channel_match)
{
if (nick && (regexec (ptr_ignore->regex_mask, nick, 0, NULL, 0) == 0))
@@ -237,7 +237,7 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
return 1;
}
}
return 0;
}
@@ -249,17 +249,17 @@ void
irc_ignore_free (struct t_irc_ignore *ignore)
{
struct t_irc_ignore *ptr_ignore;
weechat_hook_signal_send ("irc_ignore_removing",
WEECHAT_HOOK_SIGNAL_POINTER, ignore);
/* decrement number for all ignore after this one */
for (ptr_ignore = ignore->next_ignore; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
ptr_ignore->number--;
}
/* free data */
if (ignore->mask)
free (ignore->mask);
@@ -272,7 +272,7 @@ irc_ignore_free (struct t_irc_ignore *ignore)
free (ignore->server);
if (ignore->channel)
free (ignore->channel);
/* remove ignore from list */
if (ignore->prev_ignore)
(ignore->prev_ignore)->next_ignore = ignore->next_ignore;
@@ -282,9 +282,9 @@ irc_ignore_free (struct t_irc_ignore *ignore)
irc_ignore_list = ignore->next_ignore;
if (last_irc_ignore == ignore)
last_irc_ignore = ignore->prev_ignore;
free (ignore);
weechat_hook_signal_send ("irc_ignore_removed",
WEECHAT_HOOK_SIGNAL_STRING, NULL);
}
@@ -310,10 +310,10 @@ struct t_hdata *
irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_ignore", "next_ignore");
if (hdata)
{
@@ -340,21 +340,21 @@ irc_ignore_add_to_infolist (struct t_infolist *infolist,
struct t_irc_ignore *ignore)
{
struct t_infolist_item *ptr_item;
if (!infolist || !ignore)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "mask", ignore->mask))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "server", ignore->server))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "channel", ignore->channel))
return 0;
return 1;
}
@@ -366,7 +366,7 @@ void
irc_ignore_print_log ()
{
struct t_irc_ignore *ptr_ignore;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
ptr_ignore = ptr_ignore->next_ignore)
{
+1 -1
View File
@@ -56,5 +56,5 @@ extern struct t_hdata *irc_ignore_hdata_ignore_cb (void *data,
extern int irc_ignore_add_to_infolist (struct t_infolist *infolist,
struct t_irc_ignore *ignore);
extern void irc_ignore_print_log ();
#endif /* __WEECHAT_IRC_IGNORE_H */
+24 -24
View File
@@ -74,10 +74,10 @@ irc_info_get_info_cb (void *data, const char *info_name,
static char str_true[2] = "1";
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
/* make C compiler happy */
(void) data;
if (weechat_strcasecmp (info_name, "irc_is_channel") == 0)
{
if (irc_channel_is_channel (arguments))
@@ -118,7 +118,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
host = NULL;
ptr_server = NULL;
ptr_channel = NULL;
pos_comma = strchr (arguments, ',');
if (pos_comma)
{
@@ -140,7 +140,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
else
server = strdup (arguments);
}
/*
* replace channel by nick in host if channel is not a channel
* (private ?)
@@ -154,10 +154,10 @@ irc_info_get_info_cb (void *data, const char *info_name,
nick = irc_message_get_nick_from_host (host);
if (nick)
channel = strdup (nick);
}
}
/* search for server or channel buffer */
if (server)
{
@@ -165,14 +165,14 @@ irc_info_get_info_cb (void *data, const char *info_name,
if (ptr_server && channel)
ptr_channel = irc_channel_search (ptr_server, channel);
}
if (server)
free (server);
if (channel)
free (channel);
if (host)
free (host);
if (ptr_channel)
{
irc_info_create_string_with_pointer (&ptr_channel->buffer_as_string,
@@ -227,7 +227,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
}
return isupport_value;
}
return NULL;
}
@@ -243,13 +243,13 @@ irc_info_get_info_hashtable_cb (void *data, const char *info_name,
const char *server, *message;
struct t_irc_server *ptr_server;
struct t_hashtable *value;
/* make C compiler happy */
(void) data;
if (!hashtable)
return NULL;
if (weechat_strcasecmp (info_name, "irc_message_parse") == 0)
{
message = weechat_hashtable_get (hashtable, "message");
@@ -270,7 +270,7 @@ irc_info_get_info_hashtable_cb (void *data, const char *info_name,
return value;
}
}
return NULL;
}
@@ -290,18 +290,18 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
struct t_irc_notify *ptr_notify;
char **argv;
int argc;
/* make C compiler happy */
(void) data;
if (!infolist_name || !infolist_name[0])
return NULL;
if (weechat_strcasecmp (infolist_name, "irc_server") == 0)
{
if (pointer && !irc_server_valid (pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (ptr_infolist)
{
@@ -367,7 +367,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
{
if (pointer && !irc_channel_valid (ptr_server, pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (ptr_infolist)
{
@@ -441,7 +441,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
{
if (pointer && !irc_nick_valid (ptr_channel, pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (ptr_infolist)
{
@@ -480,7 +480,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
{
if (pointer && !irc_ignore_valid (pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (ptr_infolist)
{
@@ -514,7 +514,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
{
if (pointer && !irc_notify_valid (NULL, pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (ptr_infolist)
{
@@ -553,7 +553,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
}
}
}
return NULL;
}
@@ -601,7 +601,7 @@ irc_info_init ()
N_("value of feature, if supported by server (from IRC message 005)"),
N_("server,feature"),
&irc_info_get_info_cb, NULL);
/* info_hashtable hooks */
weechat_hook_info_hashtable ("irc_message_parse",
N_("parse an IRC message"),
@@ -622,7 +622,7 @@ irc_info_init ()
"messages, "
"\"count\": number of messages"),
&irc_info_get_info_hashtable_cb, NULL);
/* infolist hooks */
weechat_hook_infolist ("irc_server",
N_("list of IRC servers"),
+26 -26
View File
@@ -46,19 +46,19 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
{
struct t_irc_nick *ptr_nick;
char *text_decoded;
text_decoded = irc_color_decode (text,
weechat_config_boolean (irc_config_network_colors_send));
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
if (ptr_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
ptr_nick = irc_nick_search (ptr_channel, ptr_server->nick);
else
ptr_nick = NULL;
weechat_printf_tags (buffer,
irc_protocol_tags ("privmsg",
"notify_none,no_highlight",
@@ -70,7 +70,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
IRC_COLOR_CHAT_NICK_SELF),
(text_decoded) ? text_decoded : text);
}
if (text_decoded)
free (text_decoded);
}
@@ -89,12 +89,12 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
int number;
char hash_key[32], *str_args;
struct t_hashtable *hashtable;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_channel || !message || !message[0])
return;
if (!ptr_server->is_connected)
{
weechat_printf (buffer,
@@ -132,9 +132,9 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
{
const char *ptr_data;
char *data_with_colors, *msg;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
if (buffer == irc_raw_buffer)
{
if (weechat_strcasecmp (input_data, "q") == 0)
@@ -156,7 +156,7 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
}
return WEECHAT_RC_OK;
}
if (ptr_channel)
{
ptr_data = weechat_string_input_for_buffer (input_data);
@@ -164,14 +164,14 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
ptr_data = input_data;
data_with_colors = irc_color_encode (ptr_data,
weechat_config_boolean (irc_config_network_colors_send));
msg = strdup ((data_with_colors) ? data_with_colors : ptr_data);
if (msg)
{
irc_input_send_user_message (buffer, flags, NULL, msg);
free (msg);
}
if (data_with_colors)
free (data_with_colors);
}
@@ -182,7 +182,7 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
weechat_prefix ("error"), IRC_PLUGIN_NAME);
}
}
return WEECHAT_RC_OK;
}
@@ -196,7 +196,7 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
{
/* make C compiler happy */
(void) data;
return irc_input_data (buffer, input_data, IRC_SERVER_SEND_OUTQ_PRIO_HIGH);
}
@@ -226,14 +226,14 @@ irc_input_send_cb (void *data, const char *signal,
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
ptr_string = (const char *)signal_data;
server = NULL;
channel = NULL;
flags = NULL;
@@ -241,7 +241,7 @@ irc_input_send_cb (void *data, const char *signal,
ptr_message = NULL;
ptr_server = NULL;
ptr_channel = NULL;
pos_semicol1 = strchr (ptr_string, ';');
if (pos_semicol1)
{
@@ -278,7 +278,7 @@ irc_input_send_cb (void *data, const char *signal,
}
}
}
flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
if (flags)
{
@@ -287,7 +287,7 @@ irc_input_send_cb (void *data, const char *signal,
if (flags_value < 0)
flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
}
if (server && ptr_message)
{
ptr_server = irc_server_search (server);
@@ -300,10 +300,10 @@ irc_input_send_cb (void *data, const char *signal,
if (ptr_channel)
ptr_buffer = ptr_channel->buffer;
}
/* set tags to use by default */
irc_server_set_send_default_tags (tags);
/* send text to buffer, or execute command */
if (weechat_string_input_for_buffer (ptr_message))
{
@@ -320,12 +320,12 @@ irc_input_send_cb (void *data, const char *signal,
if (data_with_colors)
free (data_with_colors);
}
/* reset tags to use by default */
irc_server_set_send_default_tags (NULL);
}
}
if (server)
free (server);
if (channel)
@@ -334,6 +334,6 @@ irc_input_send_cb (void *data, const char *signal,
free (flags);
if (tags)
free (tags);
return WEECHAT_RC_OK;
}
+55 -55
View File
@@ -41,7 +41,7 @@ irc_message_parse (const char *message, char **nick, char **host,
char **command, char **channel, char **arguments)
{
const char *pos, *pos2, *pos3, *pos4, *pos5;
if (nick)
*nick = NULL;
if (host)
@@ -52,10 +52,10 @@ irc_message_parse (const char *message, char **nick, char **host,
*channel = NULL;
if (arguments)
*arguments = NULL;
if (!message)
return;
/*
* we will use this message as example:
* :FlashCode!n=FlashCod@host.com PRIVMSG #channel :hello!
@@ -177,9 +177,9 @@ irc_message_parse_to_hashtable (const char *message)
char *nick, *host, *command, *channel, *arguments;
char empty_str[1] = { '\0' };
struct t_hashtable *hashtable;
irc_message_parse (message, &nick, &host, &command, &channel, &arguments);
hashtable = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -187,13 +187,13 @@ irc_message_parse_to_hashtable (const char *message)
NULL);
if (!hashtable)
return NULL;
weechat_hashtable_set (hashtable, "nick", (nick) ? nick : empty_str);
weechat_hashtable_set (hashtable, "host", (host) ? host : empty_str);
weechat_hashtable_set (hashtable, "command", (command) ? command : empty_str);
weechat_hashtable_set (hashtable, "channel", (channel) ? channel : empty_str);
weechat_hashtable_set (hashtable, "arguments", (arguments) ? arguments : empty_str);
if (nick)
free (nick);
if (host)
@@ -204,7 +204,7 @@ irc_message_parse_to_hashtable (const char *message)
free (channel);
if (arguments)
free (arguments);
return hashtable;
}
@@ -218,10 +218,10 @@ irc_message_get_nick_from_host (const char *host)
static char nick[128];
char host2[128], *pos_space, *pos;
const char *ptr_host;
if (!host)
return NULL;
nick[0] = '\0';
if (host)
{
@@ -238,10 +238,10 @@ irc_message_get_nick_from_host (const char *host)
snprintf (host2, sizeof (host2), "%s", host);
ptr_host = host2;
}
if (ptr_host[0] == ':')
ptr_host++;
pos = strchr (ptr_host, '!');
if (pos && (pos - ptr_host < (int)sizeof (nick)))
{
@@ -253,7 +253,7 @@ irc_message_get_nick_from_host (const char *host)
snprintf (nick, sizeof (nick), "%s", ptr_host);
}
}
return nick;
}
@@ -267,7 +267,7 @@ irc_message_get_address_from_host (const char *host)
static char address[256];
char host2[256], *pos_space, *pos;
const char *ptr_host;
address[0] = '\0';
if (host)
{
@@ -284,7 +284,7 @@ irc_message_get_address_from_host (const char *host)
snprintf (host2, sizeof (host2), "%s", host);
ptr_host = host2;
}
if (ptr_host[0] == ':')
ptr_host++;
pos = strchr (ptr_host, '!');
@@ -293,7 +293,7 @@ irc_message_get_address_from_host (const char *host)
else
snprintf (address, sizeof (address), "%s", ptr_host);
}
return address;
}
@@ -310,31 +310,31 @@ irc_message_replace_vars (struct t_irc_server *server,
char *var_nick, *var_channel, *var_server;
char empty_string[1] = { '\0' };
char *res, *temp;
var_nick = (server && server->nick) ? server->nick : empty_string;
var_channel = (channel) ? channel->name : empty_string;
var_server = (server) ? server->name : empty_string;
/* replace nick */
temp = weechat_string_replace (string, "$nick", var_nick);
if (!temp)
return NULL;
res = temp;
/* replace channel */
temp = weechat_string_replace (res, "$channel", var_channel);
free (res);
if (!temp)
return NULL;
res = temp;
/* replace server */
temp = weechat_string_replace (res, "$server", var_server);
free (res);
if (!temp)
return NULL;
res = temp;
/* return result */
return res;
}
@@ -348,7 +348,7 @@ irc_message_split_add (struct t_hashtable *hashtable, int number,
const char *message, const char *arguments)
{
char key[32], value[32];
if (message)
{
snprintf (key, sizeof (key), "msg%d", number);
@@ -398,7 +398,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
const char *pos, *pos_max, *pos_next, *pos_last_delim;
char message[1024], *dup_arguments;
int max_length, number;
/*
* Examples of arguments for this function:
*
@@ -420,7 +420,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
* arguments: "is eating"
* suffix : "\01"
*/
max_length = 510;
if (max_length_host >= 0)
max_length -= max_length_host;
@@ -433,10 +433,10 @@ irc_message_split_string (struct t_hashtable *hashtable,
max_length -= strlen (prefix);
if (suffix)
max_length -= strlen (suffix);
if (max_length < 2)
return 0;
/* debug message */
if (weechat_irc_plugin->debug >= 2)
{
@@ -447,9 +447,9 @@ irc_message_split_string (struct t_hashtable *hashtable,
host, command, target, prefix, arguments, suffix,
max_length);
}
number = 1;
if (!arguments || !arguments[0])
{
snprintf (message, sizeof (message), "%s%s%s %s%s%s%s",
@@ -463,7 +463,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
irc_message_split_add (hashtable, 1, message, "");
return 1;
}
while (arguments && arguments[0])
{
pos = arguments;
@@ -498,7 +498,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
}
arguments = (pos == pos_last_delim) ? pos + 1 : pos;
}
return 1;
}
@@ -516,14 +516,14 @@ irc_message_split_join (struct t_hashtable *hashtable,
int length_to_add, index_channel;
char **channels, **keys, *pos, *str;
char msg_to_send[2048], keys_to_add[2048];
number = 1;
channels = NULL;
channels_count = 0;
keys = NULL;
keys_count = 0;
pos = strchr (arguments, ' ');
if (pos)
{
@@ -543,7 +543,7 @@ irc_message_split_join (struct t_hashtable *hashtable,
{
channels = weechat_string_split (arguments, ",", 0, 0, &channels_count);
}
snprintf (msg_to_send, sizeof (msg_to_send), "%s%sJOIN",
(host) ? host : "",
(host) ? " " : "");
@@ -589,7 +589,7 @@ irc_message_split_join (struct t_hashtable *hashtable,
keys_to_add[0] = '\0';
}
}
if (length > length_no_channel)
{
strcat (msg_to_send, keys_to_add);
@@ -597,12 +597,12 @@ irc_message_split_join (struct t_hashtable *hashtable,
msg_to_send,
msg_to_send + length_no_channel + 1);
}
if (channels)
weechat_string_free_split (channels);
if (keys)
weechat_string_free_split (keys);
return 1;
}
@@ -620,7 +620,7 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
{
char prefix[512], suffix[2], *pos, saved_char;
int length, rc;
/*
* message sent looks like:
* PRIVMSG #channel :hello world!
@@ -628,7 +628,7 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
* when IRC server sends message to other people, message looks like:
* :nick!user@host.com PRIVMSG #channel :hello world!
*/
/* for CTCP, prefix will be ":\01xxxx " and suffix "\01" */
prefix[0] = '\0';
suffix[0] = '\0';
@@ -652,11 +652,11 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
}
if (!prefix[0])
strcpy (prefix, ":");
rc = irc_message_split_string (hashtable, host, command, target,
prefix, arguments, suffix,
' ', max_length_host);
return rc;
}
@@ -670,7 +670,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
char *host, char *command, char *target, char *arguments)
{
char *pos, suffix[512];
/*
* 005 message looks like:
* :server 005 mynick MODES=4 CHANLIMIT=#:20 NICKLEN=16 USERLEN=10
@@ -678,7 +678,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
* CHANTYPES=# PREFIX=(ov)@+ CASEMAPPING=ascii CAPAB IRCD=dancer
* :are available on this server
*/
/* search suffix */
suffix[0] = '\0';
pos = strstr (arguments, " :");
@@ -687,7 +687,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
snprintf (suffix, sizeof (suffix), "%s", pos);
pos[0] = '\0';
}
return irc_message_split_string (hashtable, host, command, target,
NULL, arguments, suffix, ' ', -1);
}
@@ -713,7 +713,7 @@ irc_message_split (struct t_irc_server *server, const char *message)
struct t_hashtable *hashtable;
char **argv, **argv_eol, *host, *command, *arguments, target[512];
int split_ok, argc, index_args, max_length_nick, max_length_host;
split_ok = 0;
host = NULL;
command = NULL;
@@ -721,11 +721,11 @@ irc_message_split (struct t_irc_server *server, const char *message)
index_args = 0;
argv = NULL;
argv_eol = NULL;
/* debug message */
if (weechat_irc_plugin->debug >= 2)
weechat_printf (NULL, "irc_message_split: message='%s'", message);
hashtable = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -733,16 +733,16 @@ irc_message_split (struct t_irc_server *server, const char *message)
NULL);
if (!hashtable)
return NULL;
if (!message || !message[0])
goto end;
argv = weechat_string_split (message, " ", 0, 0, &argc);
argv_eol = weechat_string_split (message, " ", 2, 0, NULL);
if (argc < 2)
goto end;
if (argv[0][0] == ':')
{
if (argc < 3)
@@ -758,7 +758,7 @@ irc_message_split (struct t_irc_server *server, const char *message)
arguments = argv_eol[1];
index_args = 1;
}
max_length_nick = (server && (server->nick_max_length > 0)) ?
server->nick_max_length : 16;
max_length_host = 1 + /* ":" */
@@ -841,18 +841,18 @@ irc_message_split (struct t_irc_server *server, const char *message)
}
}
}
end:
if (!split_ok
|| (weechat_hashtable_get_integer (hashtable, "items_count") == 0))
{
irc_message_split_add (hashtable, 1, message, arguments);
}
if (argv)
weechat_string_free_split (argv);
if (argv_eol)
weechat_string_free_split (argv_eol);
return hashtable;
}
+9 -9
View File
@@ -46,12 +46,12 @@ irc_mode_channel_set (struct t_irc_server *server,
char *pos_args, *str_modes, set_flag, **argv, *pos, *ptr_arg;
int modes_count, channel_modes_updated, argc, current_arg;
struct t_irc_nick *ptr_nick;
if (!server || !channel || !modes)
return 0;
channel_modes_updated = 0;
argc = 0;
argv = NULL;
pos_args = strchr (modes, ' ');
@@ -85,7 +85,7 @@ irc_mode_channel_set (struct t_irc_server *server,
pos++;
}
current_arg = argc - modes_count;
if (str_modes && str_modes[0])
{
set_flag = '+';
@@ -158,14 +158,14 @@ irc_mode_channel_set (struct t_irc_server *server,
pos++;
}
}
if (str_modes)
free (str_modes);
if (argv)
weechat_string_free_split (argv);
weechat_bar_item_update ("buffer_name");
return channel_modes_updated;
}
@@ -180,7 +180,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
str_mode[0] = mode;
str_mode[1] = '\0';
if (server->nick_modes)
{
if (!strchr (server->nick_modes, mode))
@@ -218,7 +218,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
{
char *pos, *nick_modes2;
int new_size;
if (server->nick_modes)
{
pos = strchr (server->nick_modes, mode);
+8 -8
View File
@@ -50,7 +50,7 @@ irc_msgbuffer_get_option (struct t_irc_server *server, const char *message)
{
snprintf (option_name, sizeof (option_name),
"%s.%s", server->name, message);
/* search for msgbuffer in config file, for server */
ptr_option = weechat_config_search_option (irc_config_file,
irc_config_section_msgbuffer,
@@ -58,14 +58,14 @@ irc_msgbuffer_get_option (struct t_irc_server *server, const char *message)
if (ptr_option)
return ptr_option;
}
/* search for msgbuffer in config file */
ptr_option = weechat_config_search_option (irc_config_file,
irc_config_section_msgbuffer,
message);
if (ptr_option)
return ptr_option;
/* no msgbuffer found in config */
return NULL;
}
@@ -92,18 +92,18 @@ irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick,
struct t_gui_buffer *ptr_buffer;
struct t_irc_channel *ptr_channel;
struct t_weechat_plugin *buffer_plugin;
ptr_option = irc_msgbuffer_get_option (server, message);
if (!ptr_option && alias && alias[0])
ptr_option = irc_msgbuffer_get_option (server, alias);
if (!ptr_option)
{
if (default_buffer)
return default_buffer;
return (server) ? server->buffer : NULL;
}
target = weechat_config_integer (ptr_option);
switch (target)
{
@@ -129,11 +129,11 @@ irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick,
return (server) ? server->buffer : NULL;
break;
}
ptr_buffer = weechat_current_buffer ();
buffer_plugin = weechat_buffer_get_pointer (ptr_buffer, "plugin");
if (buffer_plugin == weechat_irc_plugin)
return ptr_buffer;
return (server) ? server->buffer : NULL;
}
+92 -92
View File
@@ -47,16 +47,16 @@ int
irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick)
{
struct t_irc_nick *ptr_nick;
if (!channel)
return 0;
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
if (ptr_nick == nick)
return 1;
}
/* nick not found */
return 0;
}
@@ -71,22 +71,22 @@ int
irc_nick_is_nick (const char *string)
{
const char *ptr;
if (!string || !string[0])
return 0;
/* first char must not be a number or hyphen */
ptr = string;
if (strchr ("0123456789-", *ptr))
return 0;
while (ptr && ptr[0])
{
if (!strchr (IRC_NICK_VALID_CHARS, *ptr))
return 0;
ptr++;
}
return 1;
}
@@ -100,7 +100,7 @@ irc_nick_strdup_for_color (const char *nickname)
{
int char_size, other_char_seen;
char *result, *pos, utf_char[16];
result = malloc (strlen (nickname) + 1);
pos = result;
other_char_seen = 0;
@@ -109,7 +109,7 @@ irc_nick_strdup_for_color (const char *nickname)
char_size = weechat_utf8_char_size (nickname);
memcpy (utf_char, nickname, char_size);
utf_char[char_size] = '\0';
if (strstr (weechat_config_string (irc_config_look_nick_color_stop_chars),
utf_char))
{
@@ -125,7 +125,7 @@ irc_nick_strdup_for_color (const char *nickname)
}
memcpy (pos, utf_char, char_size);
pos += char_size;
nickname += char_size;
}
pos[0] = '\0';
@@ -141,13 +141,13 @@ irc_nick_hash_color (const char *nickname)
{
int color;
const char *ptr_nick;
if (!irc_config_nick_colors)
irc_config_set_nick_colors ();
if (irc_config_num_nick_colors == 0)
return 0;
color = 0;
ptr_nick = nickname;
while (ptr_nick && ptr_nick[0])
@@ -155,7 +155,7 @@ irc_nick_hash_color (const char *nickname)
color += weechat_utf8_char_int (ptr_nick);
ptr_nick = weechat_utf8_next_char (ptr_nick);
}
return (color % irc_config_num_nick_colors);
}
@@ -170,15 +170,15 @@ irc_nick_find_color (const char *nickname)
int color;
char *nickname2;
const char *forced_color, *str_color;
if (!irc_config_nick_colors)
irc_config_set_nick_colors ();
if (irc_config_num_nick_colors == 0)
return weechat_color ("default");
nickname2 = irc_nick_strdup_for_color (nickname);
/* look if color is forced */
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
(nickname2) ? nickname2 : nickname);
@@ -192,12 +192,12 @@ irc_nick_find_color (const char *nickname)
return forced_color;
}
}
/* hash nickname to get color */
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
if (nickname2)
free (nickname2);
/* return color */
str_color = weechat_color (irc_config_nick_colors[color]);
return (str_color[0]) ? str_color : weechat_color("default");
@@ -215,15 +215,15 @@ irc_nick_find_color_name (const char *nickname)
char *nickname2;
const char *forced_color;
static char *default_color = "default";
if (!irc_config_nick_colors)
irc_config_set_nick_colors ();
if (irc_config_num_nick_colors == 0)
return default_color;
nickname2 = irc_nick_strdup_for_color (nickname);
/* look if color is forced */
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
(nickname2) ? nickname2 : nickname);
@@ -233,12 +233,12 @@ irc_nick_find_color_name (const char *nickname)
free (nickname2);
return forced_color;
}
/* hash nickname to get color */
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
if (nickname2)
free (nickname2);
/* return color name */
return irc_config_nick_colors[color];
}
@@ -252,7 +252,7 @@ void
irc_nick_set_current_prefix (struct t_irc_nick *nick)
{
char *ptr_prefixes;
nick->prefix[0] = ' ';
for (ptr_prefixes = nick->prefixes; ptr_prefixes[0]; ptr_prefixes++)
{
@@ -275,7 +275,7 @@ irc_nick_set_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
int set, char prefix)
{
int index;
index = irc_server_get_prefix_char_index (server, prefix);
if (index >= 0)
{
@@ -293,10 +293,10 @@ irc_nick_set_prefixes (struct t_irc_server *server, struct t_irc_nick *nick,
const char *prefixes)
{
const char *ptr_prefixes;
/* reset all prefixes in nick */
memset (nick->prefixes, ' ', strlen (nick->prefixes));
/* add prefixes in nick */
if (prefixes)
{
@@ -305,7 +305,7 @@ irc_nick_set_prefixes (struct t_irc_server *server, struct t_irc_nick *nick,
irc_nick_set_prefix (server, nick, 1, ptr_prefixes[0]);
}
}
/* set current prefix */
irc_nick_set_current_prefix (nick);
}
@@ -319,14 +319,14 @@ int
irc_nick_is_op (struct t_irc_server *server, struct t_irc_nick *nick)
{
int index;
if (nick->prefix[0] == ' ')
return 0;
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
if (index < 0)
return 0;
return (index <= irc_server_get_prefix_mode_index (server, 'o')) ? 1 : 0;
}
@@ -342,11 +342,11 @@ irc_nick_has_prefix_mode (struct t_irc_server *server, struct t_irc_nick *nick,
char prefix_mode)
{
char prefix_char;
prefix_char = irc_server_get_prefix_char_for_mode (server, prefix_mode);
if (prefix_char == ' ')
return 0;
return (strchr (nick->prefixes, prefix_char)) ? 1 : 0;
}
@@ -363,10 +363,10 @@ irc_nick_get_nicklist_group (struct t_irc_server *server,
char str_group[2];
const char *prefix_modes;
struct t_gui_nick_group *ptr_group;
if (!server || !buffer || !nick)
return NULL;
ptr_group = NULL;
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
if (index < 0)
@@ -381,7 +381,7 @@ irc_nick_get_nicklist_group (struct t_irc_server *server,
str_group[1] = '\0';
ptr_group = weechat_nicklist_search_group (buffer, NULL, str_group);
}
return ptr_group;
}
@@ -397,7 +397,7 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server,
const char *prefix_modes, *color;
char mode[2];
int i, index;
if (irc_config_hashtable_nick_prefixes)
{
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
@@ -425,7 +425,7 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server,
return color;
}
}
/* no color by default */
return default_color;
}
@@ -441,10 +441,10 @@ irc_nick_get_color_for_nicklist (struct t_irc_server *server,
static char *nick_color_bar_fg = "bar_fg";
static char *nick_color_self = "weechat.color.chat_nick_self";
static char *nick_color_away = "weechat.color.nicklist_away";
if (nick->away)
return nick_color_away;
if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist))
{
if (weechat_strcasecmp (nick->name, server->nick) == 0)
@@ -452,7 +452,7 @@ irc_nick_get_color_for_nicklist (struct t_irc_server *server,
else
return irc_nick_find_color_name (nick->name);
}
return nick_color_bar_fg;
}
@@ -466,7 +466,7 @@ irc_nick_nicklist_add (struct t_irc_server *server,
struct t_irc_nick *nick)
{
struct t_gui_nick_group *ptr_group;
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
nick->name,
@@ -486,7 +486,7 @@ irc_nick_nicklist_remove (struct t_irc_server *server,
struct t_irc_nick *nick)
{
struct t_gui_nick_group *ptr_group;
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
weechat_nicklist_remove_nick (channel->buffer,
weechat_nicklist_search_nick (channel->buffer,
@@ -523,7 +523,7 @@ irc_nick_nicklist_set_prefix_color_all ()
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -552,7 +552,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;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -580,28 +580,28 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
{
struct t_irc_nick *new_nick, *ptr_nick;
int length;
/* nick already exists on this channel? */
ptr_nick = irc_nick_search (channel, nickname);
if (ptr_nick)
{
/* remove old nick from nicklist */
irc_nick_nicklist_remove (server, channel, ptr_nick);
/* update nick */
irc_nick_set_prefixes (server, ptr_nick, prefixes);
ptr_nick->away = away;
/* add new nick in nicklist */
irc_nick_nicklist_add (server, channel, ptr_nick);
return ptr_nick;
}
/* alloc memory for new nick */
if ((new_nick = malloc (sizeof (*new_nick))) == NULL)
return NULL;
/* initialize new nick */
new_nick->name = strdup (nickname);
new_nick->host = NULL;
@@ -620,7 +620,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
new_nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
else
new_nick->color = strdup (irc_nick_find_color (new_nick->name));
/* add nick to end of list */
new_nick->prev_nick = channel->last_nick;
if (channel->nicks)
@@ -629,14 +629,14 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
channel->nicks = new_nick;
channel->last_nick = new_nick;
new_nick->next_nick = NULL;
channel->nicks_count++;
channel->nick_completion_reset = 1;
/* add nick to buffer nicklist */
irc_nick_nicklist_add (server, channel, new_nick);
/* all is ok, return address of new nick */
return new_nick;
}
@@ -650,15 +650,15 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
struct t_irc_nick *nick, const char *new_nick)
{
int nick_is_me;
/* remove nick from nicklist */
irc_nick_nicklist_remove (server, channel, nick);
/* update nicks speaking */
nick_is_me = (strcmp (nick->name, server->nick) == 0) ? 1 : 0;
if (!nick_is_me)
irc_channel_nick_speaking_rename (channel, nick->name, new_nick);
/* change nickname */
if (nick->name)
free (nick->name);
@@ -669,7 +669,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
else
nick->color = strdup (irc_nick_find_color (nick->name));
/* add nick in nicklist */
irc_nick_nicklist_add (server, channel, nick);
}
@@ -684,21 +684,21 @@ irc_nick_set_mode (struct t_irc_server *server, struct t_irc_channel *channel,
{
int index;
const char *prefix_chars;
index = irc_server_get_prefix_mode_index (server, mode);
if (index < 0)
return;
/* remove nick from nicklist */
irc_nick_nicklist_remove (server, channel, nick);
/* set flag */
prefix_chars = irc_server_get_prefix_chars (server);
irc_nick_set_prefix (server, nick, set, prefix_chars[index]);
/* add nick in nicklist */
irc_nick_nicklist_add (server, channel, nick);
if (strcmp (nick->name, server->nick) == 0)
weechat_bar_item_update ("input_prompt");
}
@@ -712,13 +712,13 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
struct t_irc_nick *nick)
{
struct t_irc_nick *new_nicks;
if (!channel || !nick)
return;
/* remove nick from nicklist */
irc_nick_nicklist_remove (server, channel, nick);
/* remove nick */
if (channel->last_nick == nick)
channel->last_nick = nick->prev_nick;
@@ -729,12 +729,12 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
}
else
new_nicks = nick->next_nick;
if (nick->next_nick)
(nick->next_nick)->prev_nick = nick->prev_nick;
channel->nicks_count--;
/* free data */
if (nick->name)
free (nick->name);
@@ -744,9 +744,9 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
free (nick->prefixes);
if (nick->color)
free (nick->color);
free (nick);
channel->nicks = new_nicks;
channel->nick_completion_reset = 1;
}
@@ -760,13 +760,13 @@ irc_nick_free_all (struct t_irc_server *server, struct t_irc_channel *channel)
{
if (!channel)
return;
/* remove all nicks for the channel */
while (channel->nicks)
{
irc_nick_free (server, channel, channel->nicks);
}
/* sould be zero, but prevent any bug :D */
channel->nicks_count = 0;
}
@@ -779,17 +779,17 @@ struct t_irc_nick *
irc_nick_search (struct t_irc_channel *channel, const char *nickname)
{
struct t_irc_nick *ptr_nick;
if (!channel || !nickname)
return NULL;
for (ptr_nick = channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
if (weechat_strcasecmp (ptr_nick->name, nickname) == 0)
return ptr_nick;
}
/* nick not found */
return NULL;
}
@@ -804,7 +804,7 @@ irc_nick_count (struct t_irc_server *server, struct t_irc_channel *channel,
int *count_normal)
{
struct t_irc_nick *ptr_nick;
(*total) = 0;
(*count_op) = 0;
(*count_halfop) = 0;
@@ -865,7 +865,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
static char result[256];
char prefix[2];
const char *str_prefix_color;
prefix[0] = (nick) ? nick->prefix[0] : '\0';
prefix[1] = '\0';
if (weechat_config_boolean (weechat_config_get ("weechat.look.nickmode")))
@@ -889,7 +889,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
prefix[0] = '\0';
str_prefix_color = IRC_COLOR_RESET;
}
snprintf (result, sizeof (result), "%s%s%s%s%s%s%s%s\t",
(weechat_config_string (irc_config_look_nick_prefix)
&& weechat_config_string (irc_config_look_nick_prefix)[0]) ?
@@ -907,7 +907,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
(weechat_config_string (irc_config_look_nick_suffix)
&& weechat_config_string (irc_config_look_nick_suffix)[0]) ?
weechat_config_string (irc_config_look_nick_suffix) : "");
return result;
}
@@ -925,7 +925,7 @@ irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname)
if (channel->pv_remote_nick_color)
return channel->pv_remote_nick_color;
}
return IRC_COLOR_CHAT_NICK_OTHER;
}
@@ -937,10 +937,10 @@ struct t_hdata *
irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
if (hdata)
{
@@ -966,14 +966,14 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
struct t_irc_nick *nick)
{
struct t_infolist_item *ptr_item;
if (!infolist || !nick)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "name", nick->name))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "host", nick->host))
@@ -986,7 +986,7 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
return 0;
return 1;
}
+59 -59
View File
@@ -56,7 +56,7 @@ irc_notify_valid (struct t_irc_server *server, struct t_irc_notify *notify)
{
struct t_irc_server *ptr_server;
struct t_irc_notify *ptr_notify;
if (!notify)
return 0;
@@ -82,7 +82,7 @@ irc_notify_valid (struct t_irc_server *server, struct t_irc_notify *notify)
}
}
}
/* notify not found */
return 0;
}
@@ -95,17 +95,17 @@ struct t_irc_notify *
irc_notify_search (struct t_irc_server *server, const char *nick)
{
struct t_irc_notify *ptr_notify;
if (!server || !nick)
return NULL;
for (ptr_notify = server->notify_list; ptr_notify;
ptr_notify = ptr_notify->next_notify)
{
if (strcmp (ptr_notify->nick, nick) == 0)
return ptr_notify;
}
/* notify not found */
return NULL;
}
@@ -121,7 +121,7 @@ irc_notify_set_server_option (struct t_irc_server *server)
char *str, *str2;
struct t_irc_notify *ptr_notify;
int total_length, length;
if (!server)
return;
@@ -183,10 +183,10 @@ struct t_irc_notify *
irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
{
struct t_irc_notify *new_notify;
if (!server || !nick || !nick[0])
return NULL;
new_notify = malloc (sizeof (*new_notify));
if (new_notify)
{
@@ -196,7 +196,7 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
new_notify->is_on_server = 0;
new_notify->away_message = NULL;
new_notify->ison_received = 0;
/* add notify to notify list on server */
new_notify->prev_notify = server->last_notify;
if (server->notify_list)
@@ -206,7 +206,7 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
server->last_notify = new_notify;
new_notify->next_notify = NULL;
}
return new_notify;
}
@@ -221,14 +221,14 @@ irc_notify_new_for_server (struct t_irc_server *server)
const char *notify;
char **items, *pos_params, **params;
int i, j, num_items, num_params, check_away;
irc_notify_free_all (server);
notify = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NOTIFY);
if (!notify || !notify[0])
return;
items = weechat_string_split (notify, ",", 0, 0, &num_items);
if (items)
@@ -272,7 +272,7 @@ void
irc_notify_new_for_all_servers ()
{
struct t_irc_server *ptr_server;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -289,13 +289,13 @@ irc_notify_free (struct t_irc_server *server, struct t_irc_notify *notify)
{
weechat_hook_signal_send ("irc_notify_removing",
WEECHAT_HOOK_SIGNAL_POINTER, notify);
/* free data */
if (notify->nick)
free (notify->nick);
if (notify->away_message)
free (notify->away_message);
/* remove notify from list */
if (notify->prev_notify)
(notify->prev_notify)->next_notify = notify->next_notify;
@@ -305,9 +305,9 @@ irc_notify_free (struct t_irc_server *server, struct t_irc_notify *notify)
server->notify_list = notify->next_notify;
if (server->last_notify == notify)
server->last_notify = notify->prev_notify;
free (notify);
weechat_hook_signal_send ("irc_notify_removed",
WEECHAT_HOOK_SIGNAL_STRING, NULL);
}
@@ -436,13 +436,13 @@ irc_notify_get_tags (struct t_config_option *option)
{
static char string[1024];
const char *tags;
tags = weechat_config_string (option);
snprintf (string, sizeof (string), "irc_notify%s%s",
(tags && tags[0]) ? "," : "",
(tags && tags[0]) ? tags : "");
return string;
}
@@ -457,11 +457,11 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify,
{
if (!notify)
return;
/* same status, then do nothing */
if (notify->is_on_server == is_on_server)
return;
notify->is_on_server = is_on_server;
weechat_printf_tags (notify->server->buffer,
@@ -489,13 +489,13 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
{
if (!notify)
return;
/* same away message, then do nothing */
if ((!notify->away_message && !away_message)
|| (notify->away_message && away_message
&& (strcmp (notify->away_message, away_message) == 0)))
return;
if (!notify->away_message && away_message)
{
weechat_printf_tags (notify->server->buffer,
@@ -528,7 +528,7 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
IRC_COLOR_RESET,
away_message);
}
if (notify->away_message)
free (notify->away_message);
notify->away_message = (away_message) ? strdup (away_message) : NULL;
@@ -550,30 +550,30 @@ irc_notify_hsignal_cb (void *data, const char *signal,
int away_message_updated, no_such_nick;
struct t_irc_server *ptr_server;
struct t_irc_notify *ptr_notify;
/* make C compiler happy */
(void) data;
(void) signal;
error = weechat_hashtable_get (hashtable, "error");
server = weechat_hashtable_get (hashtable, "server");
pattern = weechat_hashtable_get (hashtable, "pattern");
command = weechat_hashtable_get (hashtable, "command");
output = weechat_hashtable_get (hashtable, "output");
/* if there is an error on redirection, just ignore result */
if (error && error[0])
return WEECHAT_RC_OK;
/* missing things in redirection */
if (!server || !pattern || !command || !output)
return WEECHAT_RC_OK;
/* search server */
ptr_server = irc_server_search (server);
if (!ptr_server)
return WEECHAT_RC_OK;
/* search for start of arguments in command sent to server */
ptr_args = strchr (command, ' ');
if (!ptr_args)
@@ -585,7 +585,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
}
if (!ptr_args[0])
return WEECHAT_RC_OK;
/* read output of command */
if (strcmp (pattern, "ison") == 0)
{
@@ -663,7 +663,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
irc_notify_set_is_on_server (ptr_notify, 0);
}
}
}
weechat_string_free_split (messages);
}
@@ -716,7 +716,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
}
}
}
return WEECHAT_RC_OK;
}
@@ -733,11 +733,11 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
struct t_irc_server *ptr_server;
struct t_irc_notify *ptr_notify, *ptr_next_notify;
struct t_hashtable *hashtable;
/* make C compiler happy */
(void) data;
(void) remaining_calls;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -746,16 +746,16 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
message = malloc (7);
if (!message)
continue;
snprintf (message, 7, "ISON :");
total_length = 7;
nicks_added = 0;
ptr_notify = ptr_server->notify_list;
while (ptr_notify)
{
ptr_next_notify = ptr_notify->next_notify;
length = strlen (ptr_notify->nick);
total_length += length + 1;
message2 = realloc (message, total_length);
@@ -771,10 +771,10 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
strcat (message, " ");
strcat (message, ptr_notify->nick);
nicks_added++;
ptr_notify = ptr_next_notify;
}
if (message && (nicks_added > 0))
{
hashtable = irc_message_split (ptr_server, message);
@@ -798,12 +798,12 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
weechat_hashtable_free (hashtable);
}
}
if (message)
free (message);
}
}
return WEECHAT_RC_OK;
}
@@ -816,11 +816,11 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
{
struct t_irc_server *ptr_server;
struct t_irc_notify *ptr_notify, *ptr_next_notify;
/* make C compiler happy */
(void) data;
(void) remaining_calls;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -830,7 +830,7 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
while (ptr_notify)
{
ptr_next_notify = ptr_notify->next_notify;
if (ptr_notify->check_away)
{
/*
@@ -844,12 +844,12 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
"WHOIS :%s", ptr_notify->nick);
}
ptr_notify = ptr_next_notify;
}
}
}
return WEECHAT_RC_OK;
}
@@ -861,10 +861,10 @@ struct t_hdata *
irc_notify_hdata_notify_cb (void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_notify", "next_notify");
if (hdata)
{
@@ -890,10 +890,10 @@ irc_notify_add_to_infolist (struct t_infolist *infolist,
struct t_irc_notify *notify)
{
struct t_infolist_item *ptr_item;
if (!infolist || !notify)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
@@ -910,7 +910,7 @@ irc_notify_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "away_message", notify->away_message))
return 0;
return 1;
}
@@ -922,7 +922,7 @@ void
irc_notify_print_log (struct t_irc_server *server)
{
struct t_irc_notify *ptr_notify;
for (ptr_notify = server->notify_list; ptr_notify;
ptr_notify = ptr_notify->next_notify)
{
@@ -948,7 +948,7 @@ irc_notify_hook_timer_ison ()
{
if (irc_notify_timer_ison)
weechat_unhook (irc_notify_timer_ison);
irc_notify_timer_ison = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_ison),
0, 0, &irc_notify_timer_ison_cb, NULL);
@@ -963,7 +963,7 @@ irc_notify_hook_timer_whois ()
{
if (irc_notify_timer_whois)
weechat_unhook (irc_notify_timer_whois);
irc_notify_timer_whois = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_whois),
0, 0, &irc_notify_timer_whois_cb, NULL);
@@ -978,7 +978,7 @@ irc_notify_init ()
{
irc_notify_hook_timer_ison ();
irc_notify_hook_timer_whois ();
irc_notify_hsignal = weechat_hook_hsignal ("irc_redirection_notify_*",
&irc_notify_hsignal_cb,
NULL);
+1 -1
View File
@@ -64,5 +64,5 @@ extern void irc_notify_hook_timer_ison ();
extern void irc_notify_hook_timer_whois ();
extern void irc_notify_init ();
extern void irc_notify_end ();
#endif /* __WEECHAT_IRC_NOTIFY_H */
File diff suppressed because it is too large Load Diff
+30 -30
View File
@@ -67,7 +67,7 @@ void
irc_raw_open (int switch_to_buffer)
{
struct t_irc_raw_message *ptr_raw_message;
if (!irc_raw_buffer)
{
irc_raw_buffer = weechat_buffer_search (IRC_PLUGIN_NAME,
@@ -77,14 +77,14 @@ irc_raw_open (int switch_to_buffer)
irc_raw_buffer = weechat_buffer_new (IRC_RAW_BUFFER_NAME,
&irc_input_data_cb, NULL,
&irc_buffer_close_cb, NULL);
/* failed to create buffer ? then return */
if (!irc_raw_buffer)
return;
weechat_buffer_set (irc_raw_buffer,
"title", _("IRC raw messages"));
if (!weechat_buffer_get_integer (irc_raw_buffer, "short_name_is_set"))
{
weechat_buffer_set (irc_raw_buffer, "short_name",
@@ -94,7 +94,7 @@ irc_raw_open (int switch_to_buffer)
weechat_buffer_set (irc_raw_buffer, "localvar_set_server", IRC_RAW_BUFFER_NAME);
weechat_buffer_set (irc_raw_buffer, "localvar_set_channel", IRC_RAW_BUFFER_NAME);
weechat_buffer_set (irc_raw_buffer, "localvar_set_no_log", "1");
/* disable all highlights on this buffer */
weechat_buffer_set (irc_raw_buffer, "highlight_words", "-");
@@ -106,7 +106,7 @@ irc_raw_open (int switch_to_buffer)
}
}
}
if (irc_raw_buffer && switch_to_buffer)
weechat_buffer_set (irc_raw_buffer, "display", "1");
}
@@ -119,7 +119,7 @@ void
irc_raw_message_free (struct t_irc_raw_message *raw_message)
{
struct t_irc_raw_message *new_raw_messages;
/* remove message from raw messages list */
if (last_irc_raw_message == raw_message)
last_irc_raw_message = raw_message->prev_message;
@@ -130,20 +130,20 @@ irc_raw_message_free (struct t_irc_raw_message *raw_message)
}
else
new_raw_messages = raw_message->next_message;
if (raw_message->next_message)
(raw_message->next_message)->prev_message = raw_message->prev_message;
/* free data */
if (raw_message->prefix)
free (raw_message->prefix);
if (raw_message->message)
free (raw_message->message);
free (raw_message);
irc_raw_messages = new_raw_messages;
irc_raw_messages_count--;
}
@@ -168,7 +168,7 @@ void
irc_raw_message_remove_old ()
{
int max_messages;
max_messages = weechat_config_integer (irc_config_look_raw_messages);
while (irc_raw_messages && (irc_raw_messages_count >= max_messages))
{
@@ -185,19 +185,19 @@ irc_raw_message_add_to_list (time_t date, const char *prefix,
const char *message)
{
struct t_irc_raw_message *new_raw_message;
if (!prefix || !message)
return NULL;
irc_raw_message_remove_old ();
new_raw_message = malloc (sizeof (*new_raw_message));
if (new_raw_message)
{
new_raw_message->date = date;
new_raw_message->prefix = strdup (prefix);
new_raw_message->message = strdup (message);
/* add message to list */
new_raw_message->prev_message = last_irc_raw_message;
new_raw_message->next_message = NULL;
@@ -206,10 +206,10 @@ irc_raw_message_add_to_list (time_t date, const char *prefix,
else
irc_raw_messages = new_raw_message;
last_irc_raw_message = new_raw_message;
irc_raw_messages_count++;
}
return new_raw_message;
}
@@ -226,7 +226,7 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
const char *hexa = "0123456789ABCDEF";
int pos_buf, pos_buf2, char_size, i;
struct t_irc_raw_message *new_raw_message;
buf = weechat_iconv_to_internal (NULL, message);
buf2 = malloc ((strlen (buf) * 3) + 1);
if (buf2)
@@ -282,7 +282,7 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
break;
}
snprintf (prefix, sizeof (prefix), "%s%s%s%s%s",
(server) ? weechat_color ("chat_server") : "",
(server) ? server->name : "",
@@ -291,16 +291,16 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
weechat_color ("chat_prefix_quit") :
weechat_color ("chat_prefix_join"),
prefix_arrow);
new_raw_message = irc_raw_message_add_to_list (time (NULL),
prefix,
(buf2) ? buf2 : ((buf) ? buf : message));
if (buf)
free (buf);
if (buf2)
free (buf2);
return new_raw_message;
}
@@ -313,14 +313,14 @@ irc_raw_print (struct t_irc_server *server, int flags,
const char *message)
{
struct t_irc_raw_message *new_raw_message;
if (!message)
return;
/* auto-open IRC raw buffer if debug for irc plugin is >= 1 */
if (!irc_raw_buffer && (weechat_irc_plugin->debug >= 1))
irc_raw_open (0);
new_raw_message = irc_raw_message_add (server, flags, message);
if (new_raw_message)
{
@@ -341,20 +341,20 @@ irc_raw_add_to_infolist (struct t_infolist *infolist,
struct t_irc_raw_message *raw_message)
{
struct t_infolist_item *ptr_item;
if (!infolist || !raw_message)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "date", raw_message->date))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "prefix", raw_message->prefix))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "message", raw_message->message))
return 0;
return 1;
}
+88 -88
View File
@@ -249,17 +249,17 @@ struct t_irc_redirect_pattern *
irc_redirect_pattern_search (const char *name)
{
struct t_irc_redirect_pattern *ptr_redirect_pattern;
if (!name)
return NULL;
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
{
if (strcmp (ptr_redirect_pattern->name, name) == 0)
return ptr_redirect_pattern;
}
/* redirect pattern not found */
return NULL;
}
@@ -274,10 +274,10 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
const char *cmd_extra)
{
struct t_irc_redirect_pattern *ptr_redirect_pattern, *new_redirect_pattern;
if (!name)
return NULL;
if (!cmd_stop || !cmd_stop[0])
{
weechat_printf (NULL,
@@ -286,7 +286,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
"cmd_stop");
return NULL;
}
/* check if redirect pattern already exists */
ptr_redirect_pattern = irc_redirect_pattern_search (name);
if (ptr_redirect_pattern)
@@ -297,11 +297,11 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
name);
return NULL;
}
new_redirect_pattern = malloc (sizeof (*new_redirect_pattern));
if (!new_redirect_pattern)
return NULL;
/* initialize new redirect */
new_redirect_pattern->name = strdup (name);
new_redirect_pattern->temp_pattern = temp_pattern;
@@ -309,7 +309,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
new_redirect_pattern->cmd_start = (cmd_start) ? strdup (cmd_start) : NULL;
new_redirect_pattern->cmd_stop = strdup (cmd_stop);
new_redirect_pattern->cmd_extra = (cmd_extra) ? strdup (cmd_extra) : NULL;
/* add redirect pattern to end of list */
new_redirect_pattern->prev_redirect = last_irc_redirect_pattern;
if (irc_redirect_patterns)
@@ -318,7 +318,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
irc_redirect_patterns = new_redirect_pattern;
last_irc_redirect_pattern = new_redirect_pattern;
new_redirect_pattern->next_redirect = NULL;
return new_redirect_pattern;
}
@@ -330,10 +330,10 @@ void
irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
{
struct t_irc_redirect_pattern *new_redirect_patterns;
if (!redirect_pattern)
return;
/* remove redirect */
if (last_irc_redirect_pattern == redirect_pattern)
last_irc_redirect_pattern = redirect_pattern->prev_redirect;
@@ -344,10 +344,10 @@ irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
}
else
new_redirect_patterns = redirect_pattern->next_redirect;
if (redirect_pattern->next_redirect)
(redirect_pattern->next_redirect)->prev_redirect = redirect_pattern->prev_redirect;
/* free data */
if (redirect_pattern->name)
free (redirect_pattern->name);
@@ -357,9 +357,9 @@ irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
free (redirect_pattern->cmd_stop);
if (redirect_pattern->cmd_extra)
free (redirect_pattern->cmd_extra);
free (redirect_pattern);
irc_redirect_patterns = new_redirect_patterns;
}
@@ -396,11 +396,11 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
int i, j, num_items[4];
long value;
struct t_hashtable *hash_cmd[4];
new_redirect = malloc (sizeof (*new_redirect));
if (!new_redirect)
return NULL;
/* create hashtables with commands */
for (i = 0; i < 4; i++)
{
@@ -448,7 +448,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
weechat_string_free_split (items[i]);
}
}
/* initialize new redirect */
new_redirect->server = server;
new_redirect->pattern = strdup (pattern);
@@ -467,7 +467,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
new_redirect->cmd_filter = hash_cmd[3];
new_redirect->output = NULL;
new_redirect->output_size = 0;
/* add redirect to end of list */
new_redirect->prev_redirect = server->last_redirect;
if (server->redirects)
@@ -476,7 +476,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
server->redirects = new_redirect;
server->last_redirect = new_redirect;
new_redirect->next_redirect = NULL;
return new_redirect;
}
@@ -492,7 +492,7 @@ irc_redirect_new (struct t_irc_server *server,
{
struct t_irc_redirect_pattern *ptr_redirect_pattern;
struct t_irc_redirect *new_redirect;
if (!server->is_connected)
{
weechat_printf (NULL,
@@ -501,7 +501,7 @@ irc_redirect_new (struct t_irc_server *server,
server->name);
return NULL;
}
if (!pattern || !pattern[0])
{
weechat_printf (NULL, _("%s%s: missing argument \"%s\" for redirect"),
@@ -514,7 +514,7 @@ irc_redirect_new (struct t_irc_server *server,
weechat_prefix ("error"), IRC_PLUGIN_NAME, "signal");
return NULL;
}
ptr_redirect_pattern = irc_redirect_pattern_search (pattern);
if (!ptr_redirect_pattern)
{
@@ -523,7 +523,7 @@ irc_redirect_new (struct t_irc_server *server,
pattern);
return NULL;
}
new_redirect = irc_redirect_new_with_commands (server, pattern, signal,
count, string,
(timeout > 0) ? timeout : ptr_redirect_pattern->timeout,
@@ -531,14 +531,14 @@ irc_redirect_new (struct t_irc_server *server,
ptr_redirect_pattern->cmd_stop,
ptr_redirect_pattern->cmd_extra,
cmd_filter);
/*
* remove redirect pattern if it is temporary (created by external
* plugin/script)
*/
if (new_redirect && ptr_redirect_pattern->temp_pattern)
irc_redirect_pattern_free (ptr_redirect_pattern);
return new_redirect;
}
@@ -550,17 +550,17 @@ struct t_irc_redirect *
irc_redirect_search_available (struct t_irc_server *server)
{
struct t_irc_redirect *ptr_redirect;
if (!server)
return NULL;
for (ptr_redirect = server->redirects; ptr_redirect;
ptr_redirect = ptr_redirect->next_redirect)
{
if (ptr_redirect->start_time == 0)
return ptr_redirect;
}
/* no redirect available */
return NULL;
}
@@ -575,10 +575,10 @@ irc_redirect_init_command (struct t_irc_redirect *redirect,
const char *command)
{
char *pos;
if (!redirect)
return;
if (command)
{
pos = strchr (command, '\r');
@@ -591,9 +591,9 @@ irc_redirect_init_command (struct t_irc_redirect *redirect,
}
else
redirect->command = NULL;
redirect->start_time = time (NULL);
if (weechat_irc_plugin->debug >= 2)
{
weechat_printf (redirect->server->buffer,
@@ -618,11 +618,11 @@ irc_redirect_message_match_hash (struct t_irc_redirect *redirect,
struct t_hashtable *cmd_hash)
{
int *value;
value = weechat_hashtable_get (cmd_hash, command);
if (!value)
return 0;
/*
* if string is in redirect and that this command requires string to
* be in message, then search for this string
@@ -631,11 +631,11 @@ irc_redirect_message_match_hash (struct t_irc_redirect *redirect,
{
if (!arguments_argv || (*value >= arguments_argc))
return 0;
if (weechat_strcasecmp (arguments_argv[*value], redirect->string) != 0)
return 0;
}
return 1;
}
@@ -648,7 +648,7 @@ irc_redirect_message_add (struct t_irc_redirect *redirect, const char *message,
const char *command)
{
char *output2;
/*
* if command is not for output, then don't add message
* (it is silently ignored)
@@ -656,7 +656,7 @@ irc_redirect_message_add (struct t_irc_redirect *redirect, const char *message,
if (redirect->cmd_filter
&& !weechat_hashtable_has_key (redirect->cmd_filter, command))
return;
/* add message to output */
if (redirect->output)
{
@@ -716,21 +716,21 @@ irc_redirect_stop (struct t_irc_redirect *redirect, const char *error)
(redirect->output) ? redirect->output : "");
snprintf (str_int, sizeof (str_int), "%d", redirect->output_size);
weechat_hashtable_set (hashtable, "output_size", str_int);
/* set some other fields with values from redirect */
weechat_hashtable_set (hashtable, "server", redirect->server->name);
weechat_hashtable_set (hashtable, "pattern", redirect->pattern);
weechat_hashtable_set (hashtable, "signal", redirect->signal);
weechat_hashtable_set (hashtable, "command", redirect->command);
}
snprintf (signal_name, sizeof (signal_name), "irc_redirection_%s_%s",
redirect->signal, redirect->pattern);
weechat_hook_hsignal_send (signal_name, hashtable);
if (hashtable)
weechat_hashtable_free (hashtable);
irc_redirect_free (redirect);
}
else
@@ -760,10 +760,10 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
struct t_irc_redirect *ptr_redirect, *ptr_next_redirect;
int rc, match_stop, arguments_argc;
char **arguments_argv;
if (!server || !server->redirects || !message || !command)
return 0;
rc = 0;
if (arguments && arguments[0])
@@ -776,12 +776,12 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
arguments_argv = NULL;
arguments_argc = 0;
}
ptr_redirect = server->redirects;
while (ptr_redirect)
{
ptr_next_redirect = ptr_redirect->next_redirect;
if (ptr_redirect->start_time > 0)
{
if (ptr_redirect->cmd_stop_received)
@@ -870,14 +870,14 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
}
}
}
ptr_redirect = ptr_next_redirect;
}
end:
if (arguments_argv)
weechat_string_free_split (arguments_argv);
return rc;
}
@@ -892,12 +892,12 @@ irc_redirect_free (struct t_irc_redirect *redirect)
struct t_irc_redirect *new_redirects;
int priority;
struct t_irc_outqueue *ptr_outqueue;
if (!redirect)
return;
server = redirect->server;
/* remove redirect */
if (server->last_redirect == redirect)
server->last_redirect = redirect->prev_redirect;
@@ -908,10 +908,10 @@ irc_redirect_free (struct t_irc_redirect *redirect)
}
else
new_redirects = redirect->next_redirect;
if (redirect->next_redirect)
(redirect->next_redirect)->prev_redirect = redirect->prev_redirect;
/* remove any pointer to this redirect */
for (priority = 0; priority < IRC_SERVER_NUM_OUTQUEUES_PRIO; priority++)
{
@@ -922,7 +922,7 @@ irc_redirect_free (struct t_irc_redirect *redirect)
ptr_outqueue->redirect = NULL;
}
}
/* free data */
if (redirect->pattern)
free (redirect->pattern);
@@ -942,9 +942,9 @@ irc_redirect_free (struct t_irc_redirect *redirect)
weechat_hashtable_free (redirect->cmd_filter);
if (redirect->output)
free (redirect->output);
free (redirect);
server->redirects = new_redirects;
}
@@ -969,10 +969,10 @@ struct t_hdata *
irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
if (hdata)
{
@@ -998,10 +998,10 @@ struct t_hdata *
irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name)
{
struct t_hdata *hdata;
/* make C compiler happy */
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
if (hdata)
{
@@ -1038,14 +1038,14 @@ irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
struct t_irc_redirect_pattern *redirect_pattern)
{
struct t_infolist_item *ptr_item;
if (!infolist || !redirect_pattern)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "name", redirect_pattern->name))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "temp_pattern", redirect_pattern->temp_pattern))
@@ -1058,7 +1058,7 @@ irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "cmd_extra", redirect_pattern->cmd_extra))
return 0;
return 1;
}
@@ -1072,14 +1072,14 @@ irc_redirect_add_to_infolist (struct t_infolist *infolist,
struct t_irc_redirect *redirect)
{
struct t_infolist_item *ptr_item;
if (!infolist || !redirect)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_pointer (ptr_item, "server", redirect->server))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "server_name", redirect->server->name))
@@ -1116,7 +1116,7 @@ irc_redirect_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "output_size", redirect->output_size))
return 0;
return 1;
}
@@ -1129,7 +1129,7 @@ void
irc_redirect_pattern_print_log ()
{
struct t_irc_redirect_pattern *ptr_redirect_pattern;
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
{
@@ -1154,7 +1154,7 @@ void
irc_redirect_print_log (struct t_irc_server *server)
{
struct t_irc_redirect *ptr_redirect;
for (ptr_redirect = server->redirects; ptr_redirect;
ptr_redirect = ptr_redirect->next_redirect)
{
@@ -1205,20 +1205,20 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra;
char *error;
int number, timeout;
/* make C compiler happy */
(void) data;
(void) signal;
if (!hashtable)
return WEECHAT_RC_ERROR;
pattern = weechat_hashtable_get (hashtable, "pattern");
str_timeout = weechat_hashtable_get (hashtable, "timeout");
cmd_start = weechat_hashtable_get (hashtable, "cmd_start");
cmd_stop = weechat_hashtable_get (hashtable, "cmd_stop");
cmd_extra = weechat_hashtable_get (hashtable, "cmd_extra");
if (!pattern || !pattern[0])
{
weechat_printf (NULL,
@@ -1236,7 +1236,7 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
weechat_prefix ("error"), IRC_PLUGIN_NAME, "cmd_stop");
return WEECHAT_RC_ERROR;
}
timeout = 0;
if (str_timeout && str_timeout[0])
{
@@ -1244,14 +1244,14 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
if (error && !error[0])
timeout = number;
}
/*
* create a temporary redirect pattern (it will be removed when a
* redirect will use it)
*/
irc_redirect_pattern_new (pattern, 1, timeout,
cmd_start, cmd_stop, cmd_extra);
return WEECHAT_RC_OK;
}
@@ -1271,14 +1271,14 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
char *error;
struct t_irc_server *ptr_server;
int number, count, timeout;
/* make C compiler happy */
(void) data;
(void) signal;
if (!hashtable)
return WEECHAT_RC_ERROR;
server = weechat_hashtable_get (hashtable, "server");
pattern = weechat_hashtable_get (hashtable, "pattern");
redirect_signal = weechat_hashtable_get (hashtable, "signal");
@@ -1286,7 +1286,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
string = weechat_hashtable_get (hashtable, "string");
str_timeout = weechat_hashtable_get (hashtable, "timeout");
cmd_filter = weechat_hashtable_get (hashtable, "cmd_filter");
if (!server || !server[0])
{
weechat_printf (NULL,
@@ -1302,7 +1302,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
weechat_prefix ("error"), IRC_PLUGIN_NAME, server);
return WEECHAT_RC_ERROR;
}
count = 1;
if (str_count && str_count[0])
{
@@ -1310,7 +1310,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
if (error && !error[0])
count = number;
}
timeout = 0;
if (str_timeout && str_timeout[0])
{
@@ -1318,10 +1318,10 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
if (error && !error[0])
timeout = number;
}
irc_redirect_new (ptr_server, pattern, redirect_signal,
count, string, timeout, cmd_filter);
return WEECHAT_RC_OK;
}
+19 -19
View File
@@ -51,7 +51,7 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
{
char *string, *answer_base64;
int length_username, length;
answer_base64 = NULL;
length_username = strlen (sasl_username);
length = ((length_username + 1) * 2) + strlen (sasl_password) + 1;
@@ -62,14 +62,14 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
sasl_username, sasl_username, sasl_password);
string[length_username] = '\0';
string[(length_username * 2) + 1] = '\0';
answer_base64 = malloc (length * 4);
if (answer_base64)
weechat_string_encode_base64 (string, length - 1, answer_base64);
free (string);
}
return answer_base64;
}
@@ -101,7 +101,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
gcry_mpi_t data_prime_number, data_generator_number, data_server_pub_key;
gcry_mpi_t pub_key, priv_key, secret_mpi;
gcry_cipher_hd_t gcrypt_handle;
data = NULL;
secret_bin = NULL;
public_bin = NULL;
@@ -109,12 +109,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
password_crypted = NULL;
answer = NULL;
answer_base64 = NULL;
/* decode data */
data = malloc (strlen (data_base64) + 1);
length_data = weechat_string_decode_base64 (data_base64, data);
ptr_data = (unsigned char *)data;
/* extract prime number */
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
ptr_data += 2;
@@ -126,7 +126,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
num_bits_prime_number = gcry_mpi_get_nbits (data_prime_number);
ptr_data += size;
length_data -= size;
/* extract generator number */
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
ptr_data += 2;
@@ -137,7 +137,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
gcry_mpi_scan (&data_generator_number, GCRYMPI_FMT_USG, ptr_data, size, NULL);
ptr_data += size;
length_data -= size;
/* extract server-generated public key */
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
ptr_data += 2;
@@ -146,14 +146,14 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
goto end;
data_server_pub_key = gcry_mpi_new (size * 8);
gcry_mpi_scan (&data_server_pub_key, GCRYMPI_FMT_USG, ptr_data, size, NULL);
/* generate keys */
pub_key = gcry_mpi_new (num_bits_prime_number);
priv_key = gcry_mpi_new (num_bits_prime_number);
gcry_mpi_randomize (priv_key, num_bits_prime_number, GCRY_STRONG_RANDOM);
/* pub_key = (g ^ priv_key) % p */
gcry_mpi_powm (pub_key, data_generator_number, priv_key, data_prime_number);
/* compute secret_bin */
length_key = num_bits_prime_number / 8;
secret_bin = malloc (length_key);
@@ -162,12 +162,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
gcry_mpi_powm (secret_mpi, data_server_pub_key, priv_key, data_prime_number);
gcry_mpi_print (GCRYMPI_FMT_USG, secret_bin, length_key,
&num_written, secret_mpi);
/* create public_bin */
public_bin = malloc (length_key);
gcry_mpi_print (GCRYMPI_FMT_USG, public_bin, length_key,
&num_written, pub_key);
/* create password buffers (clear and crypted) */
length_password = strlen (sasl_password) +
((8 - (strlen (sasl_password) % 8)) % 8);
@@ -176,7 +176,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
memset (password_clear, 0, length_password);
memset (password_crypted, 0, length_password);
memcpy (password_clear, sasl_password, strlen (sasl_password));
/* crypt password using blowfish */
if (gcry_cipher_open (&gcrypt_handle, GCRY_CIPHER_BLOWFISH,
GCRY_CIPHER_MODE_ECB, 0) != 0)
@@ -187,7 +187,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
password_crypted, length_password,
password_clear, length_password) != 0)
goto end;
/*
* build answer for server, it is concatenation of:
* 1. key length (2 bytes)
@@ -206,12 +206,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
memcpy (ptr_answer, sasl_username, length_username + 1);
ptr_answer += length_username + 1;
memcpy (ptr_answer, password_crypted, length_password);
/* encode answer to base64 */
answer_base64 = malloc (length_answer * 4);
if (answer_base64)
weechat_string_encode_base64 (answer, length_answer, answer_base64);
end:
if (data)
free (data);
@@ -225,14 +225,14 @@ end:
free (password_crypted);
if (answer)
free (answer);
return answer_base64;
#else
/* make C compiler happy */
(void) data_base64;
(void) sasl_username;
(void) sasl_password;
return NULL;
#endif
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -121,7 +121,7 @@ struct t_irc_server
/* user choices */
char *name; /* internal name of server */
struct t_config_option *options[IRC_SERVER_NUM_OPTIONS];
/* internal vars */
int temp_server; /* temporary server (not saved) */
int reloading_from_config; /* 1 if reloading from config file */
+18 -18
View File
@@ -59,7 +59,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
struct t_irc_notify *ptr_notify;
struct t_irc_raw_message *ptr_raw_message;
int rc;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -78,7 +78,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
weechat_infolist_free (infolist);
if (!rc)
return 0;
/* save server channels and nicks */
for (ptr_channel = ptr_server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
@@ -98,7 +98,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
weechat_infolist_free (infolist);
if (!rc)
return 0;
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
@@ -119,7 +119,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
return 0;
}
}
/* save server redirects */
for (ptr_redirect = ptr_server->redirects; ptr_redirect;
ptr_redirect = ptr_redirect->next_redirect)
@@ -139,7 +139,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
if (!rc)
return 0;
}
/* save server notify list */
for (ptr_notify = ptr_server->notify_list; ptr_notify;
ptr_notify = ptr_notify->next_notify)
@@ -160,7 +160,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
return 0;
}
}
/* save raw messages */
for (ptr_raw_message = irc_raw_messages; ptr_raw_message;
ptr_raw_message = ptr_raw_message->next_message)
@@ -180,7 +180,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
if (!rc)
return 0;
}
/* save redirect patterns */
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
@@ -204,7 +204,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
return 0;
}
}
return 1;
}
@@ -218,15 +218,15 @@ irc_upgrade_save ()
{
int rc;
struct t_upgrade_file *upgrade_file;
upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 1);
if (!upgrade_file)
return 0;
rc = irc_upgrade_save_all_data (upgrade_file);
weechat_upgrade_close (upgrade_file);
return rc;
}
@@ -240,7 +240,7 @@ irc_upgrade_set_buffer_callbacks ()
{
struct t_infolist *infolist;
struct t_gui_buffer *ptr_buffer;
infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (infolist)
{
@@ -279,11 +279,11 @@ irc_upgrade_read_cb (void *data,
struct t_irc_redirect *ptr_redirect;
struct t_irc_notify *ptr_notify;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
(void) upgrade_file;
weechat_infolist_reset_item_cursor (infolist);
while (weechat_infolist_next (infolist))
{
@@ -603,7 +603,7 @@ irc_upgrade_read_cb (void *data,
break;
}
}
return WEECHAT_RC_OK;
}
@@ -619,10 +619,10 @@ irc_upgrade_load ()
struct t_upgrade_file *upgrade_file;
irc_upgrade_set_buffer_callbacks ();
upgrade_file = weechat_upgrade_new (IRC_UPGRADE_FILENAME, 0);
rc = weechat_upgrade_read (upgrade_file, &irc_upgrade_read_cb, NULL);
return rc;
}
+32 -32
View File
@@ -68,11 +68,11 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
void *signal_data)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
(void) data;
(void) signal;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
for (ptr_server = irc_servers; ptr_server;
@@ -82,7 +82,7 @@ irc_signal_quit_cb (void *data, const char *signal, const char *type_data,
(signal_data) ? (char *)signal_data : NULL);
}
}
return WEECHAT_RC_OK;
}
@@ -96,15 +96,15 @@ irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
{
struct t_irc_server *ptr_server;
int disconnected;
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
(void) signal_data;
irc_signal_upgrade_received = 1;
/*
* FIXME: it's not possible to upgrade with SSL servers connected (GnuTLS
* lib can't reload data after upgrade), so we close connection for
@@ -142,7 +142,7 @@ irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
disconnected,
NG_("server", "servers", disconnected));
}
return WEECHAT_RC_OK;
}
@@ -154,23 +154,23 @@ int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int i, auto_connect, upgrading;
weechat_plugin = plugin;
if (!irc_config_init ())
return WEECHAT_RC_ERROR;
if (irc_config_read () < 0)
return WEECHAT_RC_ERROR;
irc_command_init ();
irc_info_init ();
irc_redirect_init ();
irc_notify_init ();
/* hook some signals */
irc_debug_init ();
weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
@@ -179,20 +179,20 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_hook_signal ("xfer_resume_ready", &irc_server_xfer_resume_ready_cb, NULL);
weechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL);
weechat_hook_signal ("irc_input_send", &irc_input_send_cb, NULL);
/* hook hsignals for redirection */
weechat_hook_hsignal ("irc_redirect_pattern", &irc_redirect_pattern_hsignal_cb, NULL);
weechat_hook_hsignal ("irc_redirect_command", &irc_redirect_command_hsignal_cb, NULL);
/* modifiers */
weechat_hook_modifier ("irc_color_decode", &irc_color_modifier_cb, NULL);
weechat_hook_modifier ("irc_color_encode", &irc_color_modifier_cb, NULL);
/* hook completions */
irc_completion_init ();
irc_bar_item_init ();
/* look at arguments */
auto_connect = 1;
upgrading = 0;
@@ -219,7 +219,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
upgrading = 1;
}
}
if (upgrading)
{
if (!irc_upgrade_load ())
@@ -236,10 +236,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
if (auto_connect)
irc_server_auto_connect ();
}
irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
&irc_server_timer_cb, NULL);
return WEECHAT_RC_OK;
}
@@ -252,10 +252,10 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
{
/* make C compiler happy */
(void) plugin;
if (irc_hook_timer)
weechat_unhook (irc_hook_timer);
if (irc_signal_upgrade_received)
{
irc_config_write (1);
@@ -266,18 +266,18 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
irc_config_write (0);
irc_server_disconnect_all ();
}
irc_ignore_free_all ();
irc_raw_message_free_all ();
irc_server_free_all ();
irc_config_free ();
irc_notify_end ();
irc_redirect_end ();
return WEECHAT_RC_OK;
}