summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c62
-rw-r--r--src/core/wee-config-file.c535
-rw-r--r--src/core/wee-config-file.h90
-rw-r--r--src/core/wee-config.c9
-rw-r--r--src/core/wee-config.h12
-rw-r--r--src/core/wee-hook.c107
-rw-r--r--src/core/wee-hook.h103
-rw-r--r--src/core/wee-input.c1
-rw-r--r--src/core/wee-input.h5
-rw-r--r--src/core/wee-list.c68
-rw-r--r--src/core/wee-list.h31
-rw-r--r--src/core/wee-log.c4
-rw-r--r--src/core/wee-log.h2
-rw-r--r--src/core/wee-string.c36
-rw-r--r--src/core/wee-string.h36
-rw-r--r--src/core/wee-upgrade.c2
-rw-r--r--src/core/wee-utf8.c8
-rw-r--r--src/core/wee-utf8.h28
-rw-r--r--src/core/wee-util.c8
-rw-r--r--src/core/wee-util.h15
-rw-r--r--src/core/weechat.c4
-rw-r--r--src/core/weechat.h4
-rw-r--r--src/gui/curses/gui-curses-chat.c10
-rw-r--r--src/gui/curses/gui-curses-input.c1
-rw-r--r--src/gui/curses/gui-curses-keyboard.c1
-rw-r--r--src/gui/curses/gui-curses-main.c3
-rw-r--r--src/gui/curses/gui-curses-nicklist.c1
-rw-r--r--src/gui/curses/gui-curses-status.c1
-rw-r--r--src/gui/curses/gui-curses-window.c3
-rw-r--r--src/gui/curses/gui-curses.h13
-rw-r--r--src/gui/gtk/gui-gtk-chat.c1
-rw-r--r--src/gui/gtk/gui-gtk-main.c3
-rw-r--r--src/gui/gtk/gui-gtk-window.c3
-rw-r--r--src/gui/gtk/gui-gtk.h14
-rw-r--r--src/gui/gui-action.c3
-rw-r--r--src/gui/gui-action.h106
-rw-r--r--src/gui/gui-buffer.c18
-rw-r--r--src/gui/gui-buffer.h75
-rw-r--r--src/gui/gui-chat.c3
-rw-r--r--src/gui/gui-chat.h43
-rw-r--r--src/gui/gui-color.h8
-rw-r--r--src/gui/gui-completion.c11
-rw-r--r--src/gui/gui-completion.h11
-rw-r--r--src/gui/gui-history.c68
-rw-r--r--src/gui/gui-history.h8
-rw-r--r--src/gui/gui-hotlist.c6
-rw-r--r--src/gui/gui-hotlist.h15
-rw-r--r--src/gui/gui-infobar.c4
-rw-r--r--src/gui/gui-infobar.h12
-rw-r--r--src/gui/gui-input.c12
-rw-r--r--src/gui/gui-input.h20
-rw-r--r--src/gui/gui-keyboard.c9
-rw-r--r--src/gui/gui-keyboard.h24
-rw-r--r--src/gui/gui-main.h2
-rw-r--r--src/gui/gui-nicklist.c33
-rw-r--r--src/gui/gui-nicklist.h40
-rw-r--r--src/gui/gui-status.h4
-rw-r--r--src/gui/gui-window.c1
-rw-r--r--src/gui/gui-window.h97
-rw-r--r--src/plugins/alias/alias.c36
-rw-r--r--src/plugins/aspell/aspell.c18
-rw-r--r--src/plugins/aspell/aspell.h6
-rw-r--r--src/plugins/demo/demo.c29
-rw-r--r--src/plugins/fifo/fifo.c52
-rw-r--r--src/plugins/irc/irc-buffer.h8
-rw-r--r--src/plugins/irc/irc-channel.c18
-rw-r--r--src/plugins/irc/irc-channel.h88
-rw-r--r--src/plugins/irc/irc-color.c3
-rw-r--r--src/plugins/irc/irc-color.h8
-rw-r--r--src/plugins/irc/irc-command.c249
-rw-r--r--src/plugins/irc/irc-command.h14
-rw-r--r--src/plugins/irc/irc-completion.c64
-rw-r--r--src/plugins/irc/irc-completion.h11
-rw-r--r--src/plugins/irc/irc-config.c11
-rw-r--r--src/plugins/irc/irc-config.h5
-rw-r--r--src/plugins/irc/irc-dcc.c517
-rw-r--r--src/plugins/irc/irc-dcc.h32
-rw-r--r--src/plugins/irc/irc-display.h18
-rw-r--r--src/plugins/irc/irc-mode.c10
-rw-r--r--src/plugins/irc/irc-mode.h9
-rw-r--r--src/plugins/irc/irc-nick.c5
-rw-r--r--src/plugins/irc/irc-nick.h39
-rw-r--r--src/plugins/irc/irc-protocol.c16
-rw-r--r--src/plugins/irc/irc-protocol.h125
-rw-r--r--src/plugins/irc/irc-server.c117
-rw-r--r--src/plugins/irc/irc-server.h98
-rw-r--r--src/plugins/irc/irc.c14
-rw-r--r--src/plugins/logger/CMakeLists.txt3
-rw-r--r--src/plugins/logger/Makefile.am7
-rw-r--r--src/plugins/logger/logger-buffer.c25
-rw-r--r--src/plugins/logger/logger-buffer.h10
-rw-r--r--src/plugins/logger/logger-tail.c223
-rw-r--r--src/plugins/logger/logger-tail.h32
-rw-r--r--src/plugins/logger/logger.c278
-rw-r--r--src/plugins/logger/logger.h29
-rw-r--r--src/plugins/plugin-api.c1470
-rw-r--r--src/plugins/plugin-api.h209
-rw-r--r--src/plugins/plugin-config.c8
-rw-r--r--src/plugins/plugin-config.h10
-rw-r--r--src/plugins/plugin-infolist.c12
-rw-r--r--src/plugins/plugin-infolist.h54
-rw-r--r--src/plugins/plugin.c208
-rw-r--r--src/plugins/plugin.h20
-rw-r--r--src/plugins/scripts/lua/lua.c2
-rw-r--r--src/plugins/scripts/perl/perl.c4
-rw-r--r--src/plugins/scripts/python/python.c4
-rw-r--r--src/plugins/scripts/ruby/ruby.c2
-rw-r--r--src/plugins/scripts/script.c58
-rw-r--r--src/plugins/scripts/script.h130
-rw-r--r--src/plugins/trigger/trigger-libc.c14
-rw-r--r--src/plugins/trigger/trigger.c4
-rw-r--r--src/plugins/weechat-plugin.h671
112 files changed, 3147 insertions, 3817 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 77c70e3a8..66e9727ca 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -38,6 +38,7 @@
#include "wee-string.h"
#include "wee-utf8.h"
#include "wee-list.h"
+#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-history.h"
@@ -54,7 +55,7 @@
*/
int
-command_buffer (void *data, void *buffer,
+command_buffer (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_gui_buffer *ptr_buffer;
@@ -84,7 +85,7 @@ command_buffer (void *data, void *buffer,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
(ptr_buffer->plugin) ?
- ((struct t_weechat_plugin *)ptr_buffer->plugin)->name :
+ ptr_buffer->plugin->name :
"weechat",
ptr_buffer->category,
ptr_buffer->name);
@@ -114,10 +115,10 @@ command_buffer (void *data, void *buffer,
{
if (argv[2][0] == '+')
gui_buffer_move_to_number (buffer,
- ((struct t_gui_buffer *)buffer)->number + ((int) number));
+ buffer->number + ((int) number));
else if (argv[2][0] == '-')
gui_buffer_move_to_number (buffer,
- ((struct t_gui_buffer *)buffer)->number - ((int) number));
+ buffer->number - ((int) number));
else
gui_buffer_move_to_number (buffer, (int) number);
}
@@ -132,7 +133,7 @@ command_buffer (void *data, void *buffer,
}
else if (string_strcasecmp (argv[1], "close") == 0)
{
- if (!((struct t_gui_buffer *)buffer)->plugin)
+ if (!buffer->plugin)
{
gui_chat_printf (NULL,
_("%sError: WeeChat main buffer can't be "
@@ -140,7 +141,7 @@ command_buffer (void *data, void *buffer,
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return WEECHAT_RC_ERROR;
}
- gui_buffer_free (buffer, 1);
+ gui_buffer_close (buffer, 1);
gui_status_draw (gui_current_window->buffer, 1);
gui_input_draw (gui_current_window->buffer, 1);
}
@@ -186,7 +187,7 @@ command_buffer (void *data, void *buffer,
"%d %s"),
gui_chat_prefix[GUI_CHAT_PREFIX_INFO],
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
- ((struct t_gui_buffer *)buffer)->name,
+ buffer->name,
GUI_COLOR(GUI_COLOR_CHAT),
number,
GUI_COLOR(GUI_COLOR_CHAT));
@@ -258,7 +259,7 @@ command_buffer (void *data, void *buffer,
number = strtol (argv[1] + 1, &error, 10);
if (error && (error[0] == '\0'))
{
- target_buffer = ((struct t_gui_buffer *)buffer)->number - (int) number;
+ target_buffer = buffer->number - (int) number;
if (target_buffer < 1)
target_buffer = (last_gui_buffer) ?
last_gui_buffer->number + target_buffer : 1;
@@ -273,7 +274,7 @@ command_buffer (void *data, void *buffer,
number = strtol (argv[1] + 1, &error, 10);
if (error && (error[0] == '\0'))
{
- target_buffer = ((struct t_gui_buffer *)buffer)->number + (int) number;
+ target_buffer = buffer->number + (int) number;
if (last_gui_buffer && target_buffer > last_gui_buffer->number)
target_buffer -= last_gui_buffer->number;
gui_buffer_switch_by_number (gui_current_window,
@@ -321,7 +322,7 @@ command_buffer (void *data, void *buffer,
*/
int
-command_builtin (void *data, void *buffer,
+command_builtin (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *command;
@@ -354,7 +355,7 @@ command_builtin (void *data, void *buffer,
*/
int
-command_clear (void *data, void *buffer,
+command_clear (void *data, struct t_gui_buffer *buffer,
int argc, char**argv, char **argv_eol)
{
struct t_gui_buffer *ptr_buffer;
@@ -435,7 +436,7 @@ command_debug_display_windows (struct t_gui_window_tree *tree, int indent)
*/
int
-command_debug (void *data, void *buffer,
+command_debug (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/* make C compiler happy */
@@ -479,7 +480,7 @@ command_debug (void *data, void *buffer,
*/
int
-command_help (void *data, void *buffer,
+command_help (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_hook *ptr_hook;
@@ -605,7 +606,7 @@ command_help (void *data, void *buffer,
*/
int
-command_history (void *data, void *buffer,
+command_history (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_gui_history *ptr_history;
@@ -628,10 +629,10 @@ command_history (void *data, void *buffer,
n_user = atoi (argv[1]);
}
- if (((struct t_gui_buffer *)buffer)->history)
+ if (buffer->history)
{
n_total = 1;
- for (ptr_history = ((struct t_gui_buffer *)buffer)->history;
+ for (ptr_history = buffer->history;
ptr_history->next_history;
ptr_history = ptr_history->next_history)
{
@@ -696,7 +697,7 @@ command_key_display (t_gui_key *key, int new_key)
*/
int
-command_key (void *data, void *buffer,
+command_key (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *args, *internal_code;
@@ -1059,7 +1060,7 @@ command_plugin_list (char *name, int full)
*/
int
-command_plugin (void *data, void *buffer,
+command_plugin (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/* make C compiler happy */
@@ -1123,7 +1124,7 @@ command_plugin (void *data, void *buffer,
*/
int
-command_quit (void *data, void *buffer,
+command_quit (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/* make C compiler happy */
@@ -1132,7 +1133,7 @@ command_quit (void *data, void *buffer,
(void) argc;
(void) argv;
- hook_signal_exec ("quit",
+ hook_signal_send ("quit",
(argc > 1) ?
argv_eol[1] : CONFIG_STRING(config_look_default_msg_quit));
@@ -1146,7 +1147,7 @@ command_quit (void *data, void *buffer,
*/
int
-command_reload (void *data, void *buffer,
+command_reload (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/* make C compiler happy */
@@ -1177,7 +1178,7 @@ command_reload (void *data, void *buffer,
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
/* tell to plugins to reload their configuration */
- hook_signal_exec ("config_reload", NULL);
+ hook_signal_send ("config_reload", NULL);
return WEECHAT_RC_OK;
}
@@ -1187,7 +1188,7 @@ command_reload (void *data, void *buffer,
*/
int
-command_save (void *data, void *buffer,
+command_save (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/* make C compiler happy */
@@ -1339,7 +1340,7 @@ command_set_display_option_list (struct t_config_file *config_file,
*/
int
-command_set (void *data, void *buffer,
+command_set (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *value;
@@ -1407,7 +1408,8 @@ command_set (void *data, void *buffer,
}
value = string_remove_quotes (argv_eol[3], "'\"");
rc = config_file_option_set (ptr_option,
- (value) ? value : argv_eol[3]);
+ (value) ? value : argv_eol[3],
+ 0);
if (value)
free (value);
if (rc > 0)
@@ -1437,7 +1439,7 @@ command_set (void *data, void *buffer,
*/
int
-command_setp (void *data, void *buffer,
+command_setp (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *pos, *ptr_name, *value;
@@ -1557,7 +1559,7 @@ command_setp (void *data, void *buffer,
*/
int
-command_upgrade (void *data, void *buffer,
+command_upgrade (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
/*int filename_length;
@@ -1602,7 +1604,7 @@ command_upgrade (void *data, void *buffer,
}
filename_length = strlen (weechat_home) + strlen (WEECHAT_SESSION_NAME) + 2;
- filename = (char *) malloc (filename_length * sizeof (char));
+ filename = (char *)malloc (filename_length * sizeof (char));
if (!filename)
return -2;
snprintf (filename, filename_length, "%s%s" WEECHAT_SESSION_NAME,
@@ -1655,7 +1657,7 @@ command_upgrade (void *data, void *buffer,
*/
int
-command_uptime (void *data, void *buffer,
+command_uptime (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
time_t running_time;
@@ -1716,7 +1718,7 @@ command_uptime (void *data, void *buffer,
*/
int
-command_window (void *data, void *buffer,
+command_window (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_gui_window *ptr_win;
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 55dfddefb..ea4f0cde6 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -40,6 +40,9 @@
struct t_config_file *config_files = NULL;
struct t_config_file *last_config_file = NULL;
+char *config_boolean_true[] = { "on", "yes", "y", "true", "t", "1", NULL };
+char *config_boolean_false[] = { "off", "no", "n", "false", "f", "0", NULL };
+
/*
* config_file_search: search a configuration file
@@ -66,7 +69,7 @@ config_file_search (char *filename)
*/
struct t_config_file *
-config_file_new (void *plugin, char *filename)
+config_file_new (struct t_weechat_plugin *plugin, char *filename)
{
struct t_config_file *new_config_file;
@@ -105,7 +108,8 @@ config_file_new (void *plugin, char *filename)
*/
int
-config_file_valid_for_plugin (void *plugin, struct t_config_file *config_file)
+config_file_valid_for_plugin (struct t_weechat_plugin *plugin,
+ struct t_config_file *config_file)
{
struct t_config_file *ptr_config;
@@ -113,7 +117,7 @@ config_file_valid_for_plugin (void *plugin, struct t_config_file *config_file)
ptr_config = ptr_config->next_config)
{
if ((ptr_config == config_file)
- && (ptr_config->plugin == (struct t_weechat_plugin *)plugin))
+ && (ptr_config->plugin == plugin))
return 1;
}
@@ -127,9 +131,12 @@ config_file_valid_for_plugin (void *plugin, struct t_config_file *config_file)
struct t_config_section *
config_file_new_section (struct t_config_file *config_file, char *name,
- void (*callback_read)(void *, char *, char *),
- void (*callback_write)(void *, char *),
- void (*callback_write_default)(void *, char *))
+ void (*callback_read)(struct t_config_file *config_file,
+ char *option_name, char *value),
+ void (*callback_write)(struct t_config_file *config_file,
+ char *section_name),
+ void (*callback_write_default)(struct t_config_file *,
+ char *section_name))
{
struct t_config_section *new_section;
@@ -186,7 +193,7 @@ config_file_search_section (struct t_config_file *config_file,
*/
int
-config_file_section_valid_for_plugin (void *plugin,
+config_file_section_valid_for_plugin (struct t_weechat_plugin *plugin,
struct t_config_section *section)
{
struct t_config_file *ptr_config;
@@ -195,7 +202,7 @@ config_file_section_valid_for_plugin (void *plugin,
for (ptr_config = config_files; ptr_config;
ptr_config = ptr_config->next_config)
{
- if (ptr_config->plugin == (struct t_weechat_plugin *)plugin)
+ if (ptr_config->plugin == plugin)
{
for (ptr_section = ptr_config->sections; ptr_section;
ptr_section = ptr_section->next_section)
@@ -259,8 +266,7 @@ config_file_new_option (struct t_config_section *section, char *name,
new_option->string_values = NULL;
new_option->min = CONFIG_BOOLEAN_FALSE;
new_option->max = CONFIG_BOOLEAN_TRUE;
- int_value = (config_file_string_to_boolean (default_value) == CONFIG_BOOLEAN_TRUE) ?
- CONFIG_BOOLEAN_TRUE : CONFIG_BOOLEAN_FALSE;
+ int_value = config_file_string_to_boolean (default_value);
new_option->default_value = malloc (sizeof (int));
*((int *)new_option->default_value) = int_value;
new_option->value = malloc (sizeof (int));
@@ -386,7 +392,7 @@ config_file_search_option (struct t_config_file *config_file,
*/
int
-config_file_option_valid_for_plugin (void *plugin,
+config_file_option_valid_for_plugin (struct t_weechat_plugin *plugin,
struct t_config_option *option)
{
struct t_config_file *ptr_config;
@@ -396,7 +402,7 @@ config_file_option_valid_for_plugin (void *plugin,
for (ptr_config = config_files; ptr_config;
ptr_config = ptr_config->next_config)
{
- if (ptr_config->plugin == (struct t_weechat_plugin *)plugin)
+ if (ptr_config->plugin == plugin)
{
for (ptr_section = ptr_config->sections; ptr_section;
ptr_section = ptr_section->next_section)
@@ -416,31 +422,47 @@ config_file_option_valid_for_plugin (void *plugin,
}
/*
+ * config_file_string_boolean_is_valid: return 1 if boolean is valid, otherwise 0
+ */
+
+int
+config_file_string_boolean_is_valid (char *text)
+{
+ int i;
+
+ for (i = 0; config_boolean_true[i]; i++)
+ {
+ if (string_strcasecmp (text, config_boolean_true[i]) == 0)
+ return 1;
+ }
+
+ for (i = 0; config_boolean_false[i]; i++)
+ {
+ if (string_strcasecmp (text, config_boolean_false[i]) == 0)
+ return 1;
+ }
+
+ /* text is not a boolean */
+ return 0;
+}
+
+/*
* config_file_string_to_boolean: return boolean value of string
- * return -1 if error
+ * (1 for true, 0 for false)
*/
int
config_file_string_to_boolean (char *text)
{
- if ((string_strcasecmp (text, "on") == 0)
- || (string_strcasecmp (text, "yes") == 0)
- || (string_strcasecmp (text, "y") == 0)
- || (string_strcasecmp (text, "true") == 0)
- || (string_strcasecmp (text, "t") == 0)
- || (string_strcasecmp (text, "1") == 0))
- return CONFIG_BOOLEAN_TRUE;
-
- if ((string_strcasecmp (text, "off") == 0)
- || (string_strcasecmp (text, "no") == 0)
- || (string_strcasecmp (text, "n") == 0)
- || (string_strcasecmp (text, "false") == 0)
- || (string_strcasecmp (text, "f") == 0)
- || (string_strcasecmp (text, "0") == 0))
- return CONFIG_BOOLEAN_FALSE;
-
- /* invalid text */
- return -1;
+ int i;
+
+ for (i = 0; config_boolean_true[i]; i++)
+ {
+ if (string_strcasecmp (text, config_boolean_true[i]) == 0)
+ return CONFIG_BOOLEAN_TRUE;
+ }
+
+ return CONFIG_BOOLEAN_FALSE;
}
/*
@@ -451,7 +473,8 @@ config_file_string_to_boolean (char *text)
*/
int
-config_file_option_set (struct t_config_option *option, char *new_value)
+config_file_option_set (struct t_config_option *option, char *new_value,
+ int run_callback)
{
int new_value_int, i, rc;
long number;
@@ -465,12 +488,14 @@ config_file_option_set (struct t_config_option *option, char *new_value)
case CONFIG_OPTION_BOOLEAN:
if (!new_value)
return 0;
- new_value_int = config_file_string_to_boolean (new_value);
- if (new_value_int < 0)
+ if (!config_file_string_boolean_is_valid (new_value))
return 0;
+ new_value_int = config_file_string_to_boolean (new_value);
if (new_value_int == *((int *)option->value))
return 1;
*((int *)option->value) = new_value_int;
+ if (run_callback && option->callback_change)
+ (void) (option->callback_change) ();
return 2;
case CONFIG_OPTION_INTEGER:
if (!new_value)
@@ -492,6 +517,8 @@ config_file_option_set (struct t_config_option *option, char *new_value)
if (new_value_int == *((int *)option->value))
return 1;
*((int *)option->value) = new_value_int;
+ if (run_callback && option->callback_change)
+ (void) (option->callback_change) ();
return 2;
}
else
@@ -503,6 +530,8 @@ config_file_option_set (struct t_config_option *option, char *new_value)
if (number == *((int *)option->value))
return 1;
*((int *)option->value) = number;
+ if (run_callback && option->callback_change)
+ (void) (option->callback_change) ();
return 2;
}
}
@@ -523,6 +552,8 @@ config_file_option_set (struct t_config_option *option, char *new_value)
}
else
option->value = NULL;
+ if (run_callback && (rc == 2) && option->callback_change)
+ (void) (option->callback_change) ();
return rc;
case CONFIG_OPTION_COLOR:
if (!gui_color_assign (&new_value_int, new_value))
@@ -530,6 +561,8 @@ config_file_option_set (struct t_config_option *option, char *new_value)
if (new_value_int == *((int *)option->value))
return 1;
*((int *)option->value) = new_value_int;
+ if (run_callback && option->callback_change)
+ (void) (option->callback_change) ();
return 2;
}
@@ -592,6 +625,259 @@ config_file_option_reset (struct t_config_option *option)
}
/*
+ * config_file_option_boolean: return boolean value of an option
+ */
+
+int
+config_file_option_boolean (struct t_config_option *option)
+{
+ if (option->type == CONFIG_OPTION_BOOLEAN)
+ return CONFIG_BOOLEAN(option);
+ else
+ return 0;
+}
+
+/*
+ * config_file_option_integer: return integer value of an option
+ */
+
+int
+config_file_option_integer (struct t_config_option *option)
+{
+ switch (option->type)
+ {
+ case CONFIG_OPTION_BOOLEAN:
+ if (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE)
+ return 1;
+ else
+ return 0;
+ case CONFIG_OPTION_INTEGER:
+ case CONFIG_OPTION_COLOR:
+ return CONFIG_INTEGER(option);
+ case CONFIG_OPTION_STRING:
+ return 0;
+ }
+ return 0;
+}
+
+/*
+ * config_file_option_string: return string value of an option
+ */
+
+char *
+config_file_option_string (struct t_config_option *option)
+{
+ switch (option->type)
+ {
+ case CONFIG_OPTION_STRING:
+ return CONFIG_STRING(option);
+ case CONFIG_OPTION_INTEGER:
+ if (option->string_values)
+ return option->string_values[CONFIG_INTEGER(option)];
+ return NULL;
+ default:
+ return NULL;
+ }
+ return NULL;
+}
+
+/*
+ * config_file_option_color: return color value of an option
+ */
+
+int
+config_file_option_color (struct t_config_option *option)
+{
+ if (option->type == CONFIG_OPTION_COLOR)
+ return CONFIG_COLOR(option);
+ else
+ return 0;
+}
+
+/*
+ * config_file_write_option: write an option in a config file
+ */
+
+void
+config_file_write_option (struct t_config_file *config_file,
+ struct t_config_option *option,
+ int default_value)
+{
+ void *value;
+
+ if (!config_file || !config_file->file || !option)
+ return;
+
+ value = (default_value) ? option->default_value : option->value;
+
+ switch (option->type)
+ {
+ case CONFIG_OPTION_BOOLEAN:
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option->name,
+ (*((int *)value)) == CONFIG_BOOLEAN_TRUE ?
+ "on" : "off");
+ break;
+ case CONFIG_OPTION_INTEGER:
+ if (option->string_values)
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option->name,
+ option->string_values[*((int *)value)]);
+ else
+ string_iconv_fprintf (config_file->file, "%s = %d\n",
+ option->name,
+ *((int *)value));
+ break;
+ case CONFIG_OPTION_STRING:
+ string_iconv_fprintf (config_file->file, "%s = \"%s\"\n",
+ option->name,
+ (char *)value);
+ break;
+ case CONFIG_OPTION_COLOR:
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option->name,
+ gui_color_get_name (*((int *)value)));
+ break;
+ }
+}
+
+/*
+ * config_file_write_line: write a line in a config file
+ * if value is NULL, then write a section with [ ] around
+ */
+
+void
+config_file_write_line (struct t_config_file *config_file,
+ char *option_name, char *value, ...)
+{
+ char buf[4096];
+ va_list argptr;
+
+ va_start (argptr, value);
+ vsnprintf (buf, sizeof (buf) - 1, value, argptr);
+ va_end (argptr);
+
+ if (!buf[0])
+ string_iconv_fprintf (config_file->file, "\n[%s]\n",
+ option_name);
+ else
+ {
+ string_iconv_fprintf (config_file->file, "%s = %s\n",
+ option_name, buf);
+ }
+}
+
+/*
+ * config_file_write_internal: write a configuration file
+ * (should not be called directly)
+ * return: 0 if ok
+ * -1 if error writing file
+ * -2 if not enough memory
+ */
+
+int
+config_file_write_internal (struct t_config_file *config_file, int default_options)
+{
+ int filename_length, rc;
+ char *filename, *filename2;
+ time_t current_time;
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
+
+ if (!config_file)
+ return -1;
+
+ filename_length = strlen (weechat_home) +
+ strlen (config_file->filename) + 2;
+ filename =
+ (char *)malloc (filename_length * sizeof (char));
+ if (!filename)
+ return -2;
+ snprintf (filename, filename_length, "%s%s%s",
+ weechat_home, DIR_SEPARATOR, config_file->filename);
+
+ filename2 = (char *)malloc ((filename_length + 32) * sizeof (char));
+ if (!filename2)
+ {
+ free (filename);
+ return -2;
+ }
+ snprintf (filename2, filename_length + 32, "%s.weechattmp", filename);
+
+ if ((config_file->file = fopen (filename2, "w")) == NULL)
+ {
+ gui_chat_printf (NULL,
+ _("Error: cannot create file \"%s\"\n"),
+ filename2);
+ free (filename);
+ free (filename2);
+ return -1;
+ }
+
+ current_time = time (NULL);
+ string_iconv_fprintf (config_file->file,
+ _("#\n# %s configuration file, created by "
+ "%s v%s on %s"),
+ PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
+ ctime (&current_time));
+ string_iconv_fprintf (config_file->file,
+ _("# WARNING! Be careful when editing this file, "
+ "WeeChat may write it at any time.\n#\n"));
+
+ for (ptr_section = config_file->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
+ {
+ /* call write callback if defined for section */
+ if (default_options && ptr_section->callback_write_default)
+ {
+ (void) (ptr_section->callback_write_default) (config_file,
+ ptr_section->name);
+ }
+ else if (!default_options && ptr_section->callback_write)
+ {
+ (void) (ptr_section->callback_write) (config_file,
+ ptr_section->name);
+ }
+ else
+ {
+ /* write all options for section */
+ string_iconv_fprintf (config_file->file,
+ "\n[%s]\n", ptr_section->name);
+ for (ptr_option = ptr_section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
+ {
+ config_file_write_option (config_file, ptr_option,
+ default_options);
+ }
+ }
+ }
+
+ fclose (config_file->file);
+ config_file->file = NULL;
+ chmod (filename2, 0600);
+ unlink (filename);
+ rc = rename (filename2, filename);
+ free (filename);
+ free (filename2);
+ if (rc != 0)
+ return -1;
+ return 0;
+}
+
+/*
+ * config_file_write: write a configuration file
+ * return: 0 if ok
+ * -1 if error writing file
+ * -2 if not enough memory
+ */
+
+int
+config_file_write (struct t_config_file *config_file)
+{
+ return config_file_write_internal (config_file, 0);
+}
+
+/*
* config_file_read: read a configuration file
* return: 0 = successful
* -1 = config file file not found
@@ -611,14 +897,14 @@ config_file_read (struct t_config_file *config_file)
return -1;
filename_length = strlen (weechat_home) + strlen (config_file->filename) + 2;
- filename = (char *) malloc (filename_length * sizeof (char));
+ filename = (char *)malloc (filename_length * sizeof (char));
if (!filename)
return -2;
snprintf (filename, filename_length, "%s%s%s",
weechat_home, DIR_SEPARATOR, config_file->filename);
if ((config_file->file = fopen (filename, "r")) == NULL)
{
- config_file_write (config_file, 1);
+ config_file_write_internal (config_file, 1);
if ((config_file->file = fopen (filename, "r")) == NULL)
{
gui_chat_printf (NULL,
@@ -760,7 +1046,7 @@ config_file_read (struct t_config_file *config_file)
line);
if (ptr_option)
{
- rc = config_file_option_set (ptr_option, pos);
+ rc = config_file_option_set (ptr_option, pos, 1);
ptr_option->loaded = 1;
}
}
@@ -791,10 +1077,6 @@ config_file_read (struct t_config_file *config_file)
"\"%s\"\n"),
filename, line_number, line);
break;
- case 2:
- if (ptr_option && ptr_option->callback_change)
- (void) (ptr_option->callback_change) ();
- break;
}
}
}
@@ -865,175 +1147,6 @@ config_file_reload (struct t_config_file *config_file)
}
/*
- * config_file_write_option: write an option in a config file
- */
-
-void
-config_file_write_option (struct t_config_file *config_file,
- struct t_config_option *option,
- int default_value)
-{
- void *value;
-
- if (!config_file || !config_file->file || !option)
- return;
-
- value = (default_value) ? option->default_value : option->value;
-
- switch (option->type)
- {
- case CONFIG_OPTION_BOOLEAN:
- string_iconv_fprintf (config_file->file, "%s = %s\n",
- option->name,
- (*((int *)value)) == CONFIG_BOOLEAN_TRUE ?
- "on" : "off");
- break;
- case CONFIG_OPTION_INTEGER:
- if (option->string_values)
- string_iconv_fprintf (config_file->file, "%s = %s\n",
- option->name,
- option->string_values[*((int *)value)]);
- else
- string_iconv_fprintf (config_file->file, "%s = %d\n",
- option->name,
- *((int *)value));
- break;
- case CONFIG_OPTION_STRING:
- string_iconv_fprintf (config_file->file, "%s = \"%s\"\n",
- option->name,
- (char *)value);
- break;
- case CONFIG_OPTION_COLOR:
- string_iconv_fprintf (config_file->file, "%s = %s\n",
- option->name,
- gui_color_get_name (*((int *)value)));
- break;
- }
-}
-
-/*
- * config_file_write_line: write a line in a config file
- * if value is NULL, then write a section with [ ] around
- */
-
-void
-config_file_write_line (struct t_config_file *config_file,
- char *option_name, char *value, ...)
-{
- char buf[4096];
- va_list argptr;
-
- va_start (argptr, value);
- vsnprintf (buf, sizeof (buf) - 1, value, argptr);
- va_end (argptr);
-
- if (!buf[0])
- string_iconv_fprintf (config_file->file, "\n[%s]\n",
- option_name);
- else
- {
- string_iconv_fprintf (config_file->file, "%s = %s\n",
- option_name, buf);
- }
-}
-
-/*
- * config_file_write: write a configuration file
- * return: 0 if ok
- * -1 if error writing file
- * -2 if not enough memory
- */
-
-int
-config_file_write (struct t_config_file *config_file, int default_options)
-{
- int filename_length, rc;
- char *filename, *filename2;
- time_t current_time;
- struct t_config_section *ptr_section;
- struct t_config_option *ptr_option;
-
- if (!config_file)
- return -1;
-
- filename_length = strlen (weechat_home) +
- strlen (config_file->filename) + 2;
- filename =
- (char *) malloc (filename_length * sizeof (char));
- if (!filename)
- return -2;
- snprintf (filename, filename_length, "%s%s%s",
- weechat_home, DIR_SEPARATOR, config_file->filename);
-
- filename2 = (char *) malloc ((filename_length + 32) * sizeof (char));
- if (!filename2)
- {
- free (filename);
- return -2;
- }
- snprintf (filename2, filename_length + 32, "%s.weechattmp", filename);
-
- if ((config_file->file = fopen (filename2, "w")) == NULL)
- {
- gui_chat_printf (NULL,
- _("Error: cannot create file \"%s\"\n"),
- filename2);
- free (filename);
- free (filename2);
- return -1;
- }
-
- current_time = time (NULL);
- string_iconv_fprintf (config_file->file,
- _("#\n# %s configuration file, created by "
- "%s v%s on %s"),
- PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION,
- ctime (&current_time));
- string_iconv_fprintf (config_file->file,
- _("# WARNING! Be careful when editing this file, "
- "WeeChat may write it at any time.\n#\n"));
-
- for (ptr_section = config_file->sections; ptr_section;
- ptr_section = ptr_section->next_section)
- {
- /* call write callback if defined for section */
- if (default_options && ptr_section->callback_write_default)
- {
- (void) (ptr_section->callback_write_default) (config_file,
- ptr_section->name);
- }
- else if (!default_options && ptr_section->callback_write)
- {
- (void) (ptr_section->callback_write) (config_file,
- ptr_section->name);
- }
- else
- {
- /* write all options for section */
- string_iconv_fprintf (config_file->file,
- "\n[%s]\n", ptr_section->name);
- for (ptr_option = ptr_section->options; ptr_option;
- ptr_option = ptr_option->next_option)
- {
- config_file_write_option (config_file, ptr_option,
- default_options);
- }
- }
- }
-
- fclose (config_file->file);
- config_file->file = NULL;
- chmod (filename2, 0600);
- unlink (filename);
- rc = rename (filename2, filename);
- free (filename);
- free (filename2);
- if (rc != 0)
- return -1;
- return 0;
-}
-
-/*
* config_file_option_free: free an option
*/
@@ -1159,7 +1272,7 @@ config_file_free_all ()
*/
void
-config_file_free_all_plugin (void *plugin)
+config_file_free_all_plugin (struct t_weechat_plugin *plugin)
{
struct t_config_file *ptr_config, *next_config;
diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h
index b27bf99da..7e347e497 100644
--- a/src/core/wee-config-file.h
+++ b/src/core/wee-config-file.h
@@ -50,11 +50,14 @@ struct t_config_section
{
char *name; /* section name */
void (*callback_read) /* called when unknown option */
- (void *, char *, char *); /* is read from config file */
+ (struct t_config_file *config_file, /* is read from config file */
+ char *option_name, char *value);
void (*callback_write) /* called to write special */
- (void *, char *); /* options in config file */
+ (struct t_config_file *config_file, /* options in config file */
+ char *section_name);
void (*callback_write_default) /* called to write default */
- (void *, char *); /* options in config file */
+ (struct t_config_file *config_file, /* options in config file */
+ char *section_name);
struct t_config_option *options; /* options in section */
struct t_config_option *last_option; /* last option in section */
struct t_config_section *prev_section; /* link to previous section */
@@ -84,40 +87,57 @@ struct t_config_option
struct t_config_option *next_option; /* link to next option */
};
-extern struct t_config_file *config_file_new (void *, char *);
-extern int config_file_valid_for_plugin (void *, struct t_config_file *);
-extern struct t_config_section *config_file_new_section (struct t_config_file *,
- char *,
- void (*)(void *, char *, char *),
- void (*)(void *, char *),
- void (*)(void *, char *));
-extern struct t_config_section *config_file_search_section (struct t_config_file *,
- char *);
-extern int config_file_section_valid_for_plugin (void *, struct t_config_section *);
-extern struct t_config_option *config_file_new_option (struct t_config_section *,
- char *, char *, char *,
- char *, int, int,
- char *, void (*)());
-extern struct t_config_option *config_file_search_option (struct t_config_file *,
- struct t_config_section *,
- char *);
-extern int config_file_option_valid_for_plugin (void *, struct t_config_option *);
-extern int config_file_string_to_boolean (char *);
-extern int config_file_option_set (struct t_config_option *, char *);
-extern int config_file_option_reset (struct t_config_option *);
+extern struct t_config_file *config_file_new (struct t_weechat_plugin *plugin,
+ char *filename);
+extern int config_file_valid_for_plugin (struct t_weechat_plugin *plugin,
+ struct t_config_file *config_file);
+extern struct t_config_section *config_file_new_section (struct t_config_file *config_file,
+ char *name,
+ void (*callback_read)(struct t_config_file *config_file,
+ char *option_name,
+ char *value),
+ void (*callback_write)(struct t_config_file *config_file,
+ char *section_name),
+ void (*callback_write_default)(struct t_config_file *config_file,
+ char *section_name));
+extern struct t_config_section *config_file_search_section (struct t_config_file *config_file,
+ char *section_name);
+extern int config_file_section_valid_for_plugin (struct t_weechat_plugin *plugin,
+ struct t_config_section *);
+extern struct t_config_option *config_file_new_option (struct t_config_section *section,
+ char *name, char *type,
+ char *description,
+ char *string_values,
+ int min, int max,
+ char *default_value,
+ void (*callback_change)());
+extern struct t_config_option *config_file_search_option (struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name);
+extern int config_file_option_valid_for_plugin (struct t_weechat_plugin *plugin,
+ struct t_config_option *option);
+extern int config_file_string_to_boolean (char *text);
+extern int config_file_option_set (struct t_config_option *option,
+ char *new_value, int run_callback);
+extern int config_file_option_reset (struct t_config_option *option);
+extern int config_file_option_boolean (struct t_config_option *option);
+extern int config_file_option_integer (struct t_config_option *option);
+extern char *config_file_option_string (struct t_config_option *option);
+extern int config_file_option_color (struct t_config_option *option);
-extern int config_file_read (struct t_config_file *);
-extern int config_file_reload (struct t_config_file *);
-extern void config_file_write_line (struct t_config_file *, char *, char *, ...);
-extern int config_file_write (struct t_config_file *, int);
-extern void config_file_option_free (struct t_config_section *,
- struct t_config_option *);
-extern void config_file_section_free (struct t_config_file *,
- struct t_config_section *);
-extern void config_file_free (struct t_config_file *);
+extern void config_file_write_line (struct t_config_file *config_file,
+ char *option_name, char *value, ...);
+extern int config_file_write (struct t_config_file *config_files);
+extern int config_file_read (struct t_config_file *config_file);
+extern int config_file_reload (struct t_config_file *config_file);
+extern void config_file_option_free (struct t_config_section *section,
+ struct t_config_option *option);
+extern void config_file_section_free (struct t_config_file *config_file,
+ struct t_config_section *section);
+extern void config_file_free (struct t_config_file *config_file);
extern void config_file_free_all ();
-extern void config_file_free_all_plugin (void *);
-extern void config_file_print_stdout (struct t_config_file *);
+extern void config_file_free_all_plugin (struct t_weechat_plugin *plugin);
+extern void config_file_print_stdout (struct t_config_file *config_file);
extern void config_file_print_log ();
#endif /* wee-config-file.h */
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index cc89254ae..d11a9088e 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -41,11 +41,13 @@
#include "wee-util.h"
#include "wee-list.h"
#include "wee-string.h"
+#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-infobar.h"
#include "../gui/gui-keyboard.h"
+#include "../gui/gui-nicklist.h"
#include "../gui/gui-status.h"
#include "../gui/gui-window.h"
#include "../plugins/plugin.h"
@@ -415,7 +417,7 @@ config_change_day_change ()
*/
void
-config_weechat_read_key (void *config_file,
+config_weechat_read_key (struct t_config_file *config_file,
char *option_name, char *value)
{
/* make C compiler happy */
@@ -443,7 +445,8 @@ config_weechat_read_key (void *config_file,
*/
void
-config_weechat_write_keys (void *config_file, char *section_name)
+config_weechat_write_keys (struct t_config_file *config_file,
+ char *section_name)
{
t_gui_key *ptr_key;
char *expanded_name, *function_name;
@@ -1177,5 +1180,5 @@ int
config_weechat_write ()
{
log_printf (_("Saving WeeChat configuration to disk"));
- return config_file_write (weechat_config_file, 0);
+ return config_file_write (weechat_config_file);
}
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index 040e74f81..15de988d6 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -164,18 +164,6 @@ extern struct t_config_option *config_plugins_path;
extern struct t_config_option *config_plugins_autoload;
extern struct t_config_option *config_plugins_extension;
-extern void config_change_noop ();
-extern void config_change_save_on_exit ();
-extern void config_change_title ();
-extern void config_change_buffers ();
-extern void config_change_buffer_content ();
-extern void config_change_buffer_time_format ();
-extern void config_change_hotlist ();
-extern void config_change_read_marker ();
-extern void config_change_prefix ();
-extern void config_change_color ();
-extern void config_change_nicks_colors ();
-
extern int config_weechat_init ();
extern int config_weechat_read ();
extern int config_weechat_reload ();
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 31a782f18..e7ac17c45 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -188,7 +188,8 @@ hook_remove_deleted ()
*/
void
-hook_init_data (struct t_hook *hook, void *plugin, int type, void *callback_data)
+hook_init_data (struct t_hook *hook, struct t_weechat_plugin *plugin,
+ int type, void *callback_data)
{
hook->plugin = plugin;
hook->type = type;
@@ -231,7 +232,7 @@ hook_valid (struct t_hook *hook)
*/
int
-hook_valid_for_plugin (void *plugin, struct t_hook *hook)
+hook_valid_for_plugin (struct t_weechat_plugin *plugin, struct t_hook *hook)
{
int type;
struct t_hook *ptr_hook;
@@ -242,7 +243,7 @@ hook_valid_for_plugin (void *plugin, struct t_hook *hook)
ptr_hook = ptr_hook->next_hook)
{
if (!ptr_hook->deleted && (ptr_hook == hook)
- && (ptr_hook->plugin == (struct t_weechat_plugin *)plugin))
+ && (ptr_hook->plugin == plugin))
return 1;
}
}
@@ -277,10 +278,9 @@ hook_search_command (char *command)
*/
struct t_hook *
-hook_command (void *plugin, char *command, char *description,
+hook_command (struct t_weechat_plugin *plugin, char *command, char *description,
char *args, char *args_description, char *completion,
- t_hook_callback_command *callback,
- void *callback_data)
+ t_hook_callback_command *callback, void *callback_data)
{
struct t_hook *ptr_hook,*new_hook;
struct t_hook_command *new_hook_command;
@@ -341,7 +341,7 @@ hook_command (void *plugin, char *command, char *description,
*/
int
-hook_command_exec (void *buffer, char *string, int only_builtin)
+hook_command_exec (struct t_gui_buffer *buffer, char *string, int only_builtin)
{
struct t_hook *ptr_hook, *next_hook;
char **argv, **argv_eol;
@@ -369,9 +369,9 @@ hook_command_exec (void *buffer, char *string, int only_builtin)
&& !ptr_hook->running
&& (HOOK_COMMAND(ptr_hook, level) == 0)
&& (!only_builtin || !ptr_hook->plugin)
- && (!ptr_hook->plugin
- || !((struct t_gui_buffer *)buffer)->plugin
- || (((struct t_gui_buffer *)buffer)->plugin == ptr_hook->plugin))
+ /*&& (!ptr_hook->plugin
+ || !buffer->plugin
+ || (buffer->plugin == ptr_hook->plugin))*/
&& (string_strcasecmp (argv[0] + 1,
HOOK_COMMAND(ptr_hook, command)) == 0))
{
@@ -410,8 +410,9 @@ hook_command_exec (void *buffer, char *string, int only_builtin)
*/
struct t_hook *
-hook_timer (void *plugin, long interval, int align_second, int max_calls,
- t_hook_callback_timer *callback, void *callback_data)
+hook_timer (struct t_weechat_plugin *plugin, long interval, int align_second,
+ int max_calls, t_hook_callback_timer *callback,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_timer *new_hook_timer;
@@ -462,7 +463,7 @@ hook_timer (void *plugin, long interval, int align_second, int max_calls,
*/
int
-hook_timer_time_to_next (struct timeval *tv_time)
+hook_timer_time_to_next (struct timeval *tv_timeout)
{
struct t_hook *ptr_hook;
int found;
@@ -470,19 +471,19 @@ hook_timer_time_to_next (struct timeval *tv_time)
long diff_usec;
found = 0;
- tv_time->tv_sec = 0;
- tv_time->tv_usec = 0;
+ tv_timeout->tv_sec = 0;
+ tv_timeout->tv_usec = 0;
for (ptr_hook = weechat_hooks[HOOK_TYPE_TIMER]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
if (!ptr_hook->deleted
&& (!found
- || (util_timeval_cmp (&HOOK_TIMER(ptr_hook, next_exec), tv_time) < 0)))
+ || (util_timeval_cmp (&HOOK_TIMER(ptr_hook, next_exec), tv_timeout) < 0)))
{
found = 1;
- tv_time->tv_sec = HOOK_TIMER(ptr_hook, next_exec).tv_sec;
- tv_time->tv_usec = HOOK_TIMER(ptr_hook, next_exec).tv_usec;
+ tv_timeout->tv_sec = HOOK_TIMER(ptr_hook, next_exec).tv_sec;
+ tv_timeout->tv_usec = HOOK_TIMER(ptr_hook, next_exec).tv_usec;
}
}
@@ -493,21 +494,21 @@ hook_timer_time_to_next (struct timeval *tv_time)
gettimeofday (&tv_now, NULL);
/* next timeout is past date! */
- if (util_timeval_cmp (tv_time, &tv_now) < 0)
+ if (util_timeval_cmp (tv_timeout, &tv_now) < 0)
{
- tv_time->tv_sec = 0;
- tv_time->tv_usec = 0;
+ tv_timeout->tv_sec = 0;
+ tv_timeout->tv_usec = 0;
return 1;
}
- tv_time->tv_sec = tv_time->tv_sec - tv_now.tv_sec;
- diff_usec = tv_time->tv_usec - tv_now.tv_usec;
+ tv_timeout->tv_sec = tv_timeout->tv_sec - tv_now.tv_sec;
+ diff_usec = tv_timeout->tv_usec - tv_now.tv_usec;
if (diff_usec >= 0)
- tv_time->tv_usec = diff_usec;
+ tv_timeout->tv_usec = diff_usec;
else
{
- tv_time->tv_sec--;
- tv_time->tv_usec = 1000000 + diff_usec;
+ tv_timeout->tv_sec--;
+ tv_timeout->tv_usec = 1000000 + diff_usec;
}
return 1;
@@ -593,13 +594,14 @@ hook_search_fd (int fd)
*/
struct t_hook *
-hook_fd (void *plugin, int fd, int flags,
+hook_fd (struct t_weechat_plugin *plugin, int fd, int flag_read,
+ int flag_write, int flag_exception,
t_hook_callback_fd *callback, void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_fd *new_hook_fd;
- if (hook_search_fd (fd))
+ if ((fd < 0) || hook_search_fd (fd))
return NULL;
new_hook = (struct t_hook *)malloc (sizeof (struct t_hook));
@@ -617,7 +619,13 @@ hook_fd (void *plugin, int fd, int flags,
new_hook->hook_data = new_hook_fd;
new_hook_fd->callback = callback;
new_hook_fd->fd = fd;
- new_hook_fd->flags = flags;
+ new_hook_fd->flags = 0;
+ if (flag_read)
+ new_hook_fd->flags |= HOOK_FD_FLAG_READ;
+ if (flag_write)
+ new_hook_fd->flags |= HOOK_FD_FLAG_WRITE;
+ if (flag_exception)
+ new_hook_fd->flags |= HOOK_FD_FLAG_EXCEPTION;
hook_add_to_list (new_hook);
@@ -629,14 +637,10 @@ hook_fd (void *plugin, int fd, int flags,
*/
void
-hook_fd_set (fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
+hook_fd_set (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds)
{
struct t_hook *ptr_hook;
- FD_ZERO (read_fds);
- FD_ZERO (write_fds);
- FD_ZERO (except_fds);
-
for (ptr_hook = weechat_hooks[HOOK_TYPE_FD]; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
@@ -647,7 +651,7 @@ hook_fd_set (fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_WRITE)
FD_SET (HOOK_FD(ptr_hook, fd), write_fds);
if (HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_EXCEPTION)
- FD_SET (HOOK_FD(ptr_hook, fd), except_fds);
+ FD_SET (HOOK_FD(ptr_hook, fd), exception_fds);
}
}
}
@@ -657,7 +661,7 @@ hook_fd_set (fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
*/
void
-hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
+hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds)
{
struct t_hook *ptr_hook, *next_hook;
@@ -675,7 +679,7 @@ hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
|| ((HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_WRITE)
&& (FD_ISSET(HOOK_FD(ptr_hook, fd), write_fds)))
|| ((HOOK_FD(ptr_hook, flags) & HOOK_FD_FLAG_EXCEPTION)
- && (FD_ISSET(HOOK_FD(ptr_hook, fd), except_fds)))))
+ && (FD_ISSET(HOOK_FD(ptr_hook, fd), exception_fds)))))
{
ptr_hook->running = 1;
(HOOK_FD(ptr_hook, callback)) (ptr_hook->callback_data);
@@ -697,8 +701,9 @@ hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
*/
struct t_hook *
-hook_print (void *plugin, void *buffer, char *message, int strip_colors,
- t_hook_callback_print *callback, void *callback_data)
+hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer,
+ char *message, int strip_colors, t_hook_callback_print *callback,
+ void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_print *new_hook_print;
@@ -717,7 +722,7 @@ hook_print (void *plugin, void *buffer, char *message, int strip_colors,
new_hook->hook_data = new_hook_print;
new_hook_print->callback = callback;
- new_hook_print->buffer = (struct t_gui_buffer *)buffer;
+ new_hook_print->buffer = buffer;
new_hook_print->message = (message) ? strdup (message) : NULL;
new_hook_print->strip_colors = strip_colors;
@@ -731,7 +736,8 @@ hook_print (void *plugin, void *buffer, char *message, int strip_colors,
*/
void
-hook_print_exec (void *buffer, time_t date, char *prefix, char *message)
+hook_print_exec (struct t_gui_buffer *buffer, time_t date, char *prefix,
+ char *message)
{
struct t_hook *ptr_hook, *next_hook;
char *prefix_no_color, *message_no_color;
@@ -759,7 +765,7 @@ hook_print_exec (void *buffer, time_t date, char *prefix, char *message)
if (!ptr_hook->deleted
&& !ptr_hook->running
&& (!HOOK_PRINT(ptr_hook, buffer)
- || ((struct t_gui_buffer *)buffer == HOOK_PRINT(ptr_hook, buffer)))
+ || (buffer == HOOK_PRINT(ptr_hook, buffer)))
&& (!HOOK_PRINT(ptr_hook, message)
|| string_strcasestr (prefix_no_color, HOOK_PRINT(ptr_hook, message))
|| string_strcasestr (message_no_color, HOOK_PRINT(ptr_hook, message))))
@@ -787,7 +793,7 @@ hook_print_exec (void *buffer, time_t date, char *prefix, char *message)
*/
struct t_hook *
-hook_signal (void *plugin, char *signal,
+hook_signal (struct t_weechat_plugin *plugin, char *signal,
t_hook_callback_signal *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -818,11 +824,11 @@ hook_signal (void *plugin, char *signal,
}
/*
- * hook_signal_exec: execute signal hook
+ * hook_signal_send: send a signal
*/
void
-hook_signal_exec (char *signal, void *pointer)
+hook_signal_send (char *signal, void *signal_data)
{
struct t_hook *ptr_hook, *next_hook;
@@ -840,7 +846,7 @@ hook_signal_exec (char *signal, void *pointer)
{
ptr_hook->running = 1;
(void) (HOOK_SIGNAL(ptr_hook, callback))
- (ptr_hook->callback_data, signal, pointer);
+ (ptr_hook->callback_data, signal, signal_data);
ptr_hook->running = 0;
}
@@ -859,7 +865,7 @@ hook_signal_exec (char *signal, void *pointer)
*/
struct t_hook *
-hook_config (void *plugin, char *type, char *option,
+hook_config (struct t_weechat_plugin *plugin, char *type, char *option,
t_hook_callback_config *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -933,7 +939,7 @@ hook_config_exec (char *type, char *option, char *value)
*/
struct t_hook *
-hook_completion (void *plugin, char *completion,
+hook_completion (struct t_weechat_plugin *plugin, char *completion,
t_hook_callback_completion *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -968,7 +974,8 @@ hook_completion (void *plugin, char *completion,
*/
void
-hook_completion_exec (void *plugin, char *completion, void *buffer, void *list)
+hook_completion_exec (struct t_weechat_plugin *plugin, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
struct t_hook *ptr_hook, *next_hook;
@@ -1102,7 +1109,7 @@ unhook (struct t_hook *hook)
*/
void
-unhook_all_plugin (void *plugin)
+unhook_all_plugin (struct t_weechat_plugin *plugin)
{
int type;
struct t_hook *ptr_hook, *next_hook;
diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h
index 09b5af483..c725d8661 100644
--- a/src/core/wee-hook.h
+++ b/src/core/wee-hook.h
@@ -20,6 +20,9 @@
#ifndef __WEECHAT_HOOK_H
#define __WEECHAT_HOOK_H 1
+struct t_gui_buffer;
+struct t_weelist;
+
/* hook types */
enum t_hook_type
@@ -63,7 +66,8 @@ struct t_hook
struct t_hook *next_hook; /* link to next hook */
};
-typedef int (t_hook_callback_command)(void *, void *, int, char **, char **);
+typedef int (t_hook_callback_command)(void *data, struct t_gui_buffer *,
+ int argc, char **argv, char **argv_eol);
struct t_hook_command
{
@@ -77,7 +81,7 @@ struct t_hook_command
char *completion; /* template for completion */
};
-typedef int (t_hook_callback_timer)(void *);
+typedef int (t_hook_callback_timer)(void *data);
struct t_hook_timer
{
@@ -88,7 +92,7 @@ struct t_hook_timer
struct timeval next_exec; /* next scheduled execution */
};
-typedef int (t_hook_callback_fd)(void *);
+typedef int (t_hook_callback_fd)(void *data);
struct t_hook_fd
{
@@ -97,7 +101,8 @@ struct t_hook_fd
int flags; /* fd flags (read,write,..) */
};
-typedef int (t_hook_callback_print)(void *, void *, time_t, char *, char *);
+typedef int (t_hook_callback_print)(void *data, struct t_gui_buffer *buffer,
+ time_t date, char *prefix, char *message);
struct t_hook_print
{
@@ -107,7 +112,8 @@ struct t_hook_print
int strip_colors; /* strip colors in msg for callback? */
};
-typedef int (t_hook_callback_signal)(void *, char *, void *);
+typedef int (t_hook_callback_signal)(void *data, char *signal,
+ void *signal_data);
struct t_hook_signal
{
@@ -115,7 +121,8 @@ struct t_hook_signal
char *signal; /* signal selected ("*" = any signal)*/
};
-typedef int (t_hook_callback_config)(void *, char *, char *, char *);
+typedef int (t_hook_callback_config)(void *data, char *type, char *option,
+ char *value);
struct t_hook_config
{
@@ -125,7 +132,9 @@ struct t_hook_config
/* (NULL = hook for all options) */
};
-typedef int (t_hook_callback_completion)(void *, char *, void *, void *);
+typedef int (t_hook_callback_completion)(void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list);
struct t_hook_completion
{
@@ -141,34 +150,60 @@ extern struct t_hook *last_weechat_hook[];
/* hook functions */
extern void hook_init ();
-extern int hook_valid (struct t_hook *);
-extern int hook_valid_for_plugin (void *, struct t_hook *);
-
-extern struct t_hook *hook_command (void *, char *, char *, char *, char *,
- char *, t_hook_callback_command *, void *);
-extern int hook_command_exec (void *, char *, int);
-extern struct t_hook *hook_timer (void *, long, int, int,
- t_hook_callback_timer *, void *);
-extern int hook_timer_time_to_next (struct timeval *);
+extern int hook_valid (struct t_hook *hook);
+extern int hook_valid_for_plugin (struct t_weechat_plugin *plugin,
+ struct t_hook *hook);
+extern struct t_hook *hook_command (struct t_weechat_plugin *plugin,
+ char *command, char *description,
+ char *args, char *args_description,
+ char *completion,
+ t_hook_callback_command *callback,
+ void *callback_data);
+extern int hook_command_exec (struct t_gui_buffer *buffer, char *string,
+ int only_builtin);
+extern struct t_hook *hook_timer (struct t_weechat_plugin *plugin,
+ long interval, int align_second,
+ int max_calls,
+ t_hook_callback_timer *callback,
+ void *callback_data);
+extern int hook_timer_time_to_next (struct timeval *tv_timeout);
extern void hook_timer_exec ();
-extern struct t_hook *hook_fd (void *, int, int, t_hook_callback_fd *,void *);
-extern void hook_fd_set (fd_set *, fd_set *, fd_set *);
-extern void hook_fd_exec (fd_set *, fd_set *, fd_set *);
-extern struct t_hook *hook_print (void *, void *, char *, int,
- t_hook_callback_print *, void *);
-extern void hook_print_exec (void *, time_t, char *, char *);
-extern struct t_hook *hook_signal (void *, char *,
- t_hook_callback_signal *, void *);
-extern void hook_signal_exec (char *, void *);
-extern struct t_hook *hook_config (void *, char *, char *,
- t_hook_callback_config *, void *);
-extern void hook_config_exec (char *, char *, char *);
-extern struct t_hook *hook_completion (void *, char *,
- t_hook_callback_completion *, void *);
-extern void hook_completion_exec (void *, char *, void *, void *);
-
-extern void unhook (struct t_hook *);
-extern void unhook_all_plugin (void *);
+extern struct t_hook *hook_fd (struct t_weechat_plugin *plugin, int fd,
+ int flag_read, int flag_write,
+ int flag_exception,
+ t_hook_callback_fd * callback,
+ void *callback_data);
+extern void hook_fd_set (fd_set *read_fds, fd_set *write_fds,
+ fd_set *exception_fds);
+extern void hook_fd_exec (fd_set *read_fds, fd_set *write_fds,
+ fd_set *exception_fds);
+extern struct t_hook *hook_print (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer,
+ char *message, int strip_colors,
+ t_hook_callback_print *callback,
+ void *callback_data);
+extern void hook_print_exec (struct t_gui_buffer *buffer,
+ time_t date, char *prefix, char *message);
+extern struct t_hook *hook_signal (struct t_weechat_plugin *plugin,
+ char *signal,
+ t_hook_callback_signal *callback,
+ void *callback_data);
+extern void hook_signal_send (char *signal, void *signal_date);
+extern struct t_hook *hook_config (struct t_weechat_plugin *, char *type,
+ char *option,
+ t_hook_callback_config *callback,
+ void *callback_data);
+extern void hook_config_exec (char *type, char *option, char *value);
+extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin,
+ char *completion,
+ t_hook_callback_completion *callback,
+ void *callback_data);
+extern void hook_completion_exec (struct t_weechat_plugin *plugin,
+ char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list);
+extern void unhook (struct t_hook *hook);
+extern void unhook_all_plugin (struct t_weechat_plugin *plugin);
extern void unhook_all ();
extern void hook_print_log ();
diff --git a/src/core/wee-input.c b/src/core/wee-input.c
index ddd3b00c0..a89a2fc76 100644
--- a/src/core/wee-input.c
+++ b/src/core/wee-input.c
@@ -31,6 +31,7 @@
#include "wee-config.h"
#include "wee-hook.h"
#include "wee-string.h"
+#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../plugins/plugin.h"
diff --git a/src/core/wee-input.h b/src/core/wee-input.h
index b2bef04c9..77fd8e18c 100644
--- a/src/core/wee-input.h
+++ b/src/core/wee-input.h
@@ -20,8 +20,9 @@
#ifndef __WEECHAT_INPUT_H
#define __WEECHAT_INPUT_H 1
-#include "../gui/gui-buffer.h"
+struct t_gui_buffer;
-extern void input_data (struct t_gui_buffer *, char *, int);
+extern void input_data (struct t_gui_buffer *buffer, char *data,
+ int only_builtin);
#endif /* wee-input.h */
diff --git a/src/core/wee-list.c b/src/core/wee-list.c
index b162e0300..77e3c1533 100644
--- a/src/core/wee-list.c
+++ b/src/core/wee-list.c
@@ -78,7 +78,7 @@ weelist_find_pos (struct t_weelist *weelist, char *data)
void
weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
- int position)
+ char *where)
{
struct t_weelist_item *pos_item;
@@ -97,18 +97,12 @@ weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
{
/* search position for new element, according to pos asked */
pos_item = NULL;
- switch (position)
- {
- case WEELIST_POS_SORT:
- pos_item = weelist_find_pos (weelist, item->data);
- break;
- case WEELIST_POS_BEGINNING:
- pos_item = weelist->items;
- break;
- case WEELIST_POS_END:
- pos_item = NULL;
- break;
- }
+ if (string_strcasecmp (where, WEELIST_POS_BEGINNING) == 0)
+ pos_item = weelist->items;
+ else if (string_strcasecmp (where, WEELIST_POS_END) == 0)
+ pos_item = NULL;
+ else
+ pos_item = weelist_find_pos (weelist, item->data);
if (pos_item)
{
@@ -144,17 +138,17 @@ weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
*/
struct t_weelist_item *
-weelist_add (struct t_weelist *weelist, char *data, int position)
+weelist_add (struct t_weelist *weelist, char *data, char *where)
{
struct t_weelist_item *new_item;
- if (!weelist || !data || (!data[0]))
+ if (!weelist || !data || !data[0] || !where || !where[0])
return NULL;
- if ((new_item = ((struct t_weelist_item *) malloc (sizeof (struct t_weelist_item)))))
+ if ((new_item = ((struct t_weelist_item *)malloc (sizeof (struct t_weelist_item)))))
{
new_item->data = strdup (data);
- weelist_insert (weelist, new_item, position);
+ weelist_insert (weelist, new_item, where);
weelist->size++;
}
return new_item;
@@ -231,6 +225,46 @@ weelist_get (struct t_weelist *weelist, int position)
}
/*
+ * weelist_next: get next item
+ */
+
+struct t_weelist_item *
+weelist_next (struct t_weelist_item *item)
+{
+ return item->next_item;
+}
+
+/*
+ * weelist_prev: get previous item
+ */
+
+struct t_weelist_item *
+weelist_prev (struct t_weelist_item *item)
+{
+ return item->prev_item;
+}
+
+/*
+ * weelist_string: get string pointer to item data
+ */
+
+char *
+weelist_string (struct t_weelist_item *item)
+{
+ return item->data;
+}
+
+/*
+ * weelist_size: return size of weelist
+ */
+
+int
+weelist_size (struct t_weelist *weelist)
+{
+ return weelist->size;
+}
+
+/*
* weelist_remove: remove an item from a list
*/
diff --git a/src/core/wee-list.h b/src/core/wee-list.h
index c5226d701..852026aba 100644
--- a/src/core/wee-list.h
+++ b/src/core/wee-list.h
@@ -20,9 +20,9 @@
#ifndef __WEECHAT_LIST_H
#define __WEECHAT_LIST_H 1
-#define WEELIST_POS_SORT 0
-#define WEELIST_POS_BEGINNING 1
-#define WEELIST_POS_END 2
+#define WEELIST_POS_SORT "sort"
+#define WEELIST_POS_BEGINNING "beginning"
+#define WEELIST_POS_END "end"
struct t_weelist_item
{
@@ -39,13 +39,22 @@ struct t_weelist
};
extern struct t_weelist *weelist_new ();
-extern struct t_weelist_item *weelist_add (struct t_weelist *, char *, int);
-extern struct t_weelist_item *weelist_search (struct t_weelist *, char *);
-extern struct t_weelist_item *weelist_casesearch (struct t_weelist *, char *);
-extern struct t_weelist_item *weelist_get (struct t_weelist *, int);
-extern void weelist_remove (struct t_weelist *, struct t_weelist_item *);
-extern void weelist_remove_all (struct t_weelist *);
-extern void weelist_free (struct t_weelist *);
-extern void weelist_print_log (struct t_weelist *, char *);
+extern struct t_weelist_item *weelist_add (struct t_weelist *weelist,
+ char *data, char *where);
+extern struct t_weelist_item *weelist_search (struct t_weelist *weelist,
+ char *data);
+extern struct t_weelist_item *weelist_casesearch (struct t_weelist *weelist,
+ char *data);
+extern struct t_weelist_item *weelist_get (struct t_weelist *weelist,
+ int position);
+extern struct t_weelist_item *weelist_next (struct t_weelist_item *item);
+extern struct t_weelist_item *weelist_prev (struct t_weelist_item *item);
+extern char *weelist_string (struct t_weelist_item *item);
+extern int weelist_size (struct t_weelist *weelist);
+extern void weelist_remove (struct t_weelist *weelist,
+ struct t_weelist_item *item);
+extern void weelist_remove_all (struct t_weelist *weelist);
+extern void weelist_free (struct t_weelist *weelist);
+extern void weelist_print_log (struct t_weelist *weelist, char *name);
#endif /* wee-list.h */
diff --git a/src/core/wee-log.c b/src/core/wee-log.c
index 8c43fb501..051f9b45c 100644
--- a/src/core/wee-log.c
+++ b/src/core/wee-log.c
@@ -64,7 +64,7 @@ log_open (char *filename, char *mode)
{
filename_length = strlen (weechat_home) + 64;
weechat_log_filename =
- (char *) malloc (filename_length * sizeof (char));
+ (char *)malloc (filename_length * sizeof (char));
snprintf (weechat_log_filename, filename_length,
"%s/%s", weechat_home, WEECHAT_LOG_NAME);
}
@@ -204,7 +204,7 @@ log_crash_rename ()
log_close ();
length = strlen (weechat_home) + 128;
- new_name = (char *) malloc (length);
+ new_name = (char *)malloc (length);
if (new_name)
{
time_now = time (NULL);
diff --git a/src/core/wee-log.h b/src/core/wee-log.h
index e41e673ff..80dabbee4 100644
--- a/src/core/wee-log.h
+++ b/src/core/wee-log.h
@@ -25,7 +25,7 @@ extern FILE *weechat_log_file;
extern void log_init ();
extern void log_close ();
-extern void log_printf (char *, ...);
+extern void log_printf (char *message, ...);
extern int log_crash_rename ();
#endif /* wee-log.h */
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 2b3aa7380..902d57764 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -377,7 +377,7 @@ string_explode (char *string, char *separators, int keep_eol,
if (num_items != NULL)
*num_items = 0;
- if (!string || !string[0])
+ if (!string || !string[0] || !separators || !separators[0])
return NULL;
/* calculate number of items */
@@ -395,7 +395,7 @@ string_explode (char *string, char *separators, int keep_eol,
n_items = num_items_max;
array =
- (char **) malloc ((n_items + 1) * sizeof (char *));
+ (char **)malloc ((n_items + 1) * sizeof (char *));
ptr1 = string;
ptr2 = string;
@@ -422,7 +422,7 @@ string_explode (char *string, char *separators, int keep_eol,
else
{
array[i] =
- (char *) malloc ((ptr2 - ptr1 + 1) * sizeof (char));
+ (char *)malloc ((ptr2 - ptr1 + 1) * sizeof (char));
array[i] = strncpy (array[i], ptr1, ptr2 - ptr1);
array[i][ptr2 - ptr1] = '\0';
}
@@ -468,28 +468,28 @@ string_free_exploded (char **exploded_string)
*/
char **
-string_split_command (char *command, char sep)
+string_split_command (char *command, char separator)
{
int nb_substr, arr_idx, str_idx, type;
char **array;
char *buffer, *ptr, *p;
- if (command == NULL)
+ if (!command || !command[0])
return NULL;
nb_substr = 1;
ptr = command;
- while ( (p = strchr(ptr, sep)) != NULL)
+ while ( (p = strchr(ptr, separator)) != NULL)
{
nb_substr++;
ptr = ++p;
}
- array = (char **) malloc ((nb_substr + 1) * sizeof(char *));
+ array = (char **)malloc ((nb_substr + 1) * sizeof(char *));
if (!array)
return NULL;
- buffer = (char *) malloc ( (strlen(command) + 1) * sizeof (char));
+ buffer = (char *)malloc ( (strlen(command) + 1) * sizeof (char));
if (!buffer)
{
free (array);
@@ -539,7 +539,7 @@ string_split_command (char *command, char sep)
free (buffer);
- array = (char **) realloc (array, (arr_idx + 1) * sizeof(char *));
+ array = (char **)realloc (array, (arr_idx + 1) * sizeof(char *));
return array;
}
@@ -550,15 +550,15 @@ string_split_command (char *command, char sep)
*/
void
-string_free_splitted_command (char **commands)
+string_free_splitted_command (char **splitted_command)
{
int i;
- if (commands)
+ if (splitted_command)
{
- for (i = 0; commands[i]; i++)
- free (commands[i]);
- free (commands);
+ for (i = 0; splitted_command[i]; i++)
+ free (splitted_command[i]);
+ free (splitted_command);
}
}
@@ -590,7 +590,7 @@ string_iconv (int from_utf8, char *from_code, char *to_code, char *string)
ptr_inbuf = inbuf;
inbytesleft = strlen (inbuf);
outbytesleft = inbytesleft * 4;
- outbuf = (char *) malloc (outbytesleft + 2);
+ outbuf = (char *)malloc (outbytesleft + 2);
ptr_outbuf = outbuf;
ptr_inbuf_shift = NULL;
done = 0;
@@ -676,6 +676,9 @@ string_iconv_to_internal (char *charset, char *string)
{
char *input, *output;
+ if (!string)
+ return NULL;
+
input = strdup (string);
/* optimize for UTF-8: if charset is NULL => we use term charset =>
@@ -710,6 +713,9 @@ string_iconv_from_internal (char *charset, char *string)
{
char *input, *output;
+ if (!string)
+ return NULL;
+
input = strdup (string);
/* optimize for UTF-8: if charset is NULL => we use term charset =>
diff --git a/src/core/wee-string.h b/src/core/wee-string.h
index 67922b5d0..04cb109dc 100644
--- a/src/core/wee-string.h
+++ b/src/core/wee-string.h
@@ -21,23 +21,25 @@
#define __WEECHAT_STRING_H 1
#ifndef HAVE_STRNDUP
-extern char *strndup (char *, int);
+extern char *strndup (char *string, int length);
#endif
-extern void string_tolower (char *);
-extern void string_toupper (char *);
-extern int string_strcasecmp (char *, char *);
-extern int string_strncasecmp (char *, char *, int);
-extern char *string_strcasestr (char *, char *);
-extern char *string_replace (char *, char *, char *);
-extern char *string_remove_quotes (char *, char *);
-extern char *string_convert_hex_chars (char *);
-extern char **string_explode (char *, char *, int, int, int *);
-extern void string_free_exploded (char **);
-extern char **string_split_command (char *, char);
-extern void string_free_splitted_command (char **);
-extern char *string_iconv (int, char *, char *, char *);
-extern char *string_iconv_to_internal (char *, char *);
-extern char *string_iconv_from_internal (char *, char *);
-extern void string_iconv_fprintf (FILE *, char *, ...);
+extern void string_tolower (char *string);
+extern void string_toupper (char *string);
+extern int string_strcasecmp (char *string1, char *string2);
+extern int string_strncasecmp (char *string1, char *string2, int max);
+extern char *string_strcasestr (char *string, char *search);
+extern char *string_replace (char *string, char *search, char *replace);
+extern char *string_remove_quotes (char *string, char *quotes);
+extern char *string_convert_hex_chars (char *string);
+extern char **string_explode (char *string, char *separators, int keep_eol,
+ int num_items_max, int *num_items);
+extern void string_free_exploded (char **exploded_string);
+extern char **string_split_command (char *command, char separator);
+extern void string_free_splitted_command (char **splitted_command);
+extern char *string_iconv (int from_utf8, char *from_code, char *to_code,
+ char *string);
+extern char *string_iconv_to_internal (char *charset, char *string);
+extern char *string_iconv_from_internal (char *charset, char *string);
+extern void string_iconv_fprintf (FILE *file, char *data, ...);
#endif /* wee-string.h */
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index 0890e14cb..c0edecad0 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -600,7 +600,7 @@ session_read_str (FILE *file, char **string)
if (string)
{
- (*string) = (char *) malloc (length + 1);
+ (*string) = (char *)malloc (length + 1);
if (!(*string))
return 0;
diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c
index 9e52dd6b3..51f67a956 100644
--- a/src/core/wee-utf8.c
+++ b/src/core/wee-utf8.c
@@ -300,7 +300,7 @@ utf8_strlen_screen (char *string)
return utf8_strlen (string);
num_char = mbstowcs (NULL, string, 0) + 1;
- wstring = (wchar_t *) malloc ((num_char + 1) * sizeof (wchar_t));
+ wstring = (wchar_t *)malloc ((num_char + 1) * sizeof (wchar_t));
if (!wstring)
return utf8_strlen (string);
@@ -351,13 +351,13 @@ utf8_charcasecmp (char *string1, char *string2)
return diff;
i++;
}
- // string1 == string2 ?
+ /* string1 == string2 ? */
if ((i == length1) && (i == length2))
return 0;
- // string1 < string2 ?
+ /* string1 < string2 ? */
if (i == length1)
return 1;
- // string1 > string2
+ /* string1 > string2 */
return -1;
}
diff --git a/src/core/wee-utf8.h b/src/core/wee-utf8.h
index f16733535..7ad3477ed 100644
--- a/src/core/wee-utf8.h
+++ b/src/core/wee-utf8.h
@@ -33,19 +33,19 @@
extern int local_utf8;
extern void utf8_init ();
-extern int utf8_has_8bits (char *);
-extern int utf8_is_valid (char *, char **);
-extern void utf8_normalize (char *, char);
-extern char *utf8_prev_char (char *, char *);
-extern char *utf8_next_char (char *);
-extern int utf8_char_size (char *);
-extern int utf8_strlen (char *);
-extern int utf8_strnlen (char *, int);
-extern int utf8_strlen_screen (char *);
-extern int utf8_charcasecmp (char *, char *);
-extern int utf8_char_size_screen (char *);
-extern char *utf8_add_offset (char *, int);
-extern int utf8_real_pos (char *, int);
-extern int utf8_pos (char *, int);
+extern int utf8_has_8bits (char *string);
+extern int utf8_is_valid (char *string, char **error);
+extern void utf8_normalize (char *string, char replacement);
+extern char *utf8_prev_char (char *string_start, char *string);
+extern char *utf8_next_char (char *string);
+extern int utf8_char_size (char *string);
+extern int utf8_strlen (char *string);
+extern int utf8_strnlen (char *string, int bytes);
+extern int utf8_strlen_screen (char *string);
+extern int utf8_charcasecmp (char *string1, char *string2);
+extern int utf8_char_size_screen (char *string);
+extern char *utf8_add_offset (char *string, int offset);
+extern int utf8_real_pos (char *string, int pos);
+extern int utf8_pos (char *string, int real_pos);
#endif /* wee-utf8.h */
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index e737c7592..86f5f6b93 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -152,13 +152,17 @@ util_create_dir (char *directory, int permissions)
*/
void
-util_exec_on_files (char *directory, int (*callback)(char *))
+util_exec_on_files (char *directory, void *data,
+ int (*callback)(void *data, char *filename))
{
char complete_filename[1024];
DIR *dir;
struct dirent *entry;
struct stat statbuf;
+ if (!directory || !callback)
+ return;
+
dir = opendir (directory);
if (dir)
{
@@ -169,7 +173,7 @@ util_exec_on_files (char *directory, int (*callback)(char *))
lstat (complete_filename, &statbuf);
if (!S_ISDIR(statbuf.st_mode))
{
- (int) (*callback) (complete_filename);
+ (int) (*callback) (data, complete_filename);
}
}
closedir (dir);
diff --git a/src/core/wee-util.h b/src/core/wee-util.h
index 504c0377f..66d4bce0f 100644
--- a/src/core/wee-util.h
+++ b/src/core/wee-util.h
@@ -20,12 +20,13 @@
#ifndef __WEECHAT_UTIL_H
#define __WEECHAT_UTIL_H 1
-extern int util_timeval_cmp (struct timeval *, struct timeval *);
-extern long util_timeval_diff (struct timeval *, struct timeval *);
-extern void util_timeval_add (struct timeval *, long);
-extern int util_get_time_length (char *);
-extern int util_create_dir (char *, int);
-extern void util_exec_on_files (char *, int (*)(char *));
-extern char *util_search_full_lib_name (char *, char *);
+extern int util_timeval_cmp (struct timeval *tv1, struct timeval *tv2);
+extern long util_timeval_diff (struct timeval *tv1, struct timeval *tv2);
+extern void util_timeval_add (struct timeval *tv, long interval);
+extern int util_get_time_length (char *time_format);
+extern int util_create_dir (char *directory, int permissions);
+extern void util_exec_on_files (char *directory, void *data,
+ int (*callback)(void *data, char *filename));
+extern char *util_search_full_lib_name (char *filename, char *sys_directory);
#endif /* wee-util.h */
diff --git a/src/core/weechat.c b/src/core/weechat.c
index 8d6a74d9e..abe39e365 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -362,7 +362,7 @@ weechat_create_home_dirs ()
}
dir_length = strlen (ptr_home) + 10;
weechat_home =
- (char *) malloc (dir_length * sizeof (char));
+ (char *)malloc (dir_length * sizeof (char));
if (!weechat_home)
{
string_iconv_fprintf (stderr,
@@ -521,7 +521,7 @@ weechat_dump (int crash)
plugin_print_log ();
- hook_signal_exec ("dump_data", NULL);
+ hook_signal_send ("dump_data", NULL);
log_printf ("");
log_printf ("****** End of WeeChat dump ******");
diff --git a/src/core/weechat.h b/src/core/weechat.h
index cdc53d47a..2f98d7db1 100644
--- a/src/core/weechat.h
+++ b/src/core/weechat.h
@@ -108,7 +108,7 @@ extern int quit_weechat;
extern char *weechat_home;
extern char *local_charset;
-extern void weechat_dump (int);
-extern void weechat_shutdown (int, int);
+extern void weechat_dump (int crash);
+extern void weechat_shutdown (int return_code, int crash);
#endif /* weechat.h */
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 1558c4708..834583877 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -31,6 +31,7 @@
#include "../../core/wee-config.h"
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
+#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
@@ -849,13 +850,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
}
/*
- * gui_chat_calculate_line_diff: returns pointer to line & offset for a difference
- * with given line
+ * gui_chat_calculate_line_diff: returns pointer to line & offset for a
+ * difference with given line
*/
void
-gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **line,
- int *line_pos, int difference)
+gui_chat_calculate_line_diff (struct t_gui_window *window,
+ struct t_gui_line **line, int *line_pos,
+ int difference)
{
int backward, current_size;
diff --git a/src/gui/curses/gui-curses-input.c b/src/gui/curses/gui-curses-input.c
index 68eefc5a8..657ca3962 100644
--- a/src/gui/curses/gui-curses-input.c
+++ b/src/gui/curses/gui-curses-input.c
@@ -32,6 +32,7 @@
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-input.h"
+#include "../gui-buffer.h"
#include "../gui-color.h"
#include "../gui-keyboard.h"
#include "../gui-main.h"
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index 86f542606..89b5ed35b 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -31,6 +31,7 @@
#include "../../core/wee-utf8.h"
#include "../../core/wee-string.h"
#include "../gui-keyboard.h"
+#include "../gui-buffer.h"
#include "../gui-color.h"
#include "../gui-input.h"
#include "../gui-completion.h"
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index eebdade5c..e408161d2 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -37,6 +37,7 @@
#include "../../core/wee-util.h"
#include "../../plugins/plugin.h"
#include "../gui-main.h"
+#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-infobar.h"
@@ -198,7 +199,7 @@ gui_main_end ()
/* delete all buffers */
while (gui_buffers)
- gui_buffer_free (gui_buffers, 0);
+ gui_buffer_close (gui_buffers, 0);
/* delete global history */
gui_history_global_free ();
diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c
index a0a253609..c97484076 100644
--- a/src/gui/curses/gui-curses-nicklist.c
+++ b/src/gui/curses/gui-curses-nicklist.c
@@ -30,6 +30,7 @@
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../gui-nicklist.h"
+#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
diff --git a/src/gui/curses/gui-curses-status.c b/src/gui/curses/gui-curses-status.c
index 9422a7f44..f941f197a 100644
--- a/src/gui/curses/gui-curses-status.c
+++ b/src/gui/curses/gui-curses-status.c
@@ -31,6 +31,7 @@
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-status.h"
+#include "../gui-buffer.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-hotlist.h"
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index 8fce32f39..cdc650ca3 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -34,6 +34,7 @@
#include "../../core/wee-log.h"
#include "../../core/wee-string.h"
#include "../gui-window.h"
+#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-hotlist.h"
@@ -77,7 +78,7 @@ gui_window_objects_init (struct t_gui_window *window)
{
struct t_gui_curses_objects *new_objects;
- if ((new_objects = (struct t_gui_curses_objects *) malloc (sizeof (struct t_gui_curses_objects))))
+ if ((new_objects = (struct t_gui_curses_objects *)malloc (sizeof (struct t_gui_curses_objects))))
{
window->gui_objects = new_objects;
GUI_CURSES(window)->win_title = NULL;
diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h
index 2801b6862..f1e6aea17 100644
--- a/src/gui/curses/gui-curses.h
+++ b/src/gui/curses/gui-curses.h
@@ -50,12 +50,13 @@ extern struct t_gui_color gui_weechat_colors[];
extern int gui_refresh_screen_needed;
/* color functions */
-extern int gui_color_get_pair (int);
+extern int gui_color_get_pair (int num_color);
extern void gui_color_init ();
/* chat functions */
-extern void gui_chat_calculate_line_diff (struct t_gui_window *,
- struct t_gui_line **, int *, int);
+extern void gui_chat_calculate_line_diff (struct t_gui_window *window,
+ struct t_gui_line **line,
+ int *line_pos, int difference);
/* keyboard functions */
extern void gui_keyboard_default_bindings ();
@@ -63,9 +64,9 @@ extern void gui_keyboard_read ();
extern void gui_keyboard_flush ();
/* window functions */
-extern void gui_window_wprintw (WINDOW *, char *, ...);
-extern void gui_window_curses_clear (WINDOW *, int);
-extern void gui_window_set_weechat_color (WINDOW *, int);
+extern void gui_window_wprintw (WINDOW *window, char *data, ...);
+extern void gui_window_curses_clear (WINDOW *window, int num_color);
+extern void gui_window_set_weechat_color (WINDOW *window, int num_color);
extern void gui_window_refresh_screen_sigwinch ();
extern void gui_window_title_set ();
extern void gui_window_title_reset ();
diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c
index 97a11ddb8..4760eb62a 100644
--- a/src/gui/gtk/gui-gtk-chat.c
+++ b/src/gui/gtk/gui-gtk-chat.c
@@ -30,6 +30,7 @@
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-utf8.h"
+#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c
index 33d1fc9b2..4a316fcc8 100644
--- a/src/gui/gtk/gui-gtk-main.c
+++ b/src/gui/gtk/gui-gtk-main.c
@@ -34,6 +34,7 @@
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-main.h"
+#include "../gui-buffer.h"
#include "../gui-history.h"
#include "../gui-infobar.h"
#include "../gui-input.h"
@@ -211,7 +212,7 @@ gui_main_end ()
/* delete all buffers */
while (gui_buffers)
- gui_buffer_free (gui_buffers, 0);
+ gui_buffer_close (gui_buffers, 0);
/* delete all windows */
while (gui_windows)
diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c
index c00813f3a..bbb11c326 100644
--- a/src/gui/gtk/gui-gtk-window.c
+++ b/src/gui/gtk/gui-gtk-window.c
@@ -30,6 +30,7 @@
#include "../../core/wee-config.h"
#include "../../core/wee-log.h"
#include "../gui-window.h"
+#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-hotlist.h"
#include "../gui-nicklist.h"
@@ -67,7 +68,7 @@ gui_window_objects_init (struct t_gui_window *window)
{
struct t_gui_gtk_objects *new_objects;
- if ((new_objects = (struct t_gui_gtk_objects *) malloc (sizeof (struct t_gui_gtk_objects))))
+ if ((new_objects = (struct t_gui_gtk_objects *)malloc (sizeof (struct t_gui_gtk_objects))))
{
window->gui_objects = new_objects;
GUI_GTK(window)->textview_chat = NULL;
diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h
index e88e0ae2e..6bea6943d 100644
--- a/src/gui/gtk/gui-gtk.h
+++ b/src/gui/gtk/gui-gtk.h
@@ -22,6 +22,9 @@
#include <gtk/gtk.h>
+struct t_gui_window;
+struct t_gui_line;
+
/* TODO: remove these temporary defines */
#define A_BOLD 1
@@ -78,12 +81,13 @@ extern GtkWidget *gui_gtk_entry_input;
extern GtkWidget *gui_gtk_label1;
/* color functions */
-extern int gui_color_get_pair (int);
+extern int gui_color_get_pair (int num_color);
extern void gui_color_init ();
/* chat functions */
-extern void gui_chat_calculate_line_diff (struct t_gui_window *,
- struct t_gui_line **, int *, int);
+extern void gui_chat_calculate_line_diff (struct t_gui_window *window,
+ struct t_gui_line **line,
+ int *line_pos, int difference);
/* keyboard functions */
extern void gui_keyboard_default_bindings ();
@@ -91,7 +95,7 @@ extern void gui_keyboard_read ();
extern void gui_keyboard_flush ();
/* window functions */
-extern void gui_window_set_title ();
-extern void gui_window_reset_title ();
+extern void gui_window_title_set ();
+extern void gui_window_title_reset ();
#endif /* gui-gtk.h */
diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c
index daef042a6..87cd9b308 100644
--- a/src/gui/gui-action.c
+++ b/src/gui/gui-action.c
@@ -37,6 +37,7 @@
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
+#include "gui-action.h"
#include "gui-buffer.h"
#include "gui-chat.h"
#include "gui-completion.h"
@@ -62,7 +63,7 @@ gui_action_clipboard_copy (char *buffer, int size)
if (gui_input_clipboard != NULL)
free (gui_input_clipboard);
- gui_input_clipboard = (char *) malloc( (size + 1) * sizeof(*gui_input_clipboard));
+ gui_input_clipboard = (char *)malloc( (size + 1) * sizeof(*gui_input_clipboard));
if (gui_input_clipboard)
{
diff --git a/src/gui/gui-action.h b/src/gui/gui-action.h
index 8588beb91..cc4bf564d 100644
--- a/src/gui/gui-action.h
+++ b/src/gui/gui-action.h
@@ -22,58 +22,58 @@
/* action functions */
-extern void gui_action_clipboard_copy (char *, int);
-extern void gui_action_clipboard_paste (char *);
-extern void gui_action_return (char *);
-extern void gui_action_tab (char *);
-extern void gui_action_tab_previous (char *);
-extern void gui_action_backspace (char *);
-extern void gui_action_delete (char *);
-extern void gui_action_delete_previous_word (char *);
-extern void gui_action_delete_next_word (char *);
-extern void gui_action_delete_begin_of_line (char *);
-extern void gui_action_delete_end_of_line (char *);
-extern void gui_action_delete_line (char *);
-extern void gui_action_transpose_chars (char *);
-extern void gui_action_home (char *);
-extern void gui_action_end (char *);
-extern void gui_action_left (char *);
-extern void gui_action_previous_word (char *);
-extern void gui_action_right (char *);
-extern void gui_action_next_word (char *);
-extern void gui_action_up (char *);
-extern void gui_action_up_global (char *);
-extern void gui_action_down (char *);
-extern void gui_action_down_global (char *);
-extern void gui_action_page_up (char *);
-extern void gui_action_page_down (char *);
-extern void gui_action_scroll_up (char *);
-extern void gui_action_scroll_down (char *);
-extern void gui_action_scroll_top (char *);
-extern void gui_action_scroll_bottom (char *);
-extern void gui_action_scroll_topic_left (char *);
-extern void gui_action_scroll_topic_right (char *);
-extern void gui_action_nick_beginning (char *);
-extern void gui_action_nick_end (char *);
-extern void gui_action_nick_page_up (char *);
-extern void gui_action_nick_page_down (char *);
-extern void gui_action_jump_smart (char *);
-extern void gui_action_jump_dcc (char *);
-extern void gui_action_jump_raw_data (char *);
-extern void gui_action_jump_last_buffer (char *);
-extern void gui_action_jump_previous_buffer (char *);
-extern void gui_action_jump_server (char *);
-extern void gui_action_jump_next_server (char *);
-extern void gui_action_switch_server (char *);
-extern void gui_action_scroll_previous_highlight (char *);
-extern void gui_action_scroll_next_highlight (char *);
-extern void gui_action_scroll_unread (char *);
-extern void gui_action_set_unread (char *);
-extern void gui_action_hotlist_clear (char *);
-extern void gui_action_infobar_clear (char *);
-extern void gui_action_refresh_screen (char *);
-extern void gui_action_grab_key (char *);
-extern void gui_action_insert_string (char *);
-extern void gui_action_search_text (char *);
+extern void gui_action_clipboard_copy (char *buffer, int size);
+extern void gui_action_clipboard_paste (char *args);
+extern void gui_action_return (char *args);
+extern void gui_action_tab (char *args);
+extern void gui_action_tab_previous (char *args);
+extern void gui_action_backspace (char *args);
+extern void gui_action_delete (char *args);
+extern void gui_action_delete_previous_word (char *args);
+extern void gui_action_delete_next_word (char *args);
+extern void gui_action_delete_begin_of_line (char *args);
+extern void gui_action_delete_end_of_line (char *args);
+extern void gui_action_delete_line (char *args);
+extern void gui_action_transpose_chars (char *args);
+extern void gui_action_home (char *args);
+extern void gui_action_end (char *args);
+extern void gui_action_left (char *args);
+extern void gui_action_previous_word (char *args);
+extern void gui_action_right (char *args);
+extern void gui_action_next_word (char *args);
+extern void gui_action_up (char *args);
+extern void gui_action_up_global (char *args);
+extern void gui_action_down (char *args);
+extern void gui_action_down_global (char *args);
+extern void gui_action_page_up (char *args);
+extern void gui_action_page_down (char *args);
+extern void gui_action_scroll_up (char *args);
+extern void gui_action_scroll_down (char *args);
+extern void gui_action_scroll_top (char *args);
+extern void gui_action_scroll_bottom (char *args);
+extern void gui_action_scroll_topic_left (char *args);
+extern void gui_action_scroll_topic_right (char *args);
+extern void gui_action_nick_beginning (char *args);
+extern void gui_action_nick_end (char *args);
+extern void gui_action_nick_page_up (char *args);
+extern void gui_action_nick_page_down (char *args);
+extern void gui_action_jump_smart (char *args);
+extern void gui_action_jump_dcc (char *args);
+extern void gui_action_jump_raw_data (char *args);
+extern void gui_action_jump_last_buffer (char *args);
+extern void gui_action_jump_previous_buffer (char *args);
+extern void gui_action_jump_server (char *args);
+extern void gui_action_jump_next_server (char *args);
+extern void gui_action_switch_server (char *args);
+extern void gui_action_scroll_previous_highlight (char *args);
+extern void gui_action_scroll_next_highlight (char *args);
+extern void gui_action_scroll_unread (char *args);
+extern void gui_action_set_unread (char *args);
+extern void gui_action_hotlist_clear (char *args);
+extern void gui_action_infobar_clear (char *args);
+extern void gui_action_refresh_screen (char *args);
+extern void gui_action_grab_key (char *args);
+extern void gui_action_insert_string (char *args);
+extern void gui_action_search_text (char *args);
#endif /* gui-action.h */
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index c88c38f30..74f7d6514 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -65,8 +65,8 @@ struct t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buf. before raw */
*/
struct t_gui_buffer *
-gui_buffer_new (void *plugin, char *category, char *name,
- void (*input_data_cb)(struct t_gui_buffer *, char *))
+gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name,
+ void (*callback_input_data)(struct t_gui_buffer *buffer, char *data))
{
struct t_gui_buffer *new_buffer;
struct t_gui_completion *new_completion;
@@ -121,11 +121,11 @@ gui_buffer_new (void *plugin, char *category, char *name,
/* input */
new_buffer->input = 1;
- new_buffer->input_data_cb = input_data_cb;
+ new_buffer->input_data_cb = callback_input_data;
new_buffer->input_nick = NULL;
new_buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE;
- new_buffer->input_buffer = (char *) malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
- new_buffer->input_buffer_color_mask = (char *) malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
+ new_buffer->input_buffer = (char *)malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
+ new_buffer->input_buffer_color_mask = (char *)malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
new_buffer->input_buffer[0] = '\0';
new_buffer->input_buffer_color_mask[0] = '\0';
new_buffer->input_buffer_size = 0;
@@ -174,7 +174,7 @@ gui_buffer_new (void *plugin, char *category, char *name,
gui_window_redraw_buffer (new_buffer);
}
- hook_signal_exec ("buffer_open", new_buffer);
+ hook_signal_send ("buffer_open", new_buffer);
}
else
return NULL;
@@ -572,17 +572,17 @@ gui_buffer_clear_all ()
}
/*
- * gui_buffer_free: delete a buffer
+ * gui_buffer_close: close a buffer
*/
void
-gui_buffer_free (struct t_gui_buffer *buffer, int switch_to_another)
+gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another)
{
struct t_gui_window *ptr_window;
struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line;
- hook_signal_exec ("buffer_close", buffer);
+ hook_signal_send ("buffer_close", buffer);
if (switch_to_another)
{
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index 975f28c92..7ffb52e0e 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -50,17 +50,6 @@ struct t_gui_line
struct t_gui_line *next_line; /* link to next line */
};
-struct t_gui_nick
-{
- char *nick; /* nickname */
- int sort_index; /* index to force sort */
- int color_nick; /* color for nick in nicklist */
- char prefix; /* prefix for nick (for admins, ..) */
- int color_prefix; /* color for prefix */
- struct t_gui_nick *prev_nick; /* link to previous nick in nicklist */
- struct t_gui_nick *next_nick; /* link to next nick in nicklist */
-};
-
struct t_gui_buffer
{
struct t_weechat_plugin *plugin; /* plugin which created this buffer */
@@ -96,7 +85,7 @@ struct t_gui_buffer
/* inupt */
int input; /* = 1 if input is enabled */
- void (*input_data_cb)(struct t_gui_buffer *, char *);
+ void (*input_data_cb)(struct t_gui_buffer *buffer, char *data);
/* called when user send data */
/* to this buffer */
char *input_nick; /* self nick */
@@ -139,38 +128,40 @@ extern struct t_gui_buffer *gui_buffer_before_raw_data;
/* buffer functions */
-extern struct t_gui_buffer *gui_buffer_new (void *, char *, char *,
- void (*)(struct t_gui_buffer *, char *));
-extern int gui_buffer_valid (struct t_gui_buffer *);
-extern void *gui_buffer_get (struct t_gui_buffer *, char *);
-extern void gui_buffer_set_category (struct t_gui_buffer *, char *);
-extern void gui_buffer_set_name (struct t_gui_buffer *, char *);
-extern void gui_buffer_set_log (struct t_gui_buffer *, char *);
-extern void gui_buffer_set_title (struct t_gui_buffer *, char *);
-extern void gui_buffer_set_nick_case_sensitive (struct t_gui_buffer *, int);
-extern void gui_buffer_set_nick (struct t_gui_buffer *, char *);
-extern void gui_buffer_set (struct t_gui_buffer *, char *, char *);
+extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
+ char *category, char *name,
+ void (*input_data_cb)(struct t_gui_buffer *buffer,
+ char *data));
+extern int gui_buffer_valid (struct t_gui_buffer *buffer);
+extern void *gui_buffer_get (struct t_gui_buffer *buffer, char *property);
+extern void gui_buffer_set_category (struct t_gui_buffer *buffer,
+ char *category);
+extern void gui_buffer_set_name (struct t_gui_buffer *buffer, char *name);
+extern void gui_buffer_set_title (struct t_gui_buffer *buffer, char *new_title);
+extern void gui_buffer_set_nicklist (struct t_gui_buffer *buffer, int nicklist);
+extern void gui_buffer_set_nick_case_sensitive (struct t_gui_buffer * buffer,
+ int nick_case_sensitive);
+extern void gui_buffer_set_nick (struct t_gui_buffer *buffer, char *new_nick);
+extern void gui_buffer_set (struct t_gui_buffer *buffer, char *property,
+ char *value);
extern struct t_gui_buffer *gui_buffer_search_main ();
-extern struct t_gui_buffer *gui_buffer_search_by_category_name (char *,
- char *);
-extern struct t_gui_buffer *gui_buffer_search_by_number (int);
-extern struct t_gui_window *gui_buffer_find_window (struct t_gui_buffer *);
-extern void gui_buffer_find_context (void *, void *,
- struct t_gui_window **,
- struct t_gui_buffer **);
-extern int gui_buffer_is_scrolled (struct t_gui_buffer *);
-extern struct t_gui_buffer *gui_buffer_get_dcc (struct t_gui_window *);
-extern void gui_buffer_clear (struct t_gui_buffer *);
+extern struct t_gui_buffer *gui_buffer_search_by_category_name (char *category,
+ char *name);
+extern struct t_gui_buffer *gui_buffer_search_by_number (int number);
+extern struct t_gui_window *gui_buffer_find_window (struct t_gui_buffer *buffer);
+extern int gui_buffer_is_scrolled (struct t_gui_buffer *buffer);
+extern struct t_gui_buffer *gui_buffer_get_dcc (struct t_gui_window *window);
+extern void gui_buffer_clear (struct t_gui_buffer *buffer);
extern void gui_buffer_clear_all ();
-extern void gui_buffer_free (struct t_gui_buffer *, int);
-extern void gui_buffer_switch_previous (struct t_gui_window *);
-extern void gui_buffer_switch_next (struct t_gui_window *);
-extern void gui_buffer_switch_dcc (struct t_gui_window *);
-extern void gui_buffer_switch_raw_data (struct t_gui_window *);
-extern struct t_gui_buffer *gui_buffer_switch_by_number (struct t_gui_window *,
- int);
-extern void gui_buffer_move_to_number (struct t_gui_buffer *, int);
-extern void gui_buffer_dump_hexa (struct t_gui_buffer *);
+extern void gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another);
+extern void gui_buffer_switch_previous (struct t_gui_window *window);
+extern void gui_buffer_switch_next (struct t_gui_window *window);
+extern void gui_buffer_switch_dcc (struct t_gui_window *window);
+extern void gui_buffer_switch_raw_data (struct t_gui_window *window);
+extern struct t_gui_buffer *gui_buffer_switch_by_number (struct t_gui_window *window,
+ int number);
+extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number);
+extern void gui_buffer_dump_hexa (struct t_gui_buffer *buffer);
extern void gui_buffer_print_log ();
#endif /* gui-buffer.h */
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 94b25fc55..cf0c5e69b 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -35,6 +35,7 @@
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
#include "gui-chat.h"
+#include "gui-buffer.h"
#include "gui-color.h"
#include "gui-hotlist.h"
#include "gui-main.h"
@@ -409,7 +410,7 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
{
struct t_gui_line *new_line, *ptr_line;
- new_line = (struct t_gui_line *) malloc (sizeof (struct t_gui_line));
+ new_line = (struct t_gui_line *)malloc (sizeof (struct t_gui_line));
if (!new_line)
{
log_printf (_("Not enough memory for new line"));
diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h
index 99b0c2ee0..3da67508f 100644
--- a/src/gui/gui-chat.h
+++ b/src/gui/gui-chat.h
@@ -20,7 +20,9 @@
#ifndef __WEECHAT_GUI_CHAT_H
#define __WEECHAT_GUI_CHAT_H 1
-#include "gui-buffer.h"
+struct t_gui_window;
+struct t_gui_buffer;
+struct t_gui_line;
#define gui_chat_printf(buffer, argz...) \
gui_chat_printf_date(buffer, 0, ##argz) \
@@ -44,24 +46,33 @@ extern int gui_chat_time_length;
/* chat functions */
extern void gui_chat_prefix_build ();
-extern int gui_chat_strlen_screen (char *);
-extern int gui_chat_string_real_pos (char *, int);
-extern void gui_chat_get_word_info (struct t_gui_window *,
- char *, int *, int *, int *, int *);
+extern int gui_chat_strlen_screen (char *string);
+extern int gui_chat_string_real_pos (char *string, int pos);
+extern void gui_chat_get_word_info (struct t_gui_window *window,
+ char *data, int *word_start_offset,
+ int *word_end_offset,
+ int *word_length_with_spaces,
+ int *word_length);
extern void gui_chat_change_time_format ();
-extern int gui_chat_get_line_align (struct t_gui_buffer *,
- struct t_gui_line *, int);
-extern int gui_chat_line_search (struct t_gui_line *, char *, int);
-extern void gui_chat_line_free (struct t_gui_line *);
-extern void gui_chat_printf_date (struct t_gui_buffer *, time_t, char *, ...);
-extern void gui_chat_printf_raw_data (void *, int, int, char *);
+extern int gui_chat_get_line_align (struct t_gui_buffer *buffer,
+ struct t_gui_line *line,
+ int with_suffix);
+extern int gui_chat_line_search (struct t_gui_line *line, char *text,
+ int case_sensitive);
+extern void gui_chat_line_free (struct t_gui_line *line);
+extern void gui_chat_printf_date (struct t_gui_buffer *buffer, time_t date,
+ char *message, ...);
+extern void gui_chat_printf_raw_data (void *server, int send, int modified,
+ char *message);
/* chat functions (GUI dependent) */
-extern void gui_chat_draw_title (struct t_gui_buffer *, int);
-extern char *gui_chat_string_next_char (struct t_gui_window *, unsigned char *,
- int);
-extern void gui_chat_draw (struct t_gui_buffer *, int);
-extern void gui_chat_draw_line (struct t_gui_buffer *, struct t_gui_line *);
+extern void gui_chat_draw_title (struct t_gui_buffer *buffer, int erase);
+extern char *gui_chat_string_next_char (struct t_gui_window *window,
+ unsigned char *string,
+ int apply_style);
+extern void gui_chat_draw (struct t_gui_buffer *buffer, int erase);
+extern void gui_chat_draw_line (struct t_gui_buffer *buffer,
+ struct t_gui_line *line);
#endif /* gui-chat.h */
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 090e64f37..263805c0e 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -142,13 +142,13 @@ extern struct t_gui_color *gui_color[GUI_NUM_COLORS];
/* color functions */
-extern int gui_color_search_config (char *);
-extern unsigned char *gui_color_decode (unsigned char *);
+extern int gui_color_search_config (char *color_name);
+extern unsigned char *gui_color_decode (unsigned char *string);
/* color functions (GUI dependent) */
-extern int gui_color_assign (int *, char *);
-extern char *gui_color_get_name (int);
+extern int gui_color_assign (int *color, char *color_name);
+extern char *gui_color_get_name (int num_color);
extern void gui_color_init_pairs ();
extern void gui_color_rebuild_weechat ();
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 3689830ed..d87f506d4 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -228,7 +228,7 @@ gui_completion_nickncmp (char *base_word, char *nick, int max)
void
gui_completion_list_add (struct t_gui_completion *completion, char *word,
- int nick_completion, int position)
+ int nick_completion, char *where)
{
if (!word || !word[0])
return;
@@ -239,8 +239,7 @@ gui_completion_list_add (struct t_gui_completion *completion, char *word,
|| (!nick_completion && (string_strncasecmp (completion->base_word, word,
strlen (completion->base_word)) == 0)))
{
- weelist_add (completion->completion_list,
- word, position);
+ weelist_add (completion->completion_list, word, where);
}
}
@@ -296,7 +295,7 @@ gui_completion_list_add_filename (struct t_gui_completion *completion)
char home[3] = { '~', DIR_SEPARATOR_CHAR, '\0' };
buffer_len = PATH_MAX;
- buffer = (char *) malloc (buffer_len * sizeof (char));
+ buffer = (char *)malloc (buffer_len * sizeof (char));
if (!buffer)
return;
@@ -880,7 +879,7 @@ gui_completion_find_context (struct t_gui_completion *completion, char *data,
if (pos_start <= pos_end)
{
completion->position_replace = pos_start;
- completion->base_word = (char *) malloc (pos_end - pos_start + 2);
+ completion->base_word = (char *)malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
completion->base_word[i - pos_start] = data[i];
completion->base_word[pos_end - pos_start + 1] = '\0';
@@ -905,7 +904,7 @@ gui_completion_find_context (struct t_gui_completion *completion, char *data,
if (data[pos_end] == ' ')
pos_end--;
- completion->base_command = (char *) malloc (pos_end - pos_start + 2);
+ completion->base_command = (char *)malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
completion->base_command[i - pos_start] = data[i];
completion->base_command[pos_end - pos_start + 1] = '\0';
diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h
index e66c16ce7..a0c1806a5 100644
--- a/src/gui/gui-completion.h
+++ b/src/gui/gui-completion.h
@@ -53,9 +53,12 @@ struct t_gui_completion
/* completion functions */
-extern void gui_completion_init (struct t_gui_completion *, struct t_gui_buffer *);
-extern void gui_completion_free (struct t_gui_completion *);
-extern void gui_completion_search (struct t_gui_completion *, int, char *, int, int);
-extern void gui_completion_print_log (struct t_gui_completion *);
+extern void gui_completion_init (struct t_gui_completion *completion,
+ struct t_gui_buffer *buffer);
+extern void gui_completion_free (struct t_gui_completion *completion);
+extern void gui_completion_search (struct t_gui_completion *completion,
+ int direction, char *data, int size,
+ int pos);
+extern void gui_completion_print_log (struct t_gui_completion *completion);
#endif /* gui-completion.h */
diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c
index 971d5690a..ccf0c0bb5 100644
--- a/src/gui/gui-history.c
+++ b/src/gui/gui-history.c
@@ -44,19 +44,16 @@ int num_history_global = 0;
*/
void
-gui_history_buffer_add (void *buffer, char *string)
+gui_history_buffer_add (struct t_gui_buffer *buffer, char *string)
{
- struct t_gui_buffer *ptr_buffer;
struct t_gui_history *new_history, *ptr_history;
-
- ptr_buffer = (struct t_gui_buffer *)buffer;
if (!string)
return;
- if (!ptr_buffer->history
- || (ptr_buffer->history
- && (strcmp (ptr_buffer->history->text, string) != 0)))
+ if (!buffer->history
+ || (buffer->history
+ && (strcmp (buffer->history->text, string) != 0)))
{
new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history));
if (new_history)
@@ -65,28 +62,28 @@ gui_history_buffer_add (void *buffer, char *string)
/*if (config_log_hide_nickserv_pwd)
irc_display_hide_password (new_history->text, 1);*/
- if (ptr_buffer->history)
- ptr_buffer->history->prev_history = new_history;
+ if (buffer->history)
+ buffer->history->prev_history = new_history;
else
- ptr_buffer->last_history = new_history;
- new_history->next_history = ptr_buffer->history;
+ buffer->last_history = new_history;
+ new_history->next_history = buffer->history;
new_history->prev_history = NULL;
- ptr_buffer->history = new_history;
- ptr_buffer->num_history++;
+ buffer->history = new_history;
+ buffer->num_history++;
/* remove one command if necessary */
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
- && (ptr_buffer->num_history > CONFIG_INTEGER(config_history_max_commands)))
+ && (buffer->num_history > CONFIG_INTEGER(config_history_max_commands)))
{
- ptr_history = ptr_buffer->last_history->prev_history;
- if (ptr_buffer->ptr_history == ptr_buffer->last_history)
- ptr_buffer->ptr_history = ptr_history;
- ptr_buffer->last_history->prev_history->next_history = NULL;
- if (ptr_buffer->last_history->text)
- free (ptr_buffer->last_history->text);
- free (ptr_buffer->last_history);
- ptr_buffer->last_history = ptr_history;
- ptr_buffer->num_history++;
+ ptr_history = buffer->last_history->prev_history;
+ if (buffer->ptr_history == buffer->last_history)
+ buffer->ptr_history = ptr_history;
+ buffer->last_history->prev_history->next_history = NULL;
+ if (buffer->last_history->text)
+ free (buffer->last_history->text);
+ free (buffer->last_history);
+ buffer->last_history = ptr_history;
+ buffer->num_history++;
}
}
}
@@ -171,23 +168,20 @@ gui_history_global_free ()
*/
void
-gui_history_buffer_free (void *buffer)
+gui_history_buffer_free (struct t_gui_buffer *buffer)
{
- struct t_gui_buffer *ptr_buffer;
struct t_gui_history *ptr_history;
- ptr_buffer = (struct t_gui_buffer *)buffer;
-
- while (ptr_buffer->history)
+ while (buffer->history)
{
- ptr_history = ptr_buffer->history->next_history;
- if (ptr_buffer->history->text)
- free (ptr_buffer->history->text);
- free (ptr_buffer->history);
- ptr_buffer->history = ptr_history;
+ ptr_history = buffer->history->next_history;
+ if (buffer->history->text)
+ free (buffer->history->text);
+ free (buffer->history);
+ buffer->history = ptr_history;
}
- ptr_buffer->history = NULL;
- ptr_buffer->last_history = NULL;
- ptr_buffer->ptr_history = NULL;
- ptr_buffer->num_history = 0;
+ buffer->history = NULL;
+ buffer->last_history = NULL;
+ buffer->ptr_history = NULL;
+ buffer->num_history = 0;
}
diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h
index 40fedc71b..a97990b7d 100644
--- a/src/gui/gui-history.h
+++ b/src/gui/gui-history.h
@@ -20,6 +20,8 @@
#ifndef __WEECHAT_GUI_HISTORY_H
#define __WEECHAT_GUI_HISTORY_H 1
+struct t_gui_buffer;
+
struct t_gui_history
{
char *text; /* text or command (entered by user) */
@@ -32,9 +34,9 @@ extern struct t_gui_history *history_global_last;
extern struct t_gui_history *history_global_ptr;
/* history functions (gui-history.c) */
-extern void gui_history_buffer_add (void *, char *);
-extern void gui_history_global_add (char *);
+extern void gui_history_buffer_add (struct t_gui_buffer *buffer, char *string);
+extern void gui_history_global_add (char *string);
extern void gui_history_global_free ();
-extern void gui_history_buffer_free (void *);
+extern void gui_history_buffer_free (struct t_gui_buffer *buffer);
#endif /* gui-history.h */
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index 0e541beec..b741d5966 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -207,7 +207,8 @@ gui_hotlist_add (struct t_gui_buffer *buffer, int priority,
gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);
}
- if ((new_hotlist = (struct t_gui_hotlist *) malloc (sizeof (struct t_gui_hotlist))) == NULL)
+ new_hotlist = (struct t_gui_hotlist *)malloc (sizeof (struct t_gui_hotlist));
+ if (!new_hotlist)
{
log_printf (_("Error: not enough memory to add a buffer to "
"hotlist"));
@@ -236,7 +237,8 @@ gui_hotlist_dup (struct t_gui_hotlist *hotlist)
{
struct t_gui_hotlist *new_hotlist;
- if ((new_hotlist = (struct t_gui_hotlist *) malloc (sizeof (struct t_gui_hotlist))))
+ new_hotlist = (struct t_gui_hotlist *)malloc (sizeof (struct t_gui_hotlist));
+ if (new_hotlist)
{
new_hotlist->priority = hotlist->priority;
memcpy (&(new_hotlist->creation_time), &(hotlist->creation_time),
diff --git a/src/gui/gui-hotlist.h b/src/gui/gui-hotlist.h
index 9cb664c5c..361831437 100644
--- a/src/gui/gui-hotlist.h
+++ b/src/gui/gui-hotlist.h
@@ -44,13 +44,16 @@ extern int gui_add_hotlist;
/* hotlist functions */
-extern void gui_hotlist_add (struct t_gui_buffer *, int, struct timeval *, int);
+extern void gui_hotlist_add (struct t_gui_buffer *buffer, int priority,
+ struct timeval *creation_time,
+ int allow_current_buffer);
extern void gui_hotlist_resort ();
-extern void gui_hotlist_free (struct t_gui_hotlist **, struct t_gui_hotlist **,
- struct t_gui_hotlist *);
-extern void gui_hotlist_free_all (struct t_gui_hotlist **,
- struct t_gui_hotlist **);
-extern void gui_hotlist_remove_buffer (struct t_gui_buffer *);
+extern void gui_hotlist_free (struct t_gui_hotlist **hotlist,
+ struct t_gui_hotlist **last_hotlist,
+ struct t_gui_hotlist *ptr_hotlist);
+extern void gui_hotlist_free_all (struct t_gui_hotlist **hotlist,
+ struct t_gui_hotlist **last_hotlist);
+extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer);
extern void gui_hotlist_print_log ();
#endif /* gui-hotlist.h */
diff --git a/src/gui/gui-infobar.c b/src/gui/gui-infobar.c
index 2f29dd5a8..97e82bae6 100644
--- a/src/gui/gui-infobar.c
+++ b/src/gui/gui-infobar.c
@@ -45,7 +45,7 @@ struct t_hook *gui_infobar_highlight_timer = NULL; /* highlight timer */
*/
void
-gui_infobar_printf (int time_displayed, int color, char *message, ...)
+gui_infobar_printf (int delay, int color, char *message, ...)
{
static char buf[1024];
va_list argptr;
@@ -70,7 +70,7 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...)
pos = strchr (ptr_infobar->text, '\n');
if (pos)
pos[0] = '\0';
- ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed;
+ ptr_infobar->remaining_time = (delay <= 0) ? -1 : delay;
ptr_infobar->next_infobar = gui_infobar;
gui_infobar = ptr_infobar;
gui_infobar_draw (gui_current_window->buffer, 1);
diff --git a/src/gui/gui-infobar.h b/src/gui/gui-infobar.h
index 080c02110..d1b50406f 100644
--- a/src/gui/gui-infobar.h
+++ b/src/gui/gui-infobar.h
@@ -20,8 +20,6 @@
#ifndef __WEECHAT_GUI_INFOBAR_H
#define __WEECHAT_GUI_INFOBAR_H 1
-#include "gui-buffer.h"
-
struct t_gui_infobar
{
int color; /* text color */
@@ -40,15 +38,15 @@ extern struct t_hook *gui_infobar_highlight_timer;
/* infobar functions */
-extern void gui_infobar_printf (int, int, char *, ...);
+extern void gui_infobar_printf (int delay, int color, char *message, ...);
extern void gui_infobar_remove ();
extern void gui_infobar_remove_all ();
/* infobar functions (GUI dependent) */
-extern void gui_infobar_draw_time (struct t_gui_buffer *);
-extern void gui_infobar_draw (struct t_gui_buffer *, int);
-extern int gui_infobar_refresh_timer_cb (void *);
-extern int gui_infobar_highlight_timer_cb (void *);
+extern void gui_infobar_draw_time (struct t_gui_buffer *buffer);
+extern void gui_infobar_draw (struct t_gui_buffer *buffer, int erase);
+extern int gui_infobar_refresh_timer_cb (void *data);
+extern int gui_infobar_highlight_timer_cb (void *data);
#endif /* gui-infobar.h */
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 3144e25c7..2eff275ce 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -31,11 +31,12 @@
#include "../core/wee-utf8.h"
#include "../plugins/plugin.h"
#include "gui-input.h"
+#include "gui-buffer.h"
#include "gui-completion.h"
#include "gui-window.h"
-char *gui_input_clipboard = NULL; /* clipboard content */
+char *gui_input_clipboard = NULL; /* clipboard content */
/*
@@ -84,7 +85,8 @@ gui_input_init_color_mask (struct t_gui_buffer *buffer)
*/
void
-gui_input_move (struct t_gui_buffer *buffer, char *target, char *source, int size)
+gui_input_move (struct t_gui_buffer *buffer, char *target, char *source,
+ int size)
{
int pos_source, pos_target;
@@ -148,7 +150,7 @@ gui_input_insert_string (struct t_gui_buffer *buffer, char *string, int pos)
buffer->input_buffer_pos += length;
- string2 = (char *) malloc (size + 2);
+ string2 = (char *)malloc (size + 2);
if (string2)
{
snprintf (string2, size + 2, "*%s", string);
@@ -510,10 +512,10 @@ gui_exec_action_raw_data (struct t_gui_window *window, char *actions)
gui_window_switch_to_buffer (ptr_win,
gui_buffer_before_raw_data);
}
- gui_buffer_free (ptr_buffer, 0);
+ gui_buffer_close (ptr_buffer, 0);
}
else
- gui_buffer_free (window->buffer, 1);
+ gui_buffer_close (window->buffer, 1);
gui_window_redraw_buffer (window->buffer);
return;
break;
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index 54aebd3da..18fb98d4a 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -20,7 +20,7 @@
#ifndef __WEECHAT_GUI_INPUT_H
#define __WEECHAT_GUI_INPUT_H 1
-#include "gui-buffer.h"
+struct t_gui_buffer;
/* input variables */
@@ -28,16 +28,18 @@ extern char *gui_input_clipboard;
/* input functions */
-extern void gui_input_optimize_size (struct t_gui_buffer *);
-extern void gui_input_init_color_mask (struct t_gui_buffer *);
-extern void gui_input_move (struct t_gui_buffer *, char *, char *, int );
-extern int gui_input_insert_string (struct t_gui_buffer *, char *, int);
-extern void gui_input_complete (struct t_gui_buffer *);
-extern void gui_input_delete_line (struct t_gui_buffer *);
-extern int gui_input_get_prompt_length (struct t_gui_buffer *);
+extern void gui_input_optimize_size (struct t_gui_buffer *buffer);
+extern void gui_input_init_color_mask (struct t_gui_buffer *buffer);
+extern void gui_input_move (struct t_gui_buffer *buffer, char *target,
+ char *source, int size);
+extern int gui_input_insert_string (struct t_gui_buffer *buffer, char *string,
+ int pos);
+extern void gui_input_complete (struct t_gui_buffer *buffer);
+extern void gui_input_delete_line (struct t_gui_buffer *buffer);
+extern int gui_input_get_prompt_length (struct t_gui_buffer *buffer);
/* input functions (GUI dependent) */
-extern void gui_input_draw (struct t_gui_buffer *, int);
+extern void gui_input_draw (struct t_gui_buffer *buffer, int erase);
#endif /* gui-input.h */
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c
index edc519042..3c52f729e 100644
--- a/src/gui/gui-keyboard.c
+++ b/src/gui/gui-keyboard.c
@@ -34,6 +34,7 @@
#include "../plugins/plugin.h"
#include "gui-keyboard.h"
#include "gui-action.h"
+#include "gui-buffer.h"
#include "gui-completion.h"
#include "gui-input.h"
#include "gui-window.h"
@@ -244,7 +245,7 @@ gui_keyboard_get_internal_code (char *key)
{
char *result;
- if ((result = (char *) malloc (strlen (key) + 1)))
+ if ((result = (char *)malloc (strlen (key) + 1)))
{
result[0] = '\0';
while (key[0])
@@ -287,7 +288,7 @@ gui_keyboard_get_expanded_name (char *key)
{
char *result;
- if ((result = (char *) malloc ((strlen (key) * 5) + 1)))
+ if ((result = (char *)malloc ((strlen (key) * 5) + 1)))
{
result[0] = '\0';
while (key[0])
@@ -390,7 +391,7 @@ gui_keyboard_new (char *key, char *command, t_gui_key_func *function, char *args
char *internal_code;
int length;
- if ((new_key = (t_gui_key *) malloc (sizeof (t_gui_key))))
+ if ((new_key = (t_gui_key *)malloc (sizeof (t_gui_key))))
{
internal_code = gui_keyboard_get_internal_code (key);
new_key->key = (internal_code) ? strdup (internal_code) : strdup (key);
@@ -750,7 +751,7 @@ gui_keyboard_buffer_reset ()
{
gui_keyboard_buffer_alloc = GUI_KEYBOARD_BUFFER_BLOCK_SIZE;
gui_keyboard_buffer_size = 0;
- gui_keyboard_buffer = (int *) malloc (gui_keyboard_buffer_alloc);
+ gui_keyboard_buffer = (int *)malloc (gui_keyboard_buffer_alloc);
}
else
{
diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h
index c7e048edd..556e93a00 100644
--- a/src/gui/gui-keyboard.h
+++ b/src/gui/gui-keyboard.h
@@ -24,7 +24,7 @@
/* keyboard structures */
-typedef void (t_gui_key_func)(char *);
+typedef void (t_gui_key_func)(char *args);
typedef struct t_gui_key t_gui_key;
@@ -52,7 +52,7 @@ struct t_gui_key_function
extern t_gui_key *gui_keys;
extern t_gui_key *last_gui_key;
extern t_gui_key_function gui_key_functions[];
-extern char gui_key_combo_buffer[128];
+extern char gui_key_combo_buffer[];
extern int gui_key_grab;
extern int gui_key_grab_count;
extern int *gui_keyboard_buffer;
@@ -65,18 +65,18 @@ extern time_t gui_keyboard_last_activity_time;
extern void gui_keyboard_init ();
extern void gui_keyboard_grab_init ();
extern void gui_keyboard_grab_end ();
-extern char *gui_keyboard_get_internal_code (char *);
-extern char *gui_keyboard_get_expanded_name (char *);
-extern t_gui_key *gui_keyboard_search (char *);
-extern t_gui_key_func *gui_keyboard_function_search_by_name (char *);
-extern char *gui_keyboard_function_search_by_ptr (t_gui_key_func *);
-extern t_gui_key *gui_keyboard_bind (char *, char *);
-extern int gui_keyboard_unbind (char *);
-extern int gui_keyboard_pressed (char *);
-extern void gui_keyboard_free (t_gui_key *);
+extern char *gui_keyboard_get_internal_code (char *key);
+extern char *gui_keyboard_get_expanded_name (char *key);
+extern t_gui_key *gui_keyboard_search (char *key);
+extern t_gui_key_func *gui_keyboard_function_search_by_name (char *name);
+extern char *gui_keyboard_function_search_by_ptr (t_gui_key_func *function);
+extern t_gui_key *gui_keyboard_bind (char *key, char *command);
+extern int gui_keyboard_unbind (char *key);
+extern int gui_keyboard_pressed (char *key_str);
+extern void gui_keyboard_free (t_gui_key *key);
extern void gui_keyboard_free_all ();
extern void gui_keyboard_buffer_reset ();
-extern void gui_keyboard_buffer_add (int);
+extern void gui_keyboard_buffer_add (int key);
extern int gui_keyboard_get_paste_lines ();
extern void gui_keyboard_paste_accept ();
extern void gui_keyboard_paste_cancel ();
diff --git a/src/gui/gui-main.h b/src/gui/gui-main.h
index 04c3f2e24..f47c4965c 100644
--- a/src/gui/gui-main.h
+++ b/src/gui/gui-main.h
@@ -23,7 +23,7 @@
/* main functions (GUI dependent) */
extern void gui_main_loop ();
-extern void gui_main_pre_init (int *, char **[]);
+extern void gui_main_pre_init (int *argc, char **argv[]);
extern void gui_main_init ();
extern void gui_main_end ();
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c
index 03109d931..1433c5641 100644
--- a/src/gui/gui-nicklist.c
+++ b/src/gui/gui-nicklist.c
@@ -36,6 +36,8 @@
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
#include "gui-nicklist.h"
+#include "gui-buffer.h"
+#include "gui-color.h"
/*
@@ -171,9 +173,10 @@ gui_nicklist_search (struct t_gui_buffer *buffer, char *nick)
struct t_gui_nick *
gui_nicklist_add (struct t_gui_buffer *buffer, char *nick, int sort_index,
- int color_nick, char prefix, int color_prefix)
+ char *color_nick, char prefix, char *color_prefix)
{
struct t_gui_nick *new_nick;
+ int num_color_nick, num_color_prefix;
if (!nick || gui_nicklist_search (buffer, nick))
return NULL;
@@ -182,11 +185,19 @@ gui_nicklist_add (struct t_gui_buffer *buffer, char *nick, int sort_index,
if (!new_nick)
return NULL;
+ num_color_nick = gui_color_search_config (color_nick);
+ if (num_color_nick < 0)
+ num_color_nick = GUI_COLOR_NICKLIST;
+
+ num_color_prefix = gui_color_search_config (color_prefix);
+ if (num_color_prefix < 0)
+ num_color_prefix = GUI_COLOR_NICKLIST;
+
new_nick->nick = strdup (nick);
new_nick->sort_index = sort_index;
- new_nick->color_nick = color_nick;
+ new_nick->color_nick = num_color_nick;
new_nick->prefix = prefix;
- new_nick->color_prefix = color_prefix;
+ new_nick->color_prefix = num_color_prefix;
gui_nicklist_insert_sorted (buffer, new_nick);
@@ -202,20 +213,30 @@ gui_nicklist_add (struct t_gui_buffer *buffer, char *nick, int sort_index,
void
gui_nicklist_update (struct t_gui_buffer *buffer, struct t_gui_nick *nick,
char *new_nick, int sort_index,
- int color_nick, char prefix, int color_prefix)
+ char *color_nick, char prefix, char *color_prefix)
{
+ int num_color_nick, num_color_prefix;
+
if (!nick)
return;
+ num_color_nick = gui_color_search_config (color_nick);
+ if (num_color_nick < 0)
+ num_color_nick = GUI_COLOR_NICKLIST;
+
+ num_color_prefix = gui_color_search_config (color_prefix);
+ if (num_color_prefix < 0)
+ num_color_prefix = GUI_COLOR_NICKLIST;
+
if (new_nick)
{
free (nick->nick);
nick->nick = strdup (new_nick);
}
nick->sort_index = sort_index;
- nick->color_nick = color_nick;
+ nick->color_nick = num_color_nick;
nick->prefix = prefix;
- nick->color_prefix = color_prefix;
+ nick->color_prefix = num_color_prefix;
gui_nicklist_resort (buffer, nick);
}
diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h
index b9cf4bd3b..a69a086b6 100644
--- a/src/gui/gui-nicklist.h
+++ b/src/gui/gui-nicklist.h
@@ -20,22 +20,40 @@
#ifndef __WEECHAT_GUI_NICKLIST_H
#define __WEECHAT_GUI_NICKLIST_H 1
-#include "gui-buffer.h"
+struct t_gui_buffer;
+
+struct t_gui_nick
+{
+ char *nick; /* nickname */
+ int sort_index; /* index to force sort */
+ int color_nick; /* color for nick in nicklist */
+ char prefix; /* prefix for nick (for admins, ..) */
+ int color_prefix; /* color for prefix */
+ struct t_gui_nick *prev_nick; /* link to previous nick in nicklist */
+ struct t_gui_nick *next_nick; /* link to next nick in nicklist */
+};
/* nicklist functions */
-extern struct t_gui_nick *gui_nicklist_search (struct t_gui_buffer *, char *);
-extern struct t_gui_nick *gui_nicklist_add (struct t_gui_buffer *, char *,
- int, int, char, int);
-extern void gui_nicklist_update (struct t_gui_buffer *, struct t_gui_nick *,
- char *, int, int, char, int);
-extern void gui_nicklist_free (struct t_gui_buffer *, struct t_gui_nick *);
-extern void gui_nicklist_free_all (struct t_gui_buffer *);
-extern int gui_nicklist_remove (struct t_gui_buffer *, char *);
-extern int gui_nicklist_get_max_length (struct t_gui_buffer *);
+extern struct t_gui_nick *gui_nicklist_search (struct t_gui_buffer *buffer,
+ char *nick);
+extern struct t_gui_nick *gui_nicklist_add (struct t_gui_buffer *buffer,
+ char *nick,
+ int sort_index, char *color_nick,
+ char prefix, char *color_prefix);
+extern void gui_nicklist_update (struct t_gui_buffer *buffer,
+ struct t_gui_nick *nick,
+ char *new_nick, int sort_index,
+ char *color_nick, char prefix,
+ char *color_prefix);
+extern void gui_nicklist_free (struct t_gui_buffer *buffer,
+ struct t_gui_nick *nick);
+extern void gui_nicklist_free_all (struct t_gui_buffer *buffer);
+extern int gui_nicklist_remove (struct t_gui_buffer *buffer, char *nick);
+extern int gui_nicklist_get_max_length (struct t_gui_buffer *buffer);
/* nicklist functions (GUI dependent) */
-extern void gui_nicklist_draw (struct t_gui_buffer *, int);
+extern void gui_nicklist_draw (struct t_gui_buffer *buffer, int erase);
#endif /* gui-nicklist.h */
diff --git a/src/gui/gui-status.h b/src/gui/gui-status.h
index 0c19d6b36..706ef1a5b 100644
--- a/src/gui/gui-status.h
+++ b/src/gui/gui-status.h
@@ -20,10 +20,10 @@
#ifndef __WEECHAT_GUI_STATUS_H
#define __WEECHAT_GUI_STATUS_H 1
-#include "gui-buffer.h"
+struct t_gui_buffer;
/* statusbar functions (GUI dependent) */
-extern void gui_status_draw (struct t_gui_buffer *, int);
+extern void gui_status_draw (struct t_gui_buffer *buffer, int erase);
#endif /* gui-status.h */
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index 258a7154d..d5034935a 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -37,6 +37,7 @@
#include "../core/wee-log.h"
#include "../core/wee-utf8.h"
#include "gui-window.h"
+#include "gui-buffer.h"
#include "gui-chat.h"
#include "gui-input.h"
#include "gui-hotlist.h"
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index e1aab192c..073e89929 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -123,61 +123,68 @@ extern struct t_gui_window *gui_current_window;
extern struct t_gui_window_tree *gui_windows_tree;
/* window functions */
-extern int gui_window_tree_init (struct t_gui_window *);
-extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *,
- struct t_gui_window *);
-extern void gui_window_tree_free (struct t_gui_window_tree **);
-extern struct t_gui_window *gui_window_new (struct t_gui_window *, int, int,
- int, int, int, int);
-extern void gui_window_free (struct t_gui_window *);
-extern struct t_gui_window *gui_window_search_by_buffer (struct t_gui_buffer *);
-extern void gui_window_switch_server (struct t_gui_window *);
-extern void gui_window_switch_previous (struct t_gui_window *);
-extern void gui_window_switch_next (struct t_gui_window *);
-extern void gui_window_switch_by_buffer (struct t_gui_window *, int);
-extern void gui_window_scroll (struct t_gui_window *, char *);
-extern void gui_window_search_start (struct t_gui_window *);
-extern void gui_window_search_restart (struct t_gui_window *);
-extern void gui_window_search_stop (struct t_gui_window *);
-extern int gui_window_search_text (struct t_gui_window *);
+extern int gui_window_tree_init (struct t_gui_window *window);
+extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *node,
+ struct t_gui_window *window);
+extern void gui_window_tree_free (struct t_gui_window_tree **tree);
+extern struct t_gui_window *gui_window_new (struct t_gui_window *parent,
+ int x, int y, int width, int height,
+ int width_pct, int height_pct);
+extern void gui_window_free (struct t_gui_window *window);
+extern struct t_gui_window *gui_window_search_by_buffer (struct t_gui_buffer *buffer);
+extern void gui_window_switch_server (struct t_gui_window *window);
+extern void gui_window_switch_previous (struct t_gui_window *window);
+extern void gui_window_switch_next (struct t_gui_window *window);
+extern void gui_window_switch_by_buffer (struct t_gui_window *window,
+ int buffer_number);
+extern void gui_window_scroll (struct t_gui_window *window, char *scroll);
+extern void gui_window_search_start (struct t_gui_window *window);
+extern void gui_window_search_restart (struct t_gui_window *window);
+extern void gui_window_search_stop (struct t_gui_window *window);
+extern int gui_window_search_text (struct t_gui_window *window);
extern void gui_window_print_log ();
/* window functions (GUI dependent) */
extern int gui_window_get_width ();
extern int gui_window_get_height ();
-extern int gui_window_objects_init (struct t_gui_window *);
-extern void gui_window_objects_free (struct t_gui_window *, int);
-extern int gui_window_calculate_pos_size (struct t_gui_window *, int);
-extern void gui_window_redraw_buffer (struct t_gui_buffer *);
+extern int gui_window_objects_init (struct t_gui_window *window);
+extern void gui_window_objects_free (struct t_gui_window *window,
+ int free_separator);
+extern int gui_window_calculate_pos_size (struct t_gui_window *window,
+ int force_calculate);
+extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer);
extern void gui_window_redraw_all_buffers ();
-extern void gui_window_switch_to_buffer (struct t_gui_window *, struct t_gui_buffer *);
-extern void gui_window_page_up (struct t_gui_window *);
-extern void gui_window_page_down (struct t_gui_window *);
-extern void gui_window_scroll_up (struct t_gui_window *);
-extern void gui_window_scroll_down (struct t_gui_window *);
-extern void gui_window_scroll_top (struct t_gui_window *);
-extern void gui_window_scroll_bottom (struct t_gui_window *);
-extern void gui_window_scroll_topic_left (struct t_gui_window *);
-extern void gui_window_scroll_topic_right (struct t_gui_window *);
-extern void gui_window_nick_beginning (struct t_gui_window *);
-extern void gui_window_nick_end (struct t_gui_window *);
-extern void gui_window_nick_page_up (struct t_gui_window *);
-extern void gui_window_nick_page_down (struct t_gui_window *);
-extern void gui_window_init_subwindows (struct t_gui_window *);
+extern void gui_window_switch_to_buffer (struct t_gui_window *window,
+ struct t_gui_buffer *buffer);
+extern void gui_window_page_up (struct t_gui_window *window);
+extern void gui_window_page_down (struct t_gui_window *window);
+extern void gui_window_scroll_up (struct t_gui_window *window);
+extern void gui_window_scroll_down (struct t_gui_window *window);
+extern void gui_window_scroll_top (struct t_gui_window *window);
+extern void gui_window_scroll_bottom (struct t_gui_window *window);
+extern void gui_window_scroll_topic_left (struct t_gui_window *window);
+extern void gui_window_scroll_topic_right (struct t_gui_window *window);
+extern void gui_window_nick_beginning (struct t_gui_window *window);
+extern void gui_window_nick_end (struct t_gui_window *window);
+extern void gui_window_nick_page_up (struct t_gui_window *window);
+extern void gui_window_nick_page_down (struct t_gui_window *window);
+extern void gui_window_init_subwindows (struct t_gui_window *window);
extern void gui_window_refresh_windows ();
-extern void gui_window_split_horiz (struct t_gui_window *, int);
-extern void gui_window_split_vertic (struct t_gui_window *, int);
-extern void gui_window_resize (struct t_gui_window *, int);
-extern int gui_window_merge (struct t_gui_window *);
-extern void gui_window_merge_all (struct t_gui_window *);
-extern void gui_window_switch_up (struct t_gui_window *);
-extern void gui_window_switch_down (struct t_gui_window *);
-extern void gui_window_switch_left (struct t_gui_window *);
-extern void gui_window_switch_right (struct t_gui_window *);
+extern void gui_window_split_horiz (struct t_gui_window *window,
+ int pourcentage);
+extern void gui_window_split_vertic (struct t_gui_window *window,
+ int pourcentage);
+extern void gui_window_resize (struct t_gui_window *window, int pourcentage);
+extern int gui_window_merge (struct t_gui_window *window);
+extern void gui_window_merge_all (struct t_gui_window *window);
+extern void gui_window_switch_up (struct t_gui_window *window);
+extern void gui_window_switch_down (struct t_gui_window *window);
+extern void gui_window_switch_left (struct t_gui_window *window);
+extern void gui_window_switch_right (struct t_gui_window *window);
extern void gui_window_refresh_screen ();
extern void gui_window_title_set ();
extern void gui_window_title_reset ();
-extern void gui_window_objects_print_log (struct t_gui_window *);
+extern void gui_window_objects_print_log (struct t_gui_window *window);
#endif /* gui-window.h */
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index 0908832da..d8d9f8174 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -79,7 +79,7 @@ alias_add_word (char **alias, int *length, char *word)
if (*alias == NULL)
{
- *alias = (char *) malloc (length_word + 1);
+ *alias = (char *)malloc (length_word + 1);
strcpy (*alias, word);
}
else
@@ -174,7 +174,7 @@ alias_replace_args (char *alias_args, char *user_args)
*/
int
-alias_cb (void *data, void *buffer, int argc, char **argv,
+alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
char **argv_eol)
{
struct t_alias *ptr_alias;
@@ -219,7 +219,7 @@ alias_cb (void *data, void *buffer, int argc, char **argv,
weechat_command (buffer, args_replaced);
else
{
- alias_command = (char *) malloc (1 + strlen(args_replaced) + 1);
+ alias_command = (char *)malloc (1 + strlen(args_replaced) + 1);
if (alias_command)
{
strcpy (alias_command, "/");
@@ -239,7 +239,7 @@ alias_cb (void *data, void *buffer, int argc, char **argv,
length1 = strlen (*ptr_cmd);
length2 = strlen (argv_eol[1]);
- alias_command = (char *) malloc ( 1 + length1 + 1 + length2 + 1);
+ alias_command = (char *)malloc ( 1 + length1 + 1 + length2 + 1);
if (alias_command)
{
if (*ptr_cmd[0] != '/')
@@ -261,7 +261,7 @@ alias_cb (void *data, void *buffer, int argc, char **argv,
(void) weechat_command(buffer, *ptr_cmd);
else
{
- alias_command = (char *) malloc (1 + strlen (*ptr_cmd) + 1);
+ alias_command = (char *)malloc (1 + strlen (*ptr_cmd) + 1);
if (alias_command)
{
strcpy (alias_command, "/");
@@ -307,7 +307,7 @@ alias_new (char *name, char *command)
return ptr_alias;
}
- if ((new_alias = ((struct t_alias *) malloc (sizeof (struct t_alias)))))
+ if ((new_alias = ((struct t_alias *)malloc (sizeof (struct t_alias)))))
{
new_hook = weechat_hook_command (name, "[alias]", NULL, NULL, NULL,
alias_cb, new_alias);
@@ -419,7 +419,8 @@ alias_free_all ()
*/
void
-alias_config_read_line (void *config_file, char *option_name, char *value)
+alias_config_read_line (struct t_config_file *config_file, char *option_name,
+ char *value)
{
/* make C compiler happy */
(void) config_file;
@@ -444,7 +445,8 @@ alias_config_read_line (void *config_file, char *option_name, char *value)
*/
void
-alias_config_write_section (void *config_file, char *section_name)
+alias_config_write_section (struct t_config_file *config_file,
+ char *section_name)
{
struct t_alias *ptr_alias;
@@ -465,7 +467,8 @@ alias_config_write_section (void *config_file, char *section_name)
*/
void
-alias_config_write_default_aliases (void *config_file, char *section_name)
+alias_config_write_default_aliases (struct t_config_file *config_file,
+ char *section_name)
{
weechat_config_write_line (config_file, section_name, NULL);
@@ -537,12 +540,12 @@ alias_config_read ()
*/
int
-alias_config_reload_signal_cb (void *data, char *signal, void *pointer)
+alias_config_reload_signal_cb (void *data, char *signal, void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
- (void) pointer;
+ (void) signal_data;
alias_free_all ();
if (weechat_config_reload (alias_config_file) == 0)
@@ -574,8 +577,8 @@ alias_config_write ()
*/
int
-alias_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *alias_name;
struct t_alias *ptr_alias;
@@ -655,8 +658,8 @@ alias_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-unalias_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *alias_name;
struct t_alias *ptr_alias;
@@ -692,7 +695,8 @@ unalias_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-alias_completion_cb (void *data, char *completion, void *buffer, void *list)
+alias_completion_cb (void *data, char *completion, struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_alias *ptr_alias;
diff --git a/src/plugins/aspell/aspell.c b/src/plugins/aspell/aspell.c
index 9e771423c..4c3774a8a 100644
--- a/src/plugins/aspell/aspell.c
+++ b/src/plugins/aspell/aspell.c
@@ -48,7 +48,7 @@ weechat_aspell_new_speller (void)
{
aspell_speller_t *s;
- s = (aspell_speller_t *) malloc (sizeof (aspell_speller_t));
+ s = (aspell_speller_t *)malloc (sizeof (aspell_speller_t));
if (!s)
{
weechat_aspell_plugin->print (weechat_aspell_plugin, NULL, NULL,
@@ -203,7 +203,7 @@ weechat_aspell_new_config (void)
{
aspell_config_t *c;
- c = (aspell_config_t *) malloc (sizeof (aspell_config_t));
+ c = (aspell_config_t *)malloc (sizeof (aspell_config_t));
if (!c)
{
weechat_aspell_plugin->print (weechat_aspell_plugin, NULL, NULL,
@@ -828,7 +828,7 @@ weechat_aspell_config_save (void)
if (found == 0)
{
n = strlen (servers) + strlen (p->server) + 2;
- servers = (char *) realloc (servers, n * sizeof (char));
+ servers = (char *)realloc (servers, n * sizeof (char));
strcat (servers, " ");
strcat (servers, p->server);
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, "servers", servers);
@@ -848,13 +848,13 @@ weechat_aspell_config_save (void)
else
{
n = strlen (channels) + strlen (q->channel) + 2;
- channels = (char *) realloc (channels, n * sizeof (char));
+ channels = (char *)realloc (channels, n * sizeof (char));
strcat (channels, " ");
strcat (channels, q->channel);
}
n = 7 + strlen (p->server) + strlen (q->channel);
- option = (char *) malloc ( n * sizeof (char));
+ option = (char *)malloc (n * sizeof (char));
snprintf (option, n, "lang_%s_%s", p->server, q->channel);
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, option, q->speller->lang);
free (option);
@@ -864,7 +864,7 @@ weechat_aspell_config_save (void)
if (channels)
{
n = 10 + strlen (p->server);
- option = (char *) malloc ( n * sizeof (char));
+ option = (char *)malloc (n * sizeof (char));
snprintf (option, n, "channels_%s", p->server);
weechat_aspell_plugin->set_plugin_config (weechat_aspell_plugin, option, channels);
free (option);
@@ -899,7 +899,7 @@ weechat_aspell_config_load(void)
for (i=0; i<s; i++)
{
n = 10 + strlen (servers_list[i]);
- option_s = (char *) malloc (n * sizeof (char));
+ option_s = (char *)malloc (n * sizeof (char));
snprintf (option_s, n, "channels_%s", servers_list[i]);
channels = weechat_aspell_plugin->get_plugin_config (weechat_aspell_plugin, option_s);
@@ -911,7 +911,7 @@ weechat_aspell_config_load(void)
for (j=0; j<c; j++)
{
n = 7 + strlen (servers_list[i]) + strlen (channels_list[j]);
- option_l = (char *) malloc (n * sizeof (char));
+ option_l = (char *)malloc (n * sizeof (char));
snprintf (option_l, n, "lang_%s_%s", servers_list[i], channels_list[j]);
lang = weechat_aspell_plugin->get_plugin_config (weechat_aspell_plugin, option_l);
@@ -1174,7 +1174,7 @@ weechat_aspell_clean_word (char *word, int *offset)
return NULL;
}
- w = (char *) malloc ((len+1) * sizeof(char));
+ w = (char *)malloc ((len+1) * sizeof(char));
if (w) {
memcpy (w, buffer + *offset, len);
diff --git a/src/plugins/aspell/aspell.h b/src/plugins/aspell/aspell.h
index e83804c56..ee31d76a0 100644
--- a/src/plugins/aspell/aspell.h
+++ b/src/plugins/aspell/aspell.h
@@ -18,8 +18,8 @@
/* weechat-aspell.h: Aspell plugin support for WeeChat */
-#ifndef WEECHAT_ASPELL__H
-#define WEECHAT_ASPELL__H 1
+#ifndef __WEECHAT_ASPELL_H
+#define __WEECHAT_ASPELL_H 1
#include <aspell.h>
@@ -192,4 +192,4 @@ cmds_keep_t cmd_tokeep[] =
{ NULL, 0}
};
-#endif /* WEECHAT_ASPELL__H */
+#endif /* aspell.h */
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index dd3ce4161..130585c18 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -48,8 +48,8 @@ struct t_weechat_plugin *weechat_demo_plugin = NULL;
*/
int
-demo_printf_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
/* make C compiler happy */
(void) data;
@@ -86,8 +86,8 @@ demo_printf_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-demo_infobar_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_infobar_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
/* make C compiler happy */
(void) data;
@@ -116,8 +116,8 @@ demo_buffer_input_data_cb (struct t_gui_buffer *buffer, char *data)
*/
int
-demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_gui_buffer *new_buffer;
@@ -132,6 +132,7 @@ demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
demo_buffer_input_data_cb);
if (new_buffer)
weechat_buffer_set (new_buffer, "display", "1");
+ weechat_hook_signal_send ("logger_backlog", new_buffer);
}
return WEECHAT_RC_OK;
@@ -142,7 +143,7 @@ demo_buffer_command_cb (void *data, void *buffer, int argc, char **argv,
*/
void
-demo_infolist_print (void *infolist, char *item_name)
+demo_infolist_print (struct t_plugin_infolist *infolist, char *item_name)
{
char *fields, **argv;
int i, j, argc;
@@ -202,8 +203,8 @@ demo_infolist_print (void *infolist, char *item_name)
*/
int
-demo_infolist_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_infolist_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_plugin_infolist *infolist;
@@ -250,8 +251,8 @@ demo_infolist_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-demo_info_command_cb (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
/* make C compiler happy */
(void) data;
@@ -278,14 +279,14 @@ demo_info_command_cb (void *data, void *buffer, int argc, char **argv,
*/
int
-demo_signal_cb (void *data, char *signal, void *pointer)
+demo_signal_cb (void *data, char *signal, void *signal_data)
{
/* make C compiler happy */
(void) data;
weechat_printf (NULL,
- _("demo_signal: signal: %s, pointer: %X"),
- signal, pointer);
+ _("demo_signal: signal: %s, signal_data: %X"),
+ signal, signal_data);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/fifo/fifo.c b/src/plugins/fifo/fifo.c
index f6aaddd12..d894c5c89 100644
--- a/src/plugins/fifo/fifo.c
+++ b/src/plugins/fifo/fifo.c
@@ -49,19 +49,23 @@ char *fifo_unterminated = NULL;
/*
* fifo_create: create FIFO pipe for remote control
+ * return: 1 if ok
+ * 0 if error
*/
-void
+int
fifo_create ()
{
- int filename_length;
+ int rc, filename_length;
char *fifo_option, *weechat_home;
-
- fifo_option = weechat_plugin_config_get ("fifo");
+
+ rc = 0;
+
+ fifo_option = weechat_config_get_plugin ("fifo");
if (!fifo_option)
{
- weechat_plugin_config_set ("fifo", "on");
- fifo_option = weechat_plugin_config_get ("fifo");
+ weechat_config_set_plugin ("fifo", "on");
+ fifo_option = weechat_config_get_plugin ("fifo");
}
weechat_home = weechat_info_get ("weechat_dir");
@@ -75,8 +79,8 @@ fifo_create ()
if (!fifo_filename)
{
filename_length = strlen (weechat_home) + 64;
- fifo_filename = (char *) malloc (filename_length *
- sizeof (char));
+ fifo_filename = (char *)malloc (filename_length *
+ sizeof (char));
snprintf (fifo_filename, filename_length,
"%s/weechat_fifo_%d",
weechat_home, (int) getpid());
@@ -90,9 +94,12 @@ fifo_create ()
/* open FIFO pipe in read-only, non blockingmode */
if ((fifo_fd = open (fifo_filename,
O_RDONLY | O_NONBLOCK)) != -1)
+ {
weechat_printf (NULL,
_("%sFifo: pipe is open\n"),
weechat_prefix ("info"));
+ rc = 1;
+ }
else
weechat_printf (NULL,
_("%sFifo: unable to open pipe (%s) for "
@@ -108,10 +115,10 @@ fifo_create ()
fifo_filename);
}
}
- if (fifo_option)
- free (fifo_option);
if (weechat_home)
free (weechat_home);
+
+ return rc;
}
/*
@@ -168,6 +175,8 @@ fifo_exec (char *text)
{
pos_msg = text + 1;
ptr_buffer = weechat_buffer_search (NULL, NULL);
+ if (!ptr_buffer)
+ ptr_buffer = weechat_current_buffer;
}
else
{
@@ -198,6 +207,8 @@ fifo_exec (char *text)
}
else
ptr_buffer = weechat_buffer_search (NULL, text);
+ if (!ptr_buffer)
+ ptr_buffer = weechat_current_buffer;
}
}
@@ -232,8 +243,8 @@ fifo_read ()
ptr_buf = buffer;
if (fifo_unterminated)
{
- buf2 = (char *) malloc (strlen (fifo_unterminated) +
- strlen (buffer) + 1);
+ buf2 = (char *)malloc (strlen (fifo_unterminated) +
+ strlen (buffer) + 1);
if (buf2)
{
strcpy (buf2, fifo_unterminated);
@@ -292,7 +303,16 @@ fifo_read ()
weechat_unhook (fifo_fd_hook);
close (fifo_fd);
fifo_fd = open (fifo_filename, O_RDONLY | O_NONBLOCK);
- fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0, fifo_read, NULL);
+ if (fifo_fd < 0)
+ {
+ weechat_printf (NULL,
+ _("%sFifo: error opening file, closing it"),
+ weechat_prefix ("error"));
+ fifo_remove ();
+ }
+ else
+ fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
+ &fifo_read, NULL);
}
}
@@ -334,9 +354,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
{
weechat_plugin = plugin;
- fifo_create ();
-
- fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0, &fifo_read, NULL);
+ if (fifo_create ())
+ fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
+ &fifo_read, NULL);
weechat_hook_config ("plugin", "fifo.fifo", &fifo_config_cb, NULL);
diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h
index 88bd8eafa..600493bf5 100644
--- a/src/plugins/irc/irc-buffer.h
+++ b/src/plugins/irc/irc-buffer.h
@@ -42,9 +42,9 @@ struct t_irc_buffer_data
int all_servers;
};
-extern struct t_irc_buffer_data *irc_buffer_data_create (struct t_irc_server *);
-extern void irc_buffer_data_free (struct t_gui_buffer *);
-extern void irc_buffer_merge_servers (struct t_gui_window *);
-extern void irc_buffer_split_server (struct t_gui_window *);
+extern struct t_irc_buffer_data *irc_buffer_data_create (struct t_irc_server *server);
+extern void irc_buffer_data_free (struct t_gui_buffer *buffer);
+extern void irc_buffer_merge_servers (struct t_gui_window *window);
+extern void irc_buffer_split_server (struct t_gui_window *window);
#endif /* irc-buffer.h */
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index d3975bbb7..39a9b8ff7 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -48,7 +48,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
struct t_gui_buffer *new_buffer;
/* alloc memory for new channel */
- if ((new_channel = (struct t_irc_channel *) malloc (sizeof (struct t_irc_channel))) == NULL)
+ if ((new_channel = (struct t_irc_channel *)malloc (sizeof (struct t_irc_channel))) == NULL)
{
weechat_printf (NULL,
_("%sirc: cannot allocate new channel"),
@@ -88,7 +88,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
//new_buffer->notify_level = irc_channel_get_notify_level (server, new_channel);
/* add new channel to channels list */
- new_channel->prev_channel = ((struct t_irc_server *)server)->last_channel;
+ new_channel->prev_channel = server->last_channel;
new_channel->next_channel = NULL;
if (server->channels)
(server->last_channel)->next_channel = new_channel;
@@ -346,17 +346,17 @@ irc_channel_set_away (struct t_irc_channel *channel, char *nick, int is_away)
*/
int
-irc_channel_create_dcc (void *dcc)
+irc_channel_create_dcc (struct t_irc_dcc *dcc)
{
struct t_irc_channel *ptr_channel;
- ptr_channel = irc_channel_search_dcc (((struct t_irc_dcc *)dcc)->server,
- ((struct t_irc_dcc *)dcc)->nick);
+ ptr_channel = irc_channel_search_dcc (dcc->server, dcc->nick);
if (!ptr_channel)
{
- ptr_channel = irc_channel_new (((struct t_irc_dcc *)dcc)->server,
+ ptr_channel = irc_channel_new (dcc->server,
IRC_CHANNEL_TYPE_DCC_CHAT,
- ((struct t_irc_dcc *)dcc)->nick, 0);
+ dcc->nick,
+ 0);
if (!ptr_channel)
return 0;
}
@@ -366,7 +366,7 @@ irc_channel_create_dcc (void *dcc)
return 0;
ptr_channel->dcc_chat = dcc;
- ((struct t_irc_dcc *)dcc)->channel = ptr_channel;
+ dcc->channel = ptr_channel;
//gui_window_redraw_buffer (ptr_channel->buffer);
return 1;
}
@@ -395,7 +395,7 @@ irc_channel_get_notify_level (struct t_irc_server *server,
&& (server_default_notify == 1))
server_default_notify = 2;
- name = (char *) malloc (strlen (channel->name) + 2);
+ name = (char *)malloc (strlen (channel->name) + 2);
strcpy (name, channel->name);
strcat (name, ":");
pos = strstr (server->notify_levels, name);
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index eecce10c6..cd3c453e7 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -34,44 +34,58 @@
struct t_irc_channel
{
- int type; /* channel type */
- struct t_irc_dcc *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */
- char *name; /* name of channel (exemple: "#abc") */
- char *topic; /* topic of channel (host for private) */
- char *modes; /* channel modes */
- int limit; /* user limit (0 is limit not set) */
- char *key; /* channel key (NULL if no key is set) */
- int nicks_count; /* # nicks on channel (0 if dcc/pv) */
- int checking_away; /* = 1 if checking away with WHO cmd */
- char *away_message; /* to display away only once in private */
- int cycle; /* currently cycling (/part then /join) */
- int close; /* close request (/buffer close) */
- int display_creation_date; /* 1 if creation date should be displayed*/
- int nick_completion_reset; /* 1 if nick completion should be rebuilt*/
- /* there was some join/part on channel */
- struct t_irc_nick *nicks; /* nicks on the channel */
- struct t_irc_nick *last_nick; /* last nick on the channel */
- struct t_weelist *nicks_speaking; /* for smart completion */
- struct t_gui_buffer *buffer; /* buffer allocated for channel */
- struct t_irc_channel *prev_channel; /* link to previous channel */
- struct t_irc_channel *next_channel; /* link to next channel */
+ int type; /* channel type */
+ struct t_irc_dcc *dcc_chat; /* DCC CHAT pointer (NULL if not DCC)*/
+ char *name; /* name of channel (exemple: "#abc") */
+ char *topic; /* topic of channel (host for pv) */
+ char *modes; /* channel modes */
+ int limit; /* user limit (0 is limit not set) */
+ char *key; /* channel key (NULL if no key set) */
+ int nicks_count; /* # nicks on channel (0 if dcc/pv) */
+ int checking_away; /* = 1 if checking away with WHO cmd */
+ char *away_message; /* to display away only once in pv */
+ int cycle; /* currently cycling (/part + /join) */
+ int close; /* close request (/buffer close) */
+ int display_creation_date; /* 1 for displaying creation date */
+ int nick_completion_reset; /* 1 for resetting nick completion */
+ /* there was some join/part on chan */
+ struct t_irc_nick *nicks; /* nicks on the channel */
+ struct t_irc_nick *last_nick; /* last nick on the channel */
+ struct t_weelist *nicks_speaking; /* for smart completion */
+ struct t_gui_buffer *buffer; /* buffer allocated for channel */
+ struct t_irc_channel *prev_channel; /* link to previous channel */
+ struct t_irc_channel *next_channel; /* link to next channel */
};
-extern struct t_irc_channel *irc_channel_new (struct t_irc_server *, int, char *, int);
-extern void irc_channel_free (struct t_irc_server *, struct t_irc_channel *);
-extern void irc_channel_free_all (struct t_irc_server *);
-extern struct t_irc_channel *irc_channel_search (struct t_irc_server *, char *);
-extern struct t_irc_channel *irc_channel_search_any (struct t_irc_server *, char *);
-extern struct t_irc_channel *irc_channel_search_any_without_buffer (struct t_irc_server *, char *);
-extern struct t_irc_channel *irc_channel_search_dcc (struct t_irc_server *, char *);
-extern int irc_channel_is_channel (char *);
-extern void irc_channel_remove_away (struct t_irc_channel *);
-extern void irc_channel_check_away (struct t_irc_server *, struct t_irc_channel *, int);
-extern void irc_channel_set_away (struct t_irc_channel *, char *, int);
-extern int irc_channel_create_dcc (void *);
-extern int irc_channel_get_notify_level (struct t_irc_server *, struct t_irc_channel *);
-extern void irc_channel_set_notify_level (struct t_irc_server *, struct t_irc_channel *, int);
-extern void irc_channel_add_nick_speaking (struct t_irc_channel *, char *);
-extern void irc_channel_print_log (struct t_irc_channel *);
+extern struct t_irc_channel *irc_channel_new (struct t_irc_server *server,
+ int channel_type,
+ char *channel_name,
+ int switch_to_channel);
+extern void irc_channel_free (struct t_irc_server *server,
+ struct t_irc_channel *channel);
+extern void irc_channel_free_all (struct t_irc_server *server);
+extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
+ char *channel_name);
+extern struct t_irc_channel *irc_channel_search_any (struct t_irc_server *server,
+ char *channel_name);
+extern struct t_irc_channel *irc_channel_search_any_without_buffer (struct t_irc_server *server,
+ char *channel_name);
+extern struct t_irc_channel *irc_channel_search_dcc (struct t_irc_server *server,
+ char *channel_name);
+extern int irc_channel_is_channel (char *string);
+extern void irc_channel_remove_away (struct t_irc_channel *channel);
+extern void irc_channel_check_away (struct t_irc_server *server,
+ struct t_irc_channel *channel, int force);
+extern void irc_channel_set_away (struct t_irc_channel *channel, char *nick,
+ int is_away);
+extern int irc_channel_create_dcc (struct t_irc_dcc *dcc);
+extern int irc_channel_get_notify_level (struct t_irc_server *server,
+ struct t_irc_channel *channel);
+extern void irc_channel_set_notify_level (struct t_irc_server *server,
+ struct t_irc_channel *channel,
+ int notify);
+extern void irc_channel_add_nick_speaking (struct t_irc_channel *channel,
+ char *nick);
+extern void irc_channel_print_log (struct t_irc_channel *channel);
#endif /* irc-channel.h */
diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c
index 11fc52c7a..4a604f89a 100644
--- a/src/plugins/irc/irc-color.c
+++ b/src/plugins/irc/irc-color.c
@@ -40,7 +40,8 @@
*/
unsigned char *
-irc_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
+irc_color_decode (unsigned char *string, int keep_irc_colors,
+ int keep_weechat_attr)
{
/*unsigned char *out;
int out_length, out_pos, length;
diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h
index bee7f1426..7673bbd95 100644
--- a/src/plugins/irc/irc-color.h
+++ b/src/plugins/irc/irc-color.h
@@ -51,8 +51,10 @@
#define IRC_COLOR_UNDERLINE_CHAR '\x1F'
#define IRC_COLOR_UNDERLINE_STR "\x1F"
-extern unsigned char *irc_color_decode (unsigned char *, int, int);
-extern unsigned char *irc_color_decode_for_user_entry (unsigned char *);
-extern unsigned char *irc_color_encode (unsigned char *, int);
+extern unsigned char *irc_color_decode (unsigned char *string,
+ int keep_irc_colors,
+ int keep_weechat_attr);
+extern unsigned char *irc_color_decode_for_user_entry (unsigned char *string);
+extern unsigned char *irc_color_encode (unsigned char *string, int keep_colors);
#endif /* irc-color.h */
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index a0c064210..8ee43daff 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -45,8 +45,8 @@
*/
int
-irc_command_admin (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -143,8 +143,8 @@ irc_command_mode_nicks (struct t_irc_server *server, char *channel,
*/
int
-irc_command_ame (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ame (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
@@ -181,8 +181,8 @@ irc_command_ame (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_amsg (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_amsg (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
@@ -261,7 +261,7 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
{
if (server->away_message)
free (server->away_message);
- server->away_message = (char *) malloc (strlen (arguments) + 1);
+ server->away_message = (char *)malloc (strlen (arguments) + 1);
if (server->away_message)
strcpy (server->away_message, arguments);
@@ -376,8 +376,8 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
*/
int
-irc_command_away (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_away (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)
@@ -410,8 +410,8 @@ irc_command_away (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ban (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel;
int pos_args;
@@ -522,8 +522,8 @@ irc_command_connect_one_server (struct t_irc_server *server, int no_join)
*/
int
-irc_command_connect (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
struct t_irc_server server_tmp;
int i, nb_connect, connect_ok, all_servers, no_join, port, ipv6, ssl;
@@ -672,8 +672,8 @@ irc_command_connect (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ctcp (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos, *irc_cmd;
struct timeval tv;
@@ -760,8 +760,8 @@ irc_command_ctcp (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_cycle (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *channel_name, *pos_args, *ptr_arg, *buf, *version;
char **channels;
@@ -863,8 +863,8 @@ irc_command_cycle (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_dcc (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -872,6 +872,7 @@ irc_command_dcc (void *data, void *buffer, int argc, char **argv,
/* make compiler happy */
(void) data;
+ (void) argv_eol; // to remove!
if (argc > 1)
{
@@ -928,8 +929,8 @@ irc_command_dcc (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_dehalfop (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -965,8 +966,8 @@ irc_command_dehalfop (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_deop (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1002,8 +1003,8 @@ irc_command_deop (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_devoice (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1039,8 +1040,8 @@ irc_command_devoice (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_die (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_die (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1129,8 +1130,8 @@ irc_command_disconnect_one_server (struct t_irc_server *server)
*/
int
-irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_disconnect (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
int i, disconnect_ok;
@@ -1191,8 +1192,8 @@ irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_halfop (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1228,8 +1229,8 @@ irc_command_halfop (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_info (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_info (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1251,8 +1252,8 @@ irc_command_info (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_invite (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1287,8 +1288,8 @@ irc_command_invite (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ison (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1326,8 +1327,8 @@ irc_command_join_server (struct t_irc_server *server, char *arguments)
*/
int
-irc_command_join (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_join (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1352,8 +1353,8 @@ irc_command_join (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_kick (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel, *pos_nick, *pos_comment;
@@ -1418,8 +1419,8 @@ irc_command_kick (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_kickban (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel, *pos_nick, *pos_comment;
@@ -1486,8 +1487,8 @@ irc_command_kickban (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_kill (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1515,8 +1516,8 @@ irc_command_kill (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_links (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_links (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1539,8 +1540,8 @@ irc_command_links (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_list (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char buf[512];
int ret;
@@ -1562,7 +1563,7 @@ irc_command_list (void *data, void *buffer, int argc, char **argv,
if (argc > 1)
{
- ptr_server->cmd_list_regexp = (regex_t *) malloc (sizeof (regex_t));
+ ptr_server->cmd_list_regexp = (regex_t *)malloc (sizeof (regex_t));
if (ptr_server->cmd_list_regexp)
{
if ((ret = regcomp (ptr_server->cmd_list_regexp,
@@ -1600,8 +1601,8 @@ irc_command_list (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_lusers (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1624,7 +1625,7 @@ irc_command_lusers (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_me (void *data, void *buffer, int argc, char **argv,
+irc_command_me (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -1670,8 +1671,8 @@ irc_command_mode_server (struct t_irc_server *server, char *arguments)
*/
int
-irc_command_mode (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1696,8 +1697,8 @@ irc_command_mode (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_motd (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1720,8 +1721,8 @@ irc_command_motd (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_msg (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char **targets;
int num_targets, i;
@@ -1895,8 +1896,8 @@ irc_command_msg (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_names (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_names (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -1959,8 +1960,8 @@ irc_send_nick_server (struct t_irc_server *server, char *nickname)
*/
int
-irc_command_nick (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)
@@ -2003,8 +2004,8 @@ irc_command_nick (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_notice (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *string;
@@ -2045,7 +2046,7 @@ irc_command_notice (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_op (void *data, void *buffer, int argc, char **argv,
+irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -2082,8 +2083,8 @@ irc_command_op (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_oper (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_oper (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2108,8 +2109,8 @@ irc_command_oper (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_part (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *channel_name, *pos_args, *ptr_arg, *buf, *version;
@@ -2155,7 +2156,7 @@ irc_command_part (void *data, void *buffer, int argc, char **argv,
}
if (!ptr_channel->nicks)
{
- weechat_buffer_close (ptr_channel->buffer);
+ weechat_buffer_close (ptr_channel->buffer, 1);
ptr_channel->buffer = NULL;
irc_channel_free (ptr_server, ptr_channel);
//gui_status_draw (gui_current_window->buffer, 1);
@@ -2194,8 +2195,8 @@ irc_command_part (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_ping (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2220,8 +2221,8 @@ irc_command_ping (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_pong (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)
@@ -2246,8 +2247,8 @@ irc_command_pong (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_query (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *string;
@@ -2310,8 +2311,8 @@ irc_command_query (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_quote (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server)// || !ptr_server->is_connected)
@@ -2367,8 +2368,8 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join)
*/
int
-irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_reconnect (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
int i, nb_reconnect, reconnect_ok, all_servers, no_join;
@@ -2442,8 +2443,8 @@ irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_rehash (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2465,8 +2466,8 @@ irc_command_rehash (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_restart (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -2488,8 +2489,8 @@ irc_command_restart (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_server (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
int i, detailed_list, one_server_found;
struct t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
@@ -2568,7 +2569,7 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server add");
}
- if (irc_server_name_already_exists (argv[2]))
+ if (irc_server_search (argv[2]))
{
weechat_printf (NULL,
_("%sirc: server \"%s\" already exists, "
@@ -2974,8 +2975,8 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_service (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_service (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3000,8 +3001,8 @@ irc_command_service (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_servlist (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3024,8 +3025,8 @@ irc_command_servlist (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_squery (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3055,8 +3056,8 @@ irc_command_squery (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_squit (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3081,8 +3082,8 @@ irc_command_squit (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_stats (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3106,8 +3107,8 @@ irc_command_stats (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_summon (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3132,8 +3133,8 @@ irc_command_summon (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_time (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_time (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3156,8 +3157,8 @@ irc_command_time (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_topic (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *channel_name, *new_topic;
@@ -3219,8 +3220,8 @@ irc_command_topic (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_trace (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3243,8 +3244,8 @@ irc_command_trace (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_unban (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
char *pos_channel;
int pos_args;
@@ -3309,8 +3310,8 @@ irc_command_unban (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_userhost (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3335,8 +3336,8 @@ irc_command_userhost (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_users (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_users (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3359,8 +3360,8 @@ irc_command_users (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_version (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_version (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3391,8 +3392,8 @@ irc_command_version (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_voice (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3429,8 +3430,8 @@ irc_command_voice (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_wallops (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3455,8 +3456,8 @@ irc_command_wallops (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_who (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_who (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3479,8 +3480,8 @@ irc_command_who (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_whois (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
@@ -3505,8 +3506,8 @@ irc_command_whois (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_whowas (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
+irc_command_whowas (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
{
IRC_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index d4c4eb66a..dd9e98c79 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -20,7 +20,7 @@
#ifndef __WEECHAT_IRC_COMMAND_H
#define __WEECHAT_IRC_COMMAND_H 1
-#include "irc-server.h"
+struct t_irc_server;
#define IRC_COMMAND_TOO_FEW_ARGUMENTS(__buffer, __command) \
weechat_printf (__buffer, \
@@ -29,10 +29,14 @@
return WEECHAT_RC_ERROR;
-extern void irc_command_away_server (struct t_irc_server *, char *);
-extern void irc_command_join_server (struct t_irc_server *, char *);
-extern void irc_command_mode_server (struct t_irc_server *, char *);
-extern void irc_command_quit_server (struct t_irc_server *, char *);
+extern void irc_command_away_server (struct t_irc_server *server,
+ char *arguments);
+extern void irc_command_join_server (struct t_irc_server *server,
+ char *arguments);
+extern void irc_command_mode_server (struct t_irc_server *server,
+ char *arguments);
+extern void irc_command_quit_server (struct t_irc_server *server,
+ char *arguments);
extern void irc_command_init ();
#endif /* irc-command.h */
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 3e0eeb99f..82eb4e46f 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -40,8 +40,8 @@
*/
int
-irc_completion_server_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_server_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
IRC_GET_SERVER(buffer);
@@ -61,8 +61,9 @@ irc_completion_server_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_server_nicks_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_server_nicks_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_irc_server *ptr_server2;
struct t_irc_channel *ptr_channel2;
@@ -117,8 +118,8 @@ irc_completion_server_nicks_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_servers_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_servers_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
struct t_irc_server *ptr_server;
@@ -141,8 +142,8 @@ irc_completion_servers_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channel_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -162,8 +163,9 @@ irc_completion_channel_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channel_nicks_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_nicks_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_irc_nick *ptr_nick;
char *nick;
@@ -218,8 +220,9 @@ irc_completion_channel_nicks_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channel_nicks_hosts_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_nicks_hosts_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
struct t_irc_nick *ptr_nick;
char *buf;
@@ -243,7 +246,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, char *completion, void *buffe
{
length = strlen (ptr_nick->nick) + 1 +
strlen (ptr_nick->host) + 1;
- buf = (char *) malloc (length);
+ buf = (char *)malloc (length);
if (buf)
{
snprintf (buf, length, "%s!%s",
@@ -270,8 +273,9 @@ irc_completion_channel_nicks_hosts_cb (void *data, char *completion, void *buffe
*/
int
-irc_completion_channel_topic_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channel_topic_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list)
{
IRC_GET_SERVER_CHANNEL(buffer);
@@ -292,8 +296,8 @@ irc_completion_channel_topic_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_channels_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_channels_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
@@ -321,8 +325,8 @@ irc_completion_channels_cb (void *data, char *completion, void *buffer,
*/
int
-irc_completion_msg_part_cb (void *data, char *completion, void *buffer,
- void *list)
+irc_completion_msg_part_cb (void *data, char *completion,
+ struct t_gui_buffer *buffer, struct t_weelist *list)
{
/* make C compiler happy */
(void) data;
@@ -339,3 +343,25 @@ irc_completion_msg_part_cb (void *data, char *completion, void *buffer,
return WEECHAT_RC_OK;
}
+
+/*
+ * irc_completion_init: init completion for IRC plugin
+ */
+
+void
+irc_completion_init ()
+{
+ weechat_hook_completion ("irc_server", &irc_completion_server_cb, NULL);
+ weechat_hook_completion ("irc_server_nicks",
+ &irc_completion_server_nicks_cb, NULL);
+ weechat_hook_completion ("irc_servers", &irc_completion_servers_cb, NULL);
+ weechat_hook_completion ("irc_channel", &irc_completion_channel_cb, NULL);
+ weechat_hook_completion ("irc_channel_nicks",
+ &irc_completion_channel_nicks_cb, NULL);
+ weechat_hook_completion ("irc_channel_nicks_hosts",
+ &irc_completion_channel_nicks_hosts_cb, NULL);
+ weechat_hook_completion ("irc_channel_topic",
+ &irc_completion_channel_topic_cb, NULL);
+ weechat_hook_completion ("irc_channels", &irc_completion_channels_cb, NULL);
+ weechat_hook_completion ("irc_msg_part", &irc_completion_msg_part_cb, NULL);
+}
diff --git a/src/plugins/irc/irc-completion.h b/src/plugins/irc/irc-completion.h
index c0d2b250c..351c0cc97 100644
--- a/src/plugins/irc/irc-completion.h
+++ b/src/plugins/irc/irc-completion.h
@@ -20,15 +20,6 @@
#ifndef __WEECHAT_IRC_COMPLETION_H
#define __WEECHAT_IRC_COMPLETION_H 1
-extern int irc_completion_server_cb (void *, char *, void *, void *);
-extern int irc_completion_server_nicks_cb (void *, char *, void *, void *);
-extern int irc_completion_servers_cb (void *, char *, void *, void *);
-extern int irc_completion_channel_cb (void *, char *, void *, void *);
-extern int irc_completion_channel_nicks_cb (void *, char *, void *, void *);
-extern int irc_completion_channel_nicks_hosts_cb (void *, char *, void *,
- void *);
-extern int irc_completion_channel_topic_cb (void *, char *, void *, void *);
-extern int irc_completion_channels_cb (void *, char *, void *, void *);
-extern int irc_completion_msg_part_cb (void *, char *, void *, void *);
+extern void irc_completion_init ();
#endif /* irc-completion.h */
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 7d8f9192d..d3c0ae443 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -211,7 +211,8 @@ irc_config_change_notify_levels ()
*/
void
-irc_config_read_server_line (void *config_file, char *option_name, char *value)
+irc_config_read_server_line (struct t_config_file *config_file,
+ char *option_name, char *value)
{
struct t_config_option *ptr_option;
int rc;
@@ -228,7 +229,7 @@ irc_config_read_server_line (void *config_file, char *option_name, char *value)
option_name);
if (ptr_option)
{
- rc = weechat_config_option_set (ptr_option, value);
+ rc = weechat_config_option_set (ptr_option, value, 0);
switch (rc)
{
case 2:
@@ -280,7 +281,8 @@ irc_config_read_server_line (void *config_file, char *option_name, char *value)
*/
void
-irc_config_write_servers (void *config_file, char *section_name)
+irc_config_write_servers (struct t_config_file *config_file,
+ char *section_name)
{
struct t_irc_server *ptr_server;
@@ -337,7 +339,8 @@ irc_config_write_servers (void *config_file, char *section_name)
*/
void
-irc_config_write_server_default (void *config_file, char *section_name)
+irc_config_write_server_default (struct t_config_file *config_file,
+ char *section_name)
{
struct passwd *my_passwd;
char *realname, *pos;
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index b1cf9756e..405f7bb8f 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -67,11 +67,6 @@ struct t_config_option *irc_config_log_auto_channel;
struct t_config_option *irc_config_log_auto_private;
struct t_config_option *irc_config_log_hide_nickserv_pwd;
-void irc_config_change_noop ();
-void irc_config_change_one_server_buffer ();
-void irc_config_change_away_check ();
-void irc_config_change_log ();
-void irc_config_change_notify_levels ();
int irc_config_init ();
int irc_config_read ();
int irc_config_reload_cb ();
diff --git a/src/plugins/irc/irc-dcc.c b/src/plugins/irc/irc-dcc.c
index 01da53991..4c84000aa 100644
--- a/src/plugins/irc/irc-dcc.c
+++ b/src/plugins/irc/irc-dcc.c
@@ -169,9 +169,9 @@ irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
return;
}
- ptr_dcc->local_filename = (char *) malloc (strlen (dir2) +
- strlen (ptr_dcc->nick) +
- strlen (ptr_dcc->filename) + 4);
+ ptr_dcc->local_filename = (char *)malloc (strlen (dir2) +
+ strlen (ptr_dcc->nick) +
+ strlen (ptr_dcc->filename) + 4);
if (!ptr_dcc->local_filename)
return;
@@ -201,7 +201,7 @@ irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
return;
}
- filename2 = (char *) malloc (strlen (ptr_dcc->local_filename) + 16);
+ filename2 = (char *)malloc (strlen (ptr_dcc->local_filename) + 16);
if (!filename2)
{
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
@@ -367,49 +367,49 @@ irc_dcc_connect (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_free (struct t_irc_dcc *ptr_dcc)
+irc_dcc_free (struct t_irc_dcc *dcc)
{
struct t_irc_dcc *new_dcc_list;
- if (!ptr_dcc)
+ if (!dcc)
return;
/* DCC CHAT with channel => remove channel
(to prevent channel from becoming standard pv) */
- if (ptr_dcc->channel)
+ if (dcc->channel)
{
/* check if channel is used for another active DCC CHAT */
- if (!ptr_dcc->channel->dcc_chat
- || (IRC_DCC_ENDED(ptr_dcc->channel->dcc_chat->status)))
+ if (!dcc->channel->dcc_chat
+ || (IRC_DCC_ENDED(dcc->channel->dcc_chat->status)))
{
- gui_buffer_free (ptr_dcc->channel->buffer, 1);
- if (ptr_dcc->channel)
- irc_channel_free (ptr_dcc->server, ptr_dcc->channel);
+ gui_buffer_free (dcc->channel->buffer, 1);
+ if (dcc->channel)
+ irc_channel_free (dcc->server, dcc->channel);
}
}
/* remove DCC from list */
- if (irc_last_dcc == ptr_dcc)
- irc_last_dcc = ptr_dcc->prev_dcc;
- if (ptr_dcc->prev_dcc)
+ if (irc_last_dcc == dcc)
+ irc_last_dcc = dcc->prev_dcc;
+ if (dcc->prev_dcc)
{
- (ptr_dcc->prev_dcc)->next_dcc = ptr_dcc->next_dcc;
+ (dcc->prev_dcc)->next_dcc = dcc->next_dcc;
new_dcc_list = irc_dcc_list;
}
else
- new_dcc_list = ptr_dcc->next_dcc;
- if (ptr_dcc->next_dcc)
- (ptr_dcc->next_dcc)->prev_dcc = ptr_dcc->prev_dcc;
+ new_dcc_list = dcc->next_dcc;
+ if (dcc->next_dcc)
+ (dcc->next_dcc)->prev_dcc = dcc->prev_dcc;
/* free data */
- if (ptr_dcc->nick)
- free (ptr_dcc->nick);
- if (ptr_dcc->unterminated_message)
- free (ptr_dcc->unterminated_message);
- if (ptr_dcc->filename)
- free (ptr_dcc->filename);
-
- free (ptr_dcc);
+ if (dcc->nick)
+ free (dcc->nick);
+ if (dcc->unterminated_message)
+ free (dcc->unterminated_message);
+ if (dcc->filename)
+ free (dcc->filename);
+
+ free (dcc);
irc_dcc_list = new_dcc_list;
}
@@ -418,26 +418,26 @@ irc_dcc_free (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_child_kill (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_child_kill (struct t_irc_dcc *dcc)
{
/* kill process */
- if (ptr_dcc->child_pid > 0)
+ if (dcc->child_pid > 0)
{
- kill (ptr_dcc->child_pid, SIGKILL);
- waitpid (ptr_dcc->child_pid, NULL, 0);
- ptr_dcc->child_pid = 0;
+ kill (dcc->child_pid, SIGKILL);
+ waitpid (dcc->child_pid, NULL, 0);
+ dcc->child_pid = 0;
}
/* close pipe used with child */
- if (ptr_dcc->child_read != -1)
+ if (dcc->child_read != -1)
{
- close (ptr_dcc->child_read);
- ptr_dcc->child_read = -1;
+ close (dcc->child_read);
+ dcc->child_read = -1;
}
- if (ptr_dcc->child_write != -1)
+ if (dcc->child_write != -1)
{
- close (ptr_dcc->child_write);
- ptr_dcc->child_write = -1;
+ close (dcc->child_write);
+ dcc->child_write = -1;
}
}
@@ -446,93 +446,93 @@ irc_dcc_file_child_kill (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_close (struct t_irc_dcc *ptr_dcc, int status)
+irc_dcc_close (struct t_irc_dcc *dcc, int status)
{
t_gui_buffer *ptr_buffer;
struct stat st;
- ptr_dcc->status = status;
+ dcc->status = status;
if ((status == IRC_DCC_DONE) || (status == IRC_DCC_ABORTED)
|| (status == IRC_DCC_FAILED))
{
- if (IRC_DCC_IS_FILE(ptr_dcc->type))
+ if (IRC_DCC_IS_FILE(dcc->type))
{
- gui_chat_printf_info (ptr_dcc->server->buffer,
+ gui_chat_printf_info (dcc->server->buffer,
_("DCC: file %s%s%s"),
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
- ptr_dcc->filename,
+ dcc->filename,
GUI_COLOR(GUI_COLOR_CHAT));
- if (ptr_dcc->local_filename)
- gui_chat_printf (ptr_dcc->server->buffer,
+ if (dcc->local_filename)
+ gui_chat_printf (dcc->server->buffer,
_(" (local filename: %s%s%s)"),
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
- ptr_dcc->local_filename,
+ dcc->local_filename,
GUI_COLOR(GUI_COLOR_CHAT));
- if (ptr_dcc->type == IRC_DCC_FILE_SEND)
- gui_chat_printf (ptr_dcc->server->buffer,
+ if (dcc->type == IRC_DCC_FILE_SEND)
+ gui_chat_printf (dcc->server->buffer,
_(" sent to "));
else
- gui_chat_printf (ptr_dcc->server->buffer,
+ gui_chat_printf (dcc->server->buffer,
_(" received from "));
- gui_chat_printf (ptr_dcc->server->buffer, "%s%s%s: %s\n",
+ gui_chat_printf (dcc->server->buffer, "%s%s%s: %s\n",
GUI_COLOR(GUI_COLOR_CHAT_NICK),
- ptr_dcc->nick,
+ dcc->nick,
GUI_COLOR(GUI_COLOR_CHAT),
(status == IRC_DCC_DONE) ? _("OK") : _("FAILED"));
- irc_dcc_file_child_kill (ptr_dcc);
+ irc_dcc_file_child_kill (dcc);
}
}
if (status == IRC_DCC_ABORTED)
{
- if (IRC_DCC_IS_CHAT(ptr_dcc->type))
+ if (IRC_DCC_IS_CHAT(dcc->type))
{
- if (ptr_dcc->channel)
- ptr_buffer = ptr_dcc->channel->buffer;
+ if (dcc->channel)
+ ptr_buffer = dcc->channel->buffer;
else
- ptr_buffer = ptr_dcc->server->buffer;
+ ptr_buffer = dcc->server->buffer;
gui_chat_printf_info (ptr_buffer,
_("DCC chat closed with %s%s "
"%s(%s%d.%d.%d.%d%s)\n"),
GUI_COLOR(GUI_COLOR_CHAT_NICK),
- ptr_dcc->nick,
+ dcc->nick,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
- ptr_dcc->addr >> 24,
- (ptr_dcc->addr >> 16) & 0xff,
- (ptr_dcc->addr >> 8) & 0xff,
- ptr_dcc->addr & 0xff,
+ dcc->addr >> 24,
+ (dcc->addr >> 16) & 0xff,
+ (dcc->addr >> 8) & 0xff,
+ dcc->addr & 0xff,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
}
}
/* remove empty file if received file failed and nothing was transfered */
if (((status == IRC_DCC_FAILED) || (status == IRC_DCC_ABORTED))
- && IRC_DCC_IS_FILE(ptr_dcc->type)
- && IRC_DCC_IS_RECV(ptr_dcc->type)
- && ptr_dcc->local_filename
- && ptr_dcc->pos == 0)
+ && IRC_DCC_IS_FILE(dcc->type)
+ && IRC_DCC_IS_RECV(dcc->type)
+ && dcc->local_filename
+ && dcc->pos == 0)
{
/* erase file only if really empty on disk */
- if (stat (ptr_dcc->local_filename, &st) != -1)
+ if (stat (dcc->local_filename, &st) != -1)
{
if ((unsigned long) st.st_size == 0)
- unlink (ptr_dcc->local_filename);
+ unlink (dcc->local_filename);
}
}
- if (IRC_DCC_IS_FILE(ptr_dcc->type))
- irc_dcc_calculate_speed (ptr_dcc, 1);
+ if (IRC_DCC_IS_FILE(dcc->type))
+ irc_dcc_calculate_speed (dcc, 1);
- if (ptr_dcc->sock >= 0)
+ if (dcc->sock >= 0)
{
- close (ptr_dcc->sock);
- ptr_dcc->sock = -1;
+ close (dcc->sock);
+ dcc->sock = -1;
}
- if (ptr_dcc->file >= 0)
+ if (dcc->file >= 0)
{
- close (ptr_dcc->file);
- ptr_dcc->file = -1;
+ close (dcc->file);
+ dcc->file = -1;
}
}
@@ -541,32 +541,32 @@ irc_dcc_close (struct t_irc_dcc *ptr_dcc, int status)
*/
void
-irc_dcc_channel_for_chat (struct t_irc_dcc *ptr_dcc)
+irc_dcc_channel_for_chat (struct t_irc_dcc *dcc)
{
- if (!irc_channel_create_dcc (ptr_dcc))
+ if (!irc_channel_create_dcc (dcc))
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s can't associate DCC chat with private "
"buffer (maybe private buffer has already "
"DCC CHAT?)\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return;
}
- gui_chat_printf_type (ptr_dcc->channel->buffer, GUI_MSG_TYPE_MSG,
+ gui_chat_printf_type (dcc->channel->buffer, GUI_MSG_TYPE_MSG,
cfg_look_prefix_info, cfg_col_chat_prefix_info,
_("Connected to %s%s %s(%s%d.%d.%d.%d%s)%s via DCC "
"chat\n"),
GUI_COLOR(GUI_COLOR_CHAT_NICK),
- ptr_dcc->nick,
+ dcc->nick,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
- ptr_dcc->addr >> 24,
- (ptr_dcc->addr >> 16) & 0xff,
- (ptr_dcc->addr >> 8) & 0xff,
- ptr_dcc->addr & 0xff,
+ dcc->addr >> 24,
+ (dcc->addr >> 16) & 0xff,
+ (dcc->addr >> 8) & 0xff,
+ dcc->addr & 0xff,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT));
}
@@ -595,26 +595,26 @@ irc_dcc_chat_remove_channel (struct t_irc_channel *channel)
*/
void
-irc_dcc_recv_connect_init (struct t_irc_dcc *ptr_dcc)
+irc_dcc_recv_connect_init (struct t_irc_dcc *dcc)
{
- if (!irc_dcc_connect (ptr_dcc))
+ if (!irc_dcc_connect (dcc))
{
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
else
{
/* DCC file => launch child process */
- if (IRC_DCC_IS_FILE(ptr_dcc->type))
+ if (IRC_DCC_IS_FILE(dcc->type))
{
- ptr_dcc->status = IRC_DCC_CONNECTING;
- irc_dcc_file_recv_fork (ptr_dcc);
+ dcc->status = IRC_DCC_CONNECTING;
+ irc_dcc_file_recv_fork (dcc);
}
else
{
/* DCC CHAT => associate DCC with channel */
- ptr_dcc->status = IRC_DCC_ACTIVE;
- irc_dcc_channel_for_chat (ptr_dcc);
+ dcc->status = IRC_DCC_ACTIVE;
+ irc_dcc_channel_for_chat (dcc);
}
}
irc_dcc_redraw (GUI_HOTLIST_MSG);
@@ -625,21 +625,21 @@ irc_dcc_recv_connect_init (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_accept (struct t_irc_dcc *ptr_dcc)
+irc_dcc_accept (struct t_irc_dcc *dcc)
{
- if (IRC_DCC_IS_FILE(ptr_dcc->type) && (ptr_dcc->start_resume > 0))
+ if (IRC_DCC_IS_FILE(dcc->type) && (dcc->start_resume > 0))
{
- ptr_dcc->status = IRC_DCC_CONNECTING;
- irc_server_sendf (ptr_dcc->server,
- (strchr (ptr_dcc->filename, ' ')) ?
+ dcc->status = IRC_DCC_CONNECTING;
+ irc_server_sendf (dcc->server,
+ (strchr (dcc->filename, ' ')) ?
"PRIVMSG %s :\01DCC RESUME \"%s\" %d %u\01\n" :
"PRIVMSG %s :\01DCC RESUME %s %d %u\01",
- ptr_dcc->nick, ptr_dcc->filename,
- ptr_dcc->port, ptr_dcc->start_resume);
+ dcc->nick, dcc->filename,
+ dcc->port, dcc->start_resume);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
else
- irc_dcc_recv_connect_init (ptr_dcc);
+ irc_dcc_recv_connect_init (dcc);
}
/*
@@ -720,7 +720,7 @@ irc_dcc_alloc ()
struct t_irc_dcc *new_dcc;
/* create new DCC struct */
- if ((new_dcc = (struct t_irc_dcc *) malloc (sizeof (struct t_irc_dcc))) == NULL)
+ if ((new_dcc = (struct t_irc_dcc *)malloc (sizeof (struct t_irc_dcc))) == NULL)
return NULL;
/* default values */
@@ -937,7 +937,8 @@ irc_dcc_add (struct t_irc_server *server, int type, unsigned long addr, int port
*/
void
-irc_dcc_send_request (struct t_irc_server *server, int type, char *nick, char *filename)
+irc_dcc_send_request (struct t_irc_server *server, int type, char *nick,
+ char *filename)
{
char *dir1, *dir2, *filename2, *short_filename, *pos;
int spaces, args, port_start, port_end;
@@ -976,8 +977,8 @@ irc_dcc_send_request (struct t_irc_server *server, int type, char *nick, char *f
free (dir1);
return;
}
- filename2 = (char *) malloc (strlen (dir2) +
- strlen (filename) + 4);
+ filename2 = (char *)malloc (strlen (dir2) +
+ strlen (filename) + 4);
if (!filename2)
{
gui_chat_printf_error (server->buffer,
@@ -1177,12 +1178,12 @@ irc_dcc_send_request (struct t_irc_server *server, int type, char *nick, char *f
*/
int
-irc_dcc_chat_send (struct t_irc_dcc *ptr_dcc, char *buffer, int size_buf)
+irc_dcc_chat_send (struct t_irc_dcc *dcc, char *buffer, int size_buf)
{
- if (!ptr_dcc)
+ if (!dcc)
return -1;
- return send (ptr_dcc->sock, buffer, size_buf, 0);
+ return send (dcc->sock, buffer, size_buf, 0);
}
/*
@@ -1190,17 +1191,17 @@ irc_dcc_chat_send (struct t_irc_dcc *ptr_dcc, char *buffer, int size_buf)
*/
void
-irc_dcc_chat_sendf (struct t_irc_dcc *ptr_dcc, char *fmt, ...)
+irc_dcc_chat_sendf (struct t_irc_dcc *dcc, char *format, ...)
{
va_list args;
static char buffer[4096];
int size_buf;
- if (!ptr_dcc || (ptr_dcc->sock < 0))
+ if (!dcc || (dcc->sock < 0))
return;
- va_start (args, fmt);
- size_buf = vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
+ va_start (args, format);
+ size_buf = vsnprintf (buffer, sizeof (buffer) - 1, format, args);
va_end (args);
if ((size_buf == 0) || (strcmp (buffer, "\r\n") == 0))
@@ -1211,18 +1212,18 @@ irc_dcc_chat_sendf (struct t_irc_dcc *ptr_dcc, char *fmt, ...)
size_buf = strlen (buffer);
#ifdef DEBUG
buffer[size_buf - 2] = '\0';
- gui_chat_printf (ptr_dcc->server->buffer,
+ gui_chat_printf (dcc->server->buffer,
"[DEBUG] Sending to remote host (DCC CHAT) >>> %s\n",
buffer);
buffer[size_buf - 2] = '\r';
#endif
- if (irc_dcc_chat_send (ptr_dcc, buffer, strlen (buffer)) <= 0)
+ if (irc_dcc_chat_send (dcc, buffer, strlen (buffer)) <= 0)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s error sending data to \"%s\" via DCC "
"CHAT\n"),
- WEECHAT_ERROR, ptr_dcc->nick);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ WEECHAT_ERROR, dcc->nick);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
}
}
@@ -1231,7 +1232,7 @@ irc_dcc_chat_sendf (struct t_irc_dcc *ptr_dcc, char *fmt, ...)
*/
void
-irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
+irc_dcc_chat_recv (struct t_irc_dcc *dcc)
{
fd_set read_fd;
static struct timeval timeout;
@@ -1240,7 +1241,7 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
int num_read;
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->sock, &read_fd);
+ FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
@@ -1248,29 +1249,29 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) <= 0)
return;
- if (!FD_ISSET (ptr_dcc->sock, &read_fd))
+ if (!FD_ISSET (dcc->sock, &read_fd))
return;
/* there's something to read on socket! */
- num_read = recv (ptr_dcc->sock, buffer, sizeof (buffer) - 2, 0);
+ num_read = recv (dcc->sock, buffer, sizeof (buffer) - 2, 0);
if (num_read > 0)
{
buffer[num_read] = '\0';
buf2 = NULL;
ptr_buf = buffer;
- if (ptr_dcc->unterminated_message)
+ if (dcc->unterminated_message)
{
- buf2 = (char *) malloc (strlen (ptr_dcc->unterminated_message) +
- strlen (buffer) + 1);
+ buf2 = (char *)malloc (strlen (dcc->unterminated_message) +
+ strlen (buffer) + 1);
if (buf2)
{
- strcpy (buf2, ptr_dcc->unterminated_message);
+ strcpy (buf2, dcc->unterminated_message);
strcat (buf2, buffer);
}
ptr_buf = buf2;
- free (ptr_dcc->unterminated_message);
- ptr_dcc->unterminated_message = NULL;
+ free (dcc->unterminated_message);
+ dcc->unterminated_message = NULL;
}
while (ptr_buf && ptr_buf[0])
@@ -1292,7 +1293,7 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
}
else
{
- ptr_dcc->unterminated_message = strdup (ptr_buf);
+ dcc->unterminated_message = strdup (ptr_buf);
ptr_buf = NULL;
next_ptr_buf = NULL;
}
@@ -1300,28 +1301,28 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
if (ptr_buf)
{
- if (irc_protocol_is_highlight (ptr_buf, ptr_dcc->server->nick))
+ if (irc_protocol_is_highlight (ptr_buf, dcc->server->nick))
{
- irc_display_nick (ptr_dcc->channel->buffer, NULL,
- ptr_dcc->nick,
+ irc_display_nick (dcc->channel->buffer, NULL,
+ dcc->nick,
GUI_MSG_TYPE_NICK | GUI_MSG_TYPE_HIGHLIGHT,
1,
GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), 0);
if ((cfg_look_infobar_delay_highlight > 0)
- && (ptr_dcc->channel->buffer != gui_current_window->buffer))
+ && (dcc->channel->buffer != gui_current_window->buffer))
{
gui_infobar_printf (cfg_look_infobar_delay_highlight,
GUI_COLOR_INFOBAR_HIGHLIGHT,
_("Private %s> %s"),
- ptr_dcc->nick, ptr_buf);
+ dcc->nick, ptr_buf);
}
}
else
- irc_display_nick (ptr_dcc->channel->buffer, NULL,
- ptr_dcc->nick,
+ irc_display_nick (dcc->channel->buffer, NULL,
+ dcc->nick,
GUI_MSG_TYPE_NICK, 1,
GUI_COLOR(GUI_COLOR_CHAT_NICK_OTHER), 0);
- gui_chat_printf_type (ptr_dcc->channel->buffer,
+ gui_chat_printf_type (dcc->channel->buffer,
GUI_MSG_TYPE_MSG,
NULL, -1,
"%s%s\n",
@@ -1337,7 +1338,7 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
}
else
{
- irc_dcc_close (ptr_dcc, IRC_DCC_ABORTED);
+ irc_dcc_close (dcc, IRC_DCC_ABORTED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
}
@@ -1348,22 +1349,22 @@ irc_dcc_chat_recv (struct t_irc_dcc *ptr_dcc)
*/
int
-irc_dcc_file_create_pipe (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_create_pipe (struct t_irc_dcc *dcc)
{
int child_pipe[2];
if (pipe (child_pipe) < 0)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to create pipe\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return 0;
}
- ptr_dcc->child_read = child_pipe[0];
- ptr_dcc->child_write = child_pipe[1];
+ dcc->child_read = child_pipe[0];
+ dcc->child_write = child_pipe[1];
return 1;
}
@@ -1372,13 +1373,13 @@ irc_dcc_file_create_pipe (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_write_pipe (struct t_irc_dcc *ptr_dcc, int status, int error)
+irc_dcc_file_write_pipe (struct t_irc_dcc *dcc, int status, int error)
{
char buffer[1 + 1 + 12 + 1]; /* status + error + pos + \0 */
snprintf (buffer, sizeof (buffer), "%c%c%012lu",
- status + '0', error + '0', ptr_dcc->pos);
- write (ptr_dcc->child_write, buffer, sizeof (buffer));
+ status + '0', error + '0', dcc->pos);
+ write (dcc->child_write, buffer, sizeof (buffer));
}
/*
@@ -1386,7 +1387,7 @@ irc_dcc_file_write_pipe (struct t_irc_dcc *ptr_dcc, int status, int error)
*/
void
-irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_send_child (struct t_irc_dcc *dcc)
{
int num_read, num_sent;
static char buffer[IRC_DCC_MAX_BLOCKSIZE];
@@ -1397,28 +1398,28 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
while (1)
{
/* read DCC ACK (sent by receiver) */
- if (ptr_dcc->pos > ptr_dcc->ack)
+ if (dcc->pos > dcc->ack)
{
/* we should receive ACK for packets sent previously */
while (1)
{
- num_read = recv (ptr_dcc->sock, (char *) &ack, 4, MSG_PEEK);
+ num_read = recv (dcc->sock, (char *) &ack, 4, MSG_PEEK);
if ((num_read < 1) &&
((num_read != -1) || (errno != EAGAIN)))
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
return;
}
if (num_read == 4)
{
- recv (ptr_dcc->sock, (char *) &ack, 4, 0);
- ptr_dcc->ack = ntohl (ack);
+ recv (dcc->sock, (char *) &ack, 4, 0);
+ dcc->ack = ntohl (ack);
/* DCC send ok? */
- if ((ptr_dcc->pos >= ptr_dcc->size)
- && (ptr_dcc->ack >= ptr_dcc->size))
+ if ((dcc->pos >= dcc->size)
+ && (dcc->ack >= dcc->size))
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
return;
}
}
@@ -1428,17 +1429,17 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
}
/* send a block to receiver */
- if ((ptr_dcc->pos < ptr_dcc->size) &&
- (ptr_dcc->fast_send || (ptr_dcc->pos <= ptr_dcc->ack)))
+ if ((dcc->pos < dcc->size) &&
+ (dcc->fast_send || (dcc->pos <= dcc->ack)))
{
- lseek (ptr_dcc->file, ptr_dcc->pos, SEEK_SET);
- num_read = read (ptr_dcc->file, buffer, ptr_dcc->blocksize);
+ lseek (dcc->file, dcc->pos, SEEK_SET);
+ num_read = read (dcc->file, buffer, dcc->blocksize);
if (num_read < 1)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_READ_LOCAL);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_READ_LOCAL);
return;
}
- num_sent = send (ptr_dcc->sock, buffer, num_read, 0);
+ num_sent = send (dcc->sock, buffer, num_read, 0);
if (num_sent < 0)
{
/* socket is temporarily not available (receiver can't receive
@@ -1447,18 +1448,18 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
usleep (1000);
else
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_SEND_BLOCK);
return;
}
}
if (num_sent > 0)
{
- ptr_dcc->pos += (unsigned long) num_sent;
+ dcc->pos += (unsigned long) num_sent;
new_time = time (NULL);
if (last_sent != new_time)
{
last_sent = new_time;
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
}
}
}
@@ -1472,7 +1473,7 @@ irc_dcc_file_send_child (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_recv_child (struct t_irc_dcc *dcc)
{
int num_read;
static char buffer[IRC_DCC_MAX_BLOCKSIZE];
@@ -1480,19 +1481,19 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
time_t last_sent, new_time;
/* first connect to sender (blocking) */
- if (!irc_dcc_connect_to_sender (ptr_dcc))
+ if (!irc_dcc_connect_to_sender (dcc))
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_CONNECT_SENDER);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_CONNECT_SENDER);
return;
}
/* connection is ok, change DCC status (inform parent process) */
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
last_sent = time (NULL);
while (1)
{
- num_read = recv (ptr_dcc->sock, buffer, sizeof (buffer), 0);
+ num_read = recv (dcc->sock, buffer, sizeof (buffer), 0);
if (num_read == -1)
{
/* socket is temporarily not available (sender is not fast ?!) */
@@ -1500,7 +1501,7 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
usleep (1000);
else
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
return;
}
}
@@ -1508,26 +1509,26 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
{
if (num_read == 0)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_RECV_BLOCK);
return;
}
- if (write (ptr_dcc->file, buffer, num_read) == -1)
+ if (write (dcc->file, buffer, num_read) == -1)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_WRITE_LOCAL);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_FAILED, IRC_DCC_ERROR_WRITE_LOCAL);
return;
}
- ptr_dcc->pos += (unsigned long) num_read;
- pos = htonl (ptr_dcc->pos);
+ dcc->pos += (unsigned long) num_read;
+ pos = htonl (dcc->pos);
/* we don't check return code, not a problem if an ACK send failed */
- send (ptr_dcc->sock, (char *) &pos, 4, 0);
+ send (dcc->sock, (char *) &pos, 4, 0);
/* file received ok? */
- if (ptr_dcc->pos >= ptr_dcc->size)
+ if (dcc->pos >= dcc->size)
{
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_DONE, IRC_DCC_NO_ERROR);
return;
}
@@ -1535,7 +1536,7 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
if (last_sent != new_time)
{
last_sent = new_time;
- irc_dcc_file_write_pipe (ptr_dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
+ irc_dcc_file_write_pipe (dcc, IRC_DCC_ACTIVE, IRC_DCC_NO_ERROR);
}
}
}
@@ -1546,7 +1547,7 @@ irc_dcc_file_recv_child (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_child_read (struct t_irc_dcc *dcc)
{
fd_set read_fd;
static struct timeval timeout;
@@ -1555,7 +1556,7 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
char *error;
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->child_read, &read_fd);
+ FD_SET (dcc->child_read, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
@@ -1563,55 +1564,55 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) <= 0)
return;
- if (!FD_ISSET (ptr_dcc->child_read, &read_fd))
+ if (!FD_ISSET (dcc->child_read, &read_fd))
return;
/* there's something to read in pipe! */
- num_read = read (ptr_dcc->child_read, bufpipe, sizeof (bufpipe));
+ num_read = read (dcc->child_read, bufpipe, sizeof (bufpipe));
if (num_read > 0)
{
error = NULL;
- ptr_dcc->pos = strtol (bufpipe + 2, &error, 10);
- ptr_dcc->last_activity = time (NULL);
- irc_dcc_calculate_speed (ptr_dcc, 0);
+ dcc->pos = strtol (bufpipe + 2, &error, 10);
+ dcc->last_activity = time (NULL);
+ irc_dcc_calculate_speed (dcc, 0);
/* read error code */
switch (bufpipe[1] - '0')
{
/* errors for sender */
case IRC_DCC_ERROR_READ_LOCAL:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to read local "
"file\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_SEND_BLOCK:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to send block to "
"receiver\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_READ_ACK:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to read ACK from "
"receiver\n"),
WEECHAT_ERROR);
break;
/* errors for receiver */
case IRC_DCC_ERROR_CONNECT_SENDER:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to connect to "
"sender\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_RECV_BLOCK:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to receive block "
"from sender\n"),
WEECHAT_ERROR);
break;
case IRC_DCC_ERROR_WRITE_LOCAL:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to write local "
"file\n"),
WEECHAT_ERROR);
@@ -1622,23 +1623,23 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
switch (bufpipe[0] - '0')
{
case IRC_DCC_ACTIVE:
- if (ptr_dcc->status == IRC_DCC_CONNECTING)
+ if (dcc->status == IRC_DCC_CONNECTING)
{
/* connection was successful by child, init transfert times */
- ptr_dcc->status = IRC_DCC_ACTIVE;
- ptr_dcc->start_transfer = time (NULL);
- ptr_dcc->last_check_time = time (NULL);
+ dcc->status = IRC_DCC_ACTIVE;
+ dcc->start_transfer = time (NULL);
+ dcc->last_check_time = time (NULL);
irc_dcc_redraw (GUI_HOTLIST_MSG);
}
else
irc_dcc_redraw (GUI_HOTLIST_LOW);
break;
case IRC_DCC_DONE:
- irc_dcc_close (ptr_dcc, IRC_DCC_DONE);
+ irc_dcc_close (dcc, IRC_DCC_DONE);
irc_dcc_redraw (GUI_HOTLIST_MSG);
break;
case IRC_DCC_FAILED:
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
break;
}
@@ -1650,34 +1651,34 @@ irc_dcc_file_child_read (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_send_fork (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_send_fork (struct t_irc_dcc *dcc)
{
pid_t pid;
- if (!irc_dcc_file_create_pipe (ptr_dcc))
+ if (!irc_dcc_file_create_pipe (dcc))
return;
- ptr_dcc->file = open (ptr_dcc->local_filename, O_RDONLY | O_NONBLOCK, 0644);
+ dcc->file = open (dcc->local_filename, O_RDONLY | O_NONBLOCK, 0644);
switch (pid = fork ())
{
/* fork failed */
case -1:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to fork\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return;
/* child process */
case 0:
setuid (getuid ());
- irc_dcc_file_send_child (ptr_dcc);
+ irc_dcc_file_send_child (dcc);
_exit (EXIT_SUCCESS);
}
/* parent process */
- ptr_dcc->child_pid = pid;
+ dcc->child_pid = pid;
}
/*
@@ -1685,18 +1686,18 @@ irc_dcc_file_send_fork (struct t_irc_dcc *ptr_dcc)
*/
void
-irc_dcc_file_recv_fork (struct t_irc_dcc *ptr_dcc)
+irc_dcc_file_recv_fork (struct t_irc_dcc *dcc)
{
pid_t pid;
- if (!irc_dcc_file_create_pipe (ptr_dcc))
+ if (!irc_dcc_file_create_pipe (dcc))
return;
- if (ptr_dcc->start_resume > 0)
- ptr_dcc->file = open (ptr_dcc->local_filename,
+ if (dcc->start_resume > 0)
+ dcc->file = open (dcc->local_filename,
O_APPEND | O_WRONLY | O_NONBLOCK);
else
- ptr_dcc->file = open (ptr_dcc->local_filename,
+ dcc->file = open (dcc->local_filename,
O_CREAT | O_TRUNC | O_WRONLY | O_NONBLOCK,
0644);
@@ -1704,21 +1705,21 @@ irc_dcc_file_recv_fork (struct t_irc_dcc *ptr_dcc)
{
/* fork failed */
case -1:
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to fork\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
return;
/* child process */
case 0:
setuid (getuid ());
- irc_dcc_file_recv_child (ptr_dcc);
+ irc_dcc_file_recv_child (dcc);
_exit (EXIT_SUCCESS);
}
/* parent process */
- ptr_dcc->child_pid = pid;
+ dcc->child_pid = pid;
}
/*
@@ -1728,134 +1729,134 @@ irc_dcc_file_recv_fork (struct t_irc_dcc *ptr_dcc)
void
irc_dcc_handle ()
{
- struct t_irc_dcc *ptr_dcc;
+ struct t_irc_dcc *dcc;
fd_set read_fd;
static struct timeval timeout;
int sock;
struct sockaddr_in addr;
socklen_t length;
- for (ptr_dcc = irc_dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
+ for (dcc = irc_dcc_list; dcc; dcc = dcc->next_dcc)
{
/* check DCC timeout */
- if (IRC_DCC_IS_FILE(ptr_dcc->type) && !IRC_DCC_ENDED(ptr_dcc->status))
+ if (IRC_DCC_IS_FILE(dcc->type) && !IRC_DCC_ENDED(dcc->status))
{
if ((irc_cfg_dcc_timeout != 0)
- && (time (NULL) > ptr_dcc->last_activity + irc_cfg_dcc_timeout))
+ && (time (NULL) > dcc->last_activity + irc_cfg_dcc_timeout))
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: timeout\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
}
- if (ptr_dcc->status == IRC_DCC_CONNECTING)
+ if (dcc->status == IRC_DCC_CONNECTING)
{
- if (ptr_dcc->type == IRC_DCC_FILE_SEND)
+ if (dcc->type == IRC_DCC_FILE_SEND)
{
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->sock, &read_fd);
+ FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
/* something to read on socket? */
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
- if (FD_ISSET (ptr_dcc->sock, &read_fd))
+ if (FD_ISSET (dcc->sock, &read_fd))
{
- ptr_dcc->last_activity = time (NULL);
+ dcc->last_activity = time (NULL);
length = sizeof (addr);
- sock = accept (ptr_dcc->sock,
+ sock = accept (dcc->sock,
(struct sockaddr *) &addr, &length);
- close (ptr_dcc->sock);
- ptr_dcc->sock = -1;
+ close (dcc->sock);
+ dcc->sock = -1;
if (sock < 0)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to "
"create socket for "
"sending file\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->sock = sock;
- if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
+ dcc->sock = sock;
+ if (fcntl (dcc->sock, F_SETFL, O_NONBLOCK) == -1)
{
- gui_chat_printf_error (ptr_dcc->server->buffer,
+ gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to set "
"'nonblock' option for "
"socket\n"),
WEECHAT_ERROR);
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->addr = ntohl (addr.sin_addr.s_addr);
- ptr_dcc->status = IRC_DCC_ACTIVE;
- ptr_dcc->start_transfer = time (NULL);
+ dcc->addr = ntohl (addr.sin_addr.s_addr);
+ dcc->status = IRC_DCC_ACTIVE;
+ dcc->start_transfer = time (NULL);
irc_dcc_redraw (GUI_HOTLIST_MSG);
- irc_dcc_file_send_fork (ptr_dcc);
+ irc_dcc_file_send_fork (dcc);
}
}
}
- if (ptr_dcc->type == IRC_DCC_FILE_RECV)
+ if (dcc->type == IRC_DCC_FILE_RECV)
{
- if (ptr_dcc->child_read != -1)
- irc_dcc_file_child_read (ptr_dcc);
+ if (dcc->child_read != -1)
+ irc_dcc_file_child_read (dcc);
}
}
- if (ptr_dcc->status == IRC_DCC_WAITING)
+ if (dcc->status == IRC_DCC_WAITING)
{
- if (ptr_dcc->type == IRC_DCC_CHAT_SEND)
+ if (dcc->type == IRC_DCC_CHAT_SEND)
{
FD_ZERO (&read_fd);
- FD_SET (ptr_dcc->sock, &read_fd);
+ FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
/* something to read on socket? */
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
- if (FD_ISSET (ptr_dcc->sock, &read_fd))
+ if (FD_ISSET (dcc->sock, &read_fd))
{
length = sizeof (addr);
- sock = accept (ptr_dcc->sock, (struct sockaddr *) &addr, &length);
- close (ptr_dcc->sock);
- ptr_dcc->sock = -1;
+ sock = accept (dcc->sock, (struct sockaddr *) &addr, &length);
+ close (dcc->sock);
+ dcc->sock = -1;
if (sock < 0)
{
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->sock = sock;
- if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
+ dcc->sock = sock;
+ if (fcntl (dcc->sock, F_SETFL, O_NONBLOCK) == -1)
{
- irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
+ irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (GUI_HOTLIST_MSG);
continue;
}
- ptr_dcc->addr = ntohl (addr.sin_addr.s_addr);
- ptr_dcc->status = IRC_DCC_ACTIVE;
+ dcc->addr = ntohl (addr.sin_addr.s_addr);
+ dcc->status = IRC_DCC_ACTIVE;
irc_dcc_redraw (GUI_HOTLIST_MSG);
- irc_dcc_channel_for_chat (ptr_dcc);
+ irc_dcc_channel_for_chat (dcc);
}
}
}
}
- if (ptr_dcc->status == IRC_DCC_ACTIVE)
+ if (dcc->status == IRC_DCC_ACTIVE)
{
- if (IRC_DCC_IS_CHAT(ptr_dcc->type))
- irc_dcc_chat_recv (ptr_dcc);
+ if (IRC_DCC_IS_CHAT(dcc->type))
+ irc_dcc_chat_recv (dcc);
else
- irc_dcc_file_child_read (ptr_dcc);
+ irc_dcc_file_child_read (dcc);
}
}
}
diff --git a/src/plugins/irc/irc-dcc.h b/src/plugins/irc/irc-dcc.h
index af8f0baf7..f36bb0c51 100644
--- a/src/plugins/irc/irc-dcc.h
+++ b/src/plugins/irc/irc-dcc.h
@@ -110,20 +110,26 @@ extern struct t_irc_dcc *irc_dcc_list;
extern struct t_irc_dcc *irc_last_dcc;
extern char *irc_dcc_status_string[6];
-extern void irc_dcc_redraw (int);
-extern void irc_dcc_free (struct t_irc_dcc *);
-extern void irc_dcc_close (struct t_irc_dcc *, int);
-extern void irc_dcc_chat_remove_channel (struct t_irc_channel *);
-extern void irc_dcc_accept (struct t_irc_dcc *);
-extern void irc_dcc_accept_resume (struct t_irc_server *, char *, int, unsigned long);
-extern void irc_dcc_start_resume (struct t_irc_server *, char *, int, unsigned long);
+extern void irc_dcc_redraw (int highlight);
+extern void irc_dcc_free (struct t_irc_dcc *dcc);
+extern void irc_dcc_close (struct t_irc_dcc *dcc, int status);
+extern void irc_dcc_chat_remove_channel (struct t_irc_channel *channel);
+extern void irc_dcc_accept (struct t_irc_dcc *dcc);
+extern void irc_dcc_accept_resume (struct t_irc_server *server, char *filename,
+ int port, unsigned long pos_start);
+extern void irc_dcc_start_resume (struct t_irc_server *server, char *filename,
+ int port, unsigned long pos_start);
extern struct t_irc_dcc *irc_dcc_alloc ();
-extern struct t_irc_dcc *irc_dcc_add (struct t_irc_server *, int, unsigned long, int, char *, int,
- char *, char *, unsigned long);
-extern void irc_dcc_send_request (struct t_irc_server *, int, char *, char *);
-extern void irc_dcc_chat_sendf (struct t_irc_dcc *, char *, ...);
-extern void irc_dcc_file_send_fork (struct t_irc_dcc *);
-extern void irc_dcc_file_recv_fork (struct t_irc_dcc *);
+extern struct t_irc_dcc *irc_dcc_add (struct t_irc_server *server,
+ int type, unsigned long addr,
+ int port, char *nick, int sock,
+ char *filename, char *local_filename,
+ unsigned long size);
+extern void irc_dcc_send_request (struct t_irc_server *server, int type,
+ char *nick, char *filename);
+extern void irc_dcc_chat_sendf (struct t_irc_dcc *dcc, char *format, ...);
+extern void irc_dcc_file_send_fork (struct t_irc_dcc *dcc);
+extern void irc_dcc_file_recv_fork (struct t_irc_dcc *dcc);
extern void irc_dcc_handle ();
extern void irc_dcc_end ();
extern void irc_dcc_print_log ();
diff --git a/src/plugins/irc/irc-display.h b/src/plugins/irc/irc-display.h
index 778eea778..06aa927c0 100644
--- a/src/plugins/irc/irc-display.h
+++ b/src/plugins/irc/irc-display.h
@@ -20,12 +20,16 @@
#ifndef __WEECHAT_IRC_DISPLAY_H
#define __WEECHAT_IRC_DISPLAY_H 1
-extern void irc_display_hide_password (char *, int);
-extern void irc_display_nick (struct t_gui_buffer *, struct t_irc_nick *,
- char *, int, int, char *, int);
-extern void irc_display_away (struct t_irc_server *, char *, char *);
-extern void irc_display_mode (struct t_gui_buffer *, char *, char *,
- char, char *, char *, char *, char *);
-extern void irc_display_server (struct t_irc_server *, int);
+extern void irc_display_hide_password (char *string, int look_for_nickserv);
+extern void irc_display_nick (struct t_gui_buffer *buffer,
+ struct t_irc_nick *nick, char *nickname,
+ int type, int display_around, char *force_color,
+ int no_nickmode);
+extern void irc_display_away (struct t_irc_server *server, char *string1,
+ char *string2);
+extern void irc_display_mode (struct t_gui_buffer *buffer, char *channel_name,
+ char *nick_name, char set_flag, char *symbol,
+ char *nick_host, char *message, char *param);
+extern void irc_display_server (struct t_irc_server *server, int with_detail);
#endif /* irc-display.h */
diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c
index 97efeb434..433c7e06d 100644
--- a/src/plugins/irc/irc-mode.c
+++ b/src/plugins/irc/irc-mode.c
@@ -239,8 +239,8 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
{
if (!strchr (server->nick_modes, mode))
{
- server->nick_modes = (char *) realloc (server->nick_modes,
- strlen (server->nick_modes) + 1 + 1);
+ server->nick_modes = (char *)realloc (server->nick_modes,
+ strlen (server->nick_modes) + 1 + 1);
strcat (server->nick_modes, str_mode);
//gui_status_draw (gui_current_window->buffer, 1);
//gui_input_draw (gui_current_window->buffer, 1);
@@ -248,7 +248,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
}
else
{
- server->nick_modes = (char *) malloc (2);
+ server->nick_modes = (char *)malloc (2);
strcpy (server->nick_modes, str_mode);
//gui_status_draw (gui_current_window->buffer, 1);
//gui_input_draw (gui_current_window->buffer, 1);
@@ -272,8 +272,8 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
{
new_size = strlen (server->nick_modes);
memmove (pos, pos + 1, strlen (pos + 1) + 1);
- server->nick_modes = (char *) realloc (server->nick_modes,
- new_size);
+ server->nick_modes = (char *)realloc (server->nick_modes,
+ new_size);
//gui_status_draw (gui_current_window->buffer, 1);
//gui_input_draw (gui_current_window->buffer, 1);
}
diff --git a/src/plugins/irc/irc-mode.h b/src/plugins/irc/irc-mode.h
index 5e1b958ee..c53612f55 100644
--- a/src/plugins/irc/irc-mode.h
+++ b/src/plugins/irc/irc-mode.h
@@ -22,9 +22,10 @@
#include "irc-server.h"
-extern void irc_mode_channel_set (struct t_irc_server *,
- struct t_irc_channel *, char *);
-extern void irc_mode_user_set (struct t_irc_server *, char *);
-extern int irc_mode_nick_prefix_allowed (struct t_irc_server *, char);
+extern void irc_mode_channel_set (struct t_irc_server *server,
+ struct t_irc_channel *channel, char *modes);
+extern void irc_mode_user_set (struct t_irc_server *server, char *modes);
+extern int irc_mode_nick_prefix_allowed (struct t_irc_server *server,
+ char prefix);
#endif /* irc-mode.h */
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index f1c6a6290..d51fde31f 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -49,7 +49,8 @@ irc_nick_find_color (struct t_irc_nick *nick)
{
color += (int)(nick->nick[i]);
}
- color = (color % weechat_config_integer (weechat_config_get ("look_color_nicks_number")));
+ color = (color %
+ weechat_config_integer (weechat_config_get_weechat ("look_color_nicks_number")));
return color;
}
@@ -164,7 +165,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
}
// alloc memory for new nick
- if ((new_nick = (struct t_irc_nick *) malloc (sizeof (struct t_irc_nick))) == NULL)
+ if ((new_nick = (struct t_irc_nick *)malloc (sizeof (struct t_irc_nick))) == NULL)
return NULL;
// initialize new nick
diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h
index 698e01437..f0bc5ecd5 100644
--- a/src/plugins/irc/irc-nick.h
+++ b/src/plugins/irc/irc-nick.h
@@ -50,19 +50,30 @@ struct t_irc_nick
struct t_irc_nick *next_nick; /* link to next nick on channel */
};
-extern int irc_nick_find_color (struct t_irc_nick *);
-extern void irc_nick_get_gui_infos (struct t_irc_nick *, int *, char *, int *);
-extern struct t_irc_nick *irc_nick_new (struct t_irc_server *,
- struct t_irc_channel *, char *,
- int, int, int, int, int, int, int);
-extern void irc_nick_change (struct t_irc_server *, struct t_irc_channel *,
- struct t_irc_nick *, char *);
-extern void irc_nick_free (struct t_irc_channel *, struct t_irc_nick *);
-extern void irc_nick_free_all (struct t_irc_channel *);
-extern struct t_irc_nick *irc_nick_search (struct t_irc_channel *, char *);
-extern void irc_nick_count (struct t_irc_channel *, int *, int *, int *, int *, int *);
-extern void irc_nick_set_away (struct t_irc_channel *, struct t_irc_nick *, int);
-extern char *irc_nick_as_prefix (struct t_irc_nick *, char *, char *);
-extern void irc_nick_print_log (struct t_irc_nick *);
+extern int irc_nick_find_color (struct t_irc_nick *nick);
+extern void irc_nick_get_gui_infos (struct t_irc_nick *nick, int *sort_index,
+ char *prefix, int *color_prefix);
+extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
+ struct t_irc_channel *channel,
+ char *nick_name, int is_chanowner,
+ int is_chanadmin, int is_chanadmin2,
+ int is_op, int is_halfop,
+ int has_voice, int is_chanuser);
+extern void irc_nick_change (struct t_irc_server *server,
+ struct t_irc_channel *channel,
+ struct t_irc_nick *nick, char *new_nick);
+extern void irc_nick_free (struct t_irc_channel *channel,
+ struct t_irc_nick *nick);
+extern void irc_nick_free_all (struct t_irc_channel *channel);
+extern struct t_irc_nick *irc_nick_search (struct t_irc_channel *channel,
+ char *nickname);
+extern void irc_nick_count (struct t_irc_channel *channel, int *total,
+ int *count_op, int *count_halfop, int *count_voice,
+ int *count_normal);
+extern void irc_nick_set_away (struct t_irc_channel *channel,
+ struct t_irc_nick *nick, int is_away);
+extern char *irc_nick_as_prefix (struct t_irc_nick *nick, char *nickname,
+ char *force_color);
+extern void irc_nick_print_log (struct t_irc_nick *nick);
#endif /* irc-nick.h */
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index f9169391f..3e657977f 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1177,7 +1177,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *h
(void) irc_message;
look_infobar_delay_highlight = weechat_config_integer (
- weechat_config_get ("look_infobar_delay_highlight"));
+ weechat_config_get_weechat ("look_infobar_delay_highlight"));
host2 = NULL;
if (host)
@@ -1485,7 +1485,7 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos
}
if (ptr_channel->close)
{
- weechat_buffer_close (ptr_channel->buffer);
+ weechat_buffer_close (ptr_channel->buffer, 1);
ptr_channel->buffer = NULL;
irc_channel_free (server, ptr_channel);
ptr_channel = NULL;
@@ -1608,7 +1608,7 @@ irc_protocol_reply_version (struct t_irc_server *server, struct t_irc_channel *c
pos = NULL;
}
- buf = (struct utsname *) malloc (sizeof (struct utsname));
+ buf = (struct utsname *)malloc (sizeof (struct utsname));
if (buf && (uname (buf) >= 0))
{
irc_server_sendf (server,
@@ -1679,7 +1679,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char *
}
look_infobar_delay_highlight = weechat_config_integer (
- weechat_config_get ("look_infobar_delay_highlight"));
+ weechat_config_get_weechat ("look_infobar_delay_highlight"));
pos = strchr (host, '!');
if (pos)
@@ -3817,10 +3817,10 @@ irc_protocol_cmd_324 (struct t_irc_server *server, char *irc_message, char *host
if (pos_modes[0])
{
if (ptr_channel->modes)
- ptr_channel->modes = (char *) realloc (ptr_channel->modes,
- strlen (pos_modes) + 1);
+ ptr_channel->modes = (char *)realloc (ptr_channel->modes,
+ strlen (pos_modes) + 1);
else
- ptr_channel->modes = (char *) malloc (strlen (pos_modes) + 1);
+ ptr_channel->modes = (char *)malloc (strlen (pos_modes) + 1);
strcpy (ptr_channel->modes, pos_modes);
irc_mode_channel_set (server, ptr_channel, pos_modes);
}
@@ -4715,7 +4715,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, char *irc_message, char *host
if (ptr_nick->host)
free (ptr_nick->host);
length = strlen (pos_user) + 1 + strlen (pos_host) + 1;
- ptr_nick->host = (char *) malloc (length);
+ ptr_nick->host = (char *)malloc (length);
if (ptr_nick->host)
snprintf (ptr_nick->host, length, "%s@%s", pos_user, pos_host);
irc_nick_set_away (ptr_channel, ptr_nick,
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index 55e02ba40..d76911657 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -22,8 +22,9 @@
#include "irc-server.h"
-typedef int (t_irc_recv_func)(struct t_irc_server *, char *, char *, char *,
- char *, int, int);
+typedef int (t_irc_recv_func)(struct t_irc_server *server, char *irc_message,
+ char *host, char *nick, char *arguments,
+ int ignore, int highlight);
struct t_irc_protocol_msg
{
@@ -34,65 +35,65 @@ struct t_irc_protocol_msg
extern int irc_protocol_is_highlight (char *, char *);
extern int irc_protocol_recv_command (struct t_irc_server *, char *, char *, char *, char *);
-extern int irc_protocol_cmd_error (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_invite (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_join (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_kick (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_kill (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_mode (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_nick (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_notice (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_part (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_ping (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_pong (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_privmsg (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_quit (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_server_mode_reason (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_server_msg (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_server_reply (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_topic (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_wallops (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_001 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_005 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_221 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_301 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_302 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_303 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_305 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_306 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_whois_nick_msg (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_310 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_311 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_312 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_314 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_315 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_317 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_319 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_321 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_322 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_323 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_324 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_327 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_329 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_331 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_332 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_333 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_338 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_341 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_344 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_345 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_348 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_349 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_351 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_352 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_353 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_365 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_366 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_367 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_368 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_432 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_433 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_438 (struct t_irc_server *, char *, char *, char *, char *, int, int);
-extern int irc_protocol_cmd_671 (struct t_irc_server *, char *, char *, char *, char *, int, int);
+extern int irc_protocol_cmd_error (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_invite (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_kick (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_kill (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_mode (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_nick (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_notice (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_ping (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_pong (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_privmsg (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_quit (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_server_msg (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_server_reply (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_topic (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_wallops (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_001 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_005 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_221 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_301 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_302 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_303 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_305 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_306 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_310 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_311 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_312 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_314 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_315 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_317 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_319 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_321 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_322 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_323 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_324 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_327 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_329 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_331 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_332 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_333 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_338 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_341 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_344 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_345 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_348 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_349 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_351 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_352 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_365 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_367 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_438 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_671 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
#endif /* irc-protocol.h */
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 9461f4baf..0b9ac0906 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -235,7 +235,7 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
server->autojoin = strdup (pos_channel);
else
{
- server->autojoin = (char *) malloc (strlen (pos_channel) + 2);
+ server->autojoin = (char *)malloc (strlen (pos_channel) + 2);
strcpy (server->autojoin, "#");
strcat (server->autojoin, pos_channel);
}
@@ -249,10 +249,10 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
/* some default values */
if (server->port < 0)
server->port = IRC_SERVER_DEFAULT_PORT;
- server->nick2 = (char *) malloc (strlen (server->nick1) + 2);
+ server->nick2 = (char *)malloc (strlen (server->nick1) + 2);
strcpy (server->nick2, server->nick1);
server->nick2 = strcat (server->nick2, "1");
- server->nick3 = (char *) malloc (strlen (server->nick1) + 2);
+ server->nick3 = (char *)malloc (strlen (server->nick1) + 2);
strcpy (server->nick3, server->nick1);
server->nick3 = strcat (server->nick3, "2");
@@ -266,7 +266,7 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
void
irc_server_init_with_config_options (struct t_irc_server *server,
- void *section,
+ struct t_config_section *section,
int config_reload)
{
struct t_config_option *ptr_option;
@@ -423,7 +423,7 @@ irc_server_alloc ()
struct t_irc_server *new_server;
/* alloc memory for new server */
- if ((new_server = (struct t_irc_server *) malloc (sizeof (struct t_irc_server))) == NULL)
+ if ((new_server = (struct t_irc_server *)malloc (sizeof (struct t_irc_server))) == NULL)
{
weechat_printf (NULL,
_("%sirc: error when allocating new server"),
@@ -952,7 +952,7 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message)
*/
void
-irc_server_sendf (struct t_irc_server *server, char *fmt, ...)
+irc_server_sendf (struct t_irc_server *server, char *format, ...)
{
va_list args;
static char buffer[4096];
@@ -962,8 +962,8 @@ irc_server_sendf (struct t_irc_server *server, char *fmt, ...)
if (!server)
return;
- va_start (args, fmt);
- vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
+ va_start (args, format);
+ vsnprintf (buffer, sizeof (buffer) - 1, format, args);
va_end (args);
ptr_buf = buffer;
@@ -1044,7 +1044,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
if (!server->unterminated_message && !msg[0])
return;
- message = (struct t_irc_message *) malloc (sizeof (struct t_irc_message));
+ message = (struct t_irc_message *)malloc (sizeof (struct t_irc_message));
if (!message)
{
weechat_printf (server->buffer,
@@ -1056,8 +1056,8 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
message->server = server;
if (server->unterminated_message)
{
- message->data = (char *) malloc (strlen (server->unterminated_message) +
- strlen (msg) + 1);
+ message->data = (char *)malloc (strlen (server->unterminated_message) +
+ strlen (msg) + 1);
if (!message->data)
{
weechat_printf (server->buffer,
@@ -1102,9 +1102,9 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, char *string)
if (server->unterminated_message)
{
server->unterminated_message =
- (char *) realloc (server->unterminated_message,
- strlen (server->unterminated_message) +
- strlen (string) + 1);
+ (char *)realloc (server->unterminated_message,
+ strlen (server->unterminated_message) +
+ strlen (string) + 1);
if (!server->unterminated_message)
{
weechat_printf (server->buffer,
@@ -1292,11 +1292,11 @@ irc_server_msgq_flush ()
}
/*
- * irc_server_recv: receive data from an irc server
+ * irc_server_recv_cb: receive data from an irc server
*/
int
-irc_server_recv (void *arg_server)
+irc_server_recv_cb (void *arg_server)
{
struct t_irc_server *server;
@@ -1335,12 +1335,12 @@ irc_server_recv (void *arg_server)
}
/*
- * irc_server_timer: timer called each second to perform some operations
- * on servers
+ * irc_server_timer_cb: timer called each second to perform some operations
+ * on servers
*/
void
-irc_server_timer (void *empty)
+irc_server_timer_cb (void *empty)
{
struct t_irc_server *ptr_server;
time_t new_time;
@@ -1540,7 +1540,8 @@ irc_server_child_read (void *arg_server)
num_read = read (server->child_read, buffer, sizeof (buffer));
if (num_read > 0)
{
- config_proxy_use = weechat_config_boolean (weechat_config_get ("proxy_use"));
+ config_proxy_use = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_use"));
switch (buffer[0])
{
/* connection OK */
@@ -1568,7 +1569,7 @@ irc_server_child_read (void *arg_server)
weechat_unhook (server->hook_fd);
server->hook_fd = weechat_hook_fd (server->sock,
1, 0, 0,
- irc_server_recv,
+ irc_server_recv_cb,
server);
break;
/* adress not found */
@@ -1630,7 +1631,7 @@ irc_server_child_read (void *arg_server)
*/
void
-irc_server_convbase64_8x3_to_6x4 (char *from, char* to)
+irc_server_convbase64_8x3_to_6x4 (char *from, char *to)
{
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -1700,8 +1701,10 @@ irc_server_pass_httpproxy (int sock, char *address, int port)
char *config_proxy_username, *config_proxy_password;
int n, m;
- config_proxy_username = weechat_config_string (weechat_config_get ("proxy_username"));
- config_proxy_username = weechat_config_string (weechat_config_get ("proxy_password"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_username"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_password"));
if (config_proxy_username && config_proxy_username[0])
{
@@ -1854,8 +1857,10 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
socks5.version = 5;
socks5.nmethods = 1;
- config_proxy_username = weechat_config_string (weechat_config_get ("proxy_username"));
- config_proxy_username = weechat_config_string (weechat_config_get ("proxy_password"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_username"));
+ config_proxy_username = weechat_config_string (
+ weechat_config_get_weechat ("proxy_password"));
if (config_proxy_username && config_proxy_username[0])
socks5.method = 2; /* with authentication */
@@ -1913,7 +1918,7 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
/* authentication successful then giving address/port to connect */
addr_len = strlen(address);
addr_buffer_len = 4 + 1 + addr_len + 2;
- addr_buffer = (unsigned char *) malloc (addr_buffer_len * sizeof(*addr_buffer));
+ addr_buffer = (unsigned char *)malloc (addr_buffer_len * sizeof(*addr_buffer));
if (!addr_buffer)
return 1;
addr_buffer[0] = 5; /* version 5 */
@@ -1985,7 +1990,8 @@ irc_server_pass_proxy (int sock, char *address, int port, char *username)
int rc;
char *config_proxy_type;
- config_proxy_type = weechat_config_string (weechat_config_get ("proxy_type"));
+ config_proxy_type = weechat_config_string (
+ weechat_config_get_weechat ("proxy_type"));
rc = 1;
if (config_proxy_type)
@@ -2015,10 +2021,14 @@ irc_server_child (struct t_irc_server *server)
res = NULL;
res_local = NULL;
- config_proxy_use = weechat_config_boolean (weechat_config_get ("proxy_use"));
- config_proxy_ipv6 = weechat_config_integer (weechat_config_get ("proxy_ipv6"));
- config_proxy_port = weechat_config_integer (weechat_config_get ("proxy_port"));
- config_proxy_address = weechat_config_string (weechat_config_get ("proxy_address"));
+ config_proxy_use = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_use"));
+ config_proxy_ipv6 = weechat_config_integer (
+ weechat_config_get_weechat ("proxy_ipv6"));
+ config_proxy_port = weechat_config_integer (
+ weechat_config_get_weechat ("proxy_port"));
+ config_proxy_address = weechat_config_string (
+ weechat_config_get_weechat ("proxy_address"));
if (config_proxy_use)
{
@@ -2155,11 +2165,16 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
char *config_proxy_type, *config_proxy_address;
int config_proxy_use, config_proxy_ipv6, config_proxy_port;
- config_proxy_use = weechat_config_boolean (weechat_config_get ("proxy_use"));
- config_proxy_ipv6 = weechat_config_boolean (weechat_config_get ("proxy_ipv6"));
- config_proxy_type = weechat_config_string (weechat_config_get ("proxy_type"));
- config_proxy_address = weechat_config_string (weechat_config_get ("proxy_address"));
- config_proxy_port = weechat_config_integer (weechat_config_get ("proxy_port"));
+ config_proxy_use = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_use"));
+ config_proxy_ipv6 = weechat_config_boolean (
+ weechat_config_get_weechat ("proxy_ipv6"));
+ config_proxy_type = weechat_config_string (
+ weechat_config_get_weechat ("proxy_type"));
+ config_proxy_address = weechat_config_string (
+ weechat_config_get_weechat ("proxy_address"));
+ config_proxy_port = weechat_config_integer (
+ weechat_config_get_weechat ("proxy_port"));
if (!server->buffer)
{
@@ -2167,6 +2182,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (!server->buffer)
return 0;
weechat_buffer_set (server->buffer, "display", "1");
+ weechat_hook_signal_send ("logger_backlog", server->buffer);
}
#ifndef HAVE_GNUTLS
@@ -2477,17 +2493,17 @@ irc_server_autojoin_channels (struct t_irc_server *server)
*/
struct t_irc_server *
-irc_server_search (char *servername)
+irc_server_search (char *server_name)
{
struct t_irc_server *ptr_server;
- if (!servername)
+ if (!server_name)
return NULL;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- if (strcmp (ptr_server->name, servername) == 0)
+ if (strcmp (ptr_server->name, server_name) == 0)
return ptr_server;
}
return NULL;
@@ -2538,27 +2554,6 @@ irc_server_get_number_buffer (struct t_irc_server *server,
}
/*
- * irc_server_name_already_exists: return 1 if server name already exists
- * otherwise return 0
- */
-
-int
-irc_server_name_already_exists (char *name)
-{
- struct t_irc_server *ptr_server;
-
- if (!name)
- return 0;
-
- for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
- {
- if (strcmp (ptr_server->name, name) == 0)
- return 1;
- }
- return 0;
-}
-
-/*
* irc_server_get_channel_count: return number of channels for server
*/
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index c610f53f9..2c70d9b43 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -132,54 +132,70 @@ extern const int gnutls_prot_prio[];
#endif
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
-extern void irc_server_init (struct t_irc_server *);
-extern int irc_server_init_with_url (struct t_irc_server *, char *);
-extern void irc_server_init_with_config_options (struct t_irc_server *, void *,
- int);
+extern void irc_server_init (struct t_irc_server *server);
+extern int irc_server_init_with_url (struct t_irc_server *server, char *irc_url);
+extern void irc_server_init_with_config_options (struct t_irc_server *server,
+ struct t_config_section *section,
+ int config_reload);
extern struct t_irc_server *irc_server_alloc ();
-extern void irc_server_outqueue_free_all (struct t_irc_server *);
-extern void irc_server_free_data (struct t_irc_server *);
-extern void irc_server_free (struct t_irc_server *);
+extern void irc_server_outqueue_free_all (struct t_irc_server *server);
+extern void irc_server_free_data (struct t_irc_server *server);
+extern void irc_server_free (struct t_irc_server *server);
extern void irc_server_free_all ();
-extern struct t_irc_server *irc_server_new (char *, int, int, int, int, char *,
- int, int, int, char *, char *,
- char *, char *, char *, char *,
- char *, char *, int, char *, int,
- char *);
-extern struct t_irc_server *irc_server_duplicate (struct t_irc_server *, char *);
-extern int irc_server_rename (struct t_irc_server *, char *);
-extern int irc_server_send (struct t_irc_server *, char *, int);
-extern void irc_server_outqueue_send (struct t_irc_server *);
-extern void irc_server_sendf (struct t_irc_server *, char *, ...);
-extern void irc_server_parse_message (char *, char **, char **, char **);
-extern int irc_server_recv (void *);
-extern void irc_server_timer (void *);
-extern void irc_server_timer_check_away (void *);
-extern int irc_server_child_read (void *);
-extern void irc_server_convbase64_8x3_to_6x4 (char *, char*);
-extern void irc_server_base64encode (char *, char *);
-extern int irc_server_pass_httpproxy (int, char*, int);
-extern int irc_server_resolve (char *, char *, int *);
-extern int irc_server_pass_socks4proxy (int, char*, int, char*);
-extern int irc_server_pass_socks5proxy (int, char*, int);
-extern int irc_server_pass_proxy (int, char*, int, char*);
-extern int irc_server_connect (struct t_irc_server *, int);
-extern void irc_server_reconnect (struct t_irc_server *);
-extern void irc_server_auto_connect (int, int);
-extern void irc_server_disconnect (struct t_irc_server *, int);
+extern struct t_irc_server *irc_server_new (char *name, int autoconnect,
+ int autoreconnect,
+ int autoreconnect_delay,
+ int temp_server, char *address,
+ int port, int ipv6, int ssl,
+ char *password, char *nick1,
+ char *nick2, char *nick3,
+ char *username, char *realname,
+ char *hostname, char *command,
+ int command_delay, char *autojoin,
+ int autorejoin,
+ char *notify_levels);
+extern struct t_irc_server *irc_server_duplicate (struct t_irc_server *server,
+ char *new_name);
+extern int irc_server_rename (struct t_irc_server *server, char *new_name);
+extern int irc_server_send (struct t_irc_server *server, char *buffer,
+ int size_buf);
+extern void irc_server_outqueue_send (struct t_irc_server *server);
+extern void irc_server_sendf (struct t_irc_server *server, char *format, ...);
+extern void irc_server_parse_message (char *message, char **host,
+ char **command, char **args);
+extern int irc_server_recv_cb (void *arg_server);
+extern void irc_server_timer_cb (void *empty);
+extern void irc_server_timer_check_away (void *empty);
+extern int irc_server_child_read (void *arg_server);
+extern void irc_server_convbase64_8x3_to_6x4 (char *from, char *to);
+extern void irc_server_base64encode (char *from, char *to);
+extern int irc_server_pass_httpproxy (int sock, char *address, int port);
+extern int irc_server_resolve (char *hostname, char *ip, int *version);
+extern int irc_server_pass_socks4proxy (int sock, char *address, int port,
+ char *username);
+extern int irc_server_pass_socks5proxy (int sock, char *address, int port);
+extern int irc_server_pass_proxy (int sock, char *address, int port,
+ char *username);
+extern int irc_server_connect (struct t_irc_server *server,
+ int disable_autojoin);
+extern void irc_server_reconnect (struct t_irc_server *server);
+extern void irc_server_auto_connect (int auto_connect, int temp_server);
+extern void irc_server_disconnect (struct t_irc_server *server, int reconnect);
extern void irc_server_disconnect_all ();
extern void irc_server_autojoin_channels ();
-extern struct t_irc_server *irc_server_search (char *);
+extern struct t_irc_server *irc_server_search (char *server_name);
extern int irc_server_get_number_connected ();
-extern void irc_server_get_number_buffer (struct t_irc_server *, int *, int *);
-extern int irc_server_name_already_exists (char *);
-extern int irc_server_get_channel_count (struct t_irc_server *);
-extern int irc_server_get_pv_count (struct t_irc_server *);
+extern void irc_server_get_number_buffer (struct t_irc_server *server,
+ int *server_pos, int *server_total);
+extern int irc_server_get_channel_count (struct t_irc_server *server);
+extern int irc_server_get_pv_count (struct t_irc_server *server);
extern void irc_server_remove_away ();
extern void irc_server_check_away ();
-extern void irc_server_set_away (struct t_irc_server *, char *, int);
-extern int irc_server_get_default_notify_level (struct t_irc_server *);
-extern void irc_server_set_default_notify_level (struct t_irc_server *, int);
+extern void irc_server_set_away (struct t_irc_server *server, char *nick,
+ int is_away);
+extern int irc_server_get_default_notify_level (struct t_irc_server *server);
+extern void irc_server_set_default_notify_level (struct t_irc_server *server,
+ int notify);
extern void irc_server_print_log ();
#endif /* irc-server.h */
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index ab99c55dc..cc808eb0f 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -180,19 +180,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("quit", &irc_quit_cb, NULL);
/* hook completions */
- weechat_hook_completion ("irc_server", &irc_completion_server_cb, NULL);
- weechat_hook_completion ("irc_server_nicks",
- &irc_completion_server_nicks_cb, NULL);
- weechat_hook_completion ("irc_servers", &irc_completion_servers_cb, NULL);
- weechat_hook_completion ("irc_channel", &irc_completion_channel_cb, NULL);
- weechat_hook_completion ("irc_channel_nicks",
- &irc_completion_channel_nicks_cb, NULL);
- weechat_hook_completion ("irc_channel_nicks_hosts",
- &irc_completion_channel_nicks_hosts_cb, NULL);
- weechat_hook_completion ("irc_channel_topic",
- &irc_completion_channel_topic_cb, NULL);
- weechat_hook_completion ("irc_channels", &irc_completion_channels_cb, NULL);
- weechat_hook_completion ("irc_msg_part", &irc_completion_msg_part_cb, NULL);
+ irc_completion_init ();
//irc_server_auto_connect (1, 0);
diff --git a/src/plugins/logger/CMakeLists.txt b/src/plugins/logger/CMakeLists.txt
index ef4c1984c..e9000e9a8 100644
--- a/src/plugins/logger/CMakeLists.txt
+++ b/src/plugins/logger/CMakeLists.txt
@@ -14,7 +14,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-ADD_LIBRARY(logger MODULE logger.c logger-buffer.c logger-buffer.h)
+ADD_LIBRARY(logger MODULE logger.c logger.h logger-buffer.c logger-buffer.h
+logger-tail.c logger-tail.h)
SET_TARGET_PROPERTIES(logger PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(logger)
diff --git a/src/plugins/logger/Makefile.am b/src/plugins/logger/Makefile.am
index 2b94c5b2d..ddf0adb09 100644
--- a/src/plugins/logger/Makefile.am
+++ b/src/plugins/logger/Makefile.am
@@ -20,6 +20,11 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = logger.la
-logger_la_SOURCES = logger.c logger-buffer.c logger-buffer.h
+logger_la_SOURCES = logger.c \
+ logger.h \
+ logger-buffer.c \
+ logger-buffer.h \
+ logger-tail.c \
+ logger-tail.h
logger_la_LDFLAGS = -module
logger_la_LIBADD = $(LOGGER_LFLAGS)
diff --git a/src/plugins/logger/logger-buffer.c b/src/plugins/logger/logger-buffer.c
index e50acf5ee..929b68bce 100644
--- a/src/plugins/logger/logger-buffer.c
+++ b/src/plugins/logger/logger-buffer.c
@@ -39,7 +39,7 @@ struct t_logger_buffer *last_logger_buffer = NULL;
*/
struct t_logger_buffer *
-logger_buffer_add (void *buffer, char *log_filename)
+logger_buffer_add (struct t_gui_buffer *buffer, char *log_filename)
{
struct t_logger_buffer *new_logger_buffer;
@@ -52,6 +52,7 @@ logger_buffer_add (void *buffer, char *log_filename)
new_logger_buffer->buffer = buffer;
new_logger_buffer->log_filename = strdup (log_filename);
new_logger_buffer->log_file = NULL;
+ new_logger_buffer->log_enabled = 1;
new_logger_buffer->prev_buffer = last_logger_buffer;
new_logger_buffer->next_buffer = NULL;
@@ -70,14 +71,14 @@ logger_buffer_add (void *buffer, char *log_filename)
*/
struct t_logger_buffer *
-logger_buffer_search (void *buffer)
+logger_buffer_search (struct t_gui_buffer *buffer)
{
struct t_logger_buffer *ptr_logger_buffer;
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
{
- if (ptr_logger_buffer->buffer == (struct t_gui_buffer *)buffer)
+ if (ptr_logger_buffer->buffer == buffer)
return ptr_logger_buffer;
}
@@ -116,25 +117,11 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
}
/*
- * logger_buffer_remove: remove a buffer from list
+ * logger_buffer_free_all: remove all buffers from list
*/
void
-logger_buffer_remove (void *buffer)
-{
- struct t_logger_buffer *ptr_logger_buffer;
-
- ptr_logger_buffer = logger_buffer_search (buffer);
- if (ptr_logger_buffer)
- logger_buffer_free (ptr_logger_buffer);
-}
-
-/*
- * logger_buffer_remove_all: remove all buffers from list
- */
-
-void
-logger_buffer_remove_all ()
+logger_buffer_free_all ()
{
while (logger_buffers)
{
diff --git a/src/plugins/logger/logger-buffer.h b/src/plugins/logger/logger-buffer.h
index 1d7ee8225..e01e71d9c 100644
--- a/src/plugins/logger/logger-buffer.h
+++ b/src/plugins/logger/logger-buffer.h
@@ -25,6 +25,7 @@ struct t_logger_buffer
struct t_gui_buffer *buffer; /* pointer to buffer */
char *log_filename; /* log filename */
FILE *log_file; /* log file */
+ int log_enabled; /* log enabled ? */
struct t_logger_buffer *prev_buffer; /* link to previous buffer */
struct t_logger_buffer *next_buffer; /* link to next buffer */
};
@@ -32,9 +33,10 @@ struct t_logger_buffer
extern struct t_logger_buffer *logger_buffers;
extern struct t_logger_buffer *last_logger_buffer;
-extern struct t_logger_buffer *logger_buffer_add (void *, char *);
-extern struct t_logger_buffer *logger_buffer_search (void *);
-extern void logger_buffer_remove (void *);
-extern void logger_buffer_remove_all ();
+extern struct t_logger_buffer *logger_buffer_add (struct t_gui_buffer *,
+ char *log_filename);
+extern struct t_logger_buffer *logger_buffer_search (struct t_gui_buffer *buffer);
+extern void logger_buffer_free (struct t_logger_buffer *logger_buffer);
+extern void logger_buffer_free_all ();
#endif /* logger-buffer.h */
diff --git a/src/plugins/logger/logger-tail.c b/src/plugins/logger/logger-tail.c
new file mode 100644
index 000000000..47504cd4a
--- /dev/null
+++ b/src/plugins/logger/logger-tail.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* logger-tail.c: return last lines of a file */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "logger.h"
+#include "logger-tail.h"
+
+
+#define LOGGER_TAIL_BUFSIZE 4096
+
+
+/*
+ * logger_tail_last_eol: find last eol in a string
+ */
+
+char *
+logger_tail_last_eol (char *string_start, char *string_ptr)
+{
+ while (string_ptr >= string_start)
+ {
+ if ((string_ptr[0] == '\n') || (string_ptr[0] == '\r'))
+ return string_ptr;
+ string_ptr--;
+ }
+
+ /* no end-of-line found in string */
+ return NULL;
+}
+
+/*
+ * logger_tail_file: return last lines of a file
+ */
+
+struct t_logger_line *
+logger_tail_file (char *filename, int n_lines)
+{
+ int fd;
+ off_t file_length, file_pos;
+ size_t to_read;
+ ssize_t bytes_read;
+ char buf[LOGGER_TAIL_BUFSIZE + 1];
+ char *ptr_buf, *pos_eol, *part_of_line, *new_part_of_line;
+ struct t_logger_line *ptr_line, *new_line;
+
+ /* open file */
+ fd = open (filename, O_RDONLY);
+ if (fd == -1)
+ return NULL;
+
+ /* seek to the end of file */
+ file_length = lseek (fd, (off_t)0, SEEK_END);
+ if (file_length <= 0)
+ {
+ close (fd);
+ return NULL;
+ }
+ to_read = file_length;
+ file_pos = file_length - LOGGER_TAIL_BUFSIZE;
+ if (file_pos < 0)
+ file_pos = 0;
+ else
+ to_read = LOGGER_TAIL_BUFSIZE;
+ lseek (fd, file_pos, SEEK_SET);
+
+ /* loop until we have "n_lines" lines in list */
+ part_of_line = NULL;
+ ptr_line = NULL;
+ while (n_lines > 0)
+ {
+ lseek (fd, file_pos, SEEK_SET);
+ bytes_read = read (fd, buf, to_read);
+ if (bytes_read <= 0)
+ {
+ logger_tail_free (ptr_line);
+ close (fd);
+ return NULL;
+ }
+ buf[bytes_read] = '\0';
+ ptr_buf = buf + bytes_read - 1;
+ while (ptr_buf && (ptr_buf >= buf))
+ {
+ pos_eol = logger_tail_last_eol (buf, ptr_buf);
+ if ((pos_eol && pos_eol[1]) || (!pos_eol && (file_pos == 0)))
+ {
+ /* use data and part_of_line (if existing) to build a new line */
+ if (!pos_eol)
+ {
+ ptr_buf = NULL;
+ pos_eol = buf;
+ }
+ else
+ {
+ ptr_buf = pos_eol - 1;
+ pos_eol[0] = '\0';
+ pos_eol++;
+ }
+ new_line = (struct t_logger_line *)malloc (sizeof (struct t_logger_line));
+ if (!new_line)
+ {
+ logger_tail_free (ptr_line);
+ ptr_line = NULL;
+ break;
+ }
+ if (part_of_line)
+ {
+ new_line->data = (char *)malloc (strlen (pos_eol) +
+ strlen (part_of_line) + 1);
+ if (!new_line->data)
+ {
+ free (part_of_line);
+ logger_tail_free (ptr_line);
+ close (fd);
+ return NULL;
+ }
+ strcpy (new_line->data, pos_eol);
+ strcat (new_line->data, part_of_line);
+ free (part_of_line);
+ part_of_line = NULL;
+ }
+ else
+ {
+ new_line->data = strdup (pos_eol);
+ }
+ new_line->next_line = ptr_line;
+ ptr_line = new_line;
+ n_lines--;
+ if (n_lines <= 0)
+ break;
+ }
+ else if (!pos_eol)
+ {
+ /* beginning of read buffer reached without EOL, then we
+ add string to part_of_line, we'll use that later */
+ if (part_of_line)
+ {
+ new_part_of_line = (char *)malloc (strlen (buf) +
+ strlen (part_of_line) + 1);
+ if (!new_part_of_line)
+ {
+ free (part_of_line);
+ logger_tail_free (ptr_line);
+ close (fd);
+ return NULL;
+ }
+ strcpy (new_part_of_line, buf);
+ strcat (new_part_of_line, part_of_line);
+ free (part_of_line);
+ part_of_line = new_part_of_line;
+ }
+ else
+ {
+ part_of_line = (char *)malloc (strlen (buf) + 1);
+ strcpy (part_of_line, buf);
+ }
+ ptr_buf = NULL;
+ }
+ else
+ ptr_buf = pos_eol - 1;
+ }
+ if (file_pos == 0)
+ break;
+ to_read = file_pos;
+ file_pos -= LOGGER_TAIL_BUFSIZE;
+ if (file_pos < 0)
+ file_pos = 0;
+ else
+ to_read = LOGGER_TAIL_BUFSIZE;
+ }
+
+ if (part_of_line)
+ free (part_of_line);
+
+ close (fd);
+
+ return ptr_line;
+}
+
+/*
+ * logger_tail_free: free structure returned by "logger_tail_file" function
+ */
+
+void
+logger_tail_free (struct t_logger_line *lines)
+{
+ if (!lines)
+ return;
+
+ while (lines->next_line)
+ {
+ if (lines->data)
+ free (lines->data);
+ lines = lines->next_line;
+ }
+ free (lines);
+}
diff --git a/src/plugins/logger/logger-tail.h b/src/plugins/logger/logger-tail.h
new file mode 100644
index 000000000..55feb2d1c
--- /dev/null
+++ b/src/plugins/logger/logger-tail.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_LOGGER_TAIL_H
+#define __WEECHAT_LOGGER_TAIL_H 1
+
+struct t_logger_line
+{
+ char *data; /* line content */
+ struct t_logger_line *next_line; /* link to next line */
+};
+
+extern struct t_logger_line *logger_tail_file (char *filename, int n_lines);
+extern void logger_tail_free (struct t_logger_line *lines);
+
+#endif /* logger-tail.h */
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 7a0eb8041..922c38409 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -34,8 +34,9 @@
#include <fcntl.h>
#include <time.h>
-#include "../weechat-plugin.h"
+#include "logger.h"
#include "logger-buffer.h"
+#include "logger-tail.h"
char plugin_name[] = "logger";
@@ -43,36 +44,74 @@ char plugin_version[] = "0.1";
char plugin_description[] = "Logger plugin for WeeChat";
struct t_weechat_plugin *weechat_logger_plugin = NULL;
-#define weechat_plugin weechat_logger_plugin
-char *logger_path = NULL;
-char *logger_time_format = NULL;
+#define LOGGER_OPTION_PATH "path"
+#define LOGGER_OPTION_TIME_FORMAT "time_format"
+#define LOGGER_OPTION_INFO_LINES "info_lines"
+#define LOGGER_OPTION_BACKLOG "backlog"
+
+char *logger_option_path = NULL;
+char *logger_option_time_format = NULL;
+int logger_option_info_lines;
+int logger_option_backlog;
/*
* logger_config_read: read config options for logger plugin
+ * return: 1 if ok
+ * 0 if error
*/
-void
+int
logger_config_read ()
{
- if (logger_path)
- free (logger_path);
- logger_path = weechat_plugin_config_get ("path");
- if (!logger_path)
+ long number;
+ char *string, *error;
+
+ logger_option_path = weechat_config_get_plugin (LOGGER_OPTION_PATH);
+ if (!logger_option_path)
{
- weechat_plugin_config_set ("path", "%h/logs/");
- logger_path = weechat_plugin_config_get ("path");
+ weechat_config_set_plugin (LOGGER_OPTION_PATH, "%h/logs/");
+ logger_option_path = weechat_config_get_plugin ("path");
}
-
- if (logger_time_format)
- free (logger_time_format);
- logger_time_format = weechat_plugin_config_get ("time_format");
- if (!logger_time_format)
+
+ logger_option_time_format = weechat_config_get_plugin (LOGGER_OPTION_TIME_FORMAT);
+ if (!logger_option_time_format)
{
- weechat_plugin_config_set ("time_format", "%Y %b %d %H:%M:%S");
- logger_time_format = weechat_plugin_config_get ("time_format");
+ weechat_config_set_plugin (LOGGER_OPTION_TIME_FORMAT,
+ "%Y %b %d %H:%M:%S");
+ logger_option_time_format = weechat_config_get_plugin (LOGGER_OPTION_TIME_FORMAT);
}
+
+ string = weechat_config_get_plugin (LOGGER_OPTION_INFO_LINES);
+ if (!string)
+ {
+ weechat_config_set_plugin (LOGGER_OPTION_INFO_LINES, "off");
+ string = weechat_config_get_plugin (LOGGER_OPTION_INFO_LINES);
+ }
+ if (string && (weechat_config_string_to_boolean (string) > 0))
+ logger_option_info_lines = 1;
+ else
+ logger_option_info_lines = 0;
+
+ string = weechat_config_get_plugin (LOGGER_OPTION_BACKLOG);
+ if (!string)
+ {
+ weechat_config_set_plugin (LOGGER_OPTION_BACKLOG, "20");
+ string = weechat_config_get_plugin (LOGGER_OPTION_BACKLOG);
+ }
+ logger_option_backlog = 20;
+ if (string)
+ {
+ error = NULL;
+ number = strtol (string, &error, 10);
+ if (error && (error[0] == '\0'))
+ logger_option_backlog = number;
+ }
+ if (logger_option_path && logger_option_time_format && logger_option_backlog)
+ return 1;
+ else
+ return 0;
}
/*
@@ -88,7 +127,7 @@ logger_create_directory ()
rc = 1;
- dir1 = weechat_string_replace (logger_path, "~", getenv ("HOME"));
+ dir1 = weechat_string_replace (logger_option_path, "~", getenv ("HOME"));
if (dir1)
{
weechat_dir = weechat_info_get ("weechat_dir");
@@ -99,7 +138,8 @@ logger_create_directory ()
{
if (mkdir (dir2, 0755) < 0)
{
- if (errno != EEXIST) rc = 0;
+ if (errno != EEXIST)
+ rc = 0;
}
else
chmod (dir2, 0700);
@@ -124,7 +164,7 @@ logger_create_directory ()
*/
char *
-logger_get_filename (void *buffer)
+logger_get_filename (struct t_gui_buffer *buffer)
{
struct t_plugin_infolist *ptr_infolist;
char *res;
@@ -136,7 +176,8 @@ logger_get_filename (void *buffer)
dir_separator = weechat_info_get ("dir_separator");
weechat_dir = weechat_info_get ("weechat_dir");
- log_path = weechat_string_replace (logger_path, "~", getenv ("HOME"));
+ log_path = weechat_string_replace (logger_option_path, "~",
+ getenv ("HOME"));
log_path2 = weechat_string_replace (log_path, "%h", weechat_dir);
if (dir_separator && weechat_dir && log_path && log_path2)
@@ -230,22 +271,25 @@ logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...)
free (charset);
return;
}
-
- seconds = time (NULL);
- date_tmp = localtime (&seconds);
- buf_time[0] = '\0';
- if (date_tmp)
- strftime (buf_time, sizeof (buf_time) - 1,
- logger_time_format, date_tmp);
- snprintf (buf, sizeof (buf) - 1,
- _("**** Beginning of log %s ****"),
- buf_time);
- message = (charset) ?
- weechat_iconv_from_internal (charset, buf) : NULL;
- fprintf (logger_buffer->log_file,
- "%s\n", (message) ? message : buf);
- if (message)
- free (message);
+
+ if (logger_option_info_lines)
+ {
+ seconds = time (NULL);
+ date_tmp = localtime (&seconds);
+ buf_time[0] = '\0';
+ if (date_tmp)
+ strftime (buf_time, sizeof (buf_time) - 1,
+ logger_option_time_format, date_tmp);
+ snprintf (buf, sizeof (buf) - 1,
+ _("%s\t**** Beginning of log ****"),
+ buf_time);
+ message = (charset) ?
+ weechat_iconv_from_internal (charset, buf) : NULL;
+ fprintf (logger_buffer->log_file,
+ "%s\n", (message) ? message : buf);
+ if (message)
+ free (message);
+ }
}
va_start (argptr, format);
@@ -270,7 +314,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer, char *format, ...)
*/
void
-logger_start_buffer (void *buffer)
+logger_start_buffer (struct t_gui_buffer *buffer)
{
struct t_logger_buffer *ptr_logger_buffer;
char *log_filename;
@@ -333,18 +377,21 @@ logger_end (struct t_logger_buffer *logger_buffer)
if (logger_buffer->log_file)
{
- seconds = time (NULL);
- date_tmp = localtime (&seconds);
- buf_time[0] = '\0';
- if (date_tmp)
- strftime (buf_time, sizeof (buf_time) - 1,
- logger_time_format, date_tmp);
- logger_write_line (logger_buffer,
- _("**** End of log %s ****"),
- buf_time);
+ if (logger_option_info_lines)
+ {
+ seconds = time (NULL);
+ date_tmp = localtime (&seconds);
+ buf_time[0] = '\0';
+ if (date_tmp)
+ strftime (buf_time, sizeof (buf_time) - 1,
+ logger_option_time_format, date_tmp);
+ logger_write_line (logger_buffer,
+ _("%s\t**** End of log ****"),
+ buf_time);
+ }
fclose (logger_buffer->log_file);
logger_buffer->log_file = NULL;
- logger_buffer_remove (logger_buffer);
+ logger_buffer_free (logger_buffer);
}
}
@@ -356,7 +403,7 @@ void
logger_end_all ()
{
struct t_logger_buffer *ptr_logger_buffer;
-
+
for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
ptr_logger_buffer = ptr_logger_buffer->next_buffer)
{
@@ -365,7 +412,7 @@ logger_end_all ()
}
/*
- * logger_buffer_open_signal_cb: callback for buffer_open signal
+ * logger_buffer_open_signal_cb: callback for "buffer_open" signal
*/
int
@@ -382,7 +429,7 @@ logger_buffer_open_signal_cb (void *data, char *signal, void *pointer)
}
/*
- * logger_buffer_close_signal_cb: callback for buffer_close signal
+ * logger_buffer_close_signal_cb: callback for "buffer_close" signal
*/
int
@@ -399,12 +446,95 @@ logger_buffer_close_signal_cb (void *data, char *signal, void *pointer)
}
/*
+ * logger_backlog: display backlog for a buffer (by reading end of log file)
+ */
+
+void
+logger_backlog (struct t_gui_buffer *buffer, char *filename, int lines)
+{
+ struct t_logger_line *last_lines, *ptr_lines;
+ char *pos_message, *error;
+ time_t datetime;
+ struct tm tm_line;
+ int num_lines;
+
+ num_lines = 0;
+ last_lines = logger_tail_file (filename, lines);
+ ptr_lines = last_lines;
+ while (ptr_lines)
+ {
+ datetime = 0;
+ pos_message = strchr (ptr_lines->data, '\t');
+ if (pos_message)
+ {
+ pos_message[0] = '\0';
+ error = strptime (ptr_lines->data, logger_option_time_format,
+ &tm_line);
+ if (error && !error[0])
+ datetime = mktime (&tm_line);
+ pos_message[0] = '\t';
+ }
+ if (pos_message)
+ {
+ if (datetime != 0)
+ weechat_printf_date (buffer, datetime, pos_message + 1);
+ else
+ weechat_printf (buffer, ptr_lines->data);
+ }
+ else
+ {
+ weechat_printf (buffer, ptr_lines->data);
+ }
+ num_lines++;
+ ptr_lines = ptr_lines->next_line;
+ }
+ if (last_lines)
+ logger_tail_free (last_lines);
+ if (num_lines > 0)
+ weechat_printf (buffer,
+ _("===\t========== End of backlog (%d lines) =========="),
+ num_lines);
+}
+
+/*
+ * logger_backlog_signal_cb: callback for "logger_backlog" signal
+ */
+
+int
+logger_backlog_signal_cb (void *data, char *signal, void *pointer)
+{
+ struct t_logger_buffer *ptr_logger_buffer;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+
+ if (logger_option_backlog >= 0)
+ {
+ ptr_logger_buffer = logger_buffer_search (pointer);
+ if (ptr_logger_buffer && ptr_logger_buffer->log_filename
+ && ptr_logger_buffer->log_enabled)
+ {
+ ptr_logger_buffer->log_enabled = 0;
+
+ logger_backlog (pointer,
+ ptr_logger_buffer->log_filename,
+ logger_option_backlog);
+
+ ptr_logger_buffer->log_enabled = 1;
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* logger_print_cb: callback for print hook
*/
int
-logger_print_cb (void *data, void *buffer, time_t date, char *prefix,
- char *message)
+logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
+ char *prefix, char *message)
{
struct t_logger_buffer *ptr_logger_buffer;
struct tm *date_tmp;
@@ -414,20 +544,19 @@ logger_print_cb (void *data, void *buffer, time_t date, char *prefix,
(void) data;
ptr_logger_buffer = logger_buffer_search (buffer);
- if (ptr_logger_buffer && ptr_logger_buffer->log_filename)
+ if (ptr_logger_buffer && ptr_logger_buffer->log_filename
+ && ptr_logger_buffer->log_enabled)
{
date_tmp = localtime (&date);
buf_time[0] = '\0';
if (date_tmp)
strftime (buf_time, sizeof (buf_time) - 1,
- logger_time_format, date_tmp);
+ logger_option_time_format, date_tmp);
logger_write_line (ptr_logger_buffer,
- "%s%s%s%s%s",
+ "%s\t%s\t%s",
buf_time,
- (buf_time[0]) ? " " : "",
(prefix) ? prefix : "",
- (prefix && prefix[0]) ? " " : "",
message);
}
@@ -435,6 +564,24 @@ logger_print_cb (void *data, void *buffer, time_t date, char *prefix,
}
/*
+ * logger_config_cb: callback for config hook
+ */
+
+int
+logger_config_cb (void *data, char *type, char *option, char *value)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) type;
+ (void) option;
+ (void) value;
+
+ logger_config_read ();
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* weechat_plugin_init: initialize logger plugin
*/
@@ -443,8 +590,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
{
weechat_plugin = plugin;
- logger_config_read ();
- if (!logger_path || !logger_time_format)
+ if (!logger_config_read ())
return WEECHAT_RC_ERROR;
if (!logger_create_directory ())
return WEECHAT_RC_ERROR;
@@ -453,9 +599,19 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("buffer_open", &logger_buffer_open_signal_cb, NULL);
weechat_hook_signal ("buffer_close", &logger_buffer_close_signal_cb, NULL);
+ weechat_hook_signal ("logger_backlog", &logger_backlog_signal_cb, NULL);
weechat_hook_print (NULL, NULL, 1, &logger_print_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_PATH,
+ &logger_config_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_TIME_FORMAT,
+ &logger_config_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_INFO_LINES,
+ &logger_config_cb, NULL);
+ weechat_hook_config ("plugin", "logger." LOGGER_OPTION_BACKLOG,
+ &logger_config_cb, NULL);
+
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/logger/logger.h b/src/plugins/logger/logger.h
new file mode 100644
index 000000000..7bb466549
--- /dev/null
+++ b/src/plugins/logger/logger.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_LOGGER_H
+#define __WEECHAT_LOGGER_H 1
+
+#include "../weechat-plugin.h"
+
+#define weechat_plugin weechat_logger_plugin
+
+extern struct t_weechat_plugin *weechat_logger_plugin;
+
+#endif /* logger.h */
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index d2afc619f..278659024 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -33,20 +33,13 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
-#include "../core/wee-hook.h"
#include "../core/wee-input.h"
-#include "../core/wee-list.h"
-#include "../core/wee-log.h"
#include "../core/wee-string.h"
-#include "../core/wee-utf8.h"
-#include "../core/wee-util.h"
+#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-infobar.h"
-#include "../gui/gui-input.h"
#include "../gui/gui-keyboard.h"
-#include "../gui/gui-nicklist.h"
-#include "../gui/gui-status.h"
#include "../gui/gui-window.h"
#include "plugin.h"
#include "plugin-config.h"
@@ -70,51 +63,12 @@ plugin_api_charset_set (struct t_weechat_plugin *plugin, char *charset)
}
/*
- * plugin_api_iconv_to_internal: encode string from a charset to WeeChat
- * internal charset
- */
-
-char *
-plugin_api_iconv_to_internal (struct t_weechat_plugin *plugin,
- char *charset, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (!string)
- return NULL;
-
- return string_iconv_to_internal (charset, string);
-}
-
-/*
- * plugin_api_iconv_from_internal: encode string from WeeChat internal
- * charset to another
- */
-
-char *
-plugin_api_iconv_from_internal (struct t_weechat_plugin *plugin,
- char *charset, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (!string)
- return NULL;
-
- return string_iconv_from_internal (charset, string);
-}
-
-/*
* plugin_api_gettext: translate a string using gettext
*/
char *
-plugin_api_gettext (struct t_weechat_plugin *plugin, char *string)
+plugin_api_gettext (char *string)
{
- /* make C compiler happy */
- (void) plugin;
-
return _(string);
}
@@ -123,353 +77,28 @@ plugin_api_gettext (struct t_weechat_plugin *plugin, char *string)
*/
char *
-plugin_api_ngettext (struct t_weechat_plugin *plugin, char *single,
- char *plural, int count)
+plugin_api_ngettext (char *single, char *plural, int count)
{
- /* make C compiler happy */
- (void) plugin;
-
return NG_(single, plural, count);
}
/*
- * plugin_api_strcasecmp: locale and case independent string comparison
- */
-
-int
-plugin_api_strcasecmp (struct t_weechat_plugin *plugin,
- char *string1, char *string2)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_strcasecmp (string1, string2);
-}
-
-/*
- * plugin_api_strncasecmp: locale and case independent string comparison
- * with max length
- */
-
-int
-plugin_api_strncasecmp (struct t_weechat_plugin *plugin,
- char *string1, char *string2, int max)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_strncasecmp (string1, string2, max);
-}
-
-/*
- * plugin_api_strcasestr: locale and case independent string search
- */
-
-char *
-plugin_api_strcasestr (struct t_weechat_plugin *plugin,
- char *string1, char *string2)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_strcasestr (string1, string2);
-}
-
-/*
- * plugin_api_string_replace: replace a string by new one in a string
- */
-
-char *
-plugin_api_string_replace (struct t_weechat_plugin *plugin,
- char *string, char *search, char *replace)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return string_replace (string, search, replace);
-}
-
-/*
- * plugin_api_string_explode: explode a string
- */
-
-char **
-plugin_api_string_explode (struct t_weechat_plugin *plugin, char *string,
- char *separators, int keep_eol,
- int num_items_max, int *num_items)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (!string || !separators || !num_items)
- return NULL;
-
- return string_explode (string, separators, keep_eol,
- num_items_max, num_items);
-}
-
-/*
- * plugin_api_string_free_exploded: free exploded string
- */
-
-void
-plugin_api_string_free_exploded (struct t_weechat_plugin *plugin,
- char **exploded_string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- string_free_exploded (exploded_string);
-}
-
-/*
- * plugin_api_string_split_command: split a ocmmanc
- */
-
-char **
-plugin_api_string_split_command (struct t_weechat_plugin *plugin, char *string,
- char separator)
-{
- if (!plugin || !string)
- return NULL;
-
- return string_split_command (string, separator);
-}
-
-/*
- * plugin_api_string_free_splitted_command: free splitted command
- */
-
-void
-plugin_api_string_free_splitted_command (struct t_weechat_plugin *plugin,
- char **splitted_command)
-{
- /* make C compiler happy */
- (void) plugin;
-
- string_free_splitted_command (splitted_command);
-}
-
-/*
- * plugin_api_utf8_has_8bits: return 1 if string has 8-bits chars, 0 if only
- * 7-bits chars
- */
-
-int
-plugin_api_utf8_has_8bits (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_has_8bits (string);
-}
-
-/*
- * plugin_api_utf8_is_valid: return 1 if UTF-8 string is valid, 0 otherwise
- * if error is not NULL, it's set with first non
- * valid UTF-8 char in string, if any
- */
-
-int
-plugin_api_utf8_is_valid (struct t_weechat_plugin *plugin, char *string,
- char **error)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_is_valid (string, error);
-}
-
-/*
- * plugin_api_utf8_normalize: normalize UTF-8 string: remove non UTF-8 chars
- * and replace them by a char
- */
-
-void
-plugin_api_utf8_normalize (struct t_weechat_plugin *plugin, char *string,
- char replacement)
-{
- /* make C compiler happy */
- (void) plugin;
-
- utf8_normalize (string, replacement);
-}
-
-/*
- * plugin_api_utf8_prev_char: return previous UTF-8 char in a string
- */
-
-char *
-plugin_api_utf8_prev_char (struct t_weechat_plugin *plugin, char *string_start,
- char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_prev_char (string_start, string);
-}
-
-/*
- * plugin_api_utf8_next_char: return next UTF-8 char in a string
- */
-
-char *
-plugin_api_utf8_next_char (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_next_char (string);
-}
-
-/*
- * plugin_api_utf8_char_size: return UTF-8 char size (in bytes)
- */
-
-int
-plugin_api_utf8_char_size (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_char_size (string);
-}
-
-/*
- * plugin_api_utf8_strlen: return length of an UTF-8 string (<= strlen(string))
- */
-
-int
-plugin_api_utf8_strlen (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_strlen (string);
-}
-
-/*
- * plugin_api_utf8_strnlen: return length of an UTF-8 string, for N bytes max
- * in string
- */
-
-int
-plugin_api_utf8_strnlen (struct t_weechat_plugin *plugin, char *string,
- int bytes)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_strnlen (string, bytes);
-}
-
-/*
- * plugin_api_utf8_strlen_screen: return number of chars needed on screen to
- * display UTF-8 string
- */
-
-int
-plugin_api_utf8_strlen_screen (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_strlen_screen (string);
-}
-
-/*
- * plugin_api_utf8_charcasecmp: compare two utf8 chars (case is ignored)
- */
-
-int
-plugin_api_utf8_charcasecmp (struct t_weechat_plugin *plugin, char *string1,
- char *string2)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_charcasecmp (string1, string2);
-}
-
-/*
- * plugin_api_utf8_char_size_screen: return number of chars needed on screen
- * to display UTF-8 char
- */
-
-int
-plugin_api_utf8_char_size_screen (struct t_weechat_plugin *plugin, char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_char_size_screen (string);
-}
-
-/*
- * plugin_api_utf8_add_offset: moves forward N chars in an UTF-8 string
- */
-
-char *
-plugin_api_utf8_add_offset (struct t_weechat_plugin *plugin, char *string,
- int offset)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_add_offset (string, offset);
-}
-
-/*
- * plugin_api_utf8_real_pos: get real position in UTF-8
- * for example: ("aébc", 2) returns 3
- */
-
-int
-plugin_api_utf8_real_pos (struct t_weechat_plugin *plugin, char *string,
- int pos)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_real_pos (string, pos);
-}
-
-/*
- * plugin_api_utf8_pos: get position in UTF-8
- * for example: ("aébc", 3) returns 2
- */
-
-int
-plugin_api_utf8_pos (struct t_weechat_plugin *plugin, char *string,
- int real_pos)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return utf8_real_pos (string, real_pos);
-}
-
-/*
* plugin_api_mkdir_home: create a directory in WeeChat home
*/
int
-plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory,
- int mode)
+plugin_api_mkdir_home (char *directory, int mode)
{
char *dir_name;
int dir_length;
- /* make C compiler happy */
- (void) plugin;
-
if (!directory)
return 0;
/* build directory, adding WeeChat home */
dir_length = strlen (weechat_home) + strlen (directory) + 2;
dir_name =
- (char *) malloc (dir_length * sizeof (char));
+ (char *)malloc (dir_length * sizeof (char));
if (!dir_name)
return 0;
@@ -493,12 +122,8 @@ plugin_api_mkdir_home (struct t_weechat_plugin *plugin, char *directory,
*/
int
-plugin_api_mkdir (struct t_weechat_plugin *plugin, char *directory,
- int mode)
+plugin_api_mkdir (char *directory, int mode)
{
- /* make C compiler happy */
- (void) plugin;
-
if (!directory)
return 0;
@@ -512,611 +137,46 @@ plugin_api_mkdir (struct t_weechat_plugin *plugin, char *directory,
}
/*
- * plugin_api_exec_on_files: find files in a directory and execute a
- * function on each file
- */
-
-void
-plugin_api_exec_on_files (struct t_weechat_plugin *plugin, char *directory,
- int (*callback)(char *))
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (directory && callback)
- util_exec_on_files (directory, callback);
-}
-
-/*
- * plugin_api_timeval_diff: calculates difference between two times (return in
- * milliseconds)
- */
-
-long
-plugin_api_timeval_diff (struct t_weechat_plugin *plugin,
- void *timeval1, void *timeval2)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return util_timeval_diff (timeval1, timeval2);
-}
-
-/*
- * plugin_api_list_new: create a new list
- */
-
-struct t_weelist *
-plugin_api_list_new (struct t_weechat_plugin *plugin)
-{
- /* make C compiler happy */
- (void) plugin;
-
- return weelist_new ();
-}
-
-/*
- * plugin_api_list_add: add a new item in a list
- */
-
-struct t_weelist_item *
-plugin_api_list_add (struct t_weechat_plugin *plugin, void *list, char *data,
- char *where)
-{
- int position;
-
- /* make C compiler happy */
- (void) plugin;
-
- if (list && data && where)
- {
- position = WEELIST_POS_SORT;
- if (string_strcasecmp (where, "sort") == 0)
- position = WEELIST_POS_SORT;
- else if (string_strcasecmp (where, "beginning") == 0)
- position = WEELIST_POS_BEGINNING;
- else if (string_strcasecmp (where, "end") == 0)
- position = WEELIST_POS_END;
-
- return weelist_add (list, data, position);
- }
- return NULL;
-}
-
-/*
- * plugin_api_list_search: search an item in a list (case sensitive)
- */
-
-struct t_weelist_item *
-plugin_api_list_search (struct t_weechat_plugin *plugin, void *list,
- char *data)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (list && data)
- return weelist_search (list, data);
- else
- return NULL;
-}
-
-/*
- * plugin_api_list_casesearch: search an item in a list (case unsensitive)
- */
-
-struct t_weelist_item *
-plugin_api_list_casesearch (struct t_weechat_plugin *plugin, void *list,
- char *data)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (list && data)
- return weelist_casesearch (list, data);
- else
- return NULL;
-}
-
-/*
- * plugin_api_list_get: get an item with position in list
- */
-
-struct t_weelist_item *
-plugin_api_list_get (struct t_weechat_plugin *plugin, void *list, int position)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (list)
- return weelist_get (list, position);
- else
- return NULL;
-}
-
-/*
- * plugin_api_list_next: get next item
- */
-
-struct t_weelist_item *
-plugin_api_list_next (struct t_weechat_plugin *plugin, void *item)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (item)
- return ((struct t_weelist_item *)item)->next_item;
- else
- return NULL;
-}
-
-/*
- * plugin_api_list_prev: get previous item
- */
-
-struct t_weelist_item *
-plugin_api_list_prev (struct t_weechat_plugin *plugin, void *item)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (item)
- return ((struct t_weelist_item *)item)->prev_item;
- else
- return NULL;
-}
-
-/*
- * plugin_api_list_string: get string value of an item
- */
-
-char *
-plugin_api_list_string (struct t_weechat_plugin *plugin, void *item)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (item)
- return (char *)(((struct t_weelist_item *)item)->data);
- else
- return NULL;
-}
-
-/*
- * plugin_api_list_size: get size of a list (number of items)
- */
-
-int
-plugin_api_list_size (struct t_weechat_plugin *plugin, void *list)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (list)
- return ((struct t_weelist *)list)->size;
- else
- return 0;
-}
-
-/*
- * plugin_api_list_remove: remove an item from a list
- */
-
-void
-plugin_api_list_remove (struct t_weechat_plugin *plugin, void *list,
- void *item)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (list && item)
- weelist_remove (list, item);
-}
-
-/*
- * plugin_api_list_remove_all: remove all item from a list
- */
-
-void
-plugin_api_list_remove_all (struct t_weechat_plugin *plugin, void *list)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (list)
- weelist_remove_all (list);
-}
-
-/*
- * plugin_api_list_free: get size of a list (number of items)
- */
-
-void
-plugin_api_list_free (struct t_weechat_plugin *plugin, void *list)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (list)
- weelist_free (list);
-}
-
-/*
- * plugin_api_config_new: create new config file structure
- */
-
-struct t_config_file *
-plugin_api_config_new (struct t_weechat_plugin *plugin, char *filename)
-{
- return config_file_new (plugin, filename);
-}
-
-/*
- * plugin_api_config_new_section: create new section in a config
- */
-
-struct t_config_section *
-plugin_api_config_new_section (struct t_weechat_plugin *plugin,
- void *config_file, char *name,
- void (*callback_read)(void *, char *, char *),
- void (*callback_write)(void *, char *),
- void (*callback_write_default)(void *, char *))
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_new_section (config_file, name, callback_read,
- callback_write, callback_write_default);
- else
- return NULL;
-}
-
-/*
- * plugin_api_config_search_section: search a section in a config
- */
-
-struct t_config_section *
-plugin_api_config_search_section (struct t_weechat_plugin *plugin,
- void *config_file, char *name)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_search_section (config_file, name);
- else
- return NULL;
-}
-
-/*
- * plugin_api_config_new_option: create new option in a config section
- */
-
-struct t_config_option *
-plugin_api_config_new_option (struct t_weechat_plugin *plugin,
- void *section, char *name, char *type,
- char *description, char *string_values,
- int min, int max, char *default_value,
- void (*callback_change)())
-
-{
- if (plugin && config_file_section_valid_for_plugin (plugin, section))
- return config_file_new_option (section, name, type, description,
- string_values, min, max, default_value,
- callback_change);
- else
- return NULL;
-}
-
-/*
- * plugin_api_config_search_option: search an option in a config or section
- */
-
-struct t_config_option *
-plugin_api_config_search_option (struct t_weechat_plugin *plugin,
- void *config_file, void *section, char *name)
-{
- if (plugin
- && (!config_file || config_file_valid_for_plugin (plugin, config_file))
- && (!section || config_file_section_valid_for_plugin (plugin, section)))
- return config_file_search_option (config_file, section, name);
- else
- return NULL;
-}
-
-/*
- * plugin_api_config_option_set: set new value for an option
- * return: 2 if ok (value changed)
- * 1 if ok (value is the same)
- * 0 if failed
- */
-
-int
-plugin_api_config_option_set (struct t_weechat_plugin *plugin,
- void *option, char *new_value)
-{
- int rc;
-
- if (plugin && config_file_option_valid_for_plugin (plugin, option))
- {
- rc = config_file_option_set (option, new_value);
- if ((rc == 2) && (((struct t_config_option *)option)->callback_change))
- (void) (((struct t_config_option *)option)->callback_change) ();
- if (rc == 0)
- return 0;
- return 1;
- }
- return 0;
-}
-
-/*
- * plugin_api_config_string_to_boolean: return boolean value of a string
- */
-
-char
-plugin_api_config_string_to_boolean (struct t_weechat_plugin *plugin,
- char *string)
-{
- /* make C compiler happy */
- (void) plugin;
-
- if (config_file_string_to_boolean (string) == CONFIG_OPTION_BOOLEAN)
- return CONFIG_BOOLEAN_TRUE;
- else
- return CONFIG_BOOLEAN_FALSE;
-}
-
-/*
- * plugin_api_config_boolean: return boolean value of an option
- */
-
-char
-plugin_api_config_boolean (struct t_weechat_plugin *plugin, void *option)
-{
- if (plugin && config_file_option_valid_for_plugin (plugin, option)
- && (((struct t_config_option *)option)->type == CONFIG_OPTION_BOOLEAN))
- return CONFIG_BOOLEAN((struct t_config_option *)option);
- else
- return 0;
-}
-
-/*
- * plugin_api_config_integer: return integer value of an option
- */
-
-int
-plugin_api_config_integer (struct t_weechat_plugin *plugin, void *option)
-{
- if (plugin && config_file_option_valid_for_plugin (plugin, option))
- {
- switch (((struct t_config_option *)option)->type)
- {
- case CONFIG_OPTION_BOOLEAN:
- if (CONFIG_BOOLEAN((struct t_config_option *)option) == CONFIG_BOOLEAN_TRUE)
- return 1;
- else
- return 0;
- case CONFIG_OPTION_INTEGER:
- case CONFIG_OPTION_COLOR:
- return CONFIG_INTEGER((struct t_config_option *)option);
- case CONFIG_OPTION_STRING:
- return 0;
- }
- }
- return 0;
-}
-
-/*
- * plugin_api_config_string: return string value of an option
- */
-
-char *
-plugin_api_config_string (struct t_weechat_plugin *plugin, void *option)
-{
- if (plugin && config_file_option_valid_for_plugin (plugin, option))
- {
- if (((struct t_config_option *)option)->type == CONFIG_OPTION_STRING)
- return CONFIG_STRING((struct t_config_option *)option);
- if ((((struct t_config_option *)option)->type == CONFIG_OPTION_INTEGER)
- && (((struct t_config_option *)option)->string_values))
- return ((struct t_config_option *)option)->
- string_values[CONFIG_INTEGER(((struct t_config_option *)option))];
- }
- return NULL;
-}
-
-/*
- * plugin_api_config_color: return color value of an option
- */
-
-int
-plugin_api_config_color (struct t_weechat_plugin *plugin, void *option)
-{
- if (plugin && config_file_option_valid_for_plugin (plugin, option)
- && (((struct t_config_option *)option)->type == CONFIG_OPTION_COLOR))
- return CONFIG_COLOR((struct t_config_option *)option);
- else
- return 0;
-}
-
-/*
- * plugin_api_config_read: read a configuration file
- */
-
-int
-plugin_api_config_read (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_read ((struct t_config_file *)config_file);
- else
- return -1;
-}
-
-/*
- * plugin_api_config_reload: reload a configuration file
- */
-
-int
-plugin_api_config_reload (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_reload ((struct t_config_file *)config_file);
- else
- return -1;
-}
-
-/*
- * plugin_api_config_write: write a configuration file
- */
-
-int
-plugin_api_config_write (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- return config_file_write ((struct t_config_file *)config_file, 0);
- else
- return -1;
-}
-
-/*
- * plugin_api_config_write_line: write a line in configuration file
- */
-
-void
-plugin_api_config_write_line (struct t_weechat_plugin *plugin,
- void *config_file, char *option_name,
- char *value, ...)
-{
- char buf[4096];
- va_list argptr;
-
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- {
- va_start (argptr, value);
- vsnprintf (buf, sizeof (buf) - 1, value, argptr);
- va_end (argptr);
- config_file_write_line ((struct t_config_file *)config_file,
- option_name, buf);
- }
-}
-
-/*
- * plugin_api_config_free: free a configuration file
- */
-
-void
-plugin_api_config_free (struct t_weechat_plugin *plugin, void *config_file)
-{
- if (plugin && config_file_valid_for_plugin (plugin, config_file))
- config_file_free ((struct t_config_file *)config_file);
-}
-
-/*
- * plugin_api_get_config_str_value: return string value for any option
- * This function should never be called directly
- * (only used by weechat_get_config)
- */
-
-char *
-plugin_api_get_config_str_value (struct t_config_option *option)
-{
- char buf_temp[1024], *color_name;
-
- switch (option->type)
- {
- case CONFIG_OPTION_BOOLEAN:
- return (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
- strdup ("on") : strdup ("off");
- case CONFIG_OPTION_INTEGER:
- if (option->string_values)
- snprintf (buf_temp, sizeof (buf_temp), "%s",
- option->string_values[CONFIG_INTEGER(option)]);
- else
- snprintf (buf_temp, sizeof (buf_temp), "%d",
- CONFIG_INTEGER(option));
- return strdup (buf_temp);
- case CONFIG_OPTION_STRING:
- return strdup (CONFIG_STRING(option));
- case CONFIG_OPTION_COLOR:
- color_name = gui_color_get_name (CONFIG_INTEGER(option));
- return (color_name) ? strdup (color_name) : strdup ("");
- }
-
- /* should never be executed! */
- return NULL;
-}
-
-/*
- * plugin_api_config_get: get value of a WeeChat config option
+ * plugin_api_config_get_weechat: get value of a WeeChat config option
*/
struct t_config_option *
-plugin_api_config_get (struct t_weechat_plugin *plugin, char *option_name)
+plugin_api_config_get_weechat (char *option_name)
{
- /* make C compiler happy */
- (void) plugin;
-
return config_file_search_option (weechat_config_file, NULL,
option_name);
}
/*
- * plugin_api_config_set: set value of a config option
- */
-
-int
-plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name,
- char *value)
-{
- struct t_config_option *ptr_option;
- int rc;
-
- /* make C compiler happy */
- (void) plugin;
-
- if (!option_name || !value)
- return 0;
-
- /* search and set WeeChat config option if found */
- ptr_option = config_file_search_option (weechat_config_file, NULL,
- option_name);
- if (ptr_option)
- {
- rc = config_file_option_set (ptr_option, value);
- if ((rc == 2) && (ptr_option->callback_change))
- (void) (ptr_option->callback_change) ();
- if (rc == 0)
- return 0;
- return 1;
- }
-
- /* failed to set config option */
- return 0;
-}
-
-/*
- * plugin_api_plugin_config_get: get value of a plugin config option
+ * plugin_api_config_get_plugin: get value of a plugin config option
*/
char *
-plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option_name)
+plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
+ char *option_name)
{
struct t_config_option *ptr_option;
- if (!option_name)
+ if (!plugin || !option_name)
return NULL;
ptr_option = plugin_config_search (plugin->name, option_name);
if (ptr_option)
- return (ptr_option->value) ? strdup (ptr_option->value) : NULL;
+ return ptr_option->value;
/* option not found */
return NULL;
}
/*
- * plugin_api_plugin_config_set: set value of a plugin config option
+ * plugin_api_config_set_plugin: set value of a plugin config option
*/
int
-plugin_api_plugin_config_set (struct t_weechat_plugin *plugin,
+plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
char *option_name, char *value)
{
- if (!option_name)
+ if (!plugin || !option_name)
return 0;
if (plugin_config_set (plugin->name, option_name, value))
@@ -1130,9 +190,9 @@ plugin_api_plugin_config_set (struct t_weechat_plugin *plugin,
*/
char *
-plugin_api_prefix (struct t_weechat_plugin *plugin, char *prefix)
+plugin_api_prefix (char *prefix)
{
- if (!plugin || !prefix)
+ if (!prefix)
return gui_chat_prefix_empty;
if (string_strcasecmp (prefix, "info") == 0)
@@ -1156,11 +216,11 @@ plugin_api_prefix (struct t_weechat_plugin *plugin, char *prefix)
*/
char *
-plugin_api_color (struct t_weechat_plugin *plugin, char *color_name)
+plugin_api_color (char *color_name)
{
int num_color;
- if (!plugin || !color_name)
+ if (!color_name)
return GUI_NO_COLOR;
num_color = gui_color_search_config (color_name);
@@ -1171,75 +231,11 @@ plugin_api_color (struct t_weechat_plugin *plugin, char *color_name)
}
/*
- * plugin_api_printf: print a message on a buffer
- */
-
-void
-plugin_api_printf (struct t_weechat_plugin *plugin,
- void *buffer, char *format, ...)
-{
- va_list argptr;
- char buf[8192];
-
- if (!plugin || !format
- || !gui_buffer_valid ((struct t_gui_buffer *)buffer))
- return;
-
- va_start (argptr, format);
- vsnprintf (buf, sizeof (buf) - 1, format, argptr);
- va_end (argptr);
-
- gui_chat_printf ((struct t_gui_buffer *)buffer, "%s", buf);
-}
-
-/*
- * plugin_api_printf_date: print a message on a buffer with a specific date
- */
-
-void
-plugin_api_printf_date (struct t_weechat_plugin *plugin,
- void *buffer, time_t date, char *format, ...)
-{
- va_list argptr;
- char buf[8192];
-
- if (!plugin || !format
- || !gui_buffer_valid ((struct t_gui_buffer *)buffer))
- return;
-
- va_start (argptr, format);
- vsnprintf (buf, sizeof (buf) - 1, format, argptr);
- va_end (argptr);
-
- gui_chat_printf_date ((struct t_gui_buffer *)buffer, date, buf);
-}
-
-/*
- * plugin_api_log_printf: print a message in WeeChat log file
- */
-
-void
-plugin_api_log_printf (struct t_weechat_plugin *plugin, char *format, ...)
-{
- va_list argptr;
- char buf[8192];
-
- if (!plugin || !format)
- return;
-
- va_start (argptr, format);
- vsnprintf (buf, sizeof (buf) - 1, format, argptr);
- va_end (argptr);
-
- log_printf ("%s", buf);
-}
-
-/*
* plugin_api_infobar_printf: print a message in infobar
*/
void
-plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
+plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int delay,
char *color_name, char *format, ...)
{
va_list argptr;
@@ -1247,7 +243,7 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
char *buf2;
int num_color;
- if (!plugin || (time_displayed < 0) || !format)
+ if (!plugin || !format)
return;
va_start (argptr, format);
@@ -1264,8 +260,7 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
else
num_color = GUI_COLOR_INFOBAR;
- gui_infobar_printf (time_displayed,
- num_color,
+ gui_infobar_printf (delay, num_color,
"%s",
(buf2) ? buf2 : buf);
if (buf2)
@@ -1277,11 +272,8 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
*/
void
-plugin_api_infobar_remove (struct t_weechat_plugin *plugin, int how_many)
+plugin_api_infobar_remove (int how_many)
{
- if (!plugin)
- return;
-
if (how_many <= 0)
gui_infobar_remove_all ();
else
@@ -1292,294 +284,7 @@ plugin_api_infobar_remove (struct t_weechat_plugin *plugin, int how_many)
how_many--;
}
}
- //gui_infobar_draw (gui_current_window->buffer, 1);
-}
-
-/*
- * plugin_api_hook_command: hook a command
- */
-
-struct t_hook *
-plugin_api_hook_command (struct t_weechat_plugin *plugin, char *command,
- char *description, char *args,
- char *args_desc, char *completion,
- int (*callback)(void *, void *, int, char **, char **),
- void *data)
-{
- if (plugin && callback)
- return hook_command (plugin, command, description, args,
- args_desc, completion,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_timer: hook a timer
- */
-
-struct t_hook *
-plugin_api_hook_timer (struct t_weechat_plugin *plugin, long interval,
- int align_second, int max_calls,
- int (*callback)(void *), void *data)
-{
- if (plugin && (interval > 0) && callback)
- return hook_timer (plugin, interval, align_second, max_calls,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_fd: hook a file descriptor
- */
-
-struct t_hook *
-plugin_api_hook_fd (struct t_weechat_plugin *plugin, int fd,
- int flag_read, int flag_write, int flag_exception,
- int (*callback)(void *), void *data)
-{
- int flags;
-
- if (plugin && (fd >= 0) && callback)
- {
- flags = 0;
- if (flag_read)
- flags |= HOOK_FD_FLAG_READ;
- if (flag_write)
- flags |= HOOK_FD_FLAG_WRITE;
- if (flag_exception)
- flags |= HOOK_FD_FLAG_EXCEPTION;
- return hook_fd (plugin, fd, flags, callback, data);
- }
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_print: hook a printed message
- */
-
-struct t_hook *
-plugin_api_hook_print (struct t_weechat_plugin *plugin, void *buffer,
- char *message, int strip_colors,
- int (*callback)(void *, void *, time_t, char *, char *),
- void *data)
-{
- if (plugin && gui_buffer_valid ((struct t_gui_buffer *)buffer)
- && callback)
- return hook_print (plugin, buffer, message, strip_colors,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_signal: hook a signal
- */
-
-struct t_hook *
-plugin_api_hook_signal (struct t_weechat_plugin *plugin, char *signal,
- int (*callback)(void *, char *, void *),
- void *data)
-{
- if (plugin && signal && signal[0] && callback)
- return hook_signal (plugin, signal, callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_signal_send: send a signal
- */
-
-void
-plugin_api_hook_signal_send (struct t_weechat_plugin *plugin, char *signal,
- void *pointer)
-{
- if (plugin && signal && signal[0])
- hook_signal_exec (signal, pointer);
-}
-
-/*
- * plugin_api_hook_config: hook a config option
- */
-
-struct t_hook *
-plugin_api_hook_config (struct t_weechat_plugin *plugin, char *config_type,
- char *config_option,
- int (*callback)(void *, char *, char *, char *),
- void *data)
-{
- if (plugin && callback)
- return hook_config (plugin, config_type, config_option,
- callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_hook_completion: hook a completion
- */
-
-struct t_hook *
-plugin_api_hook_completion (struct t_weechat_plugin *plugin, char *completion,
- int (*callback)(void *, char *, void *, void *),
- void *data)
-{
- if (plugin && callback)
- return hook_completion (plugin, completion, callback, data);
-
- return NULL;
-}
-
-/*
- * plugin_api_unhook: unhook something
- */
-
-void
-plugin_api_unhook (struct t_weechat_plugin *plugin, void *hook)
-{
- if (plugin && hook
- && (hook_valid_for_plugin (plugin, (struct t_hook *)hook)))
- unhook ((struct t_hook *)hook);
-}
-
-/*
- * plugin_api_unhook_all: unhook all for a plugin
- */
-
-void
-plugin_api_unhook_all (struct t_weechat_plugin *plugin)
-{
- if (plugin)
- unhook_all (plugin);
-}
-
-/*
- * plugin_api_buffer_new: create a new buffer
- */
-
-struct t_gui_buffer *
-plugin_api_buffer_new (struct t_weechat_plugin *plugin, char *category,
- char *name,
- void (*input_data_cb)(struct t_gui_buffer *, char *))
-{
- if (plugin && name && name[0])
- return gui_buffer_new (plugin, category, name, input_data_cb);
-
- return NULL;
-}
-
-/*
- * plugin_api_buffer_search: search a buffer
- */
-
-struct t_gui_buffer *
-plugin_api_buffer_search (struct t_weechat_plugin *plugin, char *category,
- char *name)
-{
- struct t_gui_buffer *ptr_buffer;
-
- if (plugin)
- {
- ptr_buffer = gui_buffer_search_by_category_name (category, name);
- if (ptr_buffer)
- return ptr_buffer;
- return gui_current_window->buffer;
- }
-
- return NULL;
-}
-
-/*
- * plugin_api_buffer_close: close a buffer
- */
-
-void
-plugin_api_buffer_close (struct t_weechat_plugin *plugin, void *buffer)
-{
- if (plugin && buffer
- && gui_buffer_valid ((struct t_gui_buffer *)buffer))
- gui_buffer_free ((struct t_gui_buffer *)buffer, 1);
-}
-
-/*
- * plugin_api_buffer_get: get a buffer property
- */
-
-void *
-plugin_api_buffer_get (struct t_weechat_plugin *plugin, void *buffer,
- char *property)
-{
- if (plugin && buffer && property && property[0])
- return gui_buffer_get ((struct t_gui_buffer *)buffer, property);
-
- return NULL;
-}
-
-/*
- * plugin_api_buffer_set: set a buffer property
- */
-
-void
-plugin_api_buffer_set (struct t_weechat_plugin *plugin, void *buffer,
- char *property, char *value)
-{
- if (plugin && buffer && property && property[0])
- gui_buffer_set ((struct t_gui_buffer *)buffer, property, value);
-}
-
-/*
- * plugin_api_buffer_nick_add: add a nick to a buffer nicklist
- */
-
-void
-plugin_api_buffer_nick_add (struct t_weechat_plugin *plugin, void *buffer,
- char *nick, int sort_index, char *color_nick,
- char prefix, char *color_prefix)
-{
- int num_color_nick, num_color_prefix;
- struct t_gui_nick *ptr_nick;
-
- if (plugin && buffer && gui_buffer_valid ((struct t_gui_buffer *)buffer)
- && nick && nick[0])
- {
- num_color_nick = gui_color_search_config (color_nick);
- if (num_color_nick < 0)
- num_color_nick = GUI_COLOR_NICKLIST;
-
- num_color_prefix = gui_color_search_config (color_prefix);
- if (num_color_prefix < 0)
- num_color_prefix = GUI_COLOR_NICKLIST;
-
- ptr_nick = gui_nicklist_search ((struct t_gui_buffer *)buffer, nick);
- if (ptr_nick)
- gui_nicklist_update ((struct t_gui_buffer *)buffer,
- ptr_nick, nick, sort_index, num_color_nick,
- prefix, num_color_prefix);
- else
- gui_nicklist_add ((struct t_gui_buffer *)buffer,
- nick, sort_index, num_color_nick,
- prefix, num_color_prefix);
- }
-}
-
-/*
- * plugin_api_buffer_nick_remove: remove a nick from a buffer nicklist
- */
-
-void
-plugin_api_buffer_nick_remove (struct t_weechat_plugin *plugin, void *buffer,
- char *nick)
-{
- if (plugin && buffer && gui_buffer_valid ((struct t_gui_buffer *)buffer)
- && nick && nick[0])
- {
- if (gui_nicklist_remove ((struct t_gui_buffer *)buffer, nick))
- gui_nicklist_draw ((struct t_gui_buffer *)buffer, 0);
- //gui_nicklist_remove ((struct t_gui_buffer *)buffer, nick);
- }
+ gui_infobar_draw (gui_current_window->buffer, 1);
}
/*
@@ -1587,8 +292,8 @@ plugin_api_buffer_nick_remove (struct t_weechat_plugin *plugin, void *buffer,
*/
void
-plugin_api_command (struct t_weechat_plugin *plugin, void *buffer,
- char *command)
+plugin_api_command (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, char *command)
{
char *command2;
@@ -1612,8 +317,6 @@ plugin_api_command (struct t_weechat_plugin *plugin, void *buffer,
char *
plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
{
- //t_irc_server *ptr_server;
- //t_irc_channel *ptr_channel;
time_t inactivity;
char *return_str;
@@ -1656,7 +359,7 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
inactivity = 0;
else
inactivity = time (NULL) - gui_keyboard_last_activity_time;
- return_str = (char *) malloc (32);
+ return_str = (char *)malloc (32);
if (!return_str)
return NULL;
snprintf (return_str, 32, "%ld", (long int)inactivity);
@@ -1684,7 +387,7 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
{
if (gui_current_window->buffer->input)
{
- return_str = (char *) malloc (32);
+ return_str = (char *)malloc (32);
if (!return_str)
return NULL;
snprintf (return_str, 32, "%d",
@@ -1695,43 +398,6 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info)
return strdup ("");
}
- /* below are infos that need server to return value */
-
- /*plugin_find_server_channel (server, NULL, &ptr_server, &ptr_channel);
-
- if (string_strcasecmp (info, "nick") == 0)
- {
- if (ptr_server && ptr_server->is_connected && ptr_server->nick)
- return strdup (ptr_server->nick);
- }
- else if (string_strcasecmp (info, "channel") == 0)
- {
- if (GUI_BUFFER_IS_CHANNEL(gui_current_window->buffer)
- || GUI_BUFFER_IS_PRIVATE(gui_current_window->buffer))
- return strdup (GUI_CHANNEL(gui_current_window->buffer)->name);
- }
- else if (string_strcasecmp (info, "server") == 0)
- {
- if (ptr_server && ptr_server->is_connected && ptr_server->name)
- return strdup (ptr_server->name);
- }
- else if (string_strcasecmp (info, "type") == 0)
- {
- return_str = (char *) malloc (32);
- if (!return_str)
- return NULL;
- snprintf (return_str, 32, "%d",
- gui_current_window->buffer->type);
- return return_str;
- }
- else if (string_strcasecmp (info, "away") == 0)
- {
- if (ptr_server && ptr_server->is_connected && ptr_server->is_away)
- return strdup ("1");
- else
- return strdup ("0");
- }*/
-
/* info not found */
return NULL;
}
@@ -1815,18 +481,17 @@ plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
/*
* plugin_api_infolist_get: get list with infos about WeeChat structures
* WARNING: caller has to free string returned
- * by this function after use, with weechat_list_free()
+ * by this function after use, with weechat_infolist_free()
*/
struct t_plugin_infolist *
-plugin_api_infolist_get (struct t_weechat_plugin *plugin, char *name,
- void *pointer)
+plugin_api_infolist_get (char *name, void *pointer)
{
struct t_plugin_infolist *ptr_infolist;
struct t_gui_buffer *ptr_buffer;
struct t_gui_line *ptr_line;
- if (!plugin || !name || !name[0])
+ if (!name || !name[0])
return NULL;
if (string_strcasecmp (name, "buffer") == 0)
@@ -1904,9 +569,9 @@ plugin_api_infolist_get (struct t_weechat_plugin *plugin, char *name,
*/
int
-plugin_api_infolist_next (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_next (struct t_plugin_infolist *infolist)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist))
+ if (!infolist || !plugin_infolist_valid (infolist))
return 0;
return (plugin_infolist_next_item (infolist)) ? 1 : 0;
@@ -1919,9 +584,9 @@ plugin_api_infolist_next (struct t_weechat_plugin *plugin, void *infolist)
*/
int
-plugin_api_infolist_prev (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_prev (struct t_plugin_infolist *infolist)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist))
+ if (!infolist || !plugin_infolist_valid (infolist))
return 0;
return (plugin_infolist_prev_item (infolist)) ? 1 : 0;
@@ -1932,9 +597,9 @@ plugin_api_infolist_prev (struct t_weechat_plugin *plugin, void *infolist)
*/
char *
-plugin_api_infolist_fields (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_fields (struct t_plugin_infolist *infolist)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist))
+ if (!infolist || !plugin_infolist_valid (infolist))
return NULL;
return plugin_infolist_get_fields (infolist);
@@ -1945,10 +610,9 @@ plugin_api_infolist_fields (struct t_weechat_plugin *plugin, void *infolist)
*/
int
-plugin_api_infolist_integer (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_integer (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return 0;
@@ -1960,10 +624,9 @@ plugin_api_infolist_integer (struct t_weechat_plugin *plugin, void *infolist,
*/
char *
-plugin_api_infolist_string (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_string (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return NULL;
@@ -1975,10 +638,9 @@ plugin_api_infolist_string (struct t_weechat_plugin *plugin, void *infolist,
*/
void *
-plugin_api_infolist_pointer (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_pointer (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return NULL;
@@ -1990,10 +652,9 @@ plugin_api_infolist_pointer (struct t_weechat_plugin *plugin, void *infolist,
*/
time_t
-plugin_api_infolist_time (struct t_weechat_plugin *plugin, void *infolist,
- char *var)
+plugin_api_infolist_time (struct t_plugin_infolist *infolist, char *var)
{
- if (!plugin || !infolist || !plugin_infolist_valid (infolist)
+ if (!infolist || !plugin_infolist_valid (infolist)
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
return 0;
@@ -2005,43 +666,8 @@ plugin_api_infolist_time (struct t_weechat_plugin *plugin, void *infolist,
*/
void
-plugin_api_infolist_free (struct t_weechat_plugin *plugin, void *infolist)
+plugin_api_infolist_free (struct t_plugin_infolist *infolist)
{
- if (plugin && infolist && plugin_infolist_valid (infolist))
+ if (infolist && plugin_infolist_valid (infolist))
plugin_infolist_free (infolist);
}
-
-/*
- * plugin_api_log: add a message in buffer log file
- */
-
-void
-plugin_api_log (struct t_weechat_plugin *plugin,
- char *server, char *channel, char *message, ...)
-{
- (void) plugin;
- (void) server;
- (void) channel;
- (void) message;
-
- /*t_gui_buffer *ptr_buffer;
- va_list argptr;
- static char buf[8192];
- char *buf2;
-
- if (!plugin || !message)
- return;
-
- ptr_buffer = gui_buffer_search (server, channel);
- if (ptr_buffer)
- {
- va_start (argptr, message);
- vsnprintf (buf, sizeof (buf) - 1, message, argptr);
- va_end (argptr);
-
- buf2 = string_iconv_to_internal (plugin->charset, buf);
- gui_log_write_line (ptr_buffer, (buf2) ? buf2 : buf);
- if (buf2)
- free (buf2);
- }*/
-}
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index ef1c31553..7f9fb66c7 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -21,193 +21,50 @@
#define __WEECHAT_PLUGIN_API_H 1
/* strings */
-extern void plugin_api_charset_set (struct t_weechat_plugin *, char *);
-extern char *plugin_api_iconv_to_internal (struct t_weechat_plugin *, char *,
- char *);
-extern char *plugin_api_iconv_from_internal (struct t_weechat_plugin *, char *,
- char *);
-extern char *plugin_api_gettext (struct t_weechat_plugin *, char *);
-extern char *plugin_api_ngettext (struct t_weechat_plugin *, char *, char *,
- int);
-extern int plugin_api_strcasecmp (struct t_weechat_plugin *,char *, char *);
-extern int plugin_api_strncasecmp (struct t_weechat_plugin *,char *, char *,
- int);
-extern char *plugin_api_strcasestr (struct t_weechat_plugin *,char *, char *);
-extern char *plugin_api_string_replace (struct t_weechat_plugin *,char *,
- char *, char *);
-extern char **plugin_api_string_explode (struct t_weechat_plugin *, char *,
- char *, int, int, int *);
-extern void plugin_api_string_free_exploded (struct t_weechat_plugin *,
- char **);
-extern char **plugin_api_string_split_command (struct t_weechat_plugin *,
- char *, char);
-extern void plugin_api_string_free_splitted_command (struct t_weechat_plugin *,
- char **);
-
-/* UTF-8 strings */
-extern int plugin_api_utf8_has_8bits (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_is_valid (struct t_weechat_plugin *, char *, char **);
-extern void plugin_api_utf8_normalize (struct t_weechat_plugin *, char *, char);
-extern char *plugin_api_utf8_prev_char (struct t_weechat_plugin *, char *, char *);
-extern char *plugin_api_utf8_next_char (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_char_size (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_strlen (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_strnlen (struct t_weechat_plugin *, char *, int);
-extern int plugin_api_utf8_strlen_screen (struct t_weechat_plugin *, char *);
-extern int plugin_api_utf8_charcasecmp (struct t_weechat_plugin *, char *, char *);
-extern int plugin_api_utf8_char_size_screen (struct t_weechat_plugin *, char *);
-extern char *plugin_api_utf8_add_offset (struct t_weechat_plugin *, char *, int);
-extern int plugin_api_utf8_real_pos (struct t_weechat_plugin *, char *, int);
-extern int plugin_api_utf8_pos (struct t_weechat_plugin *, char *, int);
+extern void plugin_api_charset_set (struct t_weechat_plugin *plugin,
+ char *charset);
+extern char *plugin_api_gettext (char *string);
+extern char *plugin_api_ngettext (char *single, char *plural, int count);
/* directories */
-extern int plugin_api_mkdir_home (struct t_weechat_plugin *, char *, int);
-extern int plugin_api_mkdir (struct t_weechat_plugin *, char *, int);
-extern void plugin_api_exec_on_files (struct t_weechat_plugin *, char *,
- int (*)(char *));
-
-/* util */
-extern long plugin_api_timeval_diff (struct t_weechat_plugin *, void *, void *);;
-
-/* lists */
-extern struct t_weelist *plugin_api_list_new( struct t_weechat_plugin *);
-extern char *plugin_api_list_add (struct t_weechat_plugin *, void *, char *,
- char *);
-extern struct t_weelist_item *plugin_api_list_search (struct t_weechat_plugin *,
- void *, char *);
-extern struct t_weelist_item *plugin_api_list_casesearch (struct t_weechat_plugin *,
- void *, char *);
-extern struct t_weelist_item *plugin_api_list_get (struct t_weechat_plugin *,
- void *, int);
-extern struct t_weelist_item *plugin_api_list_next (struct t_weechat_plugin *,
- void *);
-extern struct t_weelist_item *plugin_api_list_prev (struct t_weechat_plugin *,
- void *);
-extern char *plugin_api_list_string (struct t_weechat_plugin *, void *);
-extern int plugin_api_list_size (struct t_weechat_plugin *, void *);
-extern void plugin_api_list_remove (struct t_weechat_plugin *, void *, void *);
-extern void plugin_api_list_remove_all (struct t_weechat_plugin *, void *);
-extern void plugin_api_list_free (struct t_weechat_plugin *, void *);
+extern int plugin_api_mkdir_home (char *directory, int mode);
+extern int plugin_api_mkdir (char *directory, int mode);
/* config */
-extern struct t_config_file *plugin_api_config_new (struct t_weechat_plugin *,
- char *);
-extern struct t_config_section *plugin_api_config_new_section (struct t_weechat_plugin *,
- void *, char *,
- void (*)(void *, char *, char *),
- void (*)(void *, char *),
- void (*)(void *, char *));
-extern struct t_config_section *plugin_api_config_search_section (struct t_weechat_plugin *,
- void *, char *);
-extern struct t_config_option *plugin_api_config_new_option (struct t_weechat_plugin *,
- void *, char *,
- char *, char *,
- char *, int, int,
- char *,
- void (*)());
-extern struct t_config_option *plugin_api_config_search_option (struct t_weechat_plugin *,
- void *, void *,
- char *);
-extern int plugin_api_config_option_set (struct t_weechat_plugin *, void *,
- char *);
-extern char plugin_api_config_string_to_boolean (struct t_weechat_plugin *,
- char *);
-extern char plugin_api_config_boolean (struct t_weechat_plugin *, void *);
-extern int plugin_api_config_integer (struct t_weechat_plugin *, void *);
-extern char *plugin_api_config_string (struct t_weechat_plugin *, void *);
-extern int plugin_api_config_color (struct t_weechat_plugin *, void *);
-extern int plugin_api_config_read (struct t_weechat_plugin *, void *);
-extern int plugin_api_config_reload (struct t_weechat_plugin *, void *);
-extern int plugin_api_config_write (struct t_weechat_plugin *, void *);
-extern void plugin_api_config_write_line (struct t_weechat_plugin *, void *,
- char *, char *, ...);
-extern void plugin_api_config_free (struct t_weechat_plugin *, void *);
-extern struct t_config_option *plugin_api_config_get (struct t_weechat_plugin *,
- char *);
-extern char *plugin_api_plugin_config_get (struct t_weechat_plugin *, char *);
-extern int plugin_api_plugin_config_set (struct t_weechat_plugin *, char *,
- char *);
+extern struct t_config_option *plugin_api_config_get_weechat (char *option_name);
+extern char *plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
+ char *option_name);
+extern int plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
+ char *option_name, char *value);
/* display */
-extern char *plugin_api_prefix (struct t_weechat_plugin *, char *);
-extern char *plugin_api_color (struct t_weechat_plugin *, char *);
-extern void plugin_api_printf (struct t_weechat_plugin *, void *,
- char *, ...);
-extern void plugin_api_printf_date (struct t_weechat_plugin *, void *,
- time_t, char *, ...);
-extern void plugin_api_log_printf (struct t_weechat_plugin *, char *, ...);
-extern void plugin_api_infobar_printf (struct t_weechat_plugin *, int, char *,
- char *, ...);
-extern void plugin_api_infobar_remove (struct t_weechat_plugin *, int);
-
-/* hooks */
-extern struct t_hook *plugin_api_hook_command (struct t_weechat_plugin *,
- char *, char *, char *, char *,
- char *,
- int (*)(void *, void *, int, char **, char **),
- void *);
-extern struct t_hook *plugin_api_hook_timer (struct t_weechat_plugin *,
- long, int, int,
- int (*)(void *), void *);
-extern struct t_hook *plugin_api_hook_fd (struct t_weechat_plugin *,
- int, int, int, int,
- int (*)(void *), void *);
-extern struct t_hook *plugin_api_hook_print (struct t_weechat_plugin *,
- void *, char *, int,
- int (*)(void *, void *, time_t, char *, char *),
- void *);
-extern struct t_hook *plugin_api_hook_signal (struct t_weechat_plugin *, char *,
- int (*)(void *, char *, void *),
- void *);
-extern void plugin_api_hook_signal_send (struct t_weechat_plugin *, char *,
- void *);
-extern struct t_hook *plugin_api_hook_config (struct t_weechat_plugin *,
- char *, char *,
- int (*)(void *, char *, char *, char *),
- void *);
-extern struct t_hook *plugin_api_hook_completion (struct t_weechat_plugin *,
- char *,
- int (*)(void *, char *, void *, void *),
- void *);
-extern void plugin_api_unhook (struct t_weechat_plugin *, void *);
-extern void plugin_api_unhook_all (struct t_weechat_plugin *);
-
-/* buffers */
-extern struct t_gui_buffer *plugin_api_buffer_new (struct t_weechat_plugin *,
- char *, char *,
- void (*)(struct t_gui_buffer *, char *));
-extern struct t_gui_buffer *plugin_api_buffer_search (struct t_weechat_plugin *,
- char *, char *);
-extern void plugin_api_buffer_close (struct t_weechat_plugin *, void *);
-extern void *plugin_api_buffer_get (struct t_weechat_plugin *, void *, char *);
-extern void plugin_api_buffer_set (struct t_weechat_plugin *, void *, char *,
- char *);
-extern void plugin_api_buffer_nick_add (struct t_weechat_plugin *, void *,
- char *, int, char *, char, char *);
-extern void plugin_api_buffer_nick_remove (struct t_weechat_plugin *, char *);
+extern char *plugin_api_prefix (char *prefix);
+extern char *plugin_api_color (char *color_name);
+extern void plugin_api_infobar_printf (int delay, char *color_name,
+ char *format, ...);
+extern void plugin_api_infobar_remove (int how_many);
/* command */
-extern void plugin_api_command (struct t_weechat_plugin *, void *, char *);
+extern void plugin_api_command (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, char *command);
/* infos */
-extern char *plugin_api_info_get (struct t_weechat_plugin *, char *);
+extern char *plugin_api_info_get (struct t_weechat_plugin *plugin, char *info);
/* infolists */
-extern struct t_plugin_infolist *plugin_api_infolist_get (struct t_weechat_plugin *,
- char *, void *);
-extern int plugin_api_infolist_next (struct t_weechat_plugin *,
- void *);
-extern int plugin_api_infolist_prev (struct t_weechat_plugin *,
- void *);
-extern char *plugin_api_infolist_fields (struct t_weechat_plugin *, void *);
-extern int plugin_api_infolist_integer (struct t_weechat_plugin *, void *, char *);
-extern char *plugin_api_infolist_string (struct t_weechat_plugin *, void *, char *);
-extern void *plugin_api_infolist_pointer (struct t_weechat_plugin *, void *, char *);
-extern time_t plugin_api_infolist_time (struct t_weechat_plugin *, void *, char *);
-extern void plugin_api_infolist_free (struct t_weechat_plugin *, void *);
-
-/* log */
-extern void plugin_api_log (struct t_weechat_plugin *, char *, char *,
- char *, ...);
+extern struct t_plugin_infolist *plugin_api_infolist_get (char *name,
+ void *pointer);
+extern int plugin_api_infolist_next (struct t_plugin_infolist *infolist);
+extern int plugin_api_infolist_prev (struct t_plugin_infolist *infolist);
+extern char *plugin_api_infolist_fields (struct t_plugin_infolist *infolist);
+extern int plugin_api_infolist_integer (struct t_plugin_infolist *infolist,
+ char *var);
+extern char *plugin_api_infolist_string (struct t_plugin_infolist *infolist,
+ char *var);
+extern void *plugin_api_infolist_pointer (struct t_plugin_infolist *infolist,
+ char *var);
+extern time_t plugin_api_infolist_time (struct t_plugin_infolist *infolist,
+ char *var);
+extern void plugin_api_infolist_free (struct t_plugin_infolist *infolist);
#endif /* plugin-api.h */
diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c
index 5ff41be75..3694aa558 100644
--- a/src/plugins/plugin-config.c
+++ b/src/plugins/plugin-config.c
@@ -289,7 +289,8 @@ plugin_config_free_all ()
*/
void
-plugin_config_read_option (void *config_file, char *option_name, char *value)
+plugin_config_read_option (struct t_config_file *config_file,
+ char *option_name, char *value)
{
char *value2;
@@ -311,7 +312,8 @@ plugin_config_read_option (void *config_file, char *option_name, char *value)
*/
void
-plugin_config_write_options (void *config_file, char *section_name)
+plugin_config_write_options (struct t_config_file *config_file,
+ char *section_name)
{
struct t_config_option *ptr_option;
@@ -383,5 +385,5 @@ int
plugin_config_write ()
{
log_printf (_("Saving plugins configuration to disk"));
- return config_file_write (plugin_config, 0);
+ return config_file_write (plugin_config);
}
diff --git a/src/plugins/plugin-config.h b/src/plugins/plugin-config.h
index 24e67101d..bb9a99b97 100644
--- a/src/plugins/plugin-config.h
+++ b/src/plugins/plugin-config.h
@@ -25,10 +25,12 @@
extern struct t_config_file *plugin_config;
extern struct t_config_option *plugin_options;
-extern struct t_config_option *plugin_config_search_internal (char *);
-extern struct t_config_option *plugin_config_search (char *, char *);
-extern int plugin_config_set_internal (char *, char *);
-extern int plugin_config_set (char *, char *, char *);
+extern struct t_config_option *plugin_config_search_internal (char *option_name);
+extern struct t_config_option *plugin_config_search (char *plugin_name,
+ char *option_name);
+extern int plugin_config_set_internal (char *option, char *value);
+extern int plugin_config_set (char *plugin_name, char *option_name,
+ char *value);
extern void plugin_config_init ();
extern int plugin_config_read ();
extern int plugin_config_reload ();
diff --git a/src/plugins/plugin-infolist.c b/src/plugins/plugin-infolist.c
index a12d4c379..59d6e1481 100644
--- a/src/plugins/plugin-infolist.c
+++ b/src/plugins/plugin-infolist.c
@@ -98,7 +98,7 @@ plugin_infolist_new_item (struct t_plugin_infolist *list)
struct t_plugin_infolist_var *
plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
- char *name, int value)
+ char *name, int value)
{
struct t_plugin_infolist_var *new_var;
@@ -131,7 +131,7 @@ plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
struct t_plugin_infolist_var *
plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
- char *name, char *value)
+ char *name, char *value)
{
struct t_plugin_infolist_var *new_var;
@@ -163,7 +163,7 @@ plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
struct t_plugin_infolist_var *
plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
- char *name, void *pointer)
+ char *name, void *pointer)
{
struct t_plugin_infolist_var *new_var;
@@ -195,7 +195,7 @@ plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
struct t_plugin_infolist_var *
plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
- char *name, time_t time)
+ char *name, time_t time)
{
struct t_plugin_infolist_var *new_var;
@@ -447,7 +447,7 @@ plugin_infolist_get_time (struct t_plugin_infolist *list, char *var)
void
plugin_infolist_var_free (struct t_plugin_infolist_item *item,
- struct t_plugin_infolist_var *var)
+ struct t_plugin_infolist_var *var)
{
struct t_plugin_infolist_var *new_vars;
@@ -485,7 +485,7 @@ plugin_infolist_var_free (struct t_plugin_infolist_item *item,
void
plugin_infolist_item_free (struct t_plugin_infolist *list,
- struct t_plugin_infolist_item *item)
+ struct t_plugin_infolist_item *item)
{
struct t_plugin_infolist_item *new_items;
diff --git a/src/plugins/plugin-infolist.h b/src/plugins/plugin-infolist.h
index 567c8b9b0..3a0a2620e 100644
--- a/src/plugins/plugin-infolist.h
+++ b/src/plugins/plugin-infolist.h
@@ -51,11 +51,11 @@ struct t_plugin_infolist_item
struct t_plugin_infolist
{
- struct t_plugin_infolist_item *items; /* link to items */
- struct t_plugin_infolist_item *last_item; /* last variable */
- struct t_plugin_infolist_item *ptr_item; /* pointer to current item */
- struct t_plugin_infolist *prev_infolist; /* link to previous list */
- struct t_plugin_infolist *next_infolist; /* link to next list */
+ struct t_plugin_infolist_item *items; /* link to items */
+ struct t_plugin_infolist_item *last_item; /* last variable */
+ struct t_plugin_infolist_item *ptr_item; /* pointer to current item */
+ struct t_plugin_infolist *prev_infolist; /* link to previous list */
+ struct t_plugin_infolist *next_infolist; /* link to next list */
};
/* list variables */
@@ -66,24 +66,32 @@ extern struct t_plugin_infolist *last_plugin_infolist;
/* list functions */
extern struct t_plugin_infolist *plugin_infolist_new ();
-extern struct t_plugin_infolist_item *plugin_infolist_new_item (struct t_plugin_infolist *);
-extern struct t_plugin_infolist_var *plugin_infolist_new_var_integer (struct t_plugin_infolist_item *,
- char *, int);
-extern struct t_plugin_infolist_var *plugin_infolist_new_var_string (struct t_plugin_infolist_item *,
- char *, char *);
-extern struct t_plugin_infolist_var *plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *,
- char *, void *);
-extern struct t_plugin_infolist_var *plugin_infolist_new_var_time (struct t_plugin_infolist_item *,
- char *, time_t);
-extern int plugin_infolist_valid (struct t_plugin_infolist *);
-extern struct t_plugin_infolist_item *plugin_infolist_next_item (struct t_plugin_infolist *);
-extern struct t_plugin_infolist_item *plugin_infolist_prev_item (struct t_plugin_infolist *);
-extern char *plugin_infolist_get_fields (struct t_plugin_infolist *);
-extern int plugin_infolist_get_integer (struct t_plugin_infolist *, char *);
-extern char *plugin_infolist_get_string (struct t_plugin_infolist *, char *);
-extern void *plugin_infolist_get_pointer (struct t_plugin_infolist *, char *);
-extern time_t plugin_infolist_get_time (struct t_plugin_infolist *, char *);
-extern void plugin_infolist_free (struct t_plugin_infolist *);
+extern struct t_plugin_infolist_item *plugin_infolist_new_item (struct t_plugin_infolist *list);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_integer (struct t_plugin_infolist_item *item,
+ char *name,
+ int value);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_string (struct t_plugin_infolist_item *item,
+ char *name,
+ char *value);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_pointer (struct t_plugin_infolist_item *item,
+ char *name,
+ void *pointer);
+extern struct t_plugin_infolist_var *plugin_infolist_new_var_time (struct t_plugin_infolist_item *item,
+ char *name,
+ time_t time);
+extern int plugin_infolist_valid (struct t_plugin_infolist *list);
+extern struct t_plugin_infolist_item *plugin_infolist_next_item (struct t_plugin_infolist *list);
+extern struct t_plugin_infolist_item *plugin_infolist_prev_item (struct t_plugin_infolist *list);
+extern char *plugin_infolist_get_fields (struct t_plugin_infolist *list);
+extern int plugin_infolist_get_integer (struct t_plugin_infolist *list,
+ char *var);
+extern char *plugin_infolist_get_string (struct t_plugin_infolist *list,
+ char *var);
+extern void *plugin_infolist_get_pointer (struct t_plugin_infolist *list,
+ char *var);
+extern time_t plugin_infolist_get_time (struct t_plugin_infolist *list,
+ char *var);
+extern void plugin_infolist_free (struct t_plugin_infolist *list);
extern void plugin_infolist_print_log ();
#endif /* plugin-infolist.h */
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 9ad3cce15..330d1cbda 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -36,10 +36,14 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
+#include "../core/wee-list.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
#include "../core/wee-util.h"
+#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
+#include "../gui/gui-nicklist.h"
#include "plugin.h"
#include "plugin-api.h"
#include "plugin-config.h"
@@ -51,37 +55,6 @@ struct t_weechat_plugin *last_weechat_plugin = NULL;
/*
- * plugin_exec_on_files: find files in a directory and execute a
- * function on each file
- */
-
-void
-plugin_exec_on_files (struct t_weechat_plugin *plugin, char *directory,
- int (*callback)(struct t_weechat_plugin *, char *))
-{
- char complete_filename[1024];
- DIR *dir;
- struct dirent *entry;
- struct stat statbuf;
-
- dir = opendir (directory);
- if (dir)
- {
- while ((entry = readdir (dir)))
- {
- snprintf (complete_filename, sizeof (complete_filename) - 1,
- "%s/%s", directory, entry->d_name);
- lstat (complete_filename, &statbuf);
- if (!S_ISDIR(statbuf.st_mode))
- {
- (int) (*callback) (plugin, complete_filename);
- }
- }
- closedir (dir);
- }
-}
-
-/*
* plugin_search: search a plugin by name
*/
@@ -224,99 +197,100 @@ plugin_load (char *filename)
/* functions */
new_plugin->charset_set = &plugin_api_charset_set;
- new_plugin->iconv_to_internal = &plugin_api_iconv_to_internal;
- new_plugin->iconv_from_internal = &plugin_api_iconv_from_internal;
+ new_plugin->iconv_to_internal = &string_iconv_to_internal;
+ new_plugin->iconv_from_internal = &string_iconv_from_internal;
new_plugin->gettext = &plugin_api_gettext;
new_plugin->ngettext = &plugin_api_ngettext;
- new_plugin->strcasecmp = &plugin_api_strcasecmp;
- new_plugin->strncasecmp = &plugin_api_strncasecmp;
- new_plugin->strcasestr = &plugin_api_strcasestr;
- new_plugin->string_replace = &plugin_api_string_replace;
- new_plugin->string_explode = &plugin_api_string_explode;
- new_plugin->string_free_exploded = &plugin_api_string_free_exploded;
- new_plugin->string_split_command = &plugin_api_string_split_command;
- new_plugin->string_free_splitted_command = &plugin_api_string_free_splitted_command;
-
- new_plugin->utf8_has_8bits = &plugin_api_utf8_has_8bits;
- new_plugin->utf8_is_valid = &plugin_api_utf8_is_valid;
- new_plugin->utf8_normalize = &plugin_api_utf8_normalize;
- new_plugin->utf8_prev_char = &plugin_api_utf8_prev_char;
- new_plugin->utf8_next_char = &plugin_api_utf8_next_char;
- new_plugin->utf8_char_size = &plugin_api_utf8_char_size;
- new_plugin->utf8_strlen = &plugin_api_utf8_strlen;
- new_plugin->utf8_strnlen = &plugin_api_utf8_strnlen;
- new_plugin->utf8_strlen_screen = &plugin_api_utf8_strlen_screen;
- new_plugin->utf8_charcasecmp = &plugin_api_utf8_charcasecmp;
- new_plugin->utf8_char_size_screen = &plugin_api_utf8_char_size_screen;
- new_plugin->utf8_add_offset = &plugin_api_utf8_add_offset;
- new_plugin->utf8_real_pos = &plugin_api_utf8_real_pos;
- new_plugin->utf8_pos = &plugin_api_utf8_pos;
+ new_plugin->strcasecmp = &string_strcasecmp;
+ new_plugin->strncasecmp = &string_strncasecmp;
+ new_plugin->strcasestr = &string_strcasestr;
+ new_plugin->string_replace = &string_replace;
+ new_plugin->string_explode = &string_explode;
+ new_plugin->string_free_exploded = &string_free_exploded;
+ new_plugin->string_split_command = &string_split_command;
+ new_plugin->string_free_splitted_command = &string_free_splitted_command;
+
+ new_plugin->utf8_has_8bits = &utf8_has_8bits;
+ new_plugin->utf8_is_valid = &utf8_is_valid;
+ new_plugin->utf8_normalize = &utf8_normalize;
+ new_plugin->utf8_prev_char = &utf8_prev_char;
+ new_plugin->utf8_next_char = &utf8_next_char;
+ new_plugin->utf8_char_size = &utf8_char_size;
+ new_plugin->utf8_strlen = &utf8_strlen;
+ new_plugin->utf8_strnlen = &utf8_strnlen;
+ new_plugin->utf8_strlen_screen = &utf8_strlen_screen;
+ new_plugin->utf8_charcasecmp = &utf8_charcasecmp;
+ new_plugin->utf8_char_size_screen = &utf8_char_size_screen;
+ new_plugin->utf8_add_offset = &utf8_add_offset;
+ new_plugin->utf8_real_pos = &utf8_real_pos;
+ new_plugin->utf8_pos = &utf8_pos;
new_plugin->mkdir_home = &plugin_api_mkdir_home;
new_plugin->mkdir = &plugin_api_mkdir;
- new_plugin->exec_on_files = &plugin_api_exec_on_files;
+ new_plugin->exec_on_files = &util_exec_on_files;
- new_plugin->timeval_diff = &plugin_api_timeval_diff;
+ new_plugin->timeval_cmp = &util_timeval_cmp;
+ new_plugin->timeval_diff = &util_timeval_diff;
+ new_plugin->timeval_add = &util_timeval_add;
- new_plugin->list_new = &plugin_api_list_new;
- new_plugin->list_add = &plugin_api_list_add;
- new_plugin->list_search = &plugin_api_list_search;
- new_plugin->list_casesearch = &plugin_api_list_casesearch;
- new_plugin->list_get = &plugin_api_list_get;
- new_plugin->list_next = &plugin_api_list_next;
- new_plugin->list_prev = &plugin_api_list_prev;
- new_plugin->list_string = &plugin_api_list_string;
- new_plugin->list_size = &plugin_api_list_size;
- new_plugin->list_remove = &plugin_api_list_remove;
- new_plugin->list_remove_all = &plugin_api_list_remove_all;
- new_plugin->list_free = &plugin_api_list_free;
+ new_plugin->list_new = &weelist_new;
+ new_plugin->list_add = &weelist_add;
+ new_plugin->list_search = &weelist_search;
+ new_plugin->list_casesearch = &weelist_casesearch;
+ new_plugin->list_get = &weelist_get;
+ new_plugin->list_next = &weelist_next;
+ new_plugin->list_prev = &weelist_prev;
+ new_plugin->list_string = &weelist_string;
+ new_plugin->list_size = &weelist_size;
+ new_plugin->list_remove = &weelist_remove;
+ new_plugin->list_remove_all = &weelist_remove_all;
+ new_plugin->list_free = &weelist_free;
- new_plugin->config_new = &plugin_api_config_new;
- new_plugin->config_new_section = &plugin_api_config_new_section;
- new_plugin->config_search_section = &plugin_api_config_search_section;
- new_plugin->config_new_option = &plugin_api_config_new_option;
- new_plugin->config_search_option = &plugin_api_config_search_option;
- new_plugin->config_option_set = &plugin_api_config_option_set;
- new_plugin->config_string_to_boolean = &plugin_api_config_string_to_boolean;
- new_plugin->config_boolean = &plugin_api_config_boolean;
- new_plugin->config_integer = &plugin_api_config_integer;
- new_plugin->config_string = &plugin_api_config_string;
- new_plugin->config_color = &plugin_api_config_color;
- new_plugin->config_read = &plugin_api_config_read;
- new_plugin->config_reload = &plugin_api_config_reload;
- new_plugin->config_write = &plugin_api_config_write;
- new_plugin->config_write_line = &plugin_api_config_write_line;
- new_plugin->config_free = &plugin_api_config_free;
- new_plugin->config_get = &plugin_api_config_get;
- new_plugin->plugin_config_get = &plugin_api_plugin_config_get;
- new_plugin->plugin_config_set = &plugin_api_plugin_config_set;
+ new_plugin->config_new = &config_file_new;
+ new_plugin->config_new_section = &config_file_new_section;
+ new_plugin->config_search_section = &config_file_search_section;
+ new_plugin->config_new_option = &config_file_new_option;
+ new_plugin->config_search_option = &config_file_search_option;
+ new_plugin->config_option_set = &config_file_option_set;
+ new_plugin->config_string_to_boolean = &config_file_string_to_boolean;
+ new_plugin->config_boolean = &config_file_option_boolean;
+ new_plugin->config_integer = &config_file_option_integer;
+ new_plugin->config_string = &config_file_option_string;
+ new_plugin->config_color = &config_file_option_color;
+ new_plugin->config_write_line = &config_file_write_line;
+ new_plugin->config_write = &config_file_write;
+ new_plugin->config_read = &config_file_read;
+ new_plugin->config_reload = &config_file_reload;
+ new_plugin->config_free = &config_file_free;
+ new_plugin->config_get_weechat = &plugin_api_config_get_weechat;
+ new_plugin->config_get_plugin = &plugin_api_config_get_plugin;
+ new_plugin->config_set_plugin = &plugin_api_config_set_plugin;
new_plugin->prefix = &plugin_api_prefix;
new_plugin->color = &plugin_api_color;
- new_plugin->printf = &plugin_api_printf;
- new_plugin->printf_date = &plugin_api_printf_date;
- new_plugin->log_printf = &plugin_api_log_printf;
+ new_plugin->printf_date = &gui_chat_printf_date;
+ new_plugin->log_printf = &log_printf;
new_plugin->infobar_printf = &plugin_api_infobar_printf;
new_plugin->infobar_remove = &plugin_api_infobar_remove;
- new_plugin->hook_command = &plugin_api_hook_command;
- new_plugin->hook_timer = &plugin_api_hook_timer;
- new_plugin->hook_fd = &plugin_api_hook_fd;
- new_plugin->hook_print = &plugin_api_hook_print;
- new_plugin->hook_signal = &plugin_api_hook_signal;
- new_plugin->hook_signal_send = &plugin_api_hook_signal_send;
- new_plugin->hook_config = &plugin_api_hook_config;
- new_plugin->hook_completion = &plugin_api_hook_completion;
- new_plugin->unhook = &plugin_api_unhook;
- new_plugin->unhook_all = &plugin_api_unhook_all;
+ new_plugin->hook_command = &hook_command;
+ new_plugin->hook_timer = &hook_timer;
+ new_plugin->hook_fd = &hook_fd;
+ new_plugin->hook_print = &hook_print;
+ new_plugin->hook_signal = &hook_signal;
+ new_plugin->hook_signal_send = &hook_signal_send;
+ new_plugin->hook_config = &hook_config;
+ new_plugin->hook_completion = &hook_completion;
+ new_plugin->unhook = &unhook;
+ new_plugin->unhook_all = &unhook_all_plugin;
- new_plugin->buffer_new = &plugin_api_buffer_new;
- new_plugin->buffer_search = &plugin_api_buffer_search;
- new_plugin->buffer_close = &plugin_api_buffer_close;
- new_plugin->buffer_get = &plugin_api_buffer_get;
- new_plugin->buffer_set = &plugin_api_buffer_set;
- new_plugin->buffer_nick_add = &plugin_api_buffer_nick_add;
- new_plugin->buffer_nick_remove = &plugin_api_buffer_nick_remove;
+ new_plugin->buffer_new = &gui_buffer_new;
+ new_plugin->buffer_search = &gui_buffer_search_by_category_name;
+ new_plugin->buffer_close = &gui_buffer_close;
+ new_plugin->buffer_get = &gui_buffer_get;
+ new_plugin->buffer_set = &gui_buffer_set;
+ new_plugin->buffer_nick_add = &gui_nicklist_add;
+ new_plugin->buffer_nick_remove = &gui_nicklist_remove;
new_plugin->command = &plugin_api_command;
@@ -332,8 +306,6 @@ plugin_load (char *filename)
new_plugin->infolist_time = &plugin_api_infolist_time;
new_plugin->infolist_free = &plugin_api_infolist_free;
- new_plugin->log = &plugin_api_log;
-
/* add new plugin to list */
new_plugin->prev_plugin = last_weechat_plugin;
new_plugin->next_plugin = NULL;
@@ -383,7 +355,7 @@ plugin_load (char *filename)
*/
int
-plugin_auto_load_file (struct t_weechat_plugin *plugin, char *filename)
+plugin_auto_load_file (void *plugin, char *filename)
{
char *pos;
@@ -432,11 +404,11 @@ plugin_auto_load ()
plugins_path2 = string_replace ((plugins_path) ?
plugins_path : CONFIG_STRING(config_plugins_path),
"%h", weechat_home);
- plugin_exec_on_files (NULL,
- (plugins_path2) ?
- plugins_path2 : ((plugins_path) ?
- plugins_path : CONFIG_STRING(config_plugins_path)),
- &plugin_auto_load_file);
+ util_exec_on_files ((plugins_path2) ?
+ plugins_path2 : ((plugins_path) ?
+ plugins_path : CONFIG_STRING(config_plugins_path)),
+ NULL,
+ &plugin_auto_load_file);
if (plugins_path)
free (plugins_path);
if (plugins_path2)
@@ -449,7 +421,7 @@ plugin_auto_load ()
{
snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16,
"%s/plugins", WEECHAT_LIBDIR);
- plugin_exec_on_files (NULL, dir_name, &plugin_auto_load_file);
+ util_exec_on_files (dir_name, NULL, &plugin_auto_load_file);
free (dir_name);
}
}
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
index 63e725d7c..cff9183fa 100644
--- a/src/plugins/plugin.h
+++ b/src/plugins/plugin.h
@@ -22,25 +22,23 @@
#include "weechat-plugin.h"
-typedef int (t_weechat_init_func) (struct t_weechat_plugin *);
-typedef void (t_weechat_end_func) (struct t_weechat_plugin *);
+typedef int (t_weechat_init_func) (struct t_weechat_plugin *plugin);
+typedef void (t_weechat_end_func) (struct t_weechat_plugin *plugin);
extern struct t_weechat_plugin *weechat_plugins;
extern struct t_weechat_plugin *last_weechat_plugin;
//extern t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS];
-extern void plugin_exec_on_files (struct t_weechat_plugin *, char *,
- int (*)(struct t_weechat_plugin *, char *));
-extern struct t_weechat_plugin *plugin_search (char *);
-extern struct t_weechat_plugin *plugin_load (char *);
+extern struct t_weechat_plugin *plugin_search (char *name);
+extern struct t_weechat_plugin *plugin_load (char *filename);
extern void plugin_auto_load ();
-extern void plugin_remove (struct t_weechat_plugin *);
-extern void plugin_unload (struct t_weechat_plugin *);
-extern void plugin_unload_name (char *);
+extern void plugin_remove (struct t_weechat_plugin *plugin);
+extern void plugin_unload (struct t_weechat_plugin *plugin);
+extern void plugin_unload_name (char *name);
extern void plugin_unload_all ();
-extern void plugin_reload_name (char *);
-extern void plugin_init (int);
+extern void plugin_reload_name (char *name);
+extern void plugin_init (int auto_load);
extern void plugin_end ();
extern void plugin_print_log ();
diff --git a/src/plugins/scripts/lua/lua.c b/src/plugins/scripts/lua/lua.c
index 572f71269..d3034b628 100644
--- a/src/plugins/scripts/lua/lua.c
+++ b/src/plugins/scripts/lua/lua.c
@@ -95,7 +95,7 @@ weechat_lua_exec (t_weechat_plugin *plugin,
ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
else if (ret_type == SCRIPT_EXEC_INT)
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = lua_tonumber (lua_current_interpreter, -1);
ret_value = ret_i;
diff --git a/src/plugins/scripts/perl/perl.c b/src/plugins/scripts/perl/perl.c
index 867257545..b4018d85d 100644
--- a/src/plugins/scripts/perl/perl.c
+++ b/src/plugins/scripts/perl/perl.c
@@ -131,7 +131,7 @@ weechat_perl_exec (t_weechat_plugin *plugin,
#ifndef MULTIPLICITY
int size = strlen (script->interpreter) + strlen(function) + 3;
- func = (char *) malloc ( size * sizeof(char));
+ func = (char *)malloc (size * sizeof(char));
if (!func)
return NULL;
snprintf (func, size, "%s::%s", (char *) script->interpreter, function);
@@ -199,7 +199,7 @@ weechat_perl_exec (t_weechat_plugin *plugin,
}
else if (ret_type == SCRIPT_EXEC_INT)
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = POPi;
ret_value = ret_i;
diff --git a/src/plugins/scripts/python/python.c b/src/plugins/scripts/python/python.c
index ab939ec36..383d90e30 100644
--- a/src/plugins/scripts/python/python.c
+++ b/src/plugins/scripts/python/python.c
@@ -121,7 +121,7 @@ weechat_python_exec (t_weechat_plugin *plugin,
else if (PyInt_Check (rc) && (ret_type == SCRIPT_EXEC_INT))
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = (int) PyInt_AsLong(rc);
ret_value = ret_i;
@@ -2279,7 +2279,7 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename)
if (w_home)
{
len = strlen (w_home) + 1 + strlen("python") + 1;
- p_home = (char *) malloc (len * sizeof(char));
+ p_home = (char *)malloc (len * sizeof(char));
if (p_home)
{
snprintf (p_home, len, "%s/python", w_home);
diff --git a/src/plugins/scripts/ruby/ruby.c b/src/plugins/scripts/ruby/ruby.c
index c17c8c43e..a05535af7 100644
--- a/src/plugins/scripts/ruby/ruby.c
+++ b/src/plugins/scripts/ruby/ruby.c
@@ -168,7 +168,7 @@ weechat_ruby_exec (t_weechat_plugin *plugin,
}
else if ((TYPE(rc) == T_FIXNUM) && ret_type == SCRIPT_EXEC_INT)
{
- ret_i = (int *) malloc (sizeof(int));
+ ret_i = (int *)malloc (sizeof(int));
if (ret_i)
*ret_i = NUM2INT(rc);
ret_value = ret_i;
diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c
index b091f4d33..c01380626 100644
--- a/src/plugins/scripts/script.c
+++ b/src/plugins/scripts/script.c
@@ -29,7 +29,7 @@
#include <dirent.h>
#include "../weechat-plugin.h"
-#include "weechat-script.h"
+#include "script.h"
/*
@@ -37,8 +37,8 @@
*/
void
-weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
- int (*callback)(t_weechat_plugin *, char *))
+weechat_script_auto_load (struct t_weechat_plugin *plugin, char *language,
+ int (*callback)(void *data, char *filename))
{
char *dir_home, *dir_name;
int dir_length;
@@ -49,7 +49,7 @@ weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
return;
dir_length = strlen (dir_home) + strlen (language) + 16;
dir_name =
- (char *) malloc (dir_length * sizeof (char));
+ (char *)malloc (dir_length * sizeof (char));
if (!dir_name)
{
free (dir_home);
@@ -57,7 +57,7 @@ weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
}
snprintf (dir_name, dir_length, "%s/%s/autoload", dir_home, language);
- plugin->exec_on_files (plugin, dir_name, callback);
+ plugin->exec_on_files (dir_name, plugin, callback);
free (dir_name);
free (dir_home);
@@ -68,7 +68,7 @@ weechat_script_auto_load (t_weechat_plugin *plugin, char *language,
*/
t_plugin_script *
-weechat_script_search (t_weechat_plugin *plugin,
+weechat_script_search (struct t_weechat_plugin *plugin,
t_plugin_script **list, char *name)
{
t_plugin_script *ptr_script;
@@ -89,7 +89,7 @@ weechat_script_search (t_weechat_plugin *plugin,
*/
char *
-weechat_script_search_full_name (t_weechat_plugin *plugin,
+weechat_script_search_full_name (struct t_weechat_plugin *plugin,
char *language, char *filename)
{
char *final_name, *dir_home, *dir_system;
@@ -102,7 +102,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (!dir_home)
return NULL;
length = strlen (dir_home) + strlen (filename + 1) + 1;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s%s", dir_home, filename + 1);
@@ -116,7 +116,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_home)
{
length = strlen (dir_home) + strlen (language) + 8 + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s/%s/autoload/%s", dir_home, language, filename);
@@ -135,7 +135,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_home)
{
length = strlen (dir_home) + strlen (language) + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s/%s/%s", dir_home, language, filename);
@@ -154,7 +154,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_home)
{
length = strlen (dir_home) + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name, length, "%s/%s", dir_home, filename);
@@ -173,7 +173,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
if (dir_system)
{
length = strlen (dir_system) + strlen (dir_system) + strlen (filename) + 16;
- final_name = (char *) malloc (length);
+ final_name = (char *)malloc (length);
if (final_name)
{
snprintf (final_name,length, "%s/%s/%s", dir_system, language, filename);
@@ -195,7 +195,7 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
*/
t_plugin_script *
-weechat_script_add (t_weechat_plugin *plugin,
+weechat_script_add (struct t_weechat_plugin *plugin,
t_plugin_script **script_list,
char *filename,
char *name, char *version,
@@ -245,7 +245,7 @@ weechat_script_add (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove (t_weechat_plugin *plugin,
+weechat_script_remove (struct t_weechat_plugin *plugin,
t_plugin_script **script_list, t_plugin_script *script)
{
t_plugin_handler *ptr_handler, *next_handler;
@@ -310,7 +310,7 @@ weechat_script_remove (t_weechat_plugin *plugin,
*/
void
-weechat_script_print (t_weechat_plugin *plugin,
+weechat_script_print (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *server, char *channel,
char *message, ...)
@@ -335,7 +335,7 @@ weechat_script_print (t_weechat_plugin *plugin,
*/
void
-weechat_script_print_server (t_weechat_plugin *plugin,
+weechat_script_print_server (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *message, ...)
{
@@ -359,9 +359,9 @@ weechat_script_print_server (t_weechat_plugin *plugin,
*/
void
-weechat_script_print_infobar (t_weechat_plugin *plugin,
+weechat_script_print_infobar (struct t_weechat_plugin *plugin,
t_plugin_script *script,
- int time_displayed, char *message, ...)
+ int delay, char *message, ...)
{
va_list argptr;
static char buf[1024];
@@ -373,7 +373,7 @@ weechat_script_print_infobar (t_weechat_plugin *plugin,
buf2 = (script->charset && script->charset[0]) ?
plugin->iconv_to_internal (plugin, script->charset, buf) : NULL;
- plugin->print_infobar (plugin, time_displayed, "%s", (buf2) ? buf2 : buf);
+ plugin->print_infobar (plugin, delay, "%s", (buf2) ? buf2 : buf);
if (buf2)
free (buf2);
}
@@ -383,7 +383,7 @@ weechat_script_print_infobar (t_weechat_plugin *plugin,
*/
void
-weechat_script_log (t_weechat_plugin *plugin,
+weechat_script_log (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *server, char *channel, char *message, ...)
{
@@ -407,7 +407,7 @@ weechat_script_log (t_weechat_plugin *plugin,
*/
void
-weechat_script_exec_command (t_weechat_plugin *plugin,
+weechat_script_exec_command (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *server, char *channel, char *command)
{
@@ -428,7 +428,7 @@ weechat_script_exec_command (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_handler (t_weechat_plugin *plugin,
+weechat_script_remove_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *arg1, char *arg2)
{
@@ -464,7 +464,7 @@ weechat_script_remove_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_timer_handler (t_weechat_plugin *plugin,
+weechat_script_remove_timer_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *function)
{
@@ -492,7 +492,7 @@ weechat_script_remove_timer_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
+weechat_script_remove_keyboard_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *function)
{
@@ -520,7 +520,7 @@ weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_event_handler (t_weechat_plugin *plugin,
+weechat_script_remove_event_handler (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *function)
{
@@ -549,7 +549,7 @@ weechat_script_remove_event_handler (t_weechat_plugin *plugin,
*/
void
-weechat_script_remove_modifier (t_weechat_plugin *plugin,
+weechat_script_remove_modifier (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *arg1, char *arg2, char *arg3)
{
@@ -594,7 +594,7 @@ weechat_script_remove_modifier (t_weechat_plugin *plugin,
*/
char *
-weechat_script_get_plugin_config (t_weechat_plugin *plugin,
+weechat_script_get_plugin_config (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *option)
{
@@ -621,7 +621,7 @@ weechat_script_get_plugin_config (t_weechat_plugin *plugin,
*/
int
-weechat_script_set_plugin_config (t_weechat_plugin *plugin,
+weechat_script_set_plugin_config (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *option, char *value)
{
@@ -648,7 +648,7 @@ weechat_script_set_plugin_config (t_weechat_plugin *plugin,
*/
void
-weechat_script_set_charset (t_weechat_plugin *plugin,
+weechat_script_set_charset (struct t_weechat_plugin *plugin,
t_plugin_script *script,
char *charset)
{
diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h
index 87b1cad97..1de9f1288 100644
--- a/src/plugins/scripts/script.h
+++ b/src/plugins/scripts/script.h
@@ -26,72 +26,80 @@
#define SCRIPT_EXEC_INT 1
#define SCRIPT_EXEC_STRING 2
-typedef struct t_plugin_script t_plugin_script;
-
struct t_plugin_script
{
/* script variables */
- char *filename; /* name of script on disk */
- void *interpreter; /* interpreter for script */
- char *name; /* script name */
- char *description; /* plugin description */
- char *version; /* plugin version */
- char *shutdown_func; /* function when script is unloaded */
- char *charset; /* script charset */
+ char *filename; /* name of script on disk */
+ void *interpreter; /* interpreter for script */
+ char *name; /* script name */
+ char *description; /* plugin description */
+ char *version; /* plugin version */
+ char *shutdown_func; /* function when script is unloaded*/
+ char *charset; /* script charset */
- t_plugin_script *prev_script; /* link to previous script */
- t_plugin_script *next_script; /* link to next script */
+ struct t_plugin_script *prev_script; /* link to previous script */
+ struct t_plugin_script *next_script; /* link to next script */
};
-extern void weechat_script_auto_load (t_weechat_plugin *, char *,
- int (*)(t_weechat_plugin *, char *));
-extern t_plugin_script *weechat_script_search (t_weechat_plugin *,
- t_plugin_script **, char *);
-extern char *weechat_script_search_full_name (t_weechat_plugin *,
- char *, char *);
-extern t_plugin_script *weechat_script_add (t_weechat_plugin *,
- t_plugin_script **, char *, char *,
- char *, char *, char *, char *);
-extern void weechat_script_remove (t_weechat_plugin *,
- t_plugin_script **, t_plugin_script *);
-extern void weechat_script_print (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *, ...);
-extern void weechat_script_print_server (t_weechat_plugin *,
- t_plugin_script *,
- char *, ...);
-extern void weechat_script_print_infobar (t_weechat_plugin *,
- t_plugin_script *,
- int, char *, ...);
-extern void weechat_script_log (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *, ...);
-extern void weechat_script_exec_command (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *);
-extern void weechat_script_remove_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *);
-extern void weechat_script_remove_timer_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern void weechat_script_remove_keyboard_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern void weechat_script_remove_event_handler (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern void weechat_script_remove_modifier (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *, char *);
-extern char *weechat_script_get_plugin_config (t_weechat_plugin *,
- t_plugin_script *,
- char *);
-extern int weechat_script_set_plugin_config (t_weechat_plugin *,
- t_plugin_script *,
- char *, char *);
-extern void weechat_script_set_charset (t_weechat_plugin *,
- t_plugin_script *,
- char *);
+extern void weechat_script_auto_load (struct t_weechat_plugin *plugin, char *language,
+ int (*callback)(void *data, char *filename));
+extern struct t_plugin_script *weechat_script_search (struct t_weechat_plugin *plugin,
+ struct t_plugin_script **list,
+ char *name);
+extern char *weechat_script_search_full_name (struct t_weechat_plugin *plugin,
+ char *language, char *filename);
+extern struct t_plugin_script *weechat_script_add (struct t_weechat_plugin *plugin,
+ struct t_plugin_script **script_list,
+ char *filename, char *name,
+ char *version,
+ char *shutdown_func,
+ char *description,
+ char *charset);
+extern void weechat_script_remove (struct t_weechat_plugin *plugin,
+ struct t_plugin_script **script_list,
+ struct t_plugin_script *script);
+extern void weechat_script_print (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *server, char *channel,
+ char *message, ...);
+extern void weechat_script_print_server (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *message, ...);
+extern void weechat_script_print_infobar (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ int delay, char *message, ...);
+extern void weechat_script_log (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *server, char *channel,
+ char *message, ...);
+extern void weechat_script_exec_command (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *server, char *channel,
+ char *command);
+extern void weechat_script_remove_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *arg1, char *arg2);
+extern void weechat_script_remove_timer_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *function);
+extern void weechat_script_remove_keyboard_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *function);
+extern void weechat_script_remove_event_handler (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *function);
+extern void weechat_script_remove_modifier (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *arg1, char *arg2,
+ char *arg3);
+extern char *weechat_script_get_plugin_config (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *option);
+extern int weechat_script_set_plugin_config (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *option, char *value);
+extern void weechat_script_set_charset (struct t_weechat_plugin *plugin,
+ struct t_plugin_script *script,
+ char *charset);
#endif /* weechat-script.h */
diff --git a/src/plugins/trigger/trigger-libc.c b/src/plugins/trigger/trigger-libc.c
index d8b278660..d34c3871a 100644
--- a/src/plugins/trigger/trigger-libc.c
+++ b/src/plugins/trigger/trigger-libc.c
@@ -217,8 +217,8 @@ c_explode_string (char *string, char *separators, int num_items_max,
}
array =
- (char **) malloc ((num_items_max ? n_items : n_items + 1) *
- sizeof (char *));
+ (char **)malloc ((num_items_max ? n_items : n_items + 1) *
+ sizeof (char *));
ptr1 = string;
ptr2 = string;
@@ -241,7 +241,7 @@ c_explode_string (char *string, char *separators, int num_items_max,
if (ptr2 - ptr1 > 0)
{
array[i] =
- (char *) malloc ((ptr2 - ptr1 + 1) * sizeof (char));
+ (char *)malloc ((ptr2 - ptr1 + 1) * sizeof (char));
array[i] = strncpy (array[i], ptr1, ptr2 - ptr1);
array[i][ptr2 - ptr1] = '\0';
ptr1 = ++ptr2;
@@ -310,11 +310,11 @@ c_split_multi_command (char *command, char sep)
ptr = ++p;
}
- array = (char **) malloc ((nb_substr + 1) * sizeof(char *));
+ array = (char **)malloc ((nb_substr + 1) * sizeof(char *));
if (!array)
return NULL;
- buffer = (char *) malloc ( (strlen(command) + 1) * sizeof (char));
+ buffer = (char *)malloc ((strlen(command) + 1) * sizeof (char));
if (!buffer)
{
free (array);
@@ -364,7 +364,7 @@ c_split_multi_command (char *command, char sep)
free (buffer);
- array = (char **) realloc (array, (arr_idx + 1) * sizeof(char *));
+ array = (char **)realloc (array, (arr_idx + 1) * sizeof(char *));
return array;
}
@@ -406,7 +406,7 @@ c_join_string(char **list, char *sep)
len += strlen (list[i]);
len += i*strlen (sep) + 1;
- str = (char *) malloc (len * sizeof(char));
+ str = (char *)malloc (len * sizeof(char));
if (str)
{
for (i = 0; list[i]; i++)
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index 44b410af3..2fc7a1851 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -37,7 +37,7 @@ t_weechat_trigger *weechat_trigger_alloc (char *pattern, char *domain, char *com
{
t_weechat_trigger *new;
- new = (t_weechat_trigger *) malloc (sizeof (t_weechat_trigger));
+ new = (t_weechat_trigger *)malloc (sizeof (t_weechat_trigger));
if (new)
{
new->pattern = strdup (pattern);
@@ -725,7 +725,7 @@ weechat_trigger_edit (t_weechat_plugin *plugin, int todo)
return -1;
len = strlen (weechat_dir) + strlen(DIR_SEP) + strlen(CONF_FILE) + 1;
- triggerrc = (char *) malloc (len * sizeof(char));
+ triggerrc = (char *)malloc (len * sizeof(char));
if (!triggerrc)
return -1;
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index d03d0535f..0cd9cacc1 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -23,6 +23,9 @@
#include <sys/types.h>
+struct t_gui_buffer;
+struct t_weelist;
+
/* return codes for plugin functions */
#define WEECHAT_RC_ERROR -1 /* function failed with an error */
#define WEECHAT_RC_OK 0 /* function ok */
@@ -37,6 +40,10 @@
#define WEECHAT_RC_WITH_HIGHLIGHT 4 /* ok and ask for highlight */
/* (for message handler only) */
+#define WEELIST_POS_SORT "sort"
+#define WEELIST_POS_BEGINNING "beginning"
+#define WEELIST_POS_END "end"
+
struct t_weechat_plugin
{
/* plugin variables */
@@ -56,163 +63,204 @@ struct t_weechat_plugin
existing plugins */
/* strings */
- void (*charset_set) (struct t_weechat_plugin *, char *);
- char *(*iconv_to_internal) (struct t_weechat_plugin *, char *, char *);
- char *(*iconv_from_internal) (struct t_weechat_plugin *, char *, char *);
- char *(*gettext) (struct t_weechat_plugin *, char *);
- char *(*ngettext) (struct t_weechat_plugin *, char *, char *, int);
- int (*strcasecmp) (struct t_weechat_plugin *, char *, char *);
- int (*strncasecmp) (struct t_weechat_plugin *, char *, char *, int);
- char *(*strcasestr) (struct t_weechat_plugin *, char *, char *);
- char *(*string_replace) (struct t_weechat_plugin *, char *, char *, char *);
- char **(*string_explode) (struct t_weechat_plugin *, char *, char *, int,
- int, int *);
- void (*string_free_exploded) (struct t_weechat_plugin *, char **);
- char **(*string_split_command) (struct t_weechat_plugin *, char *, char);
- void (*string_free_splitted_command) (struct t_weechat_plugin *, char **);
+ void (*charset_set) (struct t_weechat_plugin *plugin, char *charset);
+ char *(*iconv_to_internal) (char *charset, char *string);
+ char *(*iconv_from_internal) (char *charset, char *string);
+ char *(*gettext) (char *string);
+ char *(*ngettext) (char *single, char *plural, int count);
+ int (*strcasecmp) (char *string1, char *string2);
+ int (*strncasecmp) (char *string1, char *string2, int max);
+ char *(*strcasestr) (char *string1, char *string2);
+ char *(*string_replace) (char *string, char *search, char *replace);
+ char **(*string_explode) (char *string, char *separators, int keep_eol,
+ int num_items_max, int *num_items);
+ void (*string_free_exploded) (char **exploded_string);
+ char **(*string_split_command) (char *command, char separator);
+ void (*string_free_splitted_command) (char **splitted_command);
/* UTF-8 strings */
- int (*utf8_has_8bits) (struct t_weechat_plugin *, char *);
- int (*utf8_is_valid) (struct t_weechat_plugin *, char *, char **);
- void (*utf8_normalize) (struct t_weechat_plugin *, char *, char);
- char *(*utf8_prev_char) (struct t_weechat_plugin *, char *, char *);
- char *(*utf8_next_char) (struct t_weechat_plugin *, char *);
- int (*utf8_char_size) (struct t_weechat_plugin *, char *);
- int (*utf8_strlen) (struct t_weechat_plugin *, char *);
- int (*utf8_strnlen) (struct t_weechat_plugin *, char *, int);
- int (*utf8_strlen_screen) (struct t_weechat_plugin *, char *);
- int (*utf8_charcasecmp) (struct t_weechat_plugin *, char *, char *);
- int (*utf8_char_size_screen) (struct t_weechat_plugin *, char *);
- char *(*utf8_add_offset) (struct t_weechat_plugin *, char *, int);
- int (*utf8_real_pos) (struct t_weechat_plugin *, char *, int);
- int (*utf8_pos) (struct t_weechat_plugin *, char *, int);
+ int (*utf8_has_8bits) (char *string);
+ int (*utf8_is_valid) (char *string, char **error);
+ void (*utf8_normalize) (char *string, char replacement);
+ char *(*utf8_prev_char) (char *string_start, char *string);
+ char *(*utf8_next_char) (char *string);
+ int (*utf8_char_size) (char *string);
+ int (*utf8_strlen) (char *string);
+ int (*utf8_strnlen) (char *string, int bytes);
+ int (*utf8_strlen_screen) (char *string);
+ int (*utf8_charcasecmp) (char *string1, char *string2);
+ int (*utf8_char_size_screen) (char *string);
+ char *(*utf8_add_offset) (char *string, int offset);
+ int (*utf8_real_pos) (char *string, int pos);
+ int (*utf8_pos) (char *string, int real_pos);
/* directories */
- int (*mkdir_home) (struct t_weechat_plugin *, char *, int);
- int (*mkdir) (struct t_weechat_plugin *, char *, int);
- void (*exec_on_files) (struct t_weechat_plugin *, char *,
- int (*)(char *));
+ int (*mkdir_home) (char *directory, int mode);
+ int (*mkdir) (char *directory, int mode);
+ void (*exec_on_files) (char *directory, void *data,
+ int (*callback)(void *data, char *filename));
/* util */
- long (*timeval_diff) (struct t_weechat_plugin *, void *, void *);
+ int (*timeval_cmp) (struct timeval *tv1, struct timeval *tv2);
+ long (*timeval_diff) (struct timeval *tv1, struct timeval *tv2);
+ void (*timeval_add) (struct timeval *tv, long interval);
/* sorted list */
- struct t_weelist *(*list_new) (struct t_weechat_plugin *);
- char *(*list_add) (struct t_weechat_plugin *, void *, char *,
- char *);
- struct t_weelist_item *(*list_search) (struct t_weechat_plugin *, void *,
- char *);
- struct t_weelist_item *(*list_casesearch) (struct t_weechat_plugin *, void *,
- char *);
- struct t_weelist_item *(*list_get) (struct t_weechat_plugin *, void *, int);
- struct t_weelist_item *(*list_next) (struct t_weechat_plugin *, void *);
- struct t_weelist_item *(*list_prev) (struct t_weechat_plugin *, void *);
- char *(*list_string) (struct t_weechat_plugin *, void *);
- int (*list_size) (struct t_weechat_plugin *, void *);
- void (*list_remove) (struct t_weechat_plugin *, void *, void *);
- void (*list_remove_all) (struct t_weechat_plugin *, void *);
- void (*list_free) (struct t_weechat_plugin *, void *);
+ struct t_weelist *(*list_new) ();
+ struct t_weelist_item *(*list_add) (struct t_weelist *weelist, char *data,
+ char *where);
+ struct t_weelist_item *(*list_search) (struct t_weelist *weelist,
+ char *data);
+ struct t_weelist_item *(*list_casesearch) (struct t_weelist *weelist,
+ char *data);
+ struct t_weelist_item *(*list_get) (struct t_weelist *weelist,
+ int position);
+ struct t_weelist_item *(*list_next) (struct t_weelist_item *item);
+ struct t_weelist_item *(*list_prev) (struct t_weelist_item *item);
+ char *(*list_string) (struct t_weelist_item *item);
+ int (*list_size) (struct t_weelist *weelist);
+ void (*list_remove) (struct t_weelist *weelist,
+ struct t_weelist_item *item);
+ void (*list_remove_all) (struct t_weelist *weelist);
+ void (*list_free) (struct t_weelist *weelist);
/* config files */
- struct t_config_file *(*config_new) (struct t_weechat_plugin *, char *);
- struct t_config_section *(*config_new_section) (struct t_weechat_plugin *,
- void *, char *,
- void (*)(void *, char *, char *),
- void (*)(void *, char *),
- void (*)(void *, char *));
- struct t_config_section *(*config_search_section) (struct t_weechat_plugin *,
- void *, char *);
- struct t_config_option *(*config_new_option) (struct t_weechat_plugin *,
- void *, char *, char *,
- char *, char *, int, int,
- char *, void (*)());
- struct t_config_option *(*config_search_option) (struct t_weechat_plugin *,
- void *, void *, char *);
- int (*config_option_set) (struct t_weechat_plugin *, void *, char *);
- char (*config_string_to_boolean) (struct t_weechat_plugin *, char *);
- char (*config_boolean) (struct t_weechat_plugin *, void *);
- int (*config_integer) (struct t_weechat_plugin *, void *);
- char *(*config_string) (struct t_weechat_plugin *, void *);
- int (*config_color) (struct t_weechat_plugin *, void *);
- int (*config_read) (struct t_weechat_plugin *, void *);
- int (*config_reload) (struct t_weechat_plugin *, void *);
- int (*config_write) (struct t_weechat_plugin *, void *);
- void (*config_write_line) (struct t_weechat_plugin *, void *,
- char *, char *, ...);
- void (*config_free) (struct t_weechat_plugin *, void *);
- struct t_config_option *(*config_get) (struct t_weechat_plugin *, char *);
- char *(*plugin_config_get) (struct t_weechat_plugin *, char *);
- int (*plugin_config_set) (struct t_weechat_plugin *, char *, char *);
+ struct t_config_file *(*config_new) (struct t_weechat_plugin *plugin,
+ char *filename);
+ struct t_config_section *(*config_new_section) (struct t_config_file *config_file,
+ char *name,
+ void (*callback_read)
+ (struct t_config_file *config_file,
+ char *option_name,
+ char *value),
+ void (*callback_write)
+ (struct t_config_file *config_file,
+ char *section_name),
+ void (*callback_write_default)
+ (struct t_config_file *config_file,
+ char *section_name));
+ struct t_config_section *(*config_search_section) (struct t_config_file *config_file,
+ char *section_name);
+ struct t_config_option *(*config_new_option) (struct t_config_section *config_file,
+ char *name, char *type,
+ char *description,
+ char *string_values,
+ int min, int max,
+ char *default_value,
+ void (*callback_change)());
+ struct t_config_option *(*config_search_option) (struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name);
+ int (*config_string_to_boolean) (char *text);
+ int (*config_option_set) (struct t_config_option *option, char *new_value,
+ int run_callback);
+ int (*config_boolean) (struct t_config_option *option);
+ int (*config_integer) (struct t_config_option *option);
+ char *(*config_string) (struct t_config_option *option);
+ int (*config_color) (struct t_config_option *option);
+ void (*config_write_line) (struct t_config_file *config_file,
+ char *option_name, char *value, ...);
+ int (*config_write) (struct t_config_file *config_file);
+ int (*config_read) (struct t_config_file *config_file);
+ int (*config_reload) (struct t_config_file *config_file);
+ void (*config_free) (struct t_config_file *config_file);
+ struct t_config_option *(*config_get_weechat) (char *option_name);
+ char *(*config_get_plugin) (struct t_weechat_plugin *plugin,
+ char *option_name);
+ int (*config_set_plugin) (struct t_weechat_plugin *plugin,
+ char *option_name, char *value);
/* display */
- char *(*prefix) (struct t_weechat_plugin *, char *);
- char *(*color) (struct t_weechat_plugin *, char *);
- void (*printf) (struct t_weechat_plugin *, void *, char *, ...);
- void (*printf_date) (struct t_weechat_plugin *, void *, time_t,
- char *, ...);
- void (*log_printf) (struct t_weechat_plugin *, char *, ...);
- void (*infobar_printf) (struct t_weechat_plugin *, int, char *,
- char *, ...);
- void (*infobar_remove) (struct t_weechat_plugin *, int);
+ char *(*prefix) (char *prefix);
+ char *(*color) (char *color_name);
+ void (*printf_date) (struct t_gui_buffer *buffer, time_t date,
+ char *message, ...);
+ void (*log_printf) (char *message, ...);
+ void (*infobar_printf) (int delay, char *color_name, char *format, ...);
+ void (*infobar_remove) (int how_many);
/* hooks */
- struct t_hook *(*hook_command) (struct t_weechat_plugin *, char *, char *,
- char *, char *, char *,
- int (*)(void *, void *, int, char **, char **),
- void *);
- struct t_hook *(*hook_timer) (struct t_weechat_plugin *, long, int, int,
- int (*)(void *), void *);
- struct t_hook *(*hook_fd) (struct t_weechat_plugin *, int, int, int, int,
- int (*)(void *), void *);
- struct t_hook *(*hook_print) (struct t_weechat_plugin *, void *, char *,
- int,
- int (*)(void *, void *, time_t, char *, char *),
- void *);
- struct t_hook *(*hook_signal) (struct t_weechat_plugin *, char *,
- int (*)(void *, char *, void *), void *);
- void (*hook_signal_send) (struct t_weechat_plugin *, char *, void *);
- struct t_hook *(*hook_config) (struct t_weechat_plugin *, char *, char *,
- int (*)(void *, char *, char *, char *),
- void *);
- struct t_hook *(*hook_completion) (struct t_weechat_plugin *, char *,
- int (*)(void *, char *, void *, void *),
- void *);
- void (*unhook) (struct t_weechat_plugin *, void *);
- void (*unhook_all) (struct t_weechat_plugin *);
+ struct t_hook *(*hook_command) (struct t_weechat_plugin *plugin,
+ char *command, char *description,
+ char *args, char *args_description,
+ char *completion,
+ int (*callback)(void *data,
+ struct t_gui_buffer *buffer,
+ int argc, char **argv,
+ char **argv_eol),
+ void *callback_data);
+ struct t_hook *(*hook_timer) (struct t_weechat_plugin *plugin,
+ long interval, int align_second,
+ int max_calls,
+ int (*callback)(void *data),
+ void *callback_data);
+ struct t_hook *(*hook_fd) (struct t_weechat_plugin *plugin,
+ int fd, int flag_read, int flag_write,
+ int flag_exception,
+ int (*callback)(void *data),
+ void *callback_data);
+ struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer,
+ char *message, int strip_colors,
+ int (*callback)(void *data,
+ struct t_gui_buffer *buffer,
+ time_t date, char *prefix,
+ char *message),
+ void *callback_data);
+ struct t_hook *(*hook_signal) (struct t_weechat_plugin *plugin,
+ char *signal,
+ int (*callback)(void *data, char *signal,
+ void *signal_data),
+ void *callback_data);
+ void (*hook_signal_send) (char *signal, void *signal_data);
+ struct t_hook *(*hook_config) (struct t_weechat_plugin *plugin,
+ char *type, char *option,
+ int (*callback)(void *data, char *type,
+ char *option, char *value),
+ void *callback_data);
+ struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin,
+ char *completion,
+ int (*callback)(void *data,
+ char *completion,
+ struct t_gui_buffer *buffer,
+ struct t_weelist *list),
+ void *callback_data);
+ void (*unhook) (struct t_hook *hook);
+ void (*unhook_all) (struct t_weechat_plugin *plugin);
/* buffers */
- struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *,
- char *, char *,
- void (*)(struct t_gui_buffer *, char *));
- struct t_gui_buffer *(*buffer_search) (struct t_weechat_plugin *,
- char *, char *);
- void (*buffer_close) (struct t_weechat_plugin *, void *);
- void *(*buffer_get) (struct t_weechat_plugin *, void *, char *);
- void (*buffer_set) (struct t_weechat_plugin *, void *, char *, char *);
- void (*buffer_nick_add) (struct t_weechat_plugin *, void *, char *, int,
- char *, char, char *);
- void (*buffer_nick_remove) (struct t_weechat_plugin *, char *);
+ struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *plugin,
+ char *category, char *name,
+ void (*callback_input_data)(struct t_gui_buffer *buffer,
+ char *data));
+ struct t_gui_buffer *(*buffer_search) (char *category, char *name);
+ void (*buffer_close) (struct t_gui_buffer *buffer, int switch_to_another);
+ void *(*buffer_get) (struct t_gui_buffer *buffer, char *property);
+ void (*buffer_set) (struct t_gui_buffer *buffer, char *property,
+ char *value);
+ struct t_gui_nick *(*buffer_nick_add) (struct t_gui_buffer *buffer,
+ char *nick, int sort_index,
+ char *color_nick, char prefix,
+ char *color_prefix);
+ int (*buffer_nick_remove) (struct t_gui_buffer *buffer, char *nick);
/* command */
- void (*command) (struct t_weechat_plugin *, void *, char *);
+ void (*command) (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, char *command);
/* infos */
- char *(*info_get) (struct t_weechat_plugin *, char *);
+ char *(*info_get) (struct t_weechat_plugin *plugin, char *info);
/* infolists */
- struct t_plugin_infolist *(*infolist_get) (struct t_weechat_plugin *,
- char *, void *);
- int (*infolist_next) (struct t_weechat_plugin *, void *);
- int (*infolist_prev) (struct t_weechat_plugin *, void *);
- char *(*infolist_fields) (struct t_weechat_plugin *, void *);
- int (*infolist_integer) (struct t_weechat_plugin *, void *, char *);
- char *(*infolist_string) (struct t_weechat_plugin *, void *, char *);
- void *(*infolist_pointer) (struct t_weechat_plugin *, void *, char *);
- time_t (*infolist_time) (struct t_weechat_plugin *, void *, char *);
- void (*infolist_free) (struct t_weechat_plugin *, void *);
-
- /* log */
- void (*log) (struct t_weechat_plugin *, char *, char *, char *, ...);
+ struct t_plugin_infolist *(*infolist_get) (char *name, void *pointer);
+ int (*infolist_next) (struct t_plugin_infolist *infolist);
+ int (*infolist_prev) (struct t_plugin_infolist *infolist);
+ char *(*infolist_fields) (struct t_plugin_infolist *infolist);
+ int (*infolist_integer) (struct t_plugin_infolist *infolist, char *var);
+ char *(*infolist_string) (struct t_plugin_infolist *infolist, char *var);
+ void *(*infolist_pointer) (struct t_plugin_infolist *infolist, char *var);
+ time_t (*infolist_time) (struct t_plugin_infolist *infolist, char *var);
+ void (*infolist_free) (struct t_plugin_infolist *infolist);
/* WeeChat developers: ALWAYS add new functions at the end */
};
@@ -222,183 +270,174 @@ struct t_weechat_plugin
/* strings */
#define weechat_charset_set(__charset) \
weechat_plugin->charset_set(weechat_plugin, __charset)
-#define weechat_iconv_to_internal(__charset, __string) \
- weechat_plugin->iconv_to_internal(weechat_plugin, \
- __charset, __string)
-#define weechat_iconv_from_internal(__charset, __string) \
- weechat_plugin->iconv_from_internal(weechat_plugin, \
- __charset, __string)
+#define weechat_iconv_to_internal(__charset, __string) \
+ weechat_plugin->iconv_to_internal(__charset, __string)
+#define weechat_iconv_from_internal(__charset, __string) \
+ weechat_plugin->iconv_from_internal(__charset, __string)
#ifndef __WEECHAT_H
-#define _(string) weechat_plugin->gettext(weechat_plugin, string)
+#define _(string) weechat_plugin->gettext(string)
#define N_(string) (string)
-#define NG_(single,plural,number) \
- weechat_plugin->ngettext(weechat_plugin, single, plural, number)
+#define NG_(single,plural,number) \
+ weechat_plugin->ngettext(single, plural, number)
#endif
-#define weechat_strcasecmp(__string1, __string2) \
- weechat_plugin->strcasecmp(weechat_plugin, __string1, __string2)
-#define weechat_strncasecmp(__string1, __string2, __max) \
- weechat_plugin->strncasecmp(weechat_plugin, __string1, \
- __string2, __max)
-#define weechat_strcasestr(__string1, __string2) \
- weechat_plugin->strcasestr(weechat_plugin, __string1, __string2)
-#define weechat_string_replace(__string1, __search1, __replace1) \
- weechat_plugin->string_replace(weechat_plugin, __string1, \
- __search1, __replace1)
-#define weechat_string_explode(__string1, __separator, __eol, __max, \
+#define weechat_strcasecmp(__string1, __string2) \
+ weechat_plugin->strcasecmp(__string1, __string2)
+#define weechat_strncasecmp(__string1, __string2, __max) \
+ weechat_plugin->strncasecmp(__string1, __string2, __max)
+#define weechat_strcasestr(__string1, __string2) \
+ weechat_plugin->strcasestr(__string1, __string2)
+#define weechat_string_replace(__string, __search, __replace) \
+ weechat_plugin->string_replace(__string, __search, __replace)
+#define weechat_string_explode(__string, __separator, __eol, __max, \
__num_items) \
- weechat_plugin->string_explode(weechat_plugin, __string1, \
- __separator, __eol, __max, \
- __num_items)
-#define weechat_string_free_exploded(__array_str) \
- weechat_plugin->string_free_exploded(weechat_plugin, __array_str)
-#define weechat_string_split_command(__string1, __separator) \
- weechat_plugin->string_split_command(weechat_plugin, __string1, \
- __separator)
-#define weechat_string_free_splitted_command(__array_str) \
- weechat_plugin->string_free_splitted_command(weechat_plugin, \
- __array_str)
+ weechat_plugin->string_explode(__string, __separator, __eol, \
+ __max, __num_items)
+#define weechat_string_free_exploded(__exploded_string) \
+ weechat_plugin->string_free_exploded(__exploded_string)
+#define weechat_string_split_command(__command, __separator) \
+ weechat_plugin->string_split_command(__command, __separator)
+#define weechat_string_free_splitted_command(__splitted_command) \
+ weechat_plugin->string_free_splitted_command(__splitted_command)
/* UTF-8 strings */
-#define weechat_utf8_has_8bits(__string) \
- weechat_plugin->utf8_has_8bits(weechat_plugin, __string)
-#define weechat_utf8_is_valid(__string, __error) \
- weechat_plugin->utf8_is_valid(weechat_plugin, __string, __error)
-#define weechat_utf8_normalize(__string, __char) \
- weechat_plugin->utf8_normalize(weechat_plugin, __string, __char)
-#define weechat_utf8_prev_char(__start, __string) \
- weechat_plugin->utf8_prev_char(weechat_plugin, __start, __string)
-#define weechat_utf8_next_char(__string) \
- weechat_plugin->utf8_next_char(weechat_plugin, __string)
-#define weechat_utf8_char_size(__string) \
- weechat_plugin->utf8_char_size(weechat_plugin, __string)
-#define weechat_utf8_strlen(__string) \
- weechat_plugin->utf8_strlen(weechat_plugin, __string)
-#define weechat_utf8_strnlen(__string, __bytes) \
- weechat_plugin->utf8_strnlen(weechat_plugin, __string, __bytes)
-#define weechat_utf8_strlen_screen(__string) \
- weechat_plugin->utf8_strlen_screen(weechat_plugin, __string)
-#define weechat_utf8_charcasecmp(__string) \
- weechat_plugin->utf8_charcasecmp(weechat_plugin, __string)
-#define weechat_utf8_char_size_screen(__string) \
- weechat_plugin->utf8_char_size_screen(weechat_plugin, __string)
-#define weechat_utf8_add_offset(__string, __offset) \
- weechat_plugin->utf8_add_offset(weechat_plugin, __string, __offset)
-#define weechat_utf8_real_pos(__string, __pos) \
- weechat_plugin->utf8_real_pos(weechat_plugin, __string, __pos)
-#define weechat_utf8_pos(__string, __real_pos) \
- weechat_plugin->utf8_pos(weechat_plugin, __string, __real_pos)
+#define weechat_utf8_has_8bits(__string) \
+ weechat_plugin->utf8_has_8bits(__string)
+#define weechat_utf8_is_valid(__string, __error) \
+ weechat_plugin->utf8_is_valid(__string, __error)
+#define weechat_utf8_normalize(__string, __char) \
+ weechat_plugin->utf8_normalize(__string, __char)
+#define weechat_utf8_prev_char(__start, __string) \
+ weechat_plugin->utf8_prev_char(__start, __string)
+#define weechat_utf8_next_char(__string) \
+ weechat_plugin->utf8_next_char(__string)
+#define weechat_utf8_char_size(__string) \
+ weechat_plugin->utf8_char_size(__string)
+#define weechat_utf8_strlen(__string) \
+ weechat_plugin->utf8_strlen(__string)
+#define weechat_utf8_strnlen(__string, __bytes) \
+ weechat_plugin->utf8_strnlen(__string, __bytes)
+#define weechat_utf8_strlen_screen(__string) \
+ weechat_plugin->utf8_strlen_screen(__string)
+#define weechat_utf8_charcasecmp(__string) \
+ weechat_plugin->utf8_charcasecmp(__string)
+#define weechat_utf8_char_size_screen(__string) \
+ weechat_plugin->utf8_char_size_screen(__string)
+#define weechat_utf8_add_offset(__string, __offset) \
+ weechat_plugin->utf8_add_offset(__string, __offset)
+#define weechat_utf8_real_pos(__string, __pos) \
+ weechat_plugin->utf8_real_pos(__string, __pos)
+#define weechat_utf8_pos(__string, __real_pos) \
+ weechat_plugin->utf8_pos(__string, __real_pos)
/* directories */
-#define weechat_mkdir_home(__directory, __mode) \
- weechat_plugin->mkdir_home(weechat_plugin, __directory, __mode)
-#define weechat_mkdir(__directory, __mode) \
- weechat_plugin->mkdir(weechat_plugin, __directory, __mode)
-#define weechat_exec_on_files(__directory, __callback) \
- weechat_plugin->exec_on_files(weechat_plugin, __directory, \
- __callback)
+#define weechat_mkdir_home(__directory, __mode) \
+ weechat_plugin->mkdir_home(__directory, __mode)
+#define weechat_mkdir(__directory, __mode) \
+ weechat_plugin->mkdir(__directory, __mode)
+#define weechat_exec_on_files(__directory, __data, __callback) \
+ weechat_plugin->exec_on_files(__directory, __data, __callback)
/* util */
-#define weechat_timeval_diff(__time1, __time2) \
- weechat_plugin->timeval_diff(weechat_plugin, __time1, __time2)
+#define weechat_timeval_cmp(__time1, __time2) \
+ weechat_plugin->timeval_cmp(__time1, __time2)
+#define weechat_timeval_diff(__time1, __time2) \
+ weechat_plugin->timeval_diff(__time1, __time2)
+#define weechat_timeval_add(__time, __interval) \
+ weechat_plugin->timeval_add(__time, __interval)
/* sorted list */
#define weechat_list_new() \
- weechat_plugin->list_new(weechat_plugin)
-#define weechat_list_add(__list, __string, __sort) \
- weechat_plugin->list_add(weechat_plugin, __list, __string, __sort)
-#define weechat_list_search(__list, __string) \
- weechat_plugin->list_search(weechat_plugin, __list, __string)
-#define weechat_list_casesearch(__list, __string) \
- weechat_plugin->list_casesearch(weechat_plugin, __list, __string)
-#define weechat_list_get(__list, __index) \
- weechat_plugin->list_get(weechat_plugin, __list, __index)
-#define weechat_list_next(__item) \
- weechat_plugin->list_next(weechat_plugin, __item)
-#define weechat_list_prev(__item) \
- weechat_plugin->list_prev(weechat_plugin, __item)
-#define weechat_list_string(__item) \
- weechat_plugin->list_string(weechat_plugin, __item)
-#define weechat_list_size(__list) \
- weechat_plugin->list_size(weechat_plugin, __list)
-#define weechat_list_remove(__list, __item) \
- weechat_plugin->list_remove(weechat_plugin, __list, __item)
-#define weechat_list_remove_all(__list) \
- weechat_plugin->list_remove_all(weechat_plugin, __list)
-#define weechat_list_free(__list) \
- weechat_plugin->list_free(weechat_plugin, __list)
+ weechat_plugin->list_new()
+#define weechat_list_add(__list, __string, __where) \
+ weechat_plugin->list_add(__list, __string, __where)
+#define weechat_list_search(__list, __string) \
+ weechat_plugin->list_search(__list, __string)
+#define weechat_list_casesearch(__list, __string) \
+ weechat_plugin->list_casesearch(__list, __string)
+#define weechat_list_get(__list, __index) \
+ weechat_plugin->list_get(__list, __index)
+#define weechat_list_next(__item) \
+ weechat_plugin->list_next(__item)
+#define weechat_list_prev(__item) \
+ weechat_plugin->list_prev(__item)
+#define weechat_list_string(__item) \
+ weechat_plugin->list_string(__item)
+#define weechat_list_size(__list) \
+ weechat_plugin->list_size(__list)
+#define weechat_list_remove(__list, __item) \
+ weechat_plugin->list_remove(__list, __item)
+#define weechat_list_remove_all(__list) \
+ weechat_plugin->list_remove_all(__list)
+#define weechat_list_free(__list) \
+ weechat_plugin->list_free(__list)
/* config files */
#define weechat_config_new(__filename) \
weechat_plugin->config_new(weechat_plugin, __filename)
#define weechat_config_new_section(__config, __name, __cb_read, \
__cb_write_std, __cb_write_def) \
- weechat_plugin->config_new_section(weechat_plugin, \
- __config, __name, __cb_read, \
+ weechat_plugin->config_new_section(__config, __name, __cb_read, \
__cb_write_std, __cb_write_def)
-#define weechat_config_search_section(__config, __name) \
- weechat_plugin->config_search_section(weechat_plugin, \
- __config, __name)
+#define weechat_config_search_section(__config, __name) \
+ weechat_plugin->config_search_section(__config, __name)
#define weechat_config_new_option(__section, __name, __type, __desc, \
__string_values, __min, __max, \
__default, __callback) \
- weechat_plugin->config_new_option(weechat_plugin, \
- __section, __name, __type, \
+ weechat_plugin->config_new_option(__section, __name, __type, \
__desc, __string_values, \
__min, __max, __default, \
__callback)
-#define weechat_config_search_option(__config, __section, __name) \
- weechat_plugin->config_search_option(weechat_plugin, \
- __config, __section, __name)
-#define weechat_config_option_set(__option, __value) \
- weechat_plugin->config_option_set(weechat_plugin, __option, \
- __value)
-#define weechat_config_string_to_boolean(__string) \
- weechat_plugin->config_string_to_boolean(weechat_plugin, __string)
-#define weechat_config_boolean(__option) \
- weechat_plugin->config_boolean(weechat_plugin, __option)
-#define weechat_config_integer(__option) \
- weechat_plugin->config_integer(weechat_plugin, __option)
-#define weechat_config_string(__option) \
- weechat_plugin->config_string(weechat_plugin, __option)
-#define weechat_config_color(__option) \
- weechat_plugin->config_color(weechat_plugin, __option)
-#define weechat_config_read(__config) \
- weechat_plugin->config_read(weechat_plugin, __config)
-#define weechat_config_reload(__config) \
- weechat_plugin->config_reload(weechat_plugin, __config)
-#define weechat_config_write(__config) \
- weechat_plugin->config_write(weechat_plugin, __config)
+#define weechat_config_search_option(__config, __section, __name) \
+ weechat_plugin->config_search_option(__config, __section, __name)
+#define weechat_config_string_to_boolean(__string) \
+ weechat_plugin->config_string_to_boolean(__string)
+#define weechat_config_option_set(__option, __value, __run_callback) \
+ weechat_plugin->config_option_set(__option, __value, \
+ __run_callback)
+#define weechat_config_boolean(__option) \
+ weechat_plugin->config_boolean(__option)
+#define weechat_config_integer(__option) \
+ weechat_plugin->config_integer(__option)
+#define weechat_config_string(__option) \
+ weechat_plugin->config_string(__option)
+#define weechat_config_color(__option) \
+ weechat_plugin->config_color(__option)
#define weechat_config_write_line(__config, __option, \
__value...) \
- weechat_plugin->config_write_line(weechat_plugin, \
- __config, __option, \
+ weechat_plugin->config_write_line(__config, __option, \
##__value)
-#define weechat_config_free(__config) \
- weechat_plugin->config_free(weechat_plugin, __config)
-#define weechat_config_get(__option) \
- weechat_plugin->config_get(weechat_plugin, __option)
-#define weechat_plugin_config_get(__option) \
- weechat_plugin->plugin_config_get(weechat_plugin, __option)
-#define weechat_plugin_config_set(__option, __value) \
- weechat_plugin->plugin_config_set(weechat_plugin, __option, __value)
+#define weechat_config_write(__config) \
+ weechat_plugin->config_write(__config)
+#define weechat_config_read(__config) \
+ weechat_plugin->config_read(__config)
+#define weechat_config_reload(__config) \
+ weechat_plugin->config_reload(__config)
+#define weechat_config_free(__config) \
+ weechat_plugin->config_free(__config)
+#define weechat_config_get_weechat(__option) \
+ weechat_plugin->config_get_weechat(__option)
+#define weechat_config_get_plugin(__option) \
+ weechat_plugin->config_get_plugin(weechat_plugin, __option)
+#define weechat_config_set_plugin(__option, __value) \
+ weechat_plugin->config_set_plugin(weechat_plugin, __option, __value)
/* display */
-#define weechat_prefix(__prefix_name) \
- weechat_plugin->prefix(weechat_plugin, __prefix_name)
-#define weechat_color(__color_name) \
- weechat_plugin->color(weechat_plugin, __color_name)
-#define weechat_printf(__buffer, __argz...) \
- weechat_plugin->printf(weechat_plugin, __buffer, ##__argz)
-#define weechat_printf_date(__buffer, __datetime, __argz...) \
- weechat_plugin->printf_date(weechat_plugin, __buffer, __datetime, \
- ##__argz)
-#define weechat_log_printf(__argz...) \
- weechat_plugin->log_printf(weechat_plugin, ##__argz)
-#define weechat_infobar_printf(__delay, __color, __argz...) \
- weechat_plugin->infobar_printf(weechat_plugin, __delay, __color, \
+#define weechat_prefix(__prefix) \
+ weechat_plugin->prefix(__prefix)
+#define weechat_color(__color_name) \
+ weechat_plugin->color(__color_name)
+#define weechat_printf(__buffer, __message, __argz...) \
+ weechat_plugin->printf_date(__buffer, 0, __message, ##__argz)
+#define weechat_printf_date(__buffer, __date, __message, __argz...) \
+ weechat_plugin->printf_date(__buffer, __date, __message, ##__argz)
+#define weechat_log_printf(__message, __argz...) \
+ weechat_plugin->log_printf(__message, ##__argz)
+#define weechat_infobar_printf(__delay, __color_name, __message, \
+ __argz...) \
+ weechat_plugin->infobar_printf(__delay, __color_name, __message, \
##__argz)
-#define weechat_infobar_remove(__number) \
- weechat_plugin->infobar_remove(weechat_plugin, __number)
+#define weechat_infobar_remove(__how_many) \
+ weechat_plugin->infobar_remove(__how_many)
/* hooks */
#define weechat_hook_command(__command, __description, __args, \
@@ -425,34 +464,32 @@ struct t_weechat_plugin
weechat_plugin->hook_signal(weechat_plugin, __signal, __callback, \
__data)
#define weechat_hook_signal_send(__signal, __pointer) \
- weechat_plugin->hook_signal_send(weechat_plugin, __signal, \
- __pointer)
+ weechat_plugin->hook_signal_send(__signal, __pointer)
#define weechat_hook_config(__type, __option, __callback, __data) \
weechat_plugin->hook_config(weechat_plugin, __type, __option, \
__callback, __data)
#define weechat_hook_completion(__completion, __callback, __data) \
weechat_plugin->hook_completion(weechat_plugin, __completion, \
__callback, __data)
-#define weechat_unhook(__hook) \
- weechat_plugin->unhook(weechat_plugin, __hook)
-#define weechat_unhook_all() \
- weechat_plugin->unhook(weechat_plugin)
+#define weechat_unhook(__hook) \
+ weechat_plugin->unhook( __hook)
+#define weechat_unhook_all() \
+ weechat_plugin->unhook_all_plugin(weechat_plugin)
/* buffers */
-#define weechat_buffer_new(__category, __name, __input_data_cb) \
+#define weechat_buffer_new(__category, __name, __callback_input_data) \
weechat_plugin->buffer_new(weechat_plugin, __category, __name, \
- __input_data_cb)
-#define weechat_buffer_search(__category, __name) \
- weechat_plugin->buffer_search(weechat_plugin, __category, __name)
-#define weechat_current_buffer \
- weechat_plugin->buffer_search(weechat_plugin, NULL, NULL)
-#define weechat_buffer_close(__buffer) \
- weechat_plugin->buffer_close(weechat_plugin, __buffer)
-#define weechat_buffer_get(__buffer, __property) \
- weechat_plugin->buffer_get(weechat_plugin, __buffer, __property)
-#define weechat_buffer_set(__buffer, __property, __value) \
- weechat_plugin->buffer_set(weechat_plugin, __buffer, __property, \
- __value)
+ __callback_input_data)
+#define weechat_buffer_search(__category, __name) \
+ weechat_plugin->buffer_search(__category, __name)
+#define weechat_current_buffer \
+ weechat_plugin->buffer_search(NULL, NULL)
+#define weechat_buffer_close(__buffer, __switch_to_another) \
+ weechat_plugin->buffer_close(__buffer, __switch_to_another)
+#define weechat_buffer_get(__buffer, __property) \
+ weechat_plugin->buffer_get(__buffer, __property)
+#define weechat_buffer_set(__buffer, __property, __value) \
+ weechat_plugin->buffer_set(__buffer, __property, __value)
/* command */
#define weechat_command(__buffer, __command) \
@@ -463,23 +500,23 @@ struct t_weechat_plugin
weechat_plugin->info_get(weechat_plugin, __name)
/* infolists */
-#define weechat_infolist_get(__name, __pointer) \
- weechat_plugin->infolist_get(weechat_plugin, __name, __pointer)
-#define weechat_infolist_next(__list) \
- weechat_plugin->infolist_next(weechat_plugin, __list)
-#define weechat_infolist_prev(__list) \
- weechat_plugin->infolist_prev(weechat_plugin, __list)
-#define weechat_infolist_fields(__list) \
- weechat_plugin->infolist_fields(weechat_plugin, __list)
-#define weechat_infolist_integer(__item, __var) \
- weechat_plugin->infolist_integer(weechat_plugin, __item, __var)
-#define weechat_infolist_string(__item, __var) \
- weechat_plugin->infolist_string(weechat_plugin, __item, __var)
-#define weechat_infolist_pointer(__item, __var) \
- weechat_plugin->infolist_pointer(weechat_plugin, __item, __var)
-#define weechat_infolist_time(__item, __var) \
- weechat_plugin->infolist_time(weechat_plugin, __item, __var)
-#define weechat_infolist_free(__list) \
- weechat_plugin->infolist_free(weechat_plugin, __list)
+#define weechat_infolist_get(__name, __pointer) \
+ weechat_plugin->infolist_get(__name, __pointer)
+#define weechat_infolist_next(__list) \
+ weechat_plugin->infolist_next(__list)
+#define weechat_infolist_prev(__list) \
+ weechat_plugin->infolist_prev(__list)
+#define weechat_infolist_fields(__list) \
+ weechat_plugin->infolist_fields(__list)
+#define weechat_infolist_integer(__item, __var) \
+ weechat_plugin->infolist_integer(__item, __var)
+#define weechat_infolist_string(__item, __var) \
+ weechat_plugin->infolist_string(__item, __var)
+#define weechat_infolist_pointer(__item, __var) \
+ weechat_plugin->infolist_pointer(__item, __var)
+#define weechat_infolist_time(__item, __var) \
+ weechat_plugin->infolist_time(__item, __var)
+#define weechat_infolist_free(__list) \
+ weechat_plugin->infolist_free(__list)
#endif /* weechat-plugin.h */