1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +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
+4 -4
View File
@@ -80,14 +80,14 @@ weechat_backtrace_addr2line (int number, void *address, const char *symbol)
char cmd_line[1024];
char line[1024], *ptr_line, *pos;
char function_name[1024];
rc = dladdr (address, &info);
if ((rc == 0) || !info.dli_fname || !info.dli_fname[0])
{
weechat_backtrace_printf ("%03d %s", number, symbol);
return;
}
addr = address;
if (info.dli_fbase >= (const void *) 0x40000000)
addr = (void *)((unsigned long)((const char *) addr) -
@@ -166,7 +166,7 @@ weechat_backtrace ()
#ifdef HAVE_BACKTRACE
trace_size = backtrace (trace, BACKTRACE_MAX);
symbols = backtrace_symbols (trace, trace_size);
for (i = 0; i < trace_size; i++)
{
weechat_backtrace_addr2line (i + 1, trace[i], symbols[i]);
@@ -175,6 +175,6 @@ weechat_backtrace ()
weechat_backtrace_printf (" No backtrace info (no debug info available "
"or no backtrace possible on your system).");
#endif
weechat_backtrace_printf ("======= End of backtrace =======");
}
+313 -313
View File
File diff suppressed because it is too large Load Diff
+94 -94
View File
@@ -65,18 +65,18 @@ completion_list_add_bars_names_cb (void *data,
struct t_gui_completion *completion)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
gui_completion_list_add (completion, ptr_bar->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -91,18 +91,18 @@ completion_list_add_bars_options_cb (void *data,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
{
gui_completion_list_add (completion, gui_bar_option_string[i],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -117,19 +117,19 @@ completion_list_add_buffers_names_cb (void *data,
struct t_gui_completion *completion)
{
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
gui_completion_list_add (completion, ptr_buffer->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -145,12 +145,12 @@ completion_list_add_buffers_numbers_cb (void *data,
{
struct t_gui_buffer *ptr_buffer;
char str_number[32];
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -158,7 +158,7 @@ completion_list_add_buffers_numbers_cb (void *data,
gui_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
}
@@ -175,12 +175,12 @@ completion_list_add_buffers_plugins_names_cb (void *data,
{
struct t_gui_buffer *ptr_buffer;
char name[512];
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -190,7 +190,7 @@ completion_list_add_buffers_plugins_names_cb (void *data,
gui_completion_list_add (completion, name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -206,19 +206,19 @@ completion_list_add_buffer_properties_set_cb (void *data,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (i = 0; gui_buffer_properties_set[i]; i++)
{
gui_completion_list_add (completion,
gui_buffer_properties_set[i],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -234,12 +234,12 @@ completion_list_add_buffer_properties_get_cb (void *data,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (i = 0; gui_buffer_properties_get_integer[i]; i++)
{
gui_completion_list_add (completion,
@@ -258,7 +258,7 @@ completion_list_add_buffer_properties_get_cb (void *data,
gui_buffer_properties_get_pointer[i],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -274,19 +274,19 @@ completion_list_add_windows_numbers_cb (void *data,
{
struct t_gui_window *ptr_win;
char str_number[32];
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
snprintf (str_number, sizeof (str_number), "%d", ptr_win->number);
gui_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
}
@@ -302,7 +302,7 @@ completion_list_map_add_palette_color_cb (void *data,
/* make C compiler happy */
(void) hashtable;
(void) value;
gui_completion_list_add ((struct t_gui_completion *)data,
(char *)key,
0, WEECHAT_LIST_POS_SORT);
@@ -322,11 +322,11 @@ completion_list_add_palette_colors_cb (void *data,
(void) data;
(void) completion_item;
(void) buffer;
hashtable_map (gui_color_hash_palette_color,
&completion_list_map_add_palette_color_cb,
completion);
return WEECHAT_RC_OK;
}
@@ -341,19 +341,19 @@ completion_list_add_config_files_cb (void *data,
struct t_gui_completion *completion)
{
struct t_config_file *ptr_config_file;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_config_file = config_files; ptr_config_file;
ptr_config_file = ptr_config_file->next_config)
{
gui_completion_list_add (completion, ptr_config_file->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -375,19 +375,19 @@ completion_list_add_filename_cb (void *data,
struct dirent *entry;
struct stat statbuf;
char home[3] = { '~', DIR_SEPARATOR_CHAR, '\0' };
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
buf_len = PATH_MAX;
buf = malloc (buf_len);
if (!buf)
return WEECHAT_RC_OK;
completion->add_space = 0;
if ((strncmp (completion->base_word, home, 2) == 0) && getenv("HOME"))
{
real_prefix = strdup (getenv("HOME"));
@@ -407,7 +407,7 @@ completion_list_add_filename_cb (void *data,
prefix = strdup (DIR_SEPARATOR);
}
}
snprintf (buf, buf_len, "%s", completion->base_word + strlen (prefix));
p = strrchr (buf, DIR_SEPARATOR_CHAR);
if (p)
@@ -422,7 +422,7 @@ completion_list_add_filename_cb (void *data,
path_d = strdup ("");
path_b = strdup (buf);
}
sprintf (buf, "%s%s%s", real_prefix, DIR_SEPARATOR, path_d);
d_name = strdup (buf);
dp = opendir (d_name);
@@ -434,12 +434,12 @@ completion_list_add_filename_cb (void *data,
{
if (strcmp (entry->d_name, ".") == 0 || strcmp (entry->d_name, "..") == 0)
continue;
snprintf (buf, buf_len, "%s%s%s",
d_name, DIR_SEPARATOR, entry->d_name);
if (stat (buf, &statbuf) == -1)
continue;
snprintf (buf, buf_len, "%s%s%s%s%s%s",
prefix,
((strcmp(prefix, "") == 0)
@@ -448,21 +448,21 @@ completion_list_add_filename_cb (void *data,
strcmp(path_d, "") == 0 ? "" : DIR_SEPARATOR,
entry->d_name,
S_ISDIR(statbuf.st_mode) ? DIR_SEPARATOR : "");
gui_completion_list_add (completion, buf,
0, WEECHAT_LIST_POS_SORT);
}
}
closedir (dp);
}
free (d_name);
free (prefix);
free (real_prefix);
free (path_d);
free (path_b);
free (buf);
return WEECHAT_RC_OK;
}
@@ -477,19 +477,19 @@ completion_list_add_filters_cb (void *data,
struct t_gui_completion *completion)
{
struct t_gui_filter *ptr_filter;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_filter = gui_filters; ptr_filter;
ptr_filter = ptr_filter->next_filter)
{
gui_completion_list_add (completion, ptr_filter->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -504,12 +504,12 @@ completion_list_add_commands_cb (void *data,
struct t_gui_completion *completion)
{
struct t_hook *ptr_hook;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
@@ -520,7 +520,7 @@ completion_list_add_commands_cb (void *data,
HOOK_COMMAND(ptr_hook, command),
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -535,12 +535,12 @@ completion_list_add_infos_cb (void *data,
struct t_gui_completion *completion)
{
struct t_hook *ptr_hook;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_hook = weechat_hooks[HOOK_TYPE_INFO]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
@@ -551,7 +551,7 @@ completion_list_add_infos_cb (void *data,
HOOK_INFO(ptr_hook, info_name),
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -566,12 +566,12 @@ completion_list_add_infolists_cb (void *data,
struct t_gui_completion *completion)
{
struct t_hook *ptr_hook;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_hook = weechat_hooks[HOOK_TYPE_INFOLIST]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
@@ -582,7 +582,7 @@ completion_list_add_infolists_cb (void *data,
HOOK_INFOLIST(ptr_hook, infolist_name),
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -599,12 +599,12 @@ completion_list_add_nicks_cb (void *data,
struct t_gui_nick_group *ptr_group;
struct t_gui_nick *ptr_nick;
int count_before;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
count_before = weelist_size (completion->completion_list);
hook_completion_exec (completion->buffer->plugin,
"nick",
@@ -630,7 +630,7 @@ completion_list_add_nicks_cb (void *data,
&ptr_group, &ptr_nick);
}
}
return WEECHAT_RC_OK;
}
@@ -650,12 +650,12 @@ completion_list_add_config_options_cb (void *data,
struct t_config_option *ptr_option;
int length;
char *option_full_name;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_config = config_files; ptr_config;
ptr_config = ptr_config->next_config)
{
@@ -682,7 +682,7 @@ completion_list_add_config_options_cb (void *data,
}
}
}
return WEECHAT_RC_OK;
}
@@ -697,19 +697,19 @@ completion_list_add_plugins_cb (void *data,
struct t_gui_completion *completion)
{
struct t_weechat_plugin *ptr_plugin;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
gui_completion_list_add (completion, ptr_plugin->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -728,12 +728,12 @@ completion_list_add_plugins_commands_cb (void *data,
char *pos_space, *plugin_name;
struct t_weechat_plugin *ptr_plugin;
struct t_hook *ptr_hook;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
if (completion->args)
{
pos_space = strchr (completion->args, ' ');
@@ -742,7 +742,7 @@ completion_list_add_plugins_commands_cb (void *data,
pos_space - completion->args);
else
plugin_name = strdup (completion->args);
if (plugin_name)
{
ptr_plugin = NULL;
@@ -772,7 +772,7 @@ completion_list_add_plugins_commands_cb (void *data,
free (plugin_name);
}
}
return WEECHAT_RC_OK;
}
@@ -788,7 +788,7 @@ completion_list_map_add_color_alias_cb (void *data,
/* make C compiler happy */
(void) hashtable;
(void) value;
gui_completion_list_add ((struct t_gui_completion *)data,
(char *)key,
0, WEECHAT_LIST_POS_SORT);
@@ -813,12 +813,12 @@ completion_list_add_config_option_values_cb (void *data,
struct t_config_section *ptr_section, *section_found;
struct t_config_option *option_found;
struct t_gui_color_palette *color_palette;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
if (completion->args)
{
pos_space = strchr (completion->args, ' ');
@@ -827,16 +827,16 @@ completion_list_add_config_option_values_cb (void *data,
pos_space - completion->args);
else
option_full_name = strdup (completion->args);
if (option_full_name)
{
file = NULL;
section = NULL;
pos_option = NULL;
pos_section = strchr (option_full_name, '.');
pos_option = (pos_section) ? strchr (pos_section + 1, '.') : NULL;
if (pos_section && pos_option)
{
file = string_strndup (option_full_name,
@@ -1043,7 +1043,7 @@ completion_list_add_config_option_values_cb (void *data,
free (section);
}
}
return WEECHAT_RC_OK;
}
@@ -1059,12 +1059,12 @@ completion_list_add_weechat_commands_cb (void *data,
struct t_gui_completion *completion)
{
struct t_hook *ptr_hook;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
@@ -1078,7 +1078,7 @@ completion_list_add_weechat_commands_cb (void *data,
0, WEECHAT_LIST_POS_SORT);
}
}
return WEECHAT_RC_OK;
}
@@ -1093,19 +1093,19 @@ completion_list_add_proxies_names_cb (void *data,
struct t_gui_completion *completion)
{
struct t_proxy *ptr_proxy;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (ptr_proxy = weechat_proxies; ptr_proxy;
ptr_proxy = ptr_proxy->next_proxy)
{
gui_completion_list_add (completion, ptr_proxy->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -1120,18 +1120,18 @@ completion_list_add_proxies_options_cb (void *data,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (i = 0; i < PROXY_NUM_OPTIONS; i++)
{
gui_completion_list_add (completion, proxy_option_string[i],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
}
@@ -1146,18 +1146,18 @@ completion_list_add_keys_contexts_cb (void *data,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
{
gui_completion_list_add (completion, gui_key_context_string[i],
0, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
}
@@ -1174,7 +1174,7 @@ completion_list_add_keys_codes_cb (void *data,
int i;
struct t_gui_key *ptr_key;
char *expanded_name;
/* make C compiler happy */
(void) data;
(void) completion_item;
@@ -1192,7 +1192,7 @@ completion_list_add_keys_codes_cb (void *data,
free (expanded_name);
}
}
return WEECHAT_RC_OK;
}
@@ -1211,7 +1211,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
int i;
struct t_gui_key *ptr_key, *ptr_default_key;
char *expanded_name;
/* make C compiler happy */
(void) data;
(void) completion_item;
@@ -1234,7 +1234,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
free (expanded_name);
}
}
/* keys deleted */
for (ptr_default_key = gui_default_keys[i]; ptr_default_key;
ptr_default_key = ptr_default_key->next_key)
@@ -1251,7 +1251,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
}
}
}
return WEECHAT_RC_OK;
}
@@ -1268,15 +1268,15 @@ completion_list_add_cursor_areas_cb (void *data,
{
struct t_gui_bar_window *ptr_bar_win;
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
(void) data;
(void) completion_item;
(void) buffer;
/* add "chat" for chat area */
gui_completion_list_add (completion, "chat", 0, WEECHAT_LIST_POS_SORT);
/* add bar windows (of current window) */
for (ptr_bar_win = gui_current_window->bar_windows; ptr_bar_win;
ptr_bar_win = ptr_bar_win->next_bar_window)
@@ -1292,7 +1292,7 @@ completion_list_add_cursor_areas_cb (void *data,
0, WEECHAT_LIST_POS_SORT);
}
}
return WEECHAT_RC_OK;
}
+164 -164
View File
File diff suppressed because it is too large Load Diff
+145 -145
View File
@@ -252,7 +252,7 @@ config_change_save_config_on_exit (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
if (!CONFIG_BOOLEAN(config_look_save_config_on_exit))
{
gui_chat_printf (NULL,
@@ -272,7 +272,7 @@ config_change_title (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
}
@@ -287,7 +287,7 @@ config_change_buffers (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_window_ask_refresh (1);
}
@@ -301,7 +301,7 @@ config_change_buffer_content (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
if (gui_ok)
gui_current_window->refresh_needed = 1;
}
@@ -316,7 +316,7 @@ config_change_buffer_notify_default (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_buffer_notify_set_all ();
}
@@ -330,7 +330,7 @@ config_change_buffer_time_format (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_chat_time_length = gui_chat_get_time_length ();
gui_chat_change_time_format ();
if (gui_ok)
@@ -347,7 +347,7 @@ config_change_eat_newline_glitch (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
if (gui_ok)
{
if (CONFIG_BOOLEAN(config_look_eat_newline_glitch))
@@ -367,14 +367,14 @@ config_change_highlight_regex (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
if (config_highlight_regex)
{
regfree (config_highlight_regex);
free (config_highlight_regex);
config_highlight_regex = NULL;
}
if (CONFIG_STRING(config_look_highlight_regex)
&& CONFIG_STRING(config_look_highlight_regex)[0])
{
@@ -402,14 +402,14 @@ config_change_highlight_tags (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
if (config_highlight_tags)
{
string_free_split (config_highlight_tags);
config_highlight_tags = NULL;
}
config_num_highlight_tags = 0;
if (CONFIG_STRING(config_look_highlight_tags)
&& CONFIG_STRING(config_look_highlight_tags)[0])
{
@@ -428,7 +428,7 @@ config_change_hotlist (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_hotlist_resort ();
}
@@ -442,7 +442,7 @@ config_change_read_marker (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_window_ask_refresh (1);
}
@@ -456,7 +456,7 @@ config_change_prefix (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_chat_prefix_build ();
}
@@ -468,11 +468,11 @@ void
config_change_prefix_align_min (void *data, struct t_config_option *option)
{
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
(void) option;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -494,7 +494,7 @@ config_change_color (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
if (gui_ok)
{
gui_color_init_weechat ();
@@ -512,7 +512,7 @@ config_change_nick_colors (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_color_buffer_display ();
}
@@ -527,7 +527,7 @@ config_change_network_gnutls_ca_file (void *data,
/* make C compiler happy */
(void) data;
(void) option;
if (network_init_ok)
network_set_gnutls_ca_file ();
}
@@ -546,15 +546,15 @@ config_day_change_timer_cb (void *data, int remaining_calls)
int new_mday;
char text_time[256], *text_time2;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
(void) remaining_calls;
gettimeofday (&tv_time, NULL);
local_time = localtime (&tv_time.tv_sec);
new_mday = local_time->tm_mday;
if ((config_day_change_old_day >= 0)
&& (new_mday != config_day_change_old_day))
{
@@ -580,14 +580,14 @@ config_day_change_timer_cb (void *data, int remaining_calls)
free (text_time2);
gui_add_hotlist = 1;
}
/* send signal "day_changed" */
strftime (text_time, sizeof (text_time), "%Y-%m-%d", local_time);
hook_signal_send ("day_changed", WEECHAT_HOOK_SIGNAL_STRING, text_time);
}
config_day_change_old_day = new_mday;
return WEECHAT_RC_OK;
}
@@ -600,11 +600,11 @@ void
config_weechat_init_after_read ()
{
int i;
gui_buffer_notify_set_all ();
proxy_use_temp_proxies ();
gui_bar_use_temp_bars ();
if (gui_bars)
{
@@ -619,7 +619,7 @@ config_weechat_init_after_read ()
/* no bar defined => create default bars */
gui_bar_create_default ();
}
/* if no key was found config file, then we use default bindings */
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
{
@@ -640,38 +640,38 @@ int
config_weechat_reload_cb (void *data, struct t_config_file *config_file)
{
int i, rc;
/* make C compiler happy */
(void) data;
/* remove all keys */
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
{
gui_key_free_all (&gui_keys[i], &last_gui_key[i],
&gui_keys_count[i]);
}
/* remove all proxies */
proxy_free_all ();
/* remove all bars */
gui_bar_free_all ();
/* remove layout */
gui_layout_buffer_reset (&gui_layout_buffers, &last_gui_layout_buffer);
gui_layout_window_reset (&gui_layout_windows);
/* remove all notify levels */
config_file_section_free_options (weechat_config_section_notify);
/* remove all filters */
gui_filter_free_all ();
rc = config_file_reload (config_file);
if (rc == WEECHAT_CONFIG_READ_OK)
config_weechat_init_after_read ();
return rc;
}
@@ -697,11 +697,11 @@ config_weechat_debug_set_all ()
{
struct t_config_option *ptr_option;
struct t_weechat_plugin *ptr_plugin;
/* set debug for core */
ptr_option = config_weechat_debug_get (PLUGIN_CORE);
weechat_debug_core = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
/* set debug for plugins */
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
@@ -722,7 +722,7 @@ config_weechat_debug_change_cb (void *data,
/* make C compiler happy */
(void) data;
(void) option;
config_weechat_debug_set_all ();
}
@@ -739,12 +739,12 @@ config_weechat_debug_create_option_cb (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 = config_file_search_option (config_file, section,
@@ -777,10 +777,10 @@ config_weechat_debug_create_option_cb (void *data,
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
/* set debug level for "core" and all plugins */
config_weechat_debug_set_all ();
return rc;
}
@@ -798,11 +798,11 @@ config_weechat_debug_delete_option_cb (void *data,
(void) data;
(void) config_file;
(void) section;
config_file_option_free (option);
config_weechat_debug_set_all ();
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
@@ -830,11 +830,11 @@ config_weechat_palette_change_cb (void *data,
{
char *error;
int number;
/* make C compiler happy */
(void) data;
(void) option;
error = NULL;
number = (int)strtol (option->name, &error, 10);
if (error && !error[0])
@@ -857,10 +857,10 @@ config_weechat_palette_create_option_cb (void *data,
struct t_config_option *ptr_option;
char *error;
int rc, number;
/* make C compiler happy */
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
error = NULL;
@@ -908,7 +908,7 @@ config_weechat_palette_create_option_cb (void *data,
_("%sError: palette option must be numeric"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
}
return rc;
}
@@ -924,19 +924,19 @@ config_weechat_palette_delete_option_cb (void *data,
{
char *error;
int number;
/* make C compiler happy */
(void) data;
(void) config_file;
(void) section;
error = NULL;
number = (int)strtol (option->name, &error, 10);
if (error && !error[0])
gui_color_palette_remove (number);
config_file_option_free (option);
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
@@ -952,12 +952,12 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
char *pos_option, *proxy_name;
struct t_proxy *ptr_temp_proxy;
int index_option;
/* make C compiler happy */
(void) data;
(void) config_file;
(void) section;
if (option_name)
{
pos_option = strchr (option_name, '.');
@@ -982,7 +982,7 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
/* add new temp proxy at end of queue */
ptr_temp_proxy->prev_proxy = last_weechat_temp_proxy;
ptr_temp_proxy->next_proxy = NULL;
if (!weechat_temp_proxies)
weechat_temp_proxies = ptr_temp_proxy;
else
@@ -990,7 +990,7 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
last_weechat_temp_proxy = ptr_temp_proxy;
}
}
if (ptr_temp_proxy)
{
index_option = proxy_search_option (pos_option);
@@ -1000,12 +1000,12 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
value);
}
}
free (proxy_name);
}
}
}
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
@@ -1021,12 +1021,12 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
char *pos_option, *bar_name;
struct t_gui_bar *ptr_temp_bar;
int index_option;
/* make C compiler happy */
(void) data;
(void) config_file;
(void) section;
if (option_name)
{
pos_option = strchr (option_name, '.');
@@ -1051,7 +1051,7 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
/* add new temp bar at end of queue */
ptr_temp_bar->prev_bar = last_gui_temp_bar;
ptr_temp_bar->next_bar = NULL;
if (!gui_temp_bars)
gui_temp_bars = ptr_temp_bar;
else
@@ -1059,7 +1059,7 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
last_gui_temp_bar = ptr_temp_bar;
}
}
if (ptr_temp_bar)
{
index_option = gui_bar_search_option (pos_option);
@@ -1069,12 +1069,12 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
value);
}
}
free (bar_name);
}
}
}
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
@@ -1091,12 +1091,12 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
char **argv, *error1, *error2, *error3, *error4;
long number1, number2, number3, number4;
struct t_gui_layout_window *parent;
/* make C compiler happy */
(void) data;
(void) config_file;
(void) section;
if (option_name && value && value[0])
{
if (string_strcasecmp (option_name, "buffer") == 0)
@@ -1153,7 +1153,7 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
}
}
}
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
@@ -1176,21 +1176,21 @@ config_weechat_layout_write_tree (struct t_config_file *config_file,
(layout_window->buffer_name) ?
layout_window->buffer_name : "-"))
return WEECHAT_CONFIG_WRITE_ERROR;
if (layout_window->child1)
{
if (config_weechat_layout_write_tree (config_file,
layout_window->child1) != WEECHAT_CONFIG_WRITE_OK)
return WEECHAT_CONFIG_WRITE_ERROR;
}
if (layout_window->child2)
{
if (config_weechat_layout_write_tree (config_file,
layout_window->child2) != WEECHAT_CONFIG_WRITE_OK)
return WEECHAT_CONFIG_WRITE_ERROR;
}
return WEECHAT_CONFIG_WRITE_OK;
}
@@ -1203,13 +1203,13 @@ config_weechat_layout_write_cb (void *data, struct t_config_file *config_file,
const char *section_name)
{
struct t_gui_layout_buffer *ptr_layout_buffer;
/* make C compiler happy */
(void) data;
if (!config_file_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (ptr_layout_buffer = gui_layout_buffers; ptr_layout_buffer;
ptr_layout_buffer = ptr_layout_buffer->next_layout)
{
@@ -1219,14 +1219,14 @@ config_weechat_layout_write_cb (void *data, struct t_config_file *config_file,
ptr_layout_buffer->number))
return WEECHAT_CONFIG_WRITE_ERROR;
}
if (gui_layout_windows)
{
if (config_weechat_layout_write_tree (config_file,
gui_layout_windows) != WEECHAT_CONFIG_WRITE_OK)
return WEECHAT_CONFIG_WRITE_ERROR;
}
return WEECHAT_CONFIG_WRITE_OK;
}
@@ -1240,7 +1240,7 @@ config_weechat_notify_change_cb (void *data, struct t_config_option *option)
/* make C compiler happy */
(void) data;
(void) option;
gui_buffer_notify_set_all ();
}
@@ -1258,12 +1258,12 @@ config_weechat_notify_create_option_cb (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 = config_file_search_option (config_file, section,
@@ -1296,10 +1296,10 @@ config_weechat_notify_create_option_cb (void *data,
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
gui_buffer_notify_set_all ();
return rc;
}
@@ -1318,11 +1318,11 @@ config_weechat_notify_delete_option_cb (void *data,
(void) data;
(void) config_file;
(void) section;
config_file_option_free (option);
gui_buffer_notify_set_all ();
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
@@ -1339,10 +1339,10 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
const char *plugin_name;
char *option_name;
int i, value, length;
if (!buffer || !notify)
return 0;
value = -1;
for (i = 0; i < GUI_BUFFER_NUM_NOTIFY; i++)
{
@@ -1354,14 +1354,14 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
}
if ((value < 0) && (strcmp (notify, "reset") != 0))
return 0;
plugin_name = gui_buffer_get_plugin_name (buffer);
length = strlen (plugin_name) + 1 + strlen (buffer->name) + 1;
option_name = malloc (length);
if (option_name)
{
snprintf (option_name, length, "%s.%s", plugin_name, buffer->name);
/* create/update option */
config_weechat_notify_create_option_cb (NULL,
weechat_config_file,
@@ -1371,7 +1371,7 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
NULL : gui_buffer_notify_string[value]);
return 1;
}
return 0;
}
@@ -1387,12 +1387,12 @@ config_weechat_filter_read_cb (void *data,
{
char **argv, **argv_eol;
int argc;
/* make C compiler happy */
(void) data;
(void) config_file;
(void) section;
if (option_name && value && value[0])
{
argv = string_split (value, ";", 0, 0, &argc);
@@ -1407,7 +1407,7 @@ config_weechat_filter_read_cb (void *data,
if (argv_eol)
string_free_split (argv_eol);
}
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
@@ -1420,13 +1420,13 @@ config_weechat_filter_write_cb (void *data, struct t_config_file *config_file,
const char *section_name)
{
struct t_gui_filter *ptr_filter;
/* make C compiler happy */
(void) data;
if (!config_file_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (ptr_filter = gui_filters; ptr_filter;
ptr_filter = ptr_filter->next_filter)
{
@@ -1439,7 +1439,7 @@ config_weechat_filter_write_cb (void *data, struct t_config_file *config_file,
ptr_filter->regex))
return WEECHAT_CONFIG_WRITE_ERROR;
}
return WEECHAT_CONFIG_WRITE_OK;
}
@@ -1454,11 +1454,11 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
{
int context;
char *pos;
/* make C compiler happy */
(void) data;
(void) config_file;
if (option_name)
{
context = GUI_KEY_CONTEXT_DEFAULT;
@@ -1469,7 +1469,7 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
if (context < 0)
context = GUI_KEY_CONTEXT_DEFAULT;
}
if (value && value[0])
{
/* bind key (overwrite any binding with same key) */
@@ -1481,7 +1481,7 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
gui_key_unbind (NULL, context, option_name);
}
}
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
@@ -1496,10 +1496,10 @@ config_weechat_key_write_cb (void *data, struct t_config_file *config_file,
struct t_gui_key *ptr_key;
char *pos, *expanded_name;
int rc, context;
/* make C compiler happy */
(void) data;
if (!config_file_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
@@ -1526,7 +1526,7 @@ config_weechat_key_write_cb (void *data, struct t_config_file *config_file,
return WEECHAT_CONFIG_WRITE_ERROR;
}
}
return WEECHAT_CONFIG_WRITE_OK;
}
@@ -1541,12 +1541,12 @@ config_weechat_init_options ()
struct t_config_section *ptr_section;
int i;
char section_name[128];
weechat_config_file = config_file_new (NULL, WEECHAT_CONFIG_NAME,
&config_weechat_reload_cb, NULL);
if (!weechat_config_file)
return 0;
/* debug */
ptr_section = config_file_new_section (weechat_config_file, "debug",
1, 1,
@@ -1559,9 +1559,9 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
weechat_config_section_debug = ptr_section;
/* startup */
ptr_section = config_file_new_section (weechat_config_file, "startup",
0, 0,
@@ -1572,7 +1572,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
config_startup_command_after_plugins = config_file_new_option (
weechat_config_file, ptr_section,
"command_after_plugins", "string",
@@ -1593,7 +1593,7 @@ config_weechat_init_options ()
"display_version", "boolean",
N_("display WeeChat version at startup"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* look */
ptr_section = config_file_new_section (weechat_config_file, "look",
0, 0,
@@ -1604,7 +1604,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
config_look_align_end_of_lines = config_file_new_option (
weechat_config_file, ptr_section,
"align_end_of_lines", "integer",
@@ -2051,7 +2051,7 @@ config_weechat_init_options ()
N_("time format for dates converted to strings and displayed in "
"messages"),
NULL, 0, 0, "%a, %d %b %Y %T", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* palette */
ptr_section = config_file_new_section (weechat_config_file, "palette",
1, 1,
@@ -2064,7 +2064,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
/* colors */
ptr_section = config_file_new_section (weechat_config_file, "color",
0, 0,
@@ -2075,9 +2075,9 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
weechat_config_section_color = ptr_section;
/* general color settings */
config_color_separator = config_file_new_option (
weechat_config_file, ptr_section,
@@ -2414,7 +2414,7 @@ config_weechat_init_options ()
N_("text color for offline nicknames"),
NULL, -1, 0, "blue", NULL, 0,
NULL, NULL, &config_change_color, NULL, NULL, NULL);
/* completion */
ptr_section = config_file_new_section (weechat_config_file, "completion",
0, 0,
@@ -2425,7 +2425,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
config_completion_default_template = config_file_new_option (
weechat_config_file, ptr_section,
"default_template", "string",
@@ -2482,7 +2482,7 @@ config_weechat_init_options ()
"partial_completion_count", "boolean",
N_("display count for each partial completion in bar item"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* history */
ptr_section = config_file_new_section (weechat_config_file, "history",
0, 0,
@@ -2493,7 +2493,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
config_history_max_lines = config_file_new_option (
weechat_config_file, ptr_section,
"max_lines", "integer",
@@ -2517,7 +2517,7 @@ config_weechat_init_options ()
N_("maximum number of commands to display by default in "
"history listing (0 = unlimited)"),
NULL, 0, INT_MAX, "5", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* proxies */
ptr_section = config_file_new_section (weechat_config_file, "proxy",
0, 0,
@@ -2529,7 +2529,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
weechat_config_section_proxy = ptr_section;
/* network */
@@ -2542,7 +2542,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
config_network_gnutls_ca_file = config_file_new_option (
weechat_config_file, ptr_section,
"gnutls_ca_file", "string",
@@ -2555,7 +2555,7 @@ config_weechat_init_options ()
"gnutls_handshake_timeout", "integer",
N_("timeout (in seconds) for gnutls handshake"),
NULL, 1, INT_MAX, "30", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* plugin */
ptr_section = config_file_new_section (weechat_config_file, "plugin",
0, 0,
@@ -2566,7 +2566,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
config_plugin_autoload = config_file_new_option (
weechat_config_file, ptr_section,
"autoload", "string",
@@ -2605,7 +2605,7 @@ config_weechat_init_options ()
"save_config_on_unload", "boolean",
N_("save configuration files when unloading plugins"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* bars */
ptr_section = config_file_new_section (weechat_config_file, "bar",
0, 0,
@@ -2617,9 +2617,9 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
weechat_config_section_bar = ptr_section;
/* layout */
ptr_section = config_file_new_section (weechat_config_file, "layout",
0, 0,
@@ -2631,7 +2631,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
/* notify */
ptr_section = config_file_new_section (weechat_config_file, "notify",
1, 1,
@@ -2645,9 +2645,9 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
weechat_config_section_notify = ptr_section;
/* filters */
ptr_section = config_file_new_section (weechat_config_file, "filter",
0, 0,
@@ -2660,7 +2660,7 @@ config_weechat_init_options ()
config_file_free (weechat_config_file);
return 0;
}
/* keys */
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
{
@@ -2680,7 +2680,7 @@ config_weechat_init_options ()
return 0;
}
}
return 1;
}
@@ -2695,15 +2695,15 @@ config_weechat_init ()
int rc;
struct timeval tv_time;
struct tm *local_time;
rc = config_weechat_init_options ();
if (!rc)
{
gui_chat_printf (NULL,
_("FATAL: error initializing configuration options"));
}
if (!config_day_change_timer)
{
/* create timer to check if day has changed */
@@ -2721,7 +2721,7 @@ config_weechat_init ()
config_change_highlight_regex (NULL, NULL);
if (!config_highlight_tags)
config_change_highlight_tags (NULL, NULL);
return rc;
}
@@ -2737,18 +2737,18 @@ int
config_weechat_read ()
{
int rc;
rc = config_file_read (weechat_config_file);
if (rc == WEECHAT_CONFIG_READ_OK)
config_weechat_init_after_read ();
if (rc != WEECHAT_CONFIG_READ_OK)
{
gui_chat_printf (NULL,
_("%sError reading configuration"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
}
return rc;
}
+37 -37
View File
@@ -69,14 +69,14 @@ debug_dump (int crash)
/* prevent reentrance */
if (debug_dump_active)
exit (EXIT_FAILURE);
if (crash)
{
debug_dump_active = 1;
log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)...");
weechat_log_use_time = 0;
}
log_printf ("");
if (crash)
{
@@ -97,19 +97,19 @@ debug_dump (int crash)
gui_bar_print_log ();
gui_bar_item_print_log ();
gui_hotlist_print_log ();
hdata_print_log ();
infolist_print_log ();
hook_print_log ();
config_file_print_log ();
proxy_print_log ();
plugin_print_log ();
log_printf ("");
log_printf ("****** End of WeeChat dump ******");
log_printf ("");
@@ -127,10 +127,10 @@ debug_dump_cb (void *data, const char *signal, const char *type_data,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data || (string_strcasecmp ((char *)signal_data, "core") == 0))
debug_dump (0);
return WEECHAT_RC_OK;
}
@@ -145,7 +145,7 @@ debug_sigsegv ()
debug_dump (1);
unhook_all ();
gui_main_end (0);
string_iconv_fprintf (stderr, "\n");
string_iconv_fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n");
if (!log_crash_rename ())
@@ -160,9 +160,9 @@ debug_sigsegv ()
string_iconv_fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n");
string_iconv_fprintf (stderr, "*** (be careful, private info may be in this file since\n");
string_iconv_fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");
weechat_backtrace ();
/* shutdown with error code */
weechat_shutdown (EXIT_FAILURE, 1);
}
@@ -179,9 +179,9 @@ debug_buffer_cb (void *data, const char *signal, const char *type_data,
(void) data;
(void) signal;
(void) type_data;
gui_buffer_dump_hexa ((struct t_gui_buffer *)signal_data);
return WEECHAT_RC_OK;
}
@@ -193,7 +193,7 @@ void
debug_windows_tree_display (struct t_gui_window_tree *tree, int indent)
{
char format[128];
if (tree)
{
if (tree->window)
@@ -229,7 +229,7 @@ debug_windows_tree_display (struct t_gui_window_tree *tree, int indent)
tree->split_horizontal,
tree->child1, tree->child2);
}
if (tree->child1)
debug_windows_tree_display (tree->child1, indent + 1);
if (tree->child2)
@@ -262,9 +262,9 @@ debug_windows_cb (void *data, const char *signal, const char *type_data,
(void) signal;
(void) type_data;
(void) signal_data;
debug_windows_tree ();
return WEECHAT_RC_OK;
}
@@ -277,9 +277,9 @@ debug_memory ()
{
#ifdef HAVE_MALLINFO
struct mallinfo info;
info = mallinfo ();
gui_chat_printf (NULL, "");
gui_chat_printf (NULL, _("Memory usage (see \"man mallinfo\" for help):"));
gui_chat_printf (NULL, " arena :%10d", info.arena);
@@ -310,12 +310,12 @@ debug_hdata_hash_var_map_cb (void *data,
{
struct t_weelist *list;
char str_offset[16];
/* make C compiler happy */
(void) hashtable;
list = (struct t_weelist *)data;
snprintf (str_offset, sizeof (str_offset),
"%12d", (*((int *)value)) & 0xFFFF);
weelist_add (list, str_offset, WEECHAT_LIST_POS_SORT, (void *)key);
@@ -333,7 +333,7 @@ debug_hdata_hash_list_map_cb (void *data,
/* make C compiler happy */
(void) data;
(void) hashtable;
gui_chat_printf (NULL,
" list: %s -> 0x%lx",
(char *)key,
@@ -352,13 +352,13 @@ debug_hdata_map_cb (void *data, struct t_hashtable *hashtable,
struct t_weelist *list;
struct t_weelist_item *ptr_item;
void *ptr_value;
/* make C compiler happy */
(void) data;
(void) hashtable;
ptr_hdata = (struct t_hdata *)value;
gui_chat_printf (NULL,
" hdata 0x%lx: \"%s\", %d vars, %d lists:",
ptr_hdata, (const char *)key,
@@ -366,11 +366,11 @@ debug_hdata_map_cb (void *data, struct t_hashtable *hashtable,
"items_count"),
hashtable_get_integer (ptr_hdata->hash_list,
"items_count"));
/* display lists */
hashtable_map (ptr_hdata->hash_list,
&debug_hdata_hash_list_map_cb, NULL);
/* display vars */
list = weelist_new ();
hashtable_map (ptr_hdata->hash_var,
@@ -399,12 +399,12 @@ void
debug_hdata ()
{
int count;
count = hashtable_get_integer (weechat_hdata, "items_count");
gui_chat_printf (NULL, "");
gui_chat_printf (NULL, "%d hdata in memory", count);
if (count > 0)
hashtable_map (weechat_hdata, &debug_hdata_map_cb, NULL);
}
@@ -421,21 +421,21 @@ debug_infolists ()
struct t_infolist_var *ptr_var;
int i, count, count_items, count_vars, size_structs, size_data;
int total_items, total_vars, total_size;
count = 0;
for (ptr_infolist = weechat_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
count++;
}
gui_chat_printf (NULL, "");
gui_chat_printf (NULL, "%d infolists in memory (%s)", count,
(count == 0) ?
"this is ok!" :
"WARNING: this is probably a memory leak in WeeChat or "
"plugins/scripts!");
if (count > 0)
{
i = 0;
+72 -72
View File
@@ -52,16 +52,16 @@ int
hashtable_get_type (const char *type)
{
int i;
if (!type)
return -1;
for (i = 0; i < HASHTABLE_NUM_TYPES; i++)
{
if (string_strcasecmp (hashtable_type_string[i], type) == 0)
return i;
}
/* type not found */
return -1;
}
@@ -75,7 +75,7 @@ hashtable_hash_key_string_cb (struct t_hashtable *hashtable, const void *key)
{
const char *ptr_key;
unsigned long hash;
/* variant of djb2 hash */
hash = 5381;
for (ptr_key = (const char *)key; ptr_key[0]; ptr_key++)
@@ -95,7 +95,7 @@ hashtable_keycmp_string_cb (struct t_hashtable *hashtable,
{
/* make C compiler happy */
(void) hashtable;
return strcmp ((const char *)key1, (const char *)key2);
}
@@ -111,17 +111,17 @@ hashtable_new (int size,
{
struct t_hashtable *new_hashtable;
int i, type_keys_int, type_values_int;
type_keys_int = hashtable_get_type (type_keys);
if (type_keys_int < 0)
return NULL;
type_values_int = hashtable_get_type (type_values);
if (type_values_int < 0)
return NULL;
if ((type_keys_int != HASHTABLE_STRING) && (!callback_hash_key || !callback_keycmp))
return NULL;
new_hashtable = malloc (sizeof (*new_hashtable));
if (new_hashtable)
{
@@ -140,17 +140,17 @@ hashtable_new (int size,
new_hashtable->htable[i] = NULL;
}
new_hashtable->items_count = 0;
if ((type_keys_int == HASHTABLE_STRING) && !callback_hash_key)
new_hashtable->callback_hash_key = &hashtable_hash_key_string_cb;
else
new_hashtable->callback_hash_key = callback_hash_key;
if ((type_keys_int == HASHTABLE_STRING) && !callback_keycmp)
new_hashtable->callback_keycmp = &hashtable_keycmp_string_cb;
else
new_hashtable->callback_keycmp = callback_keycmp;
new_hashtable->callback_free_value = NULL;
}
return new_hashtable;
@@ -281,14 +281,14 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
{
unsigned int hash;
struct t_hashtable_item *ptr_item, *pos_item, *new_item;
if (!hashtable || !key
|| ((hashtable->type_keys == HASHTABLE_BUFFER) && (key_size <= 0))
|| ((hashtable->type_values == HASHTABLE_BUFFER) && (value_size <= 0)))
{
return 0;
}
/* search position for item in hash table */
hash = hashtable->callback_hash_key (hashtable, key);
pos_item = NULL;
@@ -299,7 +299,7 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
{
pos_item = ptr_item;
}
/* replace value if item is already in hash table */
if (ptr_item && (hashtable->callback_keycmp (hashtable, key, ptr_item->key) == 0))
{
@@ -309,12 +309,12 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
&ptr_item->value, &ptr_item->value_size);
return 1;
}
/* create new item */
new_item = malloc (sizeof (*new_item));
if (!new_item)
return 0;
/* set key and value */
hashtable_alloc_type (hashtable->type_keys,
key, key_size,
@@ -322,7 +322,7 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
hashtable_alloc_type (hashtable->type_values,
value, value_size,
&new_item->value, &new_item->value_size);
/* add item */
if (pos_item)
{
@@ -342,9 +342,9 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
(hashtable->htable[hash])->prev_item = new_item;
hashtable->htable[hash] = new_item;
}
hashtable->items_count++;
return 1;
}
@@ -374,10 +374,10 @@ hashtable_get_item (struct t_hashtable *hashtable, const void *key,
{
unsigned int key_hash;
struct t_hashtable_item *ptr_item;
if (!hashtable)
return NULL;
key_hash = hashtable->callback_hash_key (hashtable, key);
if (hash)
*hash = key_hash;
@@ -386,13 +386,13 @@ hashtable_get_item (struct t_hashtable *hashtable, const void *key,
ptr_item = ptr_item->next_item)
{
}
if (ptr_item
&& (hashtable->callback_keycmp (hashtable, key, ptr_item->key) == 0))
{
return ptr_item;
}
return NULL;
}
@@ -406,9 +406,9 @@ void *
hashtable_get (struct t_hashtable *hashtable, const void *key)
{
struct t_hashtable_item *ptr_item;
ptr_item = hashtable_get_item (hashtable, key, NULL);
return (ptr_item) ? ptr_item->value : NULL;
}
@@ -433,22 +433,22 @@ hashtable_map (struct t_hashtable *hashtable,
{
int i;
struct t_hashtable_item *ptr_item, *ptr_next_item;
if (!hashtable)
return;
for (i = 0; i < hashtable->size; i++)
{
ptr_item = hashtable->htable[i];
while (ptr_item)
{
ptr_next_item = ptr_item->next_item;
(void) (callback_map) (callback_map_data,
hashtable,
ptr_item->key,
ptr_item->value);
ptr_item = ptr_next_item;
}
}
@@ -465,10 +465,10 @@ hashtable_duplicate_map_cb (void *data,
const void *key, const void *value)
{
struct t_hashtable *hashtable2;
/* make C compiler happy */
(void) hashtable;
hashtable2 = (struct t_hashtable *)data;
if (hashtable2)
hashtable_set (hashtable2, key, value);
@@ -482,7 +482,7 @@ struct t_hashtable *
hashtable_dup (struct t_hashtable *hashtable)
{
struct t_hashtable *new_hashtable;
new_hashtable = hashtable_new (hashtable->size,
hashtable_type_string[hashtable->type_keys],
hashtable_type_string[hashtable->type_values],
@@ -495,7 +495,7 @@ hashtable_dup (struct t_hashtable *hashtable)
&hashtable_duplicate_map_cb,
new_hashtable);
}
return new_hashtable;
}
@@ -511,13 +511,13 @@ hashtable_get_list_keys_map_cb (void *data,
{
struct t_weelist *list;
char str_key[128];
/* make C compiler happy */
(void) hashtable;
(void) value;
list = (struct t_weelist *)data;
switch (hashtable->type_keys)
{
case HASHTABLE_INTEGER:
@@ -550,7 +550,7 @@ struct t_weelist *
hashtable_get_list_keys (struct t_hashtable *hashtable)
{
struct t_weelist *weelist;
weelist = weelist_new ();
if (weelist)
hashtable_map (hashtable, &hashtable_get_list_keys_map_cb, weelist);
@@ -571,7 +571,7 @@ hashtable_get_integer (struct t_hashtable *hashtable, const char *property)
else if (string_strcasecmp (property, "items_count") == 0)
return hashtable->items_count;
}
return 0;
}
@@ -586,12 +586,12 @@ hashtable_compute_length_keys_cb (void *data,
{
char str_value[128];
int *length;
/* make C compiler happy */
(void) value;
length = (int *)data;
switch (hashtable->type_keys)
{
case HASHTABLE_INTEGER:
@@ -626,10 +626,10 @@ hashtable_compute_length_values_cb (void *data,
{
char str_value[128];
int *length;
/* make C compiler happy */
(void) key;
length = (int *)data;
if (value)
@@ -686,15 +686,15 @@ hashtable_build_string_keys_cb (void *data,
{
char str_value[128];
char *str;
/* make C compiler happy */
(void) value;
str = (char *)data;
if (str[0])
strcat (str, ",");
switch (hashtable->type_keys)
{
case HASHTABLE_INTEGER:
@@ -729,12 +729,12 @@ hashtable_build_string_values_cb (void *data,
{
char str_value[128];
char *str;
/* make C compiler happy */
(void) key;
str = (char *)data;
if (str[0])
strcat (str, ",");
@@ -779,12 +779,12 @@ hashtable_build_string_keys_values_cb (void *data,
{
char str_value[128];
char *str;
str = (char *)data;
if (str[0])
strcat (str, ",");
switch (hashtable->type_keys)
{
case HASHTABLE_INTEGER:
@@ -806,7 +806,7 @@ hashtable_build_string_keys_values_cb (void *data,
case HASHTABLE_NUM_TYPES:
break;
}
strcat (str, ":");
if (value)
@@ -854,13 +854,13 @@ hashtable_get_keys_values (struct t_hashtable *hashtable,
int length;
struct t_weelist *list_keys;
struct t_weelist_item *ptr_item;
if (hashtable->keys_values)
{
free (hashtable->keys_values);
hashtable->keys_values = NULL;
}
/* first compute length of string */
length = 0;
hashtable_map (hashtable,
@@ -870,7 +870,7 @@ hashtable_get_keys_values (struct t_hashtable *hashtable,
&length);
if (length == 0)
return hashtable->keys_values;
/* build string */
hashtable->keys_values = malloc (length + 1);
if (!hashtable->keys_values)
@@ -911,7 +911,7 @@ hashtable_get_keys_values (struct t_hashtable *hashtable,
&hashtable_build_string_values_cb),
hashtable->keys_values);
}
return hashtable->keys_values;
}
@@ -939,7 +939,7 @@ hashtable_get_string (struct t_hashtable *hashtable, const char *property)
else if (string_strcasecmp (property, "keys_values_sorted") == 0)
return hashtable_get_keys_values (hashtable, 1, 1, 1);
}
return NULL;
}
@@ -971,11 +971,11 @@ hashtable_add_to_infolist (struct t_hashtable *hashtable,
int i, item_number;
struct t_hashtable_item *ptr_item;
char option_name[128];
if (!hashtable || (hashtable->type_keys != HASHTABLE_STRING)
|| !infolist_item || !prefix)
return 0;
item_number = 0;
for (i = 0; i < hashtable->size; i++)
{
@@ -1037,11 +1037,11 @@ hashtable_remove_item (struct t_hashtable *hashtable,
{
if (!hashtable || !item)
return;
/* free key and value */
hashtable_free_value (hashtable, item);
hashtable_free_key (hashtable, item);
/* remove item from list */
if (item->prev_item)
(item->prev_item)->next_item = item->next_item;
@@ -1049,9 +1049,9 @@ hashtable_remove_item (struct t_hashtable *hashtable,
(item->next_item)->prev_item = item->prev_item;
if (hashtable->htable[hash] == item)
hashtable->htable[hash] = item->next_item;
free (item);
hashtable->items_count--;
}
@@ -1064,10 +1064,10 @@ hashtable_remove (struct t_hashtable *hashtable, const void *key)
{
struct t_hashtable_item *ptr_item;
unsigned int hash;
if (!hashtable || !key)
return;
ptr_item = hashtable_get_item (hashtable, key, &hash);
if (ptr_item)
hashtable_remove_item (hashtable, ptr_item, hash);
@@ -1081,10 +1081,10 @@ void
hashtable_remove_all (struct t_hashtable *hashtable)
{
int i;
if (!hashtable)
return;
for (i = 0; i < hashtable->size; i++)
{
while (hashtable->htable[i])
@@ -1103,7 +1103,7 @@ hashtable_free (struct t_hashtable *hashtable)
{
if (!hashtable)
return;
hashtable_remove_all (hashtable);
free (hashtable->htable);
if (hashtable->keys_values)
@@ -1120,7 +1120,7 @@ hashtable_print_log (struct t_hashtable *hashtable, const char *name)
{
struct t_hashtable_item *ptr_item;
int i;
log_printf ("");
log_printf ("[hashtable %s (addr:0x%lx)]", name, hashtable);
log_printf (" size . . . . . . . . . : %d", hashtable->size);
@@ -1134,7 +1134,7 @@ hashtable_print_log (struct t_hashtable *hashtable, const char *name)
hashtable_type_string[hashtable->type_values]);
log_printf (" callback_hash_key. . . : 0x%lx", hashtable->callback_hash_key);
log_printf (" callback_keycmp. . . . : 0x%lx", hashtable->callback_keycmp);
for (i = 0; i < hashtable->size; i++)
{
log_printf (" htable[%06d] . . . . : 0x%lx", i, hashtable->htable[i]);
+3 -3
View File
@@ -91,16 +91,16 @@ struct t_hashtable
struct t_hashtable_item **htable; /* table to map hashes with linked */
/* lists */
int items_count; /* number of items in hashtable */
/* type for keys and values */
enum t_hashtable_type type_keys; /* type for keys: int/str/pointer */
enum t_hashtable_type type_values; /* type for values: int/str/pointer */
/* callbacks */
t_hashtable_hash_key *callback_hash_key; /* hash key to int value */
t_hashtable_keycmp *callback_keycmp; /* compare two keys */
t_hashtable_free_value *callback_free_value; /* callback to free value */
/* keys/values as string */
char *keys_values; /* keys/values as string (NULL if */
/* never asked) */
+39 -39
View File
@@ -51,10 +51,10 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name,
const char *var_prev, const char *var_next)
{
struct t_hdata *new_hdata;
if (!hdata_name || !hdata_name[0])
return NULL;
new_hdata = malloc (sizeof (*new_hdata));
if (new_hdata)
{
@@ -78,7 +78,7 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name,
NULL);
hashtable_set (weechat_hdata, hdata_name, new_hdata);
}
return new_hdata;
}
@@ -91,7 +91,7 @@ hdata_new_var (struct t_hdata *hdata, const char *name, int offset, int type,
const char *hdata_name)
{
int value;
if (hdata && name)
{
value = (type << 16) | (offset & 0xFFFF);
@@ -120,14 +120,14 @@ int
hdata_get_var_offset (struct t_hdata *hdata, const char *name)
{
int *ptr_value;
if (hdata && name)
{
ptr_value = hashtable_get (hdata->hash_var, name);
if (ptr_value)
return (*ptr_value) & 0xFFFF;
}
return -1;
}
@@ -139,14 +139,14 @@ int
hdata_get_var_type (struct t_hdata *hdata, const char *name)
{
int *ptr_value;
if (hdata && name)
{
ptr_value = hashtable_get (hdata->hash_var, name);
if (ptr_value)
return (*ptr_value) >> 16;
}
return -1;
}
@@ -158,14 +158,14 @@ const char *
hdata_get_var_type_string (struct t_hdata *hdata, const char *name)
{
int *ptr_value;
if (hdata && name)
{
ptr_value = hashtable_get (hdata->hash_var, name);
if (ptr_value)
return hdata_type_string[(*ptr_value) >> 16];
}
return NULL;
}
@@ -179,7 +179,7 @@ hdata_get_var_hdata (struct t_hdata *hdata, const char *name)
{
if (hdata && name)
return (const char *)hashtable_get (hdata->hash_var_hdata, name);
return NULL;
}
@@ -191,14 +191,14 @@ void *
hdata_get_var (struct t_hdata *hdata, void *pointer, const char *name)
{
int offset;
if (hdata && pointer)
{
offset = hdata_get_var_offset (hdata, name);
if (offset >= 0)
return pointer + offset;
}
return NULL;
}
@@ -212,7 +212,7 @@ hdata_get_var_at_offset (struct t_hdata *hdata, void *pointer, int offset)
{
if (hdata && pointer)
return pointer + offset;
return NULL;
}
@@ -224,14 +224,14 @@ void *
hdata_get_list (struct t_hdata *hdata, const char *name)
{
void *ptr_value;
if (hdata && name)
{
ptr_value = hashtable_get (hdata->hash_list, name);
if (ptr_value)
return *((void **)ptr_value);
}
return NULL;
}
@@ -244,12 +244,12 @@ hdata_move (struct t_hdata *hdata, void *pointer, int count)
{
char *ptr_var;
int i, abs_count;
if (hdata && pointer && (count != 0))
{
ptr_var = (count < 0) ? hdata->var_prev : hdata->var_next;
abs_count = abs(count);
for (i = 0; i < abs_count; i++)
{
pointer = hdata_pointer (hdata, pointer, ptr_var);
@@ -257,7 +257,7 @@ hdata_move (struct t_hdata *hdata, void *pointer, int count)
return pointer;
}
}
return NULL;
}
@@ -269,14 +269,14 @@ int
hdata_integer (struct t_hdata *hdata, void *pointer, const char *name)
{
int offset;
if (hdata && pointer)
{
offset = hdata_get_var_offset (hdata, name);
if (offset >= 0)
return *((int *)(pointer + offset));
}
return 0;
}
@@ -288,14 +288,14 @@ long
hdata_long (struct t_hdata *hdata, void *pointer, const char *name)
{
int offset;
if (hdata && pointer)
{
offset = hdata_get_var_offset (hdata, name);
if (offset >= 0)
return *((long *)(pointer + offset));
}
return 0;
}
@@ -307,14 +307,14 @@ const char *
hdata_string (struct t_hdata *hdata, void *pointer, const char *name)
{
int offset;
if (hdata && pointer)
{
offset = hdata_get_var_offset (hdata, name);
if (offset >= 0)
return *((char **)(pointer + offset));
}
return NULL;
}
@@ -326,14 +326,14 @@ void *
hdata_pointer (struct t_hdata *hdata, void *pointer, const char *name)
{
int offset;
if (hdata && pointer)
{
offset = hdata_get_var_offset (hdata, name);
if (offset >= 0)
return *((void **)(pointer + offset));
}
return NULL;
}
@@ -345,14 +345,14 @@ time_t
hdata_time (struct t_hdata *hdata, void *pointer, const char *name)
{
int offset;
if (hdata && pointer)
{
offset = hdata_get_var_offset (hdata, name);
if (offset >= 0)
return *((time_t *)(pointer + offset));
}
return 0;
}
@@ -388,7 +388,7 @@ hdata_get_string (struct t_hdata *hdata, const char *property)
else if (string_strcasecmp (property, "list_keys_values") == 0)
return hashtable_get_string (hdata->hash_list, "keys_values");
}
return NULL;
}
@@ -409,7 +409,7 @@ hdata_free (struct t_hdata *hdata)
hashtable_free (hdata->hash_var_hdata);
if (hdata->hash_list)
hashtable_free (hdata->hash_list);
free (hdata);
}
@@ -422,9 +422,9 @@ hdata_free_all_plugin_map_cb (void *data, struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_hdata *ptr_hdata;
ptr_hdata = (struct t_hdata *)value;
if (ptr_hdata->plugin == (struct t_weechat_plugin *)data)
{
hdata_free (ptr_hdata);
@@ -451,12 +451,12 @@ hdata_free_all_map_cb (void *data, struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_hdata *ptr_hdata;
/* make C compiler happy */
(void) data;
ptr_hdata = (struct t_hdata *)value;
hdata_free (ptr_hdata);
hashtable_remove (hashtable, key);
}
@@ -480,13 +480,13 @@ hdata_print_log_map_cb (void *data, struct t_hashtable *hashtable,
const void *key, const void *value)
{
struct t_hdata *ptr_hdata;
/* make C compiler happy */
(void) data;
(void) hashtable;
ptr_hdata = (struct t_hdata *)value;
log_printf ("");
log_printf ("[hdata (addr:0x%lx, name:'%s')]", ptr_hdata, (const char *)key);
log_printf (" plugin . . . . . . . . : 0x%lx", ptr_hdata->plugin);
+331 -331
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -108,7 +108,7 @@ struct t_hook
int running; /* 1 if hook is currently running */
int priority; /* priority (to sort hooks) */
void *callback_data; /* data sent to callback */
/* hook data (depends on hook type) */
void *hook_data; /* hook specific data */
struct t_hook *prev_hook; /* link to previous hook */
@@ -128,17 +128,17 @@ struct t_hook_command
char *args; /* (for /help) command arguments */
char *args_description; /* (for /help) args long description*/
char *completion; /* template for completion */
/* templates */
int cplt_num_templates; /* number of templates for compl. */
char **cplt_templates; /* completion templates */
char **cplt_templates_static; /* static part of template (at */
/* beginning */
/* arguments for each template */
int *cplt_template_num_args; /* number of arguments for template */
char ***cplt_template_args; /* arguments for each template */
/* concatenation of arg N for each template */
int cplt_template_num_args_concat; /* number of concatened arguments */
char **cplt_template_args_concat; /* concatened arguments */
+65 -65
View File
@@ -54,7 +54,7 @@ infolist_new (struct t_weechat_plugin *plugin)
new_infolist->items = NULL;
new_infolist->last_item = NULL;
new_infolist->ptr_item = NULL;
new_infolist->prev_infolist = last_weechat_infolist;
new_infolist->next_infolist = NULL;
if (weechat_infolists)
@@ -63,7 +63,7 @@ infolist_new (struct t_weechat_plugin *plugin)
weechat_infolists = new_infolist;
last_weechat_infolist = new_infolist;
}
return new_infolist;
}
@@ -82,7 +82,7 @@ infolist_new_item (struct t_infolist *infolist)
new_item->vars = NULL;
new_item->last_var = NULL;
new_item->fields = NULL;
new_item->prev_item = infolist->last_item;
new_item->next_item = NULL;
if (infolist->items)
@@ -91,7 +91,7 @@ infolist_new_item (struct t_infolist *infolist)
infolist->items = new_item;
infolist->last_item = new_item;
}
return new_item;
}
@@ -104,10 +104,10 @@ infolist_new_var_integer (struct t_infolist_item *item,
const char *name, int value)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
@@ -116,7 +116,7 @@ infolist_new_var_integer (struct t_infolist_item *item,
new_var->value = malloc (sizeof (int));
if (new_var->value)
*((int *)new_var->value) = value;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
@@ -125,7 +125,7 @@ infolist_new_var_integer (struct t_infolist_item *item,
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
@@ -138,17 +138,17 @@ infolist_new_var_string (struct t_infolist_item *item,
const char *name, const char *value)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = INFOLIST_STRING;
new_var->value = (value) ? strdup (value) : NULL;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
@@ -157,7 +157,7 @@ infolist_new_var_string (struct t_infolist_item *item,
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
@@ -170,17 +170,17 @@ infolist_new_var_pointer (struct t_infolist_item *item,
const char *name, void *pointer)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
new_var->name = strdup (name);
new_var->type = INFOLIST_POINTER;
new_var->value = pointer;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
@@ -189,7 +189,7 @@ infolist_new_var_pointer (struct t_infolist_item *item,
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
@@ -202,10 +202,10 @@ infolist_new_var_buffer (struct t_infolist_item *item,
const char *name, void *pointer, int size)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0] || (size <= 0))
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
@@ -215,7 +215,7 @@ infolist_new_var_buffer (struct t_infolist_item *item,
if (new_var->value)
memcpy (new_var->value, pointer, size);
new_var->size = size;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
@@ -224,7 +224,7 @@ infolist_new_var_buffer (struct t_infolist_item *item,
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
@@ -237,10 +237,10 @@ infolist_new_var_time (struct t_infolist_item *item,
const char *name, time_t time)
{
struct t_infolist_var *new_var;
if (!item || !name || !name[0])
return NULL;
new_var = malloc (sizeof (*new_var));
if (new_var)
{
@@ -249,7 +249,7 @@ infolist_new_var_time (struct t_infolist_item *item,
new_var->value = malloc (sizeof (time_t));
if (new_var->value)
*((time_t *)new_var->value) = time;
new_var->prev_var = item->last_var;
new_var->next_var = NULL;
if (item->vars)
@@ -258,7 +258,7 @@ infolist_new_var_time (struct t_infolist_item *item,
item->vars = new_var;
item->last_var = new_var;
}
return new_var;
}
@@ -272,14 +272,14 @@ int
infolist_valid (struct t_infolist *infolist)
{
struct t_infolist *ptr_infolist;
for (ptr_infolist = weechat_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
if (ptr_infolist == infolist)
return 1;
}
/* list not found */
return 0;
}
@@ -339,25 +339,25 @@ infolist_fields (struct t_infolist *infolist)
{
struct t_infolist_var *ptr_var;
int length;
if (!infolist || !infolist->ptr_item)
return NULL;
/* list of fields already asked ? if yes, just return string */
if (infolist->ptr_item->fields)
return infolist->ptr_item->fields;
length = 0;
for (ptr_var = infolist->ptr_item->vars;
ptr_var; ptr_var = ptr_var->next_var)
{
length += strlen (ptr_var->name) + 3;
}
infolist->ptr_item->fields = malloc (length + 1);
if (!infolist->ptr_item->fields)
return NULL;
infolist->ptr_item->fields[0] = '\0';
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
@@ -384,7 +384,7 @@ infolist_fields (struct t_infolist *infolist)
if (ptr_var->next_var)
strcat (infolist->ptr_item->fields, ",");
}
return infolist->ptr_item->fields;
}
@@ -396,10 +396,10 @@ int
infolist_integer (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return 0;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
@@ -411,7 +411,7 @@ infolist_integer (struct t_infolist *infolist, const char *var)
return 0;
}
}
/* variable not found */
return 0;
}
@@ -424,10 +424,10 @@ const char *
infolist_string (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
@@ -439,7 +439,7 @@ infolist_string (struct t_infolist *infolist, const char *var)
return NULL;
}
}
/* variable not found */
return NULL;
}
@@ -452,10 +452,10 @@ void *
infolist_pointer (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
@@ -467,7 +467,7 @@ infolist_pointer (struct t_infolist *infolist, const char *var)
return NULL;
}
}
/* variable not found */
return NULL;
}
@@ -482,10 +482,10 @@ infolist_buffer (struct t_infolist *infolist, const char *var,
int *size)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return NULL;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
@@ -500,7 +500,7 @@ infolist_buffer (struct t_infolist *infolist, const char *var,
return NULL;
}
}
/* variable not found */
return NULL;
}
@@ -513,10 +513,10 @@ time_t
infolist_time (struct t_infolist *infolist, const char *var)
{
struct t_infolist_var *ptr_var;
if (!infolist || !infolist->ptr_item || !var || !var[0])
return 0;
for (ptr_var = infolist->ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
@@ -528,7 +528,7 @@ infolist_time (struct t_infolist *infolist, const char *var)
return 0;
}
}
/* variable not found */
return 0;
}
@@ -542,7 +542,7 @@ infolist_var_free (struct t_infolist_item *item,
struct t_infolist_var *var)
{
struct t_infolist_var *new_vars;
/* remove var */
if (item->last_var == var)
item->last_var = var->prev_var;
@@ -553,10 +553,10 @@ infolist_var_free (struct t_infolist_item *item,
}
else
new_vars = var->next_var;
if (var->next_var)
(var->next_var)->prev_var = var->prev_var;
/* free data */
if (var->name)
free (var->name);
@@ -568,9 +568,9 @@ infolist_var_free (struct t_infolist_item *item,
{
free (var->value);
}
free (var);
item->vars = new_vars;
}
@@ -583,7 +583,7 @@ infolist_item_free (struct t_infolist *infolist,
struct t_infolist_item *item)
{
struct t_infolist_item *new_items;
/* remove var */
if (infolist->last_item == item)
infolist->last_item = item->prev_item;
@@ -594,10 +594,10 @@ infolist_item_free (struct t_infolist *infolist,
}
else
new_items = item->next_item;
if (item->next_item)
(item->next_item)->prev_item = item->prev_item;
/* free data */
while (item->vars)
{
@@ -605,9 +605,9 @@ infolist_item_free (struct t_infolist *infolist,
}
if (item->fields)
free (item->fields);
free (item);
infolist->items = new_items;
}
@@ -619,7 +619,7 @@ void
infolist_free (struct t_infolist *infolist)
{
struct t_infolist *new_weechat_infolists;
/* remove list */
if (last_weechat_infolist == infolist)
last_weechat_infolist = infolist->prev_infolist;
@@ -630,18 +630,18 @@ infolist_free (struct t_infolist *infolist)
}
else
new_weechat_infolists = infolist->next_infolist;
if (infolist->next_infolist)
(infolist->next_infolist)->prev_infolist = infolist->prev_infolist;
/* free data */
while (infolist->items)
{
infolist_item_free (infolist, infolist->items);
}
free (infolist);
weechat_infolists = new_weechat_infolists;
}
@@ -653,7 +653,7 @@ void
infolist_free_all_plugin (struct t_weechat_plugin *plugin)
{
struct t_infolist *ptr_infolist, *next_infolist;
ptr_infolist = weechat_infolists;
while (ptr_infolist)
{
@@ -674,7 +674,7 @@ infolist_print_log ()
struct t_infolist *ptr_infolist;
struct t_infolist_item *ptr_item;
struct t_infolist_var *ptr_var;
for (ptr_infolist = weechat_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
@@ -686,7 +686,7 @@ infolist_print_log ()
log_printf (" ptr_item . . . . . . . : 0x%lx", ptr_infolist->ptr_item);
log_printf (" prev_infolist. . . . . : 0x%lx", ptr_infolist->prev_infolist);
log_printf (" next_infolist. . . . . : 0x%lx", ptr_infolist->next_infolist);
for (ptr_item = ptr_infolist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
@@ -696,7 +696,7 @@ infolist_print_log ()
log_printf (" last_var . . . . . . . : 0x%lx", ptr_item->last_var);
log_printf (" prev_item. . . . . . . : 0x%lx", ptr_item->prev_item);
log_printf (" next_item. . . . . . . : 0x%lx", ptr_item->next_item);
for (ptr_var = ptr_item->vars; ptr_var;
ptr_var = ptr_var->next_var)
{
+11 -11
View File
@@ -71,17 +71,17 @@ input_exec_command (struct t_gui_buffer *buffer,
{
int rc;
char *command, *pos, *ptr_args;
if ((!string) || (!string[0]))
return;
command = strdup (string);
if (!command)
return ;
/* look for end of command */
ptr_args = NULL;
pos = &command[strlen (command) - 1];
if (pos[0] == ' ')
{
@@ -89,9 +89,9 @@ input_exec_command (struct t_gui_buffer *buffer,
pos--;
pos[1] = '\0';
}
rc = hook_command_exec (buffer, any_plugin, plugin, command);
pos = strchr (command, ' ');
if (pos)
{
@@ -103,7 +103,7 @@ input_exec_command (struct t_gui_buffer *buffer,
if (!ptr_args[0])
ptr_args = NULL;
}
switch (rc)
{
case 0: /* command hooked, KO */
@@ -161,10 +161,10 @@ input_data (struct t_gui_buffer *buffer, const char *data)
char *pos, *buf;
const char *ptr_data, *ptr_data_for_buffer;
int length, char_size;
if (!buffer || !data || !data[0] || (data[0] == '\r') || (data[0] == '\n'))
return;
/* use new data (returned by plugin) */
ptr_data = data;
while (ptr_data && ptr_data[0])
@@ -172,7 +172,7 @@ input_data (struct t_gui_buffer *buffer, const char *data)
pos = strchr (ptr_data, '\n');
if (pos)
pos[0] = '\0';
ptr_data_for_buffer = string_input_for_buffer (ptr_data);
if (ptr_data_for_buffer)
{
@@ -202,7 +202,7 @@ input_data (struct t_gui_buffer *buffer, const char *data)
/* input string is a command */
input_exec_command (buffer, 1, buffer->plugin, ptr_data);
}
if (pos)
{
pos[0] = '\n';
+24 -24
View File
@@ -64,7 +64,7 @@ weelist_find_pos (struct t_weelist *weelist, const char *data)
if (!weelist || !data)
return NULL;
for (ptr_item = weelist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
@@ -87,7 +87,7 @@ weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
if (!weelist || !item)
return;
if (weelist->items)
{
/* remove element if already in list */
@@ -106,7 +106,7 @@ weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
pos_item = NULL;
else
pos_item = weelist_find_pos (weelist, item->data);
if (pos_item)
{
/* insert data into the list (before position found) */
@@ -145,10 +145,10 @@ weelist_add (struct t_weelist *weelist, const char *data, const char *where,
void *user_data)
{
struct t_weelist_item *new_item;
if (!weelist || !data || !data[0] || !where || !where[0])
return NULL;
new_item = malloc (sizeof (*new_item));
if (new_item)
{
@@ -171,7 +171,7 @@ weelist_search (struct t_weelist *weelist, const char *data)
if (!weelist || !data)
return NULL;
for (ptr_item = weelist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
@@ -192,7 +192,7 @@ weelist_search_pos (struct t_weelist *weelist, const char *data)
{
struct t_weelist_item *ptr_item;
int i;
if (!weelist || !data)
return -1;
@@ -219,7 +219,7 @@ weelist_casesearch (struct t_weelist *weelist, const char *data)
if (!weelist || !data)
return NULL;
for (ptr_item = weelist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
@@ -240,10 +240,10 @@ weelist_casesearch_pos (struct t_weelist *weelist, const char *data)
{
struct t_weelist_item *ptr_item;
int i;
if (!weelist || !data)
return -1;
for (ptr_item = weelist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
@@ -267,7 +267,7 @@ weelist_get (struct t_weelist *weelist, int position)
if (!weelist)
return NULL;
i = 0;
ptr_item = weelist->items;
while (ptr_item)
@@ -305,7 +305,7 @@ weelist_next (struct t_weelist_item *item)
{
if (item)
return item->next_item;
return NULL;
}
@@ -318,7 +318,7 @@ weelist_prev (struct t_weelist_item *item)
{
if (item)
return item->prev_item;
return NULL;
}
@@ -331,7 +331,7 @@ weelist_string (struct t_weelist_item *item)
{
if (item)
return item->data;
return NULL;
}
@@ -344,7 +344,7 @@ weelist_size (struct t_weelist *weelist)
{
if (weelist)
return weelist->size;
return 0;
}
@@ -356,10 +356,10 @@ void
weelist_remove (struct t_weelist *weelist, struct t_weelist_item *item)
{
struct t_weelist_item *new_items;
if (!weelist || !item)
return;
/* remove item from list */
if (weelist->last_item == item)
weelist->last_item = item->prev_item;
@@ -370,16 +370,16 @@ weelist_remove (struct t_weelist *weelist, struct t_weelist_item *item)
}
else
new_items = item->next_item;
if (item->next_item)
(item->next_item)->prev_item = item->prev_item;
/* free data */
if (item->data)
free (item->data);
free (item);
weelist->items = new_items;
weelist->size--;
}
@@ -392,7 +392,7 @@ weelist_remove_all (struct t_weelist *weelist)
{
if (!weelist)
return;
while (weelist->items)
{
weelist_remove (weelist, weelist->items);
@@ -408,7 +408,7 @@ weelist_free (struct t_weelist *weelist)
{
if (!weelist)
return;
weelist_remove_all (weelist);
free (weelist);
}
@@ -421,9 +421,9 @@ void
weelist_print_log (struct t_weelist *weelist, const char *name)
{
struct t_weelist_item *ptr_item;
log_printf ("[weelist %s (addr:0x%lx)]", name, weelist);
for (ptr_item = weelist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
+9 -9
View File
@@ -74,7 +74,7 @@ log_open (const char *filename, const char *mode)
snprintf (weechat_log_filename, filename_length,
"%s/%s", weechat_home, WEECHAT_LOG_NAME);
}
weechat_log_file = fopen (weechat_log_filename, mode);
if (!weechat_log_file)
{
@@ -129,10 +129,10 @@ log_printf (const char *message, ...)
char *ptr_buffer;
static time_t seconds;
struct tm *date_tmp;
if (!weechat_log_file)
return;
weechat_va_format (message);
if (vbuffer)
{
@@ -146,7 +146,7 @@ log_printf (const char *message, ...)
ptr_buffer[0] = '.';
ptr_buffer++;
}
if (!weechat_log_use_time)
string_iconv_fprintf (weechat_log_file, "%s\n", vbuffer);
else
@@ -163,9 +163,9 @@ log_printf (const char *message, ...)
else
string_iconv_fprintf (weechat_log_file, "%s\n", vbuffer);
}
fflush (weechat_log_file);
free (vbuffer);
}
}
@@ -179,7 +179,7 @@ log_printf_hexa (const char *spaces, const char *string)
{
int msg_pos, hexa_pos, ascii_pos;
char hexa[(16 * 3) + 1], ascii[(16 * 2) + 1];
msg_pos = 0;
hexa_pos = 0;
ascii_pos = 0;
@@ -243,13 +243,13 @@ log_crash_rename ()
if (!weechat_log_filename)
return 0;
old_name = strdup (weechat_log_filename);
if (!old_name)
return 0;
log_close ();
length = strlen (weechat_home) + 128;
new_name = malloc (length);
if (new_name)
+77 -77
View File
@@ -71,7 +71,7 @@ network_set_gnutls_ca_file ()
{
#ifdef HAVE_GNUTLS
char *ca_path, *ca_path2;
ca_path = string_expand_home (CONFIG_STRING(config_network_gnutls_ca_file));
if (ca_path)
{
@@ -97,7 +97,7 @@ network_init ()
#ifdef HAVE_GNUTLS
gnutls_global_init ();
gnutls_certificate_allocate_credentials (&gnutls_xcred);
network_set_gnutls_ca_file ();
#if LIBGNUTLS_VERSION_NUMBER >= 0x02090a
/* for gnutls >= 2.9.10 */
@@ -152,7 +152,7 @@ network_pass_httpproxy (struct t_proxy *proxy, int sock, const char *address,
{
char buffer[256], authbuf[128], authbuf_base64[512];
int n, m;
if (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])
&& CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])[0])
{
@@ -172,20 +172,20 @@ network_pass_httpproxy (struct t_proxy *proxy, int sock, const char *address,
n = snprintf (buffer, sizeof (buffer),
"CONNECT %s:%d HTTP/1.0\r\n\r\n", address, port);
}
m = send (sock, buffer, n, 0);
if (n != m)
return 0;
n = recv (sock, buffer, sizeof (buffer), 0);
/* success result must be like: "HTTP/1.0 200 OK" */
if (n < 12)
return 0;
if (memcmp (buffer, "HTTP/", 5) || memcmp (buffer + 9, "200", 3))
return 0;
/* connection ok */
return 1;
}
@@ -202,34 +202,34 @@ network_resolve (const char *hostname, char *ip, int *version)
{
char ipbuffer[NI_MAXHOST];
struct addrinfo *res;
if (version != NULL)
*version = 0;
res = NULL;
if (getaddrinfo (hostname, NULL, NULL, &res) != 0)
return 0;
if (!res)
return 0;
if (getnameinfo (res->ai_addr, res->ai_addrlen, ipbuffer, sizeof(ipbuffer),
NULL, 0, NI_NUMERICHOST) != 0)
{
freeaddrinfo (res);
return 0;
}
if ((res->ai_family == AF_INET) && (version != NULL))
*version = 4;
if ((res->ai_family == AF_INET6) && (version != NULL))
*version = 6;
strcpy (ip, ipbuffer);
freeaddrinfo (res);
/* resolution ok */
return 1;
}
@@ -246,11 +246,11 @@ network_pass_socks4proxy (struct t_proxy *proxy, int sock, const char *address,
int port)
{
/* socks4 protocol is explained here: http://en.wikipedia.org/wiki/SOCKS */
struct t_network_socks4 socks4;
unsigned char buffer[24];
char ip_addr[NI_MAXHOST];
socks4.version = 4;
socks4.method = 1;
socks4.port = htons (port);
@@ -258,14 +258,14 @@ network_pass_socks4proxy (struct t_proxy *proxy, int sock, const char *address,
socks4.address = inet_addr (ip_addr);
strncpy (socks4.user, CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]),
sizeof (socks4.user) - 1);
send (sock, (char *) &socks4, 8 + strlen (socks4.user) + 1, 0);
recv (sock, buffer, sizeof (buffer), 0);
/* connection ok */
if ((buffer[0] == 0) && (buffer[1] == 90))
return 1;
/* connection failed */
return 0;
}
@@ -285,26 +285,26 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
* socks5 protocol is explained in RFC 1928
* socks5 authentication with username/pass is explained in RFC 1929
*/
struct t_network_socks5 socks5;
unsigned char buffer[288];
int username_len, password_len, addr_len, addr_buffer_len;
unsigned char *addr_buffer;
socks5.version = 5;
socks5.nmethods = 1;
if (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])
&& CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])[0])
socks5.method = 2; /* with authentication */
else
socks5.method = 0; /* without authentication */
send (sock, (char *) &socks5, sizeof(socks5), 0);
/* server socks5 must respond with 2 bytes */
if (recv (sock, buffer, 2, 0) != 2)
return 0;
if (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])
&& CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])[0])
{
@@ -314,14 +314,14 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
* - socks version (buffer[0]) = 5 => socks5
* - socks method (buffer[1]) = 2 => authentication
*/
if (buffer[0] != 5 || buffer[1] != 2)
return 0;
/* authentication as in RFC 1929 */
username_len = strlen (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]));
password_len = strlen (CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]));
/* make username/password buffer */
buffer[0] = 1;
buffer[1] = (unsigned char) username_len;
@@ -329,13 +329,13 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
buffer[2 + username_len] = (unsigned char) password_len;
memcpy (buffer + 3 + username_len,
CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]), password_len);
send (sock, buffer, 3 + username_len + password_len, 0);
/* server socks5 must respond with 2 bytes */
if (recv (sock, buffer, 2, 0) != 2)
return 0;
/* buffer[1] = auth state, must be 0 for success */
if (buffer[1] != 0)
return 0;
@@ -351,7 +351,7 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
if (!((buffer[0] == 5) && (buffer[1] == 0)))
return 0;
}
/* authentication successful then giving address/port to connect */
addr_len = strlen(address);
addr_buffer_len = 4 + 1 + addr_len + 2;
@@ -365,17 +365,17 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
addr_buffer[4] = (unsigned char) addr_len;
memcpy (addr_buffer + 5, address, addr_len); /* server address */
*((unsigned short *) (addr_buffer + 5 + addr_len)) = htons (port); /* server port */
send (sock, addr_buffer, addr_buffer_len, 0);
free (addr_buffer);
/* dialog with proxy server */
if (recv (sock, buffer, 4, 0) != 4)
return 0;
if (!((buffer[0] == 5) && (buffer[1] == 0)))
return 0;
/* buffer[3] = address type */
switch (buffer[3])
{
@@ -413,7 +413,7 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
default:
return 0;
}
/* connection ok */
return 1;
}
@@ -429,9 +429,9 @@ network_pass_proxy (const char *proxy, int sock, const char *address, int port)
{
int rc;
struct t_proxy *ptr_proxy;
rc = 0;
ptr_proxy = proxy_search (proxy);
if (ptr_proxy)
{
@@ -466,7 +466,7 @@ network_connect_to (const char *proxy, int sock,
struct hostent *hostent;
char *ip4;
int ret;
ptr_proxy = NULL;
if (proxy && proxy[0])
{
@@ -474,13 +474,13 @@ network_connect_to (const char *proxy, int sock,
if (!ptr_proxy)
return 0;
}
if (ptr_proxy)
{
memset (&addr, 0, sizeof (addr));
addr.sin_addr.s_addr = htonl (address);
ip4 = inet_ntoa(addr.sin_addr);
memset (&addr, 0, sizeof (addr));
addr.sin_port = htons (CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
addr.sin_family = AF_INET;
@@ -520,12 +520,12 @@ network_connect_child (struct t_hook *hook_connect)
char ipv4_address[INET_ADDRSTRLEN + 1], ipv6_address[INET6_ADDRSTRLEN + 1];
char status_ok_without_address[1 + 5 + 1];
int rc, length, num_written;
res = NULL;
res_local = NULL;
status_str[1] = '\0';
ptr_proxy = NULL;
if (HOOK_CONNECT(hook_connect, proxy)
&& HOOK_CONNECT(hook_connect, proxy)[0])
@@ -541,7 +541,7 @@ network_connect_child (struct t_hook *hook_connect)
return;
}
}
if (ptr_proxy)
{
/* get info about peer */
@@ -578,12 +578,12 @@ network_connect_child (struct t_hook *hook_connect)
freeaddrinfo (res);
return;
}
if (CONFIG_BOOLEAN(ptr_proxy->options[PROXY_OPTION_IPV6]))
((struct sockaddr_in6 *)(res->ai_addr))->sin6_port = htons (CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
else
((struct sockaddr_in *)(res->ai_addr))->sin_port = htons (CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
/* connect to peer */
if (connect (HOOK_CONNECT(hook_connect, sock),
res->ai_addr, res->ai_addrlen) != 0)
@@ -596,7 +596,7 @@ network_connect_child (struct t_hook *hook_connect)
freeaddrinfo (res);
return;
}
if (!network_pass_proxy (HOOK_CONNECT(hook_connect, proxy),
HOOK_CONNECT(hook_connect, sock),
HOOK_CONNECT(hook_connect, address),
@@ -652,7 +652,7 @@ network_connect_child (struct t_hook *hook_connect)
return;
}
}
/* get info about peer */
memset (&hints, 0, sizeof(hints));
hints.ai_family = (HOOK_CONNECT(hook_connect, ipv6)) ? AF_INET6 : AF_INET;
@@ -672,9 +672,9 @@ network_connect_child (struct t_hook *hook_connect)
freeaddrinfo (res_local);
return;
}
status_str[0] = '0' + WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND;
/* try all IP addresses found, stop when connection is ok */
for (ptr_res = res; ptr_res; ptr_res = ptr_res->ai_next)
{
@@ -682,7 +682,7 @@ network_connect_child (struct t_hook *hook_connect)
if ((HOOK_CONNECT(hook_connect, ipv6) && (ptr_res->ai_family != AF_INET6))
|| ((!HOOK_CONNECT(hook_connect, ipv6) && (ptr_res->ai_family != AF_INET))))
continue;
/* connect to peer */
if (HOOK_CONNECT(hook_connect, ipv6))
((struct sockaddr_in6 *)(ptr_res->ai_addr))->sin6_port =
@@ -690,7 +690,7 @@ network_connect_child (struct t_hook *hook_connect)
else
((struct sockaddr_in *)(ptr_res->ai_addr))->sin_port =
htons (HOOK_CONNECT(hook_connect, port));
if (connect (HOOK_CONNECT(hook_connect, sock),
ptr_res->ai_addr, ptr_res->ai_addrlen) == 0)
{
@@ -701,7 +701,7 @@ network_connect_child (struct t_hook *hook_connect)
status_str[0] = '0' + WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED;
}
}
if (status_str[0] == '0' + WEECHAT_HOOK_CONNECT_OK)
{
status_ok_with_address = NULL;
@@ -736,7 +736,7 @@ network_connect_child (struct t_hook *hook_connect)
status_str, (int)strlen (ptr_address), ptr_address);
}
}
if (status_ok_with_address)
{
num_written = write (HOOK_CONNECT(hook_connect, child_write),
@@ -759,7 +759,7 @@ network_connect_child (struct t_hook *hook_connect)
status_str, 1);
(void) num_written;
}
if (res)
freeaddrinfo (res);
if (res_local)
@@ -778,14 +778,14 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
{
struct t_hook *hook_connect;
int rc, direction, flags;
/* make C compiler happy */
(void) fd;
hook_connect = (struct t_hook *)arg_hook_connect;
rc = gnutls_handshake (*HOOK_CONNECT(hook_connect, gnutls_sess));
if ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED))
{
direction = gnutls_record_get_direction (*HOOK_CONNECT(hook_connect, gnutls_sess));
@@ -837,7 +837,7 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
HOOK_CONNECT(hook_connect, handshake_ip_address));
unhook (hook_connect);
}
return WEECHAT_RC_OK;
}
#endif
@@ -852,14 +852,14 @@ network_connect_gnutls_handshake_timer_cb (void *arg_hook_connect,
int remaining_calls)
{
struct t_hook *hook_connect;
/* make C compiler happy */
(void) remaining_calls;
hook_connect = (struct t_hook *)arg_hook_connect;
HOOK_CONNECT(hook_connect, handshake_hook_timer) = NULL;
(void) (HOOK_CONNECT(hook_connect, callback))
(hook_connect->callback_data,
WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR,
@@ -867,7 +867,7 @@ network_connect_gnutls_handshake_timer_cb (void *arg_hook_connect,
gnutls_strerror (GNUTLS_E_EXPIRED),
HOOK_CONNECT(hook_connect, handshake_ip_address));
unhook (hook_connect);
return WEECHAT_RC_OK;
}
#endif
@@ -889,11 +889,11 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
/* make C compiler happy */
(void) fd;
hook_connect = (struct t_hook *)arg_hook_connect;
ip_address = NULL;
num_read = read (HOOK_CONNECT(hook_connect, child_read),
buffer, sizeof (buffer));
if (num_read > 0)
@@ -1011,10 +1011,10 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
(hook_connect->callback_data, buffer[0] - '0', 0, NULL, ip_address);
unhook (hook_connect);
}
if (ip_address)
free (ip_address);
return WEECHAT_RC_OK;
}
@@ -1031,7 +1031,7 @@ network_connect_with_fork (struct t_hook *hook_connect)
const char *pos_error;
#endif
pid_t pid;
#ifdef HAVE_GNUTLS
/* initialize GnuTLS if SSL asked */
if (HOOK_CONNECT(hook_connect, gnutls_sess))
@@ -1064,7 +1064,7 @@ network_connect_with_fork (struct t_hook *hook_connect)
(gnutls_transport_ptr) ((unsigned long) HOOK_CONNECT(hook_connect, sock)));
}
#endif
/* create pipe for child process */
if (pipe (child_pipe) < 0)
{
@@ -1077,7 +1077,7 @@ network_connect_with_fork (struct t_hook *hook_connect)
}
HOOK_CONNECT(hook_connect, child_read) = child_pipe[0];
HOOK_CONNECT(hook_connect, child_write) = child_pipe[1];
switch (pid = fork ())
{
/* fork failed */
+44 -44
View File
@@ -59,16 +59,16 @@ int
proxy_search_option (const char *option_name)
{
int i;
if (!option_name)
return -1;
for (i = 0; i < PROXY_NUM_OPTIONS; i++)
{
if (string_strcasecmp (proxy_option_string[i], option_name) == 0)
return i;
}
/* proxy option not found */
return -1;
}
@@ -82,16 +82,16 @@ int
proxy_search_type (const char *type)
{
int i;
if (!type)
return -1;
for (i = 0; i < PROXY_NUM_TYPES; i++)
{
if (string_strcasecmp (proxy_type_string[i], type) == 0)
return i;
}
/* type not found */
return -1;
}
@@ -104,17 +104,17 @@ struct t_proxy *
proxy_search (const char *name)
{
struct t_proxy *ptr_proxy;
if (!name || !name[0])
return NULL;
for (ptr_proxy = weechat_proxies; ptr_proxy;
ptr_proxy = ptr_proxy->next_proxy)
{
if (strcmp (ptr_proxy->name, name) == 0)
return ptr_proxy;
}
/* proxy not found */
return NULL;
}
@@ -129,9 +129,9 @@ proxy_search_with_option_name (const char *option_name)
{
char *proxy_name, *pos_option;
struct t_proxy *ptr_proxy;
ptr_proxy = NULL;
pos_option = strchr (option_name, '.');
if (pos_option)
{
@@ -147,7 +147,7 @@ proxy_search_with_option_name (const char *option_name)
free (proxy_name);
}
}
return ptr_proxy;
}
@@ -160,10 +160,10 @@ proxy_set_name (struct t_proxy *proxy, const char *name)
{
int length;
char *option_name;
if (!name || !name[0])
return;
length = strlen (name) + 64;
option_name = malloc (length);
if (option_name)
@@ -180,11 +180,11 @@ proxy_set_name (struct t_proxy *proxy, const char *name)
config_file_option_rename (proxy->options[PROXY_OPTION_USERNAME], option_name);
snprintf (option_name, length, "%s.password", name);
config_file_option_rename (proxy->options[PROXY_OPTION_PASSWORD], option_name);
if (proxy->name)
free (proxy->name);
proxy->name = strdup (name);
free (option_name);
}
}
@@ -199,7 +199,7 @@ proxy_set (struct t_proxy *proxy, const char *property, const char *value)
{
if (!proxy || !property || !value)
return 0;
if (string_strcasecmp (property, "name") == 0)
{
proxy_set_name (proxy, value);
@@ -235,7 +235,7 @@ proxy_set (struct t_proxy *proxy, const char *property, const char *value)
config_file_option_set (proxy->options[PROXY_OPTION_PASSWORD], value, 1);
return 1;
}
return 0;
}
@@ -250,9 +250,9 @@ proxy_create_option (const char *proxy_name, int index_option,
struct t_config_option *ptr_option;
int length;
char *option_name;
ptr_option = NULL;
length = strlen (proxy_name) + 1 +
strlen (proxy_option_string[index_option]) + 1;
option_name = malloc (length);
@@ -260,7 +260,7 @@ proxy_create_option (const char *proxy_name, int index_option,
{
snprintf (option_name, length, "%s.%s",
proxy_name, proxy_option_string[index_option]);
switch (index_option)
{
case PROXY_OPTION_TYPE:
@@ -316,7 +316,7 @@ proxy_create_option (const char *proxy_name, int index_option,
}
free (option_name);
}
return ptr_option;
}
@@ -330,7 +330,7 @@ proxy_create_option_temp (struct t_proxy *temp_proxy, int index_option,
const char *value)
{
struct t_config_option *new_option;
new_option = proxy_create_option (temp_proxy->name,
index_option,
value);
@@ -347,7 +347,7 @@ proxy_alloc (const char *name)
{
struct t_proxy *new_proxy;
int i;
new_proxy = malloc (sizeof (*new_proxy));
if (new_proxy)
{
@@ -359,7 +359,7 @@ proxy_alloc (const char *name)
new_proxy->prev_proxy = NULL;
new_proxy->next_proxy = NULL;
}
return new_proxy;
}
@@ -377,7 +377,7 @@ proxy_new_with_options (const char *name,
struct t_config_option *password)
{
struct t_proxy *new_proxy;
/* create proxy */
new_proxy = proxy_alloc (name);
if (new_proxy)
@@ -388,7 +388,7 @@ proxy_new_with_options (const char *name,
new_proxy->options[PROXY_OPTION_PORT] = port;
new_proxy->options[PROXY_OPTION_USERNAME] = username;
new_proxy->options[PROXY_OPTION_PASSWORD] = password;
/* add proxy to proxies list */
new_proxy->prev_proxy = last_weechat_proxy;
if (weechat_proxies)
@@ -398,7 +398,7 @@ proxy_new_with_options (const char *name,
last_weechat_proxy = new_proxy;
new_proxy->next_proxy = NULL;
}
return new_proxy;
}
@@ -414,18 +414,18 @@ proxy_new (const char *name, const char *type, const char *ipv6,
struct t_config_option *option_type, *option_ipv6, *option_address;
struct t_config_option *option_port, *option_username, *option_password;
struct t_proxy *new_proxy;
if (!name || !name[0])
return NULL;
/* it's not possible to create 2 proxies with same name */
if (proxy_search (name))
return NULL;
/* look for type */
if (proxy_search_type (type) < 0)
return NULL;
option_type = proxy_create_option (name, PROXY_OPTION_TYPE,
type);
option_ipv6 = proxy_create_option (name, PROXY_OPTION_IPV6,
@@ -438,7 +438,7 @@ proxy_new (const char *name, const char *type, const char *ipv6,
(username) ? username : "");
option_password = proxy_create_option (name, PROXY_OPTION_PASSWORD,
(password) ? password : "");
new_proxy = proxy_new_with_options (name, option_type, option_ipv6,
option_address, option_port,
option_username, option_password);
@@ -457,7 +457,7 @@ proxy_new (const char *name, const char *type, const char *ipv6,
if (option_password)
config_file_option_free (option_password);
}
return new_proxy;
}
@@ -470,7 +470,7 @@ proxy_use_temp_proxies ()
{
struct t_proxy *ptr_temp_proxy, *next_temp_proxy;
int i, num_options_ok;
for (ptr_temp_proxy = weechat_temp_proxies; ptr_temp_proxy;
ptr_temp_proxy = ptr_temp_proxy->next_proxy)
{
@@ -486,7 +486,7 @@ proxy_use_temp_proxies ()
if (ptr_temp_proxy->options[i])
num_options_ok++;
}
if (num_options_ok == PROXY_NUM_OPTIONS)
{
proxy_new_with_options (ptr_temp_proxy->name,
@@ -509,16 +509,16 @@ proxy_use_temp_proxies ()
}
}
}
/* free all temp proxies */
while (weechat_temp_proxies)
{
next_temp_proxy = weechat_temp_proxies->next_proxy;
if (weechat_temp_proxies->name)
free (weechat_temp_proxies->name);
free (weechat_temp_proxies);
weechat_temp_proxies = next_temp_proxy;
}
last_weechat_temp_proxy = NULL;
@@ -532,10 +532,10 @@ void
proxy_free (struct t_proxy *proxy)
{
int i;
if (!proxy)
return;
/* remove proxy from proxies list */
if (proxy->prev_proxy)
(proxy->prev_proxy)->next_proxy = proxy->next_proxy;
@@ -545,7 +545,7 @@ proxy_free (struct t_proxy *proxy)
weechat_proxies = proxy->next_proxy;
if (last_weechat_proxy == proxy)
last_weechat_proxy = proxy->prev_proxy;
/* free data */
if (proxy->name)
free (proxy->name);
@@ -553,7 +553,7 @@ proxy_free (struct t_proxy *proxy)
{
config_file_option_free (proxy->options[i]);
}
free (proxy);
}
@@ -578,7 +578,7 @@ void
proxy_print_log ()
{
struct t_proxy *ptr_proxy;
for (ptr_proxy = weechat_proxies; ptr_proxy;
ptr_proxy = ptr_proxy->next_proxy)
{
+1 -1
View File
@@ -45,7 +45,7 @@ struct t_proxy
{
char *name; /* proxy name */
struct t_config_option *options[PROXY_NUM_OPTIONS];
struct t_proxy *prev_proxy; /* link to previous bar */
struct t_proxy *next_proxy; /* link to next bar */
};
+153 -153
View File
@@ -69,17 +69,17 @@ char *
string_strndup (const char *string, int length)
{
char *result;
if ((int)strlen (string) < length)
return strdup (string);
result = malloc (length + 1);
if (!result)
return NULL;
memcpy (result, string, length);
result[length] = '\0';
return result;
}
@@ -121,10 +121,10 @@ int
string_strcasecmp (const char *string1, const char *string2)
{
int diff;
if (!string1 || !string2)
return (string1) ? 1 : ((string2) ? -1 : 0);
while (string1[0] && string2[0])
{
diff = utf8_charcasecmp (string1, string2);
@@ -134,7 +134,7 @@ string_strcasecmp (const char *string1, const char *string2)
string1 = utf8_next_char (string1);
string2 = utf8_next_char (string2);
}
return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0);
}
@@ -147,22 +147,22 @@ int
string_strncasecmp (const char *string1, const char *string2, int max)
{
int count, diff;
if (!string1 || !string2)
return (string1) ? 1 : ((string2) ? -1 : 0);
count = 0;
while ((count < max) && string1[0] && string2[0])
{
diff = utf8_charcasecmp (string1, string2);
if (diff != 0)
return diff;
string1 = utf8_next_char (string1);
string2 = utf8_next_char (string2);
count++;
}
if (count >= max)
return 0;
else
@@ -178,14 +178,14 @@ string_strcmp_ignore_chars (const char *string1, const char *string2,
const char *chars_ignored, int case_sensitive)
{
int diff;
if (!string1 && !string2)
return 0;
if (!string1 && string2)
return -1;
if (string1 && !string2)
return 1;
while (string1 && string1[0] && string2 && string2[0])
{
/* skip ignored chars */
@@ -205,16 +205,16 @@ string_strcmp_ignore_chars (const char *string1, const char *string2,
return -1;
if (string1 && string1[0] && (!string2 || !string2[0]))
return 1;
/* look at diff */
diff = (case_sensitive) ?
(int)string1[0] - (int)string2[0] : utf8_charcasecmp (string1, string2);
if (diff != 0)
return diff;
string1 = utf8_next_char (string1);
string2 = utf8_next_char (string2);
/* skip ignored chars */
while (string1 && string1[0] && strchr (chars_ignored, string1[0]))
{
@@ -240,20 +240,20 @@ char *
string_strcasestr (const char *string, const char *search)
{
int length_search;
length_search = utf8_strlen (search);
if (!string || !search || (length_search == 0))
return NULL;
while (string[0])
{
if (string_strncasecmp (string, search, length_search) == 0)
return (char *)string;
string = utf8_next_char (string);
}
return NULL;
}
@@ -268,19 +268,19 @@ string_match (const char *string, const char *mask, int case_sensitive)
{
char last, *mask2;
int len_string, len_mask, rc;
if (!mask || !mask[0])
return 0;
/* if mask is "*", then any string matches */
if (strcmp (mask, "*") == 0)
return 1;
len_string = strlen (string);
len_mask = strlen (mask);
last = mask[len_mask - 1];
/* mask begins with "*" */
if ((mask[0] == '*') && (last != '*'))
{
@@ -296,7 +296,7 @@ string_match (const char *string, const char *mask, int case_sensitive)
/* no match */
return 0;
}
/* mask ends with "*" */
if ((mask[0] != '*') && (last == '*'))
{
@@ -312,7 +312,7 @@ string_match (const char *string, const char *mask, int case_sensitive)
/* no match */
return 0;
}
/* mask begins and ends with "*" */
if ((mask[0] == '*') && (last == '*'))
{
@@ -331,12 +331,12 @@ string_match (const char *string, const char *mask, int case_sensitive)
free (mask2);
return rc;
}
/* no "*" at all, compare strings */
if ((case_sensitive && (strcmp (string, mask) == 0))
|| (!case_sensitive && (string_strcasecmp (string, mask) == 0)))
return 1;
/* no match */
return 0;
}
@@ -352,13 +352,13 @@ string_replace (const char *string, const char *search, const char *replace)
const char *pos;
char *new_string;
int length1, length2, length_new, count;
if (!string || !search || !replace)
return NULL;
length1 = strlen (search);
length2 = strlen (replace);
/* count number of strings to replace */
count = 0;
pos = string;
@@ -367,19 +367,19 @@ string_replace (const char *string, const char *search, const char *replace)
count++;
pos += length1;
}
/* easy: no string to replace! */
if (count == 0)
return strdup (string);
/* compute needed memory for new string */
length_new = strlen (string) - (count * length1) + (count * length2) + 1;
/* allocate new string */
new_string = malloc (length_new);
if (!new_string)
return strdup (string);
/* replace all occurrences */
new_string[0] = '\0';
while (string && string[0])
@@ -409,22 +409,22 @@ string_expand_home (const char *path)
{
char *ptr_home, *str;
int length;
if (!path)
return NULL;
if (!path[0] || (path[0] != '~') || (path[1] != DIR_SEPARATOR_CHAR))
return strdup (path);
ptr_home = getenv ("HOME");
length = strlen (ptr_home) + strlen (path + 1) + 1;
str = malloc (length);
if (!str)
return strdup (path);
snprintf (str, length, "%s%s", ptr_home, path + 1);
return str;
}
@@ -440,7 +440,7 @@ string_remove_quotes (const char *string, const char *quotes)
{
int length;
const char *pos_start, *pos_end;
if (!string || !quotes)
return NULL;
@@ -460,14 +460,14 @@ string_remove_quotes (const char *string, const char *quotes)
}
if (!pos_start[0] || !pos_end[0] || (pos_end <= pos_start))
return strdup (string);
if (strchr (quotes, pos_start[0]) && (pos_end[0] == pos_start[0]))
{
if (pos_end == (pos_start + 1))
return strdup ("");
return string_strndup (pos_start + 1, pos_end - pos_start - 1);
}
return strdup (string);
}
@@ -480,16 +480,16 @@ char *
string_strip (const char *string, int left, int right, const char *chars)
{
const char *ptr_start, *ptr_end;
if (!string)
return NULL;
if (!string[0])
return strdup (string);
ptr_start = string;
ptr_end = string + strlen (string) - 1;
if (left)
{
while (ptr_start[0] && strchr (chars, ptr_start[0]))
@@ -499,7 +499,7 @@ string_strip (const char *string, int left, int right, const char *chars)
if (!ptr_start[0])
return strdup (ptr_start);
}
if (right)
{
while ((ptr_end >= ptr_start) && strchr (chars, ptr_end[0]))
@@ -509,7 +509,7 @@ string_strip (const char *string, int left, int right, const char *chars)
if (ptr_end < ptr_start)
return strdup ("");
}
return string_strndup (ptr_start, ptr_end - ptr_start + 1);
}
@@ -581,7 +581,7 @@ string_convert_hex_chars (const char *string)
}
output[pos_output] = '\0';
}
return output;
}
@@ -593,13 +593,13 @@ int
string_is_word_char (const char *string)
{
wint_t c = utf8_wide_char (string);
if (c == WEOF)
return 0;
if (iswalnum (c))
return 1;
switch (c)
{
case '-':
@@ -607,7 +607,7 @@ string_is_word_char (const char *string)
case '|':
return 1;
}
/* not a 'word char' */
return 0;
}
@@ -623,10 +623,10 @@ string_has_highlight (const char *string, const char *highlight_words)
{
char *msg, *highlight, *match, *match_pre, *match_post, *msg_pos, *pos, *pos_end;
int end, length, startswith, endswith, wildcard_start, wildcard_end;
if (!string || !string[0] || !highlight_words || !highlight_words[0])
return 0;
/* convert both strings to lower case */
msg = strdup (string);
if (!msg)
@@ -639,7 +639,7 @@ string_has_highlight (const char *string, const char *highlight_words)
return 0;
}
string_tolower (highlight);
pos = highlight;
end = 0;
while (!end)
@@ -657,7 +657,7 @@ string_has_highlight (const char *string, const char *highlight_words)
free (highlight);
return 0;
}
length = pos_end - pos;
pos_end[0] = '\0';
if (length > 0)
@@ -673,7 +673,7 @@ string_has_highlight (const char *string, const char *highlight_words)
length--;
}
}
if (length > 0)
{
msg_pos = msg;
@@ -699,14 +699,14 @@ string_has_highlight (const char *string, const char *highlight_words)
msg_pos = match_post;
}
}
if (!end)
pos = pos_end + 1;
}
free (msg);
free (highlight);
/* no highlight found */
return 0;
}
@@ -724,16 +724,16 @@ string_has_highlight_regex_compiled (const char *string, regex_t *regex)
int rc, startswith, endswith;
regmatch_t regex_match;
const char *match_pre;
if (!string || !regex)
return 0;
while (string && string[0])
{
rc = regexec (regex, string, 1, &regex_match, 0);
if ((rc != 0) || (regex_match.rm_so < 0) || (regex_match.rm_eo < 0))
break;
startswith = (regex_match.rm_so == 0);
if (!startswith)
{
@@ -748,10 +748,10 @@ string_has_highlight_regex_compiled (const char *string, regex_t *regex)
}
if (startswith && endswith)
return 1;
string += regex_match.rm_eo;
}
/* no highlight found */
return 0;
}
@@ -767,17 +767,17 @@ string_has_highlight_regex (const char *string, const char *regex)
{
regex_t reg;
int rc;
if (!string || !regex || !regex[0])
return 0;
if (regcomp (&reg, regex, REG_EXTENDED) != 0)
return 0;
rc = string_has_highlight_regex_compiled (string, &reg);
regfree (&reg);
return rc;
}
@@ -793,14 +793,14 @@ string_mask_to_regex (const char *mask)
const char *ptr_mask;
int index_result;
char *regex_special_char = ".[]{}()?+";
if (!mask)
return NULL;
result = malloc ((strlen (mask) * 2) + 1);
if (!result)
return NULL;
result[0] = '\0';
index_result = 0;
ptr_mask = mask;
@@ -821,13 +821,13 @@ string_mask_to_regex (const char *mask)
/* standard char, just copy it */
else
result[index_result++] = ptr_mask[0];
ptr_mask++;
}
/* add final '\0' */
result[index_result] = '\0';
return result;
}
@@ -853,17 +853,17 @@ string_split (const char *string, const char *separators, int keep_eol,
int i, j, n_items;
char *string2, **array;
char *ptr, *ptr1, *ptr2;
if (num_items != NULL)
*num_items = 0;
if (!string || !string[0] || !separators || !separators[0])
return NULL;
string2 = string_strip (string, 1, (keep_eol == 2) ? 0 : 1, separators);
if (!string2 || !string2[0])
return NULL;
/* calculate number of items */
ptr = string2;
i = 1;
@@ -876,16 +876,16 @@ string_split (const char *string, const char *separators, int keep_eol,
i++;
}
n_items = i;
if ((num_items_max != 0) && (n_items > num_items_max))
n_items = num_items_max;
array = malloc ((n_items + 1) * sizeof (array[0]));
if (!array)
return NULL;
ptr1 = string2;
for (i = 0; i < n_items; i++)
{
while (ptr1[0] && (strchr (separators, ptr1[0]) != NULL))
@@ -911,7 +911,7 @@ string_split (const char *string, const char *separators, int keep_eol,
}
}
}
if ((ptr1 == NULL) || (ptr2 == NULL))
{
array[i] = NULL;
@@ -960,13 +960,13 @@ string_split (const char *string, const char *separators, int keep_eol,
}
}
}
array[i] = NULL;
if (num_items != NULL)
*num_items = i;
free (string2);
return array;
}
@@ -978,7 +978,7 @@ void
string_free_split (char **split_string)
{
int i;
if (split_string)
{
for (i = 0; split_string[i]; i++)
@@ -999,23 +999,23 @@ string_build_with_split_string (const char **split_string,
{
int i, length, length_separator;
char *result;
if (!split_string)
return NULL;
length = 0;
length_separator = (separator) ? strlen (separator) : 0;
for (i = 0; split_string[i]; i++)
{
length += strlen (split_string[i]) + length_separator;
}
result = malloc (length + 1);
if (result)
{
result[0] = '\0';
for (i = 0; split_string[i]; i++)
{
strcat (result, split_string[i]);
@@ -1023,7 +1023,7 @@ string_build_with_split_string (const char **split_string,
strcat (result, separator);
}
}
return result;
}
@@ -1045,7 +1045,7 @@ string_split_command (const char *command, char separator)
if (!command || !command[0])
return NULL;
nb_substr = 1;
ptr = command;
while ( (p = strchr(ptr, separator)) != NULL)
@@ -1057,14 +1057,14 @@ string_split_command (const char *command, char separator)
array = malloc ((nb_substr + 1) * sizeof (array[0]));
if (!array)
return NULL;
buffer = malloc (strlen(command) + 1);
if (!buffer)
{
free (array);
return NULL;
}
ptr = command;
str_idx = 0;
arr_idx = 0;
@@ -1097,17 +1097,17 @@ string_split_command (const char *command, char separator)
str_idx++;
ptr++;
}
buffer[str_idx] = '\0';
p = buffer;
while (*p == ' ') p++;
if (p && p[0])
array[arr_idx++] = strdup (p);
array[arr_idx] = NULL;
free (buffer);
array2 = realloc (array, (arr_idx + 1) * sizeof(array[0]));
if (!array2)
{
@@ -1115,7 +1115,7 @@ string_split_command (const char *command, char separator)
free (array);
return NULL;
}
return array2;
}
@@ -1147,14 +1147,14 @@ string_iconv (int from_utf8, const char *from_code, const char *to_code,
const char *string)
{
char *outbuf;
#ifdef HAVE_ICONV
iconv_t cd;
char *inbuf, *ptr_inbuf, *ptr_outbuf, *next_char;
char *ptr_inbuf_shift;
int done;
size_t err, inbytesleft, outbytesleft;
if (from_code && from_code[0] && to_code && to_code[0]
&& (string_strcasecmp(from_code, to_code) != 0))
{
@@ -1243,7 +1243,7 @@ string_iconv (int from_utf8, const char *from_code, const char *to_code,
(void) to_code;
outbuf = strdup (string);
#endif /* HAVE_ICONV */
return outbuf;
}
@@ -1257,24 +1257,24 @@ char *
string_iconv_to_internal (const char *charset, const char *string)
{
char *input, *output;
if (!string)
return NULL;
input = strdup (string);
if (!input)
return NULL;
/*
* optimized for UTF-8: if charset is NULL => we use term charset => if
* this charset is already UTF-8, then no iconv is needed
*/
if (local_utf8 && (!charset || !charset[0]))
return input;
if (utf8_has_8bits (input) && utf8_is_valid (input, NULL))
return input;
output = string_iconv (0,
(charset && charset[0]) ?
charset : weechat_local_charset,
@@ -1297,21 +1297,21 @@ char *
string_iconv_from_internal (const char *charset, const char *string)
{
char *input, *output;
if (!string)
return NULL;
input = strdup (string);
if (!input)
return NULL;
/*
* optimized for UTF-8: if charset is NULL => we use term charset => if
* this charset is already UTF-8, then no iconv needed
*/
if (local_utf8 && (!charset || !charset[0]))
return input;
utf8_normalize (input, '?');
output = string_iconv (1,
WEECHAT_INTERNAL_CHARSET,
@@ -1334,7 +1334,7 @@ string_iconv_fprintf (FILE *file, const char *data, ...)
{
char *buf2;
int rc, num_written;
rc = 0;
weechat_va_format (data);
if (vbuffer)
@@ -1346,7 +1346,7 @@ string_iconv_fprintf (FILE *file, const char *data, ...)
free (buf2);
free (vbuffer);
}
return rc;
}
@@ -1363,9 +1363,9 @@ string_format_size (unsigned long long size)
float unit_divide[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
char format_size[128], str_size[128];
int num_unit;
str_size[0] = '\0';
if (size < 1024*10)
num_unit = 0;
else if (size < 1024*1024)
@@ -1374,7 +1374,7 @@ string_format_size (unsigned long long size)
num_unit = 2;
else
num_unit = 3;
snprintf (format_size, sizeof (format_size),
"%s %%s",
unit_format[num_unit]);
@@ -1382,7 +1382,7 @@ string_format_size (unsigned long long size)
format_size,
((float)size) / ((float)(unit_divide[num_unit])),
(size <= 1) ? _("byte") : _(unit_name[num_unit]));
return strdup (str_size);
}
@@ -1395,7 +1395,7 @@ string_convbase64_8x3_to_6x4 (const char *from, char *to)
{
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz0123456789+/";
to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
@@ -1413,10 +1413,10 @@ string_encode_base64 (const char *from, int length, char *to)
{
const char *ptr_from;
char *ptr_to;
ptr_from = from;
ptr_to = to;
while (length >= 3)
{
string_convbase64_8x3_to_6x4 (ptr_from, ptr_to);
@@ -1424,7 +1424,7 @@ string_encode_base64 (const char *from, int length, char *to)
ptr_to += 4 * sizeof (*ptr_to);
length -= 3;
}
if (length > 0)
{
char rest[3] = { 0, 0, 0 };
@@ -1475,13 +1475,13 @@ string_decode_base64 (const char *from, char *to)
unsigned char c, in[4], out[3];
unsigned char base64_table[]="|$$$}rstuvwxyz{$$$$$$$>?"
"@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
ptr_from = from;
ptr_to = to;
ptr_to[0] = '\0';
to_length = 0;
while (ptr_from && ptr_from[0])
{
length = 0;
@@ -1519,9 +1519,9 @@ string_decode_base64 (const char *from, char *to)
}
}
}
ptr_to[0] = '\0';
return to_length;
}
@@ -1534,24 +1534,24 @@ int
string_is_command_char (const char *string)
{
const char *ptr_command_chars;
if (!string)
return 0;
if (string[0] == '/')
return 1;
ptr_command_chars = CONFIG_STRING(config_look_command_chars);
if (!ptr_command_chars || !ptr_command_chars[0])
return 0;
while (ptr_command_chars && ptr_command_chars[0])
{
if (utf8_charcmp (ptr_command_chars, string) == 0)
return 1;
ptr_command_chars = utf8_next_char (ptr_command_chars);
}
return 0;
}
@@ -1566,11 +1566,11 @@ const char *
string_input_for_buffer (const char *string)
{
char *pos_slash, *pos_space, *next_char;
/* special case for C comments pasted in input line */
if (strncmp (string, "/*", 2) == 0)
return string;
/*
* special case if string starts with '/': to allow to paste a path line
* "/path/to/file.txt", we check if next '/' is after a space or not
@@ -1579,28 +1579,28 @@ string_input_for_buffer (const char *string)
{
pos_slash = strchr (string + 1, '/');
pos_space = strchr (string + 1, ' ');
/*
* if there's no other '/' of if '/' is after first space,
* then it is a command, and return NULL
*/
if (!pos_slash || (pos_space && pos_slash > pos_space))
return NULL;
return (string[1] == '/') ? string + 1 : string;
}
/* if string does not start with a command char, then it's not command */
if (!string_is_command_char (string))
return string;
/* check if first char is doubled: if yes, then it's not a command */
next_char = utf8_next_char (string);
if (!next_char || !next_char[0])
return string;
if (utf8_charcmp (string, next_char) == 0)
return next_char;
/* string is a command */
return NULL;
}
@@ -1619,15 +1619,15 @@ string_replace_with_hashtable (const char *string,
int length, length_value, index_string, index_result;
char *result, *result2, *key;
const char *pos_end_name, *ptr_value;
*errors = 0;
if (!string)
return NULL;
if (!hashtable)
return strdup (string);
length = strlen (string) + 1;
result = malloc (length);
if (result)
@@ -1676,7 +1676,7 @@ string_replace_with_hashtable (const char *string,
result[index_result++] = string[index_string++];
(*errors)++;
}
free (key);
}
else
@@ -1690,6 +1690,6 @@ string_replace_with_hashtable (const char *string,
}
result[index_result] = '\0';
}
return result;
}
+54 -54
View File
@@ -94,7 +94,7 @@ upgrade_file_write_integer (struct t_upgrade_file *upgrade_file, int value)
{
if (fwrite ((void *)(&value), sizeof (value), 1, upgrade_file->file) <= 0)
return 0;
return 1;
}
@@ -108,7 +108,7 @@ upgrade_file_write_time (struct t_upgrade_file *upgrade_file, time_t date)
{
if (fwrite ((void *)(&date), sizeof (date), 1, upgrade_file->file) <= 0)
return 0;
return 1;
}
@@ -122,7 +122,7 @@ upgrade_file_write_string (struct t_upgrade_file *upgrade_file,
const char *string)
{
int length;
if (string && string[0])
{
length = strlen (string);
@@ -136,7 +136,7 @@ upgrade_file_write_string (struct t_upgrade_file *upgrade_file,
if (!upgrade_file_write_integer (upgrade_file, 0))
return 0;
}
return 1;
}
@@ -161,7 +161,7 @@ upgrade_file_write_buffer (struct t_upgrade_file *upgrade_file, void *pointer,
if (!upgrade_file_write_integer (upgrade_file, 0))
return 0;
}
return 1;
}
@@ -176,10 +176,10 @@ upgrade_file_new (const char *filename, int write)
{
int length;
struct t_upgrade_file *new_upgrade_file;
if (!filename)
return NULL;
new_upgrade_file = malloc (sizeof (*new_upgrade_file));
if (new_upgrade_file)
{
@@ -193,33 +193,33 @@ upgrade_file_new (const char *filename, int write)
}
snprintf (new_upgrade_file->filename, length, "%s/%s.upgrade",
weechat_home, filename);
/* open file in read or write mode */
if (write)
new_upgrade_file->file = fopen (new_upgrade_file->filename, "wb");
else
new_upgrade_file->file = fopen (new_upgrade_file->filename, "rb");
if (!new_upgrade_file->file)
{
free (new_upgrade_file->filename);
free (new_upgrade_file);
return NULL;
}
/* change permissions if write mode */
if (write)
{
chmod (new_upgrade_file->filename, 0600);
/* write signature */
upgrade_file_write_string (new_upgrade_file, UPGRADE_SIGNATURE);
}
/* init positions */
new_upgrade_file->last_read_pos = 0;
new_upgrade_file->last_read_length = 0;
/* add upgrade file to list of upgrade files */
new_upgrade_file->prev_upgrade = last_upgrade_file;
new_upgrade_file->next_upgrade = NULL;
@@ -245,7 +245,7 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
char **argv;
const char *fields;
void *buf;
/* write all infolist variables */
infolist_reset_item_cursor (infolist);
while (infolist_next (infolist))
@@ -261,7 +261,7 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
UPGRADE_ERROR(_("write - object id"), "");
return 0;
}
fields = infolist_fields (infolist);
if (fields)
{
@@ -376,12 +376,12 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
if (argv)
string_free_split (argv);
}
/* write object end */
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_END))
return 0;
}
return 1;
}
@@ -416,28 +416,28 @@ int
upgrade_file_read_string (struct t_upgrade_file *upgrade_file, char **string)
{
int length;
if (string && *string)
{
free (*string);
*string = NULL;
}
if (!upgrade_file_read_integer (upgrade_file, &length))
return 0;
upgrade_file->last_read_pos = ftell (upgrade_file->file);
upgrade_file->last_read_length = length;
if (string)
{
if (length == 0)
return 1;
(*string) = malloc (length + 1);
if (!(*string))
return 0;
if (fread ((void *)(*string), length, 1, upgrade_file->file) <= 0)
{
free (*string);
@@ -464,10 +464,10 @@ upgrade_file_read_string_utf8 (struct t_upgrade_file *upgrade_file,
{
if (!upgrade_file_read_string (upgrade_file, string))
return 0;
if (string && *string)
utf8_normalize (*string, '?');
return 1;
}
@@ -481,23 +481,23 @@ upgrade_file_read_buffer (struct t_upgrade_file *upgrade_file,
{
if (!buffer)
return 0;
if (*buffer)
{
free (*buffer);
*buffer = NULL;
}
if (!upgrade_file_read_integer (upgrade_file, size))
return 0;
if (*size > 0)
{
upgrade_file->last_read_pos = ftell (upgrade_file->file);
upgrade_file->last_read_length = *size;
*buffer = malloc (*size);
if (*buffer)
{
if (fread (*buffer, *size, 1, upgrade_file->file) <= 0)
@@ -509,7 +509,7 @@ upgrade_file_read_buffer (struct t_upgrade_file *upgrade_file,
return 0;
}
}
return 1;
}
@@ -522,7 +522,7 @@ upgrade_file_read_time (struct t_upgrade_file *upgrade_file, time_t *time)
{
upgrade_file->last_read_pos = ftell (upgrade_file->file);
upgrade_file->last_read_length = sizeof (*time);
if (time)
{
if (fread ((void *)time, sizeof (*time), 1, upgrade_file->file) <= 0)
@@ -533,7 +533,7 @@ upgrade_file_read_time (struct t_upgrade_file *upgrade_file, time_t *time)
if (fseek (upgrade_file->file, sizeof (*time), SEEK_CUR) < 0)
return 0;
}
return 1;
}
@@ -551,14 +551,14 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
char *name, *value_str;
void *buffer;
time_t time;
rc = 0;
infolist = NULL;
name = NULL;
value_str = NULL;
buffer = NULL;
if (!upgrade_file_read_integer (upgrade_file, &type))
{
if (feof (upgrade_file->file))
@@ -567,19 +567,19 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
UPGRADE_ERROR(_("read - object type"), "");
goto end;
}
if (type != UPGRADE_TYPE_OBJECT_START)
{
UPGRADE_ERROR(_("read - bad object type ('object start' expected)"), "");
goto end;
}
if (!upgrade_file_read_integer (upgrade_file, &object_id))
{
UPGRADE_ERROR(_("read - object id"), "");
goto end;
}
infolist = infolist_new ();
if (!infolist)
{
@@ -592,7 +592,7 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
UPGRADE_ERROR(_("read - infolist item creation"), "");
goto end;
}
while (1)
{
if (!upgrade_file_read_integer (upgrade_file, &type))
@@ -600,10 +600,10 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
UPGRADE_ERROR(_("read - object type"), "");
goto end;
}
if (type == UPGRADE_TYPE_OBJECT_END)
break;
if (type == UPGRADE_TYPE_OBJECT_VAR)
{
if (!upgrade_file_read_string (upgrade_file, &name))
@@ -621,7 +621,7 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
UPGRADE_ERROR(_("read - variable type"), "");
goto end;
}
switch (type_var)
{
case INFOLIST_INTEGER:
@@ -661,9 +661,9 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
}
}
}
rc = 1;
if (upgrade_file->callback_read)
{
if ((int)(upgrade_file->callback_read) (upgrade_file->callback_read_data,
@@ -672,7 +672,7 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
infolist) == WEECHAT_RC_ERROR)
rc = 0;
}
end:
if (infolist)
infolist_free (infolist);
@@ -682,7 +682,7 @@ end:
free (value_str);
if (buffer)
free (buffer);
return rc;
}
@@ -700,35 +700,35 @@ upgrade_file_read (struct t_upgrade_file *upgrade_file,
void *callback_read_data)
{
char *signature;
if (!upgrade_file)
return 0;
upgrade_file->callback_read = callback_read;
upgrade_file->callback_read_data = callback_read_data;
signature = NULL;
if (!upgrade_file_read_string (upgrade_file, &signature))
{
UPGRADE_ERROR(_("read - signature not found"), "");
return 0;
}
if (!signature || (strcmp (signature, UPGRADE_SIGNATURE) != 0))
{
UPGRADE_ERROR(_("read - bad signature (upgrade file format may have "
"changed since last version)"), "");
return 0;
}
free (signature);
while (!feof (upgrade_file->file))
{
if (!upgrade_file_read_object (upgrade_file))
return 0;
}
return 1;
}
+48 -48
View File
@@ -71,14 +71,14 @@ upgrade_weechat_save_history (struct t_upgrade_file *upgrade_file,
struct t_infolist_item *ptr_item;
struct t_gui_history *ptr_history;
int rc;
if (!last_history)
return 1;
ptr_infolist = infolist_new ();
if (!ptr_infolist)
return 0;
ptr_history = last_history;
while (ptr_history)
{
@@ -88,23 +88,23 @@ upgrade_weechat_save_history (struct t_upgrade_file *upgrade_file,
infolist_free (ptr_infolist);
return 0;
}
if (!infolist_new_var_string (ptr_item, "text", ptr_history->text))
{
infolist_free (ptr_infolist);
return 0;
}
ptr_history = ptr_history->prev_history;
}
rc = upgrade_file_write_object (upgrade_file,
UPGRADE_WEECHAT_TYPE_HISTORY,
ptr_infolist);
infolist_free (ptr_infolist);
if (!rc)
return 0;
return 1;
}
@@ -119,7 +119,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line;
int rc;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -138,7 +138,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
infolist_free (ptr_infolist);
if (!rc)
return 0;
/* save nicklist */
if (ptr_buffer->nicklist)
{
@@ -157,7 +157,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
if (!rc)
return 0;
}
/* save buffer lines */
for (ptr_line = ptr_buffer->own_lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
@@ -179,7 +179,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
if (!rc)
return 0;
}
/* save command/text history of buffer */
if (ptr_buffer->history)
{
@@ -189,7 +189,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
return 0;
}
}
return 1;
}
@@ -203,11 +203,11 @@ upgrade_weechat_save_misc (struct t_upgrade_file *upgrade_file)
struct t_infolist *ptr_infolist;
struct t_infolist_item *ptr_item;
int rc;
ptr_infolist = infolist_new ();
if (!ptr_infolist)
return 0;
ptr_item = infolist_new_item (ptr_infolist);
if (!ptr_item)
{
@@ -229,12 +229,12 @@ upgrade_weechat_save_misc (struct t_upgrade_file *upgrade_file)
infolist_free (ptr_infolist);
return 0;
}
rc = upgrade_file_write_object (upgrade_file,
UPGRADE_WEECHAT_TYPE_MISC,
ptr_infolist);
infolist_free (ptr_infolist);
return rc;
}
@@ -248,7 +248,7 @@ upgrade_weechat_save_hotlist (struct t_upgrade_file *upgrade_file)
struct t_infolist *ptr_infolist;
struct t_gui_hotlist *ptr_hotlist;
int rc;
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
@@ -267,7 +267,7 @@ upgrade_weechat_save_hotlist (struct t_upgrade_file *upgrade_file)
if (!rc)
return 0;
}
return 1;
}
@@ -282,39 +282,39 @@ upgrade_weechat_save_layout_window_tree (struct t_upgrade_file *upgrade_file,
{
struct t_infolist *ptr_infolist;
int rc;
ptr_infolist = infolist_new ();
if (!ptr_infolist)
return 0;
if (!gui_layout_window_add_to_infolist (ptr_infolist, layout_window))
{
infolist_free (ptr_infolist);
return 0;
}
rc = upgrade_file_write_object (upgrade_file,
UPGRADE_WEECHAT_TYPE_LAYOUT_WINDOW,
ptr_infolist);
infolist_free (ptr_infolist);
if (!rc)
return 0;
if (layout_window->child1)
{
if (!upgrade_weechat_save_layout_window_tree (upgrade_file,
layout_window->child1))
return 0;
}
if (layout_window->child2)
{
if (!upgrade_weechat_save_layout_window_tree (upgrade_file,
layout_window->child2))
return 0;
}
return 1;
}
@@ -327,16 +327,16 @@ upgrade_weechat_save_layout_window (struct t_upgrade_file *upgrade_file)
{
struct t_gui_layout_window *layout_windows;
int rc;
/* get current layout for windows */
layout_windows = NULL;
gui_layout_window_save (&layout_windows);
/* save tree with layout of windows */
rc = upgrade_weechat_save_layout_window_tree (upgrade_file, layout_windows);
gui_layout_window_remove_all (&layout_windows);
return rc;
}
@@ -350,7 +350,7 @@ upgrade_weechat_save ()
{
int rc;
struct t_upgrade_file *upgrade_file;
upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME, 1);
if (!upgrade_file)
return 0;
@@ -361,9 +361,9 @@ upgrade_weechat_save ()
rc &= upgrade_weechat_save_misc (upgrade_file);
rc &= upgrade_weechat_save_hotlist (upgrade_file);
rc &= upgrade_weechat_save_layout_window (upgrade_file);
upgrade_file_close (upgrade_file);
return rc;
}
@@ -387,11 +387,11 @@ upgrade_weechat_read_cb (void *data,
struct timeval creation_time;
void *buf;
int i, size, index, length;
/* make C compiler happy */
(void) data;
(void) upgrade_file;
infolist_reset_item_cursor (infolist);
while (infolist_next (infolist))
{
@@ -673,7 +673,7 @@ upgrade_weechat_read_cb (void *data,
break;
}
}
return WEECHAT_RC_OK;
}
@@ -687,40 +687,40 @@ upgrade_weechat_load ()
{
int rc;
struct t_upgrade_file *upgrade_file;
upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME, 0);
rc = upgrade_file_read (upgrade_file, &upgrade_weechat_read_cb, NULL);
if (!hotlist_reset)
gui_hotlist_clear ();
gui_color_buffer_assign ();
gui_color_buffer_display ();
if (upgrade_layout_buffers)
{
gui_layout_buffer_apply (upgrade_layout_buffers);
gui_layout_buffer_remove_all (&upgrade_layout_buffers,
&last_upgrade_layout_buffer);
}
if (upgrade_layout_windows)
{
gui_layout_window_apply (upgrade_layout_windows, -1);
gui_layout_window_remove_all (&upgrade_layout_windows);
}
if (upgrade_set_current_window > 0)
gui_window_switch_by_number (upgrade_set_current_window);
if (upgrade_set_current_buffer)
{
gui_window_switch_to_buffer (gui_current_window,
upgrade_set_current_buffer, 0);
}
gui_layout_buffer_get_number_all (gui_layout_buffers);
return rc;
}
@@ -733,7 +733,7 @@ upgrade_weechat_remove_file_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
if (string_match (filename, "*.upgrade", 1))
{
if (weechat_debug_core >= 2)
@@ -752,13 +752,13 @@ upgrade_weechat_end ()
{
struct timeval tv_now;
long time_diff;
/* remove .upgrade files */
util_exec_on_files (weechat_home,
0,
NULL,
&upgrade_weechat_remove_file_cb);
/* display message for end of /upgrade with duration */
gettimeofday (&tv_now, NULL);
time_diff = util_timeval_diff (&weechat_current_start_timeval, &tv_now);
@@ -767,10 +767,10 @@ upgrade_weechat_end ()
_("Upgrade done (%.02f %s)"),
((float)time_diff) / 1000,
NG_("second", "seconds", time_diff / 1000));
/* upgrading ended */
weechat_upgrading = 0;
/* send signal for end of /upgrade */
hook_signal_send ("upgrade_ended", WEECHAT_HOOK_SIGNAL_STRING, NULL);
}
+38 -38
View File
@@ -137,7 +137,7 @@ void
utf8_normalize (char *string, char replacement)
{
char *error;
while (string && string[0])
{
if (utf8_is_valid (string, &error))
@@ -156,9 +156,9 @@ utf8_prev_char (const char *string_start, const char *string)
{
if (!string || (string <= string_start))
return NULL;
string--;
if (((unsigned char)(string[0]) & 0xC0) == 0x80)
{
/* UTF-8, at least 2 bytes */
@@ -197,7 +197,7 @@ utf8_next_char (const char *string)
{
if (!string)
return NULL;
/* UTF-8, 2 bytes: 110vvvvv 10vvvvvv */
if (((unsigned char)(string[0]) & 0xE0) == 0xC0)
{
@@ -237,12 +237,12 @@ int
utf8_char_int (const char *string)
{
const unsigned char *ptr_string;
if (!string)
return 0;
ptr_string = (unsigned char *)string;
/* UTF-8, 2 bytes: 110vvvvv 10vvvvvv */
if ((ptr_string[0] & 0xE0) == 0xC0)
{
@@ -293,10 +293,10 @@ utf8_wide_char (const char *string)
{
int char_size;
wint_t result;
if (!string || !string[0])
return WEOF;
char_size = utf8_char_size (string);
switch (char_size)
{
@@ -333,7 +333,7 @@ utf8_char_size (const char *string)
{
if (!string)
return 0;
return utf8_next_char (string) - string;
}
@@ -345,10 +345,10 @@ int
utf8_strlen (const char *string)
{
int length;
if (!string)
return 0;
length = 0;
while (string && string[0])
{
@@ -367,10 +367,10 @@ utf8_strnlen (const char *string, int bytes)
{
char *start;
int length;
if (!string)
return 0;
start = (char *)string;
length = 0;
while (string && string[0] && (string - start < bytes))
@@ -391,24 +391,24 @@ utf8_strlen_screen (const char *string)
{
int length, num_char;
wchar_t *wstring;
if (!string)
return 0;
if (!local_utf8)
return utf8_strlen (string);
num_char = mbstowcs (NULL, string, 0) + 1;
wstring = malloc ((num_char + 1) * sizeof (wstring[0]));
if (!wstring)
return utf8_strlen (string);
if (mbstowcs (wstring, string, num_char) == (size_t)(-1))
{
free (wstring);
return utf8_strlen (string);
}
length = wcswidth (wstring, num_char);
free (wstring);
return length;
@@ -422,13 +422,13 @@ int
utf8_charcmp (const char *string1, const char *string2)
{
int length1, length2, i, diff;
if (!string1 || !string2)
return (string1) ? 1 : ((string2) ? -1 : 0);
length1 = utf8_char_size (string1);
length2 = utf8_char_size (string2);
i = 0;
while ((i < length1) && (i < length2))
{
@@ -455,18 +455,18 @@ int
utf8_charcasecmp (const char *string1, const char *string2)
{
wint_t wchar1, wchar2;
if (!string1 || !string2)
return (string1) ? 1 : ((string2) ? -1 : 0);
wchar1 = utf8_wide_char (string1);
if ((wchar1 >= 'A') && (wchar1 <= 'Z'))
wchar1 += ('a' - 'A');
wchar2 = utf8_wide_char (string2);
if ((wchar2 >= 'A') && (wchar2 <= 'Z'))
wchar2 += ('a' - 'A');
return (wchar1 < wchar2) ? -1 : ((wchar1 == wchar2) ? 0 : 1);
}
@@ -480,17 +480,17 @@ utf8_char_size_screen (const char *string)
{
int char_size;
char utf_char[16];
if (!string)
return 0;
char_size = utf8_char_size (string);
if (char_size == 0)
return 0;
memcpy (utf_char, string, char_size);
utf_char[char_size] = '\0';
return utf8_strlen_screen (utf_char);
}
@@ -503,7 +503,7 @@ utf8_add_offset (const char *string, int offset)
{
if (!string)
return NULL;
while (string && string[0] && (offset > 0))
{
string = utf8_next_char (string);
@@ -522,10 +522,10 @@ utf8_real_pos (const char *string, int pos)
{
int count, real_pos;
char *next_char;
if (!string)
return pos;
count = 0;
real_pos = 0;
while (string && string[0] && (count < pos))
@@ -548,10 +548,10 @@ utf8_pos (const char *string, int real_pos)
{
int count;
char *limit;
if (!string || !weechat_local_charset)
return real_pos;
count = 0;
limit = (char *)string + real_pos;
while (string && string[0] && (string < limit))
@@ -570,13 +570,13 @@ char *
utf8_strndup (const char *string, int length)
{
const char *end;
if (!string || (length < 0))
return NULL;
if (length == 0)
return strdup ("");
end = utf8_add_offset (string, length);
if (!end || (end == string))
return strdup (string);
+32 -32
View File
@@ -73,10 +73,10 @@ long
util_timeval_diff (struct timeval *tv1, struct timeval *tv2)
{
long diff_sec, diff_usec;
diff_sec = tv2->tv_sec - tv1->tv_sec;
diff_usec = tv2->tv_usec - tv1->tv_usec;
if (diff_usec < 0)
{
diff_usec += 1000000;
@@ -93,7 +93,7 @@ void
util_timeval_add (struct timeval *tv, long interval)
{
long usec;
tv->tv_sec += (interval / 1000);
usec = tv->tv_usec + ((interval % 1000) * 1000);
if (usec > 1000000)
@@ -115,11 +115,11 @@ util_get_time_string (const time_t *date)
{
struct tm *local_time;
static char text_time[128];
local_time = localtime (date);
strftime (text_time, sizeof (text_time),
CONFIG_STRING(config_look_time_format), local_time);
return text_time;
}
@@ -131,7 +131,7 @@ void
util_catch_signal (int signum, void (*handler)(int))
{
struct sigaction act;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = handler;
@@ -148,18 +148,18 @@ util_mkdir_home (const char *directory, int mode)
{
char *dir_name;
int dir_length;
if (!directory)
return 0;
/* build directory, adding WeeChat home */
dir_length = strlen (weechat_home) + strlen (directory) + 2;
dir_name = malloc (dir_length);
if (!dir_name)
return 0;
snprintf (dir_name, dir_length, "%s/%s", weechat_home, directory);
if (mkdir (dir_name, mode) < 0)
{
if (errno != EEXIST)
@@ -168,7 +168,7 @@ util_mkdir_home (const char *directory, int mode)
return 0;
}
}
free (dir_name);
return 1;
}
@@ -183,13 +183,13 @@ util_mkdir (const char *directory, int mode)
{
if (!directory)
return 0;
if (mkdir (directory, mode) < 0)
{
if (errno != EEXIST)
return 0;
}
return 1;
}
@@ -204,26 +204,26 @@ util_mkdir_parents (const char *directory, int mode)
char *string, *ptr_string, *pos_sep;
struct stat buf;
int rc;
if (!directory)
return 0;
string = strdup (directory);
if (!string)
return 0;
ptr_string = string;
while (ptr_string[0] == DIR_SEPARATOR_CHAR)
{
ptr_string++;
}
while (ptr_string && ptr_string[0])
{
pos_sep = strchr (ptr_string, DIR_SEPARATOR_CHAR);
if (pos_sep)
pos_sep[0] = '\0';
rc = stat (string, &buf);
if ((rc < 0) || !S_ISDIR(buf.st_mode))
{
@@ -234,7 +234,7 @@ util_mkdir_parents (const char *directory, int mode)
return 0;
}
}
if (pos_sep)
{
pos_sep[0] = DIR_SEPARATOR_CHAR;
@@ -243,9 +243,9 @@ util_mkdir_parents (const char *directory, int mode)
else
ptr_string = NULL;
}
free (string);
return 1;
}
@@ -262,10 +262,10 @@ util_exec_on_files (const char *directory, int hidden_files, void *data,
DIR *dir;
struct dirent *entry;
struct stat statbuf;
if (!directory || !callback)
return;
dir = opendir (directory);
if (dir)
{
@@ -302,11 +302,11 @@ util_search_full_lib_name (const char *filename, const char *sys_directory)
char *name_with_ext, *final_name;
int length;
struct stat st;
/* filename is already a full path */
if (strchr (filename, '/') || strchr (filename, '\\'))
return strdup (filename);
length = strlen (filename) + 16;
if (CONFIG_STRING(config_plugin_extension)
&& CONFIG_STRING(config_plugin_extension)[0])
@@ -319,7 +319,7 @@ util_search_full_lib_name (const char *filename, const char *sys_directory)
&& CONFIG_STRING(config_plugin_extension)
&& CONFIG_STRING(config_plugin_extension)[0])
strcat (name_with_ext, CONFIG_STRING(config_plugin_extension));
/* try WeeChat user's dir */
length = strlen (weechat_home) + strlen (name_with_ext) +
strlen (sys_directory) + 16;
@@ -337,7 +337,7 @@ util_search_full_lib_name (const char *filename, const char *sys_directory)
return final_name;
}
free (final_name);
/* try WeeChat global lib dir */
length = strlen (WEECHAT_LIBDIR) + strlen (name_with_ext) +
strlen (sys_directory) + 16;
@@ -372,10 +372,10 @@ util_file_get_content (const char *filename)
char *buffer, *buffer2;
FILE *f;
size_t count, fp;
buffer = NULL;
fp = 0;
f = fopen (filename, "r");
if (f)
{
@@ -408,7 +408,7 @@ util_file_get_content (const char *filename)
buffer[fp] = '\0';
fclose (f);
}
return buffer;
}
@@ -430,7 +430,7 @@ util_version_number (const char *version)
char **items, buf[64], *ptr_item, *error;
int num_items, i, version_int[4], index_buf;
long number;
items = string_split (version, ".", 0, 4, &num_items);
for (i = 0; i < 4; i++)
{
@@ -468,7 +468,7 @@ util_version_number (const char *version)
}
if (items)
string_free_split (items);
return (version_int[0] << 24) | (version_int[1] << 16)
| (version_int[2] << 8) | version_int[3];
}
+10 -10
View File
@@ -197,14 +197,14 @@ void
weechat_parse_args (int argc, char *argv[])
{
int i;
weechat_argv0 = strdup (argv[0]);
weechat_upgrading = 0;
weechat_home = NULL;
weechat_server_cmd_line = 0;
weechat_auto_load_plugins = 1;
weechat_plugin_no_dlclose = 0;
for (i = 1; i < argc; i++)
{
if ((strcmp (argv[i], "-c") == 0)
@@ -323,7 +323,7 @@ weechat_create_home_dirs ()
weechat_shutdown (EXIT_FAILURE, 0);
}
}
/* create home directory; error is fatal */
if (!util_mkdir (weechat_home, 0755))
{
@@ -383,7 +383,7 @@ weechat_shutdown (int return_code, int crash)
free (weechat_local_charset);
network_end ();
if (crash)
abort();
else
@@ -398,21 +398,21 @@ int
main (int argc, char *argv[])
{
weechat_init_vars (); /* initialize some variables */
setlocale (LC_ALL, ""); /* initialize gettext */
#ifdef ENABLE_NLS
bindtextdomain (PACKAGE, LOCALEDIR);
bind_textdomain_codeset (PACKAGE, "UTF-8");
textdomain (PACKAGE);
#endif
#ifdef HAVE_LANGINFO_CODESET
weechat_local_charset = strdup (nl_langinfo (CODESET));
#else
weechat_local_charset = strdup ("");
#endif
utf8_init ();
util_catch_signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */
util_catch_signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
util_catch_signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
@@ -449,9 +449,9 @@ main (int argc, char *argv[])
gui_layout_window_apply (gui_layout_windows, -1); /* apply win layout */
if (weechat_upgrading)
upgrade_weechat_end (); /* remove .upgrade files + signal */
gui_main_loop (); /* WeeChat main loop */
gui_layout_save_on_exit (); /* save layout */
plugin_end (); /* end plugin interface(s) */
if (CONFIG_BOOLEAN(config_look_save_config_on_exit))
@@ -463,6 +463,6 @@ main (int argc, char *argv[])
unhook_all (); /* remove all hooks */
hdata_end (); /* end hdata */
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */
return EXIT_SUCCESS; /* make C compiler happy */
}
+1 -1
View File
@@ -75,7 +75,7 @@
"\n" \
"You should have received a copy of the GNU General Public License\n" \
"along with WeeChat. If not, see <http://www.gnu.org/licenses/>.\n\n"
/* directory separator, depending on OS */
#ifdef _WIN32