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

core: add pointer in some callbacks (closes #406)

This pointer is the first argument received by callbacks, and the
existing argument "data" is now automatically freed by WeeChat when the
object containing the callback is removed.

With this new pointer, the linked list of callbacks in scripts has been
removed. This will improve speed of scripts (using a lot of hooks),
reduce memory used by scripts and reduce time to unload scripts.

Following functions are affected in the C API:

* exec_on_files
* config_new
* config_new_section
* config_new_option
* hook_command
* hook_command_run
* hook_timer
* hook_fd
* hook_process
* hook_process_hashtable
* hook_connect
* hook_print
* hook_signal
* hook_hsignal
* hook_config
* hook_completion
* hook_modifier
* hook_info
* hook_info_hashtable
* hook_infolist
* hook_hdata
* hook_focus
* unhook_all_plugin
* buffer_new
* bar_item_new
* upgrade_new
* upgrade_read
This commit is contained in:
Sébastien Helleu
2016-03-21 18:11:21 +01:00
parent 6d764b64c5
commit cf6aca1619
207 changed files with 9596 additions and 7472 deletions
+11 -6
View File
@@ -114,10 +114,12 @@ trigger_buffer_set_title ()
*/
int
trigger_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data)
trigger_buffer_input_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
const char *input_data)
{
/* make C compiler happy */
(void) pointer;
(void) data;
/* close buffer */
@@ -144,9 +146,11 @@ trigger_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
*/
int
trigger_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
trigger_buffer_close_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) buffer;
@@ -188,9 +192,10 @@ trigger_buffer_open (const char *filter, int switch_to_buffer)
{
if (!trigger_buffer)
{
trigger_buffer = weechat_buffer_new (TRIGGER_BUFFER_NAME,
&trigger_buffer_input_cb, NULL,
&trigger_buffer_close_cb, NULL);
trigger_buffer = weechat_buffer_new (
TRIGGER_BUFFER_NAME,
&trigger_buffer_input_cb, NULL, NULL,
&trigger_buffer_close_cb, NULL, NULL);
/* failed to create buffer ? then return */
if (!trigger_buffer)
+24 -19
View File
@@ -56,8 +56,7 @@ trigger_callback_irc_message_parse (const char *irc_message,
hashtable_in = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
NULL, NULL);
if (hashtable_in)
{
weechat_hashtable_set (hashtable_in, "message", irc_message);
@@ -187,8 +186,7 @@ trigger_callback_replace_regex (struct t_trigger *trigger,
pointers = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
NULL,
NULL);
NULL, NULL);
if (!pointers)
return;
pointers_allocated = 1;
@@ -366,8 +364,9 @@ trigger_callback_execute (struct t_trigger *trigger,
*/
int
trigger_callback_signal_cb (void *data, const char *signal,
const char *type_data, void *signal_data)
trigger_callback_signal_cb (const void *pointer, void *data,
const char *signal, const char *type_data,
void *signal_data)
{
const char *ptr_signal_data;
char str_data[128], *irc_server;
@@ -463,7 +462,8 @@ end:
*/
int
trigger_callback_hsignal_cb (void *data, const char *signal,
trigger_callback_hsignal_cb (const void *pointer, void *data,
const char *signal,
struct t_hashtable *hashtable)
{
const char *type_values;
@@ -510,8 +510,9 @@ end:
*/
char *
trigger_callback_modifier_cb (void *data, const char *modifier,
const char *modifier_data, const char *string)
trigger_callback_modifier_cb (const void *pointer, void *data,
const char *modifier, const char *modifier_data,
const char *string)
{
struct t_gui_buffer *buffer;
const char *ptr_string;
@@ -691,7 +692,8 @@ end:
*/
int
trigger_callback_print_cb (void *data, struct t_gui_buffer *buffer,
trigger_callback_print_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
time_t date, int tags_count, const char **tags,
int displayed, int highlight, const char *prefix,
const char *message)
@@ -766,7 +768,8 @@ end:
*/
int
trigger_callback_command_cb (void *data, struct t_gui_buffer *buffer,
trigger_callback_command_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char str_name[32];
@@ -799,7 +802,8 @@ end:
*/
int
trigger_callback_command_run_cb (void *data, struct t_gui_buffer *buffer,
trigger_callback_command_run_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
const char *command)
{
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
@@ -823,7 +827,8 @@ end:
*/
int
trigger_callback_timer_cb (void *data, int remaining_calls)
trigger_callback_timer_cb (const void *pointer, void *data,
int remaining_calls)
{
char str_temp[128];
int i;
@@ -870,7 +875,8 @@ end:
*/
int
trigger_callback_config_cb (void *data, const char *option, const char *value)
trigger_callback_config_cb (const void *pointer, void *data,
const char *option, const char *value)
{
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
@@ -892,7 +898,8 @@ end:
*/
struct t_hashtable *
trigger_callback_focus_cb (void *data, struct t_hashtable *info)
trigger_callback_focus_cb (const void *pointer, void *data,
struct t_hashtable *info)
{
const char *ptr_value;
long unsigned int value;
@@ -936,8 +943,7 @@ trigger_callback_init ()
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
NULL, NULL);
if (trigger_callback_hashtable_options_conditions)
{
weechat_hashtable_set (trigger_callback_hashtable_options_conditions,
@@ -948,8 +954,7 @@ trigger_callback_init ()
32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
NULL, NULL);
}
/*
+27 -17
View File
@@ -26,10 +26,11 @@
int trigger_rc; \
pointers = NULL; \
extra_vars = NULL; \
(void) data; \
(void) trigger_rc; \
if (!trigger_enabled) \
return __rc; \
trigger = (struct t_trigger *)data; \
trigger = (struct t_trigger *)pointer; \
if (!trigger || trigger->hook_running) \
return __rc; \
trigger->hook_count_cb++; \
@@ -43,8 +44,7 @@
32, \
WEECHAT_HASHTABLE_STRING, \
WEECHAT_HASHTABLE_POINTER, \
NULL, \
NULL); \
NULL, NULL); \
if (!pointers) \
goto end;
@@ -53,8 +53,7 @@
32, \
WEECHAT_HASHTABLE_STRING, \
WEECHAT_HASHTABLE_STRING, \
NULL, \
NULL); \
NULL, NULL); \
if (!extra_vars) \
goto end;
@@ -66,27 +65,38 @@
trigger->hook_running = 0; \
return __rc;
extern int trigger_callback_signal_cb (void *data, const char *signal,
const char *type_data, void *signal_data);
extern int trigger_callback_hsignal_cb (void *data, const char *signal,
extern int trigger_callback_signal_cb (const void *pointer, void *data,
const char *signal,
const char *type_data,
void *signal_data);
extern int trigger_callback_hsignal_cb (const void *pointer, void *data,
const char *signal,
struct t_hashtable *hashtable);
extern char *trigger_callback_modifier_cb (void *data, const char *modifier,
extern char *trigger_callback_modifier_cb (const void *pointer, void *data,
const char *modifier,
const char *modifier_data,
const char *string);
extern int trigger_callback_print_cb (void *data, struct t_gui_buffer *buffer,
extern int trigger_callback_print_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
time_t date, int tags_count,
const char **tags, int displayed,
int highlight, const char *prefix,
const char *message);
extern int trigger_callback_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol);
extern int trigger_callback_command_run_cb (void *data,
extern int trigger_callback_command_cb (const void *pointer,
void *data,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol);
extern int trigger_callback_command_run_cb (const void *pointer,
void *data,
struct t_gui_buffer *buffer,
const char *command);
extern int trigger_callback_timer_cb (void *data, int remaining_calls);
extern int trigger_callback_config_cb (void *data, const char *option,
const char *value);
extern struct t_hashtable *trigger_callback_focus_cb (void *data,
extern int trigger_callback_timer_cb (const void *pointer, void *data,
int remaining_calls);
extern int trigger_callback_config_cb (const void *pointer, void *data,
const char *option, const char *value);
extern struct t_hashtable *trigger_callback_focus_cb (const void *pointer,
void *data,
struct t_hashtable *info);
extern void trigger_callback_init ();
extern void trigger_callback_end ();
+4 -2
View File
@@ -449,7 +449,8 @@ end:
*/
int
trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
trigger_command_trigger (const void *pointer, void *data,
struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
struct t_trigger *ptr_trigger, *ptr_trigger2;
@@ -459,6 +460,7 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,
int regex_count, regex_rc;
/* make C compiler happy */
(void) pointer;
(void) data;
rc = WEECHAT_RC_OK;
@@ -1180,5 +1182,5 @@ trigger_command_init ()
" || restore %(trigger_names_default)|%*"
" || default"
" || monitor %(trigger_names)|%(trigger_hooks_filter)",
&trigger_command_trigger, NULL);
&trigger_command_trigger, NULL, NULL);
}
+44 -22
View File
@@ -33,13 +33,15 @@
*/
int
trigger_completion_triggers_cb (void *data, const char *completion_item,
trigger_completion_triggers_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -59,7 +61,8 @@ trigger_completion_triggers_cb (void *data, const char *completion_item,
*/
int
trigger_completion_triggers_default_cb (void *data,
trigger_completion_triggers_default_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
@@ -67,6 +70,7 @@ trigger_completion_triggers_default_cb (void *data,
int i;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -86,13 +90,15 @@ trigger_completion_triggers_default_cb (void *data,
*/
int
trigger_completion_options_cb (void *data, const char *completion_item,
trigger_completion_options_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -112,7 +118,8 @@ trigger_completion_options_cb (void *data, const char *completion_item,
*/
int
trigger_completion_option_value_cb (void *data, const char *completion_item,
trigger_completion_option_value_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -122,6 +129,7 @@ trigger_completion_option_value_cb (void *data, const char *completion_item,
struct t_trigger *ptr_trigger;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -170,13 +178,15 @@ trigger_completion_option_value_cb (void *data, const char *completion_item,
*/
int
trigger_completion_hooks_cb (void *data, const char *completion_item,
trigger_completion_hooks_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
int i;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -196,7 +206,8 @@ trigger_completion_hooks_cb (void *data, const char *completion_item,
*/
int
trigger_completion_hooks_filter_cb (void *data, const char *completion_item,
trigger_completion_hooks_filter_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
@@ -204,6 +215,7 @@ trigger_completion_hooks_filter_cb (void *data, const char *completion_item,
char str_hook[128];
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -300,11 +312,13 @@ trigger_completion_add_default_for_hook (struct t_gui_completion *completion,
*/
int
trigger_completion_hook_arguments_cb (void *data, const char *completion_item,
trigger_completion_hook_arguments_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -323,11 +337,13 @@ trigger_completion_hook_arguments_cb (void *data, const char *completion_item,
*/
int
trigger_completion_hook_conditions_cb (void *data, const char *completion_item,
trigger_completion_hook_conditions_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -347,11 +363,13 @@ trigger_completion_hook_conditions_cb (void *data, const char *completion_item,
*/
int
trigger_completion_hook_regex_cb (void *data, const char *completion_item,
trigger_completion_hook_regex_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -371,11 +389,13 @@ trigger_completion_hook_regex_cb (void *data, const char *completion_item,
*/
int
trigger_completion_hook_command_cb (void *data, const char *completion_item,
trigger_completion_hook_command_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -395,11 +415,13 @@ trigger_completion_hook_command_cb (void *data, const char *completion_item,
*/
int
trigger_completion_hook_rc_cb (void *data, const char *completion_item,
trigger_completion_hook_rc_cb (const void *pointer, void *data,
const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) completion_item;
(void) buffer;
@@ -420,35 +442,35 @@ trigger_completion_init ()
{
weechat_hook_completion ("trigger_names",
N_("triggers"),
&trigger_completion_triggers_cb, NULL);
&trigger_completion_triggers_cb, NULL, NULL);
weechat_hook_completion ("trigger_names_default",
N_("default triggers"),
&trigger_completion_triggers_default_cb, NULL);
&trigger_completion_triggers_default_cb, NULL, NULL);
weechat_hook_completion ("trigger_options",
N_("options for triggers"),
&trigger_completion_options_cb, NULL);
&trigger_completion_options_cb, NULL, NULL);
weechat_hook_completion ("trigger_option_value",
N_("value of a trigger option"),
&trigger_completion_option_value_cb, NULL);
&trigger_completion_option_value_cb, NULL, NULL);
weechat_hook_completion ("trigger_hooks",
N_("hooks for triggers"),
&trigger_completion_hooks_cb, NULL);
&trigger_completion_hooks_cb, NULL, NULL);
weechat_hook_completion ("trigger_hooks_filter",
N_("hooks for triggers (for filter in monitor buffer)"),
&trigger_completion_hooks_filter_cb, NULL);
&trigger_completion_hooks_filter_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_arguments",
N_("default arguments for a hook"),
&trigger_completion_hook_arguments_cb, NULL);
&trigger_completion_hook_arguments_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_conditions",
N_("default conditions for a hook"),
&trigger_completion_hook_conditions_cb, NULL);
&trigger_completion_hook_conditions_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_regex",
N_("default regular expression for a hook"),
&trigger_completion_hook_regex_cb, NULL);
&trigger_completion_hook_regex_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_command",
N_("default command for a hook"),
&trigger_completion_hook_command_cb, NULL);
&trigger_completion_hook_command_cb, NULL, NULL);
weechat_hook_completion ("trigger_hook_rc",
N_("default return codes for hook callback"),
&trigger_completion_hook_rc_cb, NULL);
&trigger_completion_hook_rc_cb, NULL, NULL);
}
+80 -49
View File
@@ -102,9 +102,11 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] =
*/
void
trigger_config_change_enabled (void *data, struct t_config_option *option)
trigger_config_change_enabled (const void *pointer, void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) pointer;
(void) data;
trigger_enabled = weechat_config_boolean (option);
@@ -115,12 +117,13 @@ trigger_config_change_enabled (void *data, struct t_config_option *option)
*/
void
trigger_config_change_trigger_enabled (void *data,
trigger_config_change_trigger_enabled (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
(void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -138,11 +141,13 @@ trigger_config_change_trigger_enabled (void *data,
*/
void
trigger_config_change_trigger_hook (void *data, struct t_config_option *option)
trigger_config_change_trigger_hook (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
(void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -158,12 +163,13 @@ trigger_config_change_trigger_hook (void *data, struct t_config_option *option)
*/
void
trigger_config_change_trigger_arguments (void *data,
trigger_config_change_trigger_arguments (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
(void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -179,11 +185,13 @@ trigger_config_change_trigger_arguments (void *data,
*/
void
trigger_config_change_trigger_regex (void *data, struct t_config_option *option)
trigger_config_change_trigger_regex (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
(void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -223,12 +231,13 @@ trigger_config_change_trigger_regex (void *data, struct t_config_option *option)
*/
void
trigger_config_change_trigger_command (void *data,
trigger_config_change_trigger_command (const void *pointer, void *data,
struct t_config_option *option)
{
struct t_trigger *ptr_trigger;
/* make C compiler happy */
(void) pointer;
(void) data;
ptr_trigger = trigger_search_with_option (option);
@@ -273,8 +282,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "boolean",
N_("if disabled, the hooks are removed from trigger, so it is "
"not called any more"),
NULL, 0, 0, value, NULL, 0, NULL, NULL,
&trigger_config_change_trigger_enabled, NULL, NULL, NULL);
NULL, 0, 0, value, NULL, 0,
NULL, NULL, NULL,
&trigger_config_change_trigger_enabled, NULL, NULL,
NULL, NULL, NULL);
break;
case TRIGGER_OPTION_HOOK:
ptr_option = weechat_config_new_option (
@@ -282,8 +293,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "integer",
N_("type of hook used"),
trigger_hook_option_values,
0, 0, value, NULL, 0, NULL, NULL,
&trigger_config_change_trigger_hook, NULL, NULL, NULL);
0, 0, value, NULL, 0,
NULL, NULL, NULL,
&trigger_config_change_trigger_hook, NULL, NULL,
NULL, NULL, NULL);
break;
case TRIGGER_OPTION_ARGUMENTS:
ptr_option = weechat_config_new_option (
@@ -291,8 +304,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "string",
N_("arguments for the hook (depend on the hook type, see /help "
"trigger)"),
NULL, 0, 0, value, NULL, 0, NULL, NULL,
&trigger_config_change_trigger_arguments, NULL, NULL, NULL);
NULL, 0, 0, value, NULL, 0,
NULL, NULL, NULL,
&trigger_config_change_trigger_arguments, NULL, NULL,
NULL, NULL, NULL);
break;
case TRIGGER_OPTION_CONDITIONS:
ptr_option = weechat_config_new_option (
@@ -302,7 +317,7 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
"hook callback) (note: content is evaluated when trigger is "
"run, see /help eval)"),
NULL, 0, 0, value, NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case TRIGGER_OPTION_REGEX:
ptr_option = weechat_config_new_option (
@@ -321,8 +336,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
"replace: ${re:0} to ${re:99}, ${re:+} for last match and "
"${hide:c,${re:N}} to replace all chars of group N by "
"char 'c'"),
NULL, 0, 0, value, NULL, 0, NULL, NULL,
&trigger_config_change_trigger_regex, NULL, NULL, NULL);
NULL, 0, 0, value, NULL, 0,
NULL, NULL, NULL,
&trigger_config_change_trigger_regex, NULL, NULL,
NULL, NULL, NULL);
break;
case TRIGGER_OPTION_COMMAND:
ptr_option = weechat_config_new_option (
@@ -330,8 +347,10 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
option_name, "string",
N_("command(s) to run if conditions are OK, after regex "
"replacements (many commands can be separated by semicolons)"),
NULL, 0, 0, value, NULL, 0, NULL, NULL,
&trigger_config_change_trigger_command, NULL, NULL, NULL);
NULL, 0, 0, value, NULL, 0,
NULL, NULL, NULL,
&trigger_config_change_trigger_command, NULL, NULL,
NULL, NULL, NULL);
break;
case TRIGGER_OPTION_RETURN_CODE:
ptr_option = weechat_config_new_option (
@@ -340,7 +359,7 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
N_("return code for hook callback (see plugin API reference to "
"know where ok_eat/error can be used efficiently)"),
"ok|ok_eat|error", 0, 0, value, NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
break;
case TRIGGER_NUM_OPTIONS:
break;
@@ -434,7 +453,8 @@ trigger_config_use_temp_triggers ()
*/
int
trigger_config_trigger_read_cb (void *data, struct t_config_file *config_file,
trigger_config_trigger_read_cb (const void *pointer, void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
@@ -443,6 +463,7 @@ trigger_config_trigger_read_cb (void *data, struct t_config_file *config_file,
int index_option;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) config_file;
(void) section;
@@ -504,7 +525,7 @@ trigger_config_trigger_read_cb (void *data, struct t_config_file *config_file,
*/
int
trigger_config_trigger_write_default_cb (void *data,
trigger_config_trigger_write_default_cb (const void *pointer, void *data,
struct t_config_file *config_file,
const char *section_name)
{
@@ -512,6 +533,7 @@ trigger_config_trigger_write_default_cb (void *data,
char option_name[512];
/* make C compiler happy */
(void) pointer;
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
@@ -545,11 +567,13 @@ trigger_config_trigger_write_default_cb (void *data,
*/
int
trigger_config_reload_cb (void *data, struct t_config_file *config_file)
trigger_config_reload_cb (const void *pointer, void *data,
struct t_config_file *config_file)
{
int rc;
/* make C compiler happy */
(void) pointer;
(void) data;
trigger_free_all ();
@@ -574,17 +598,19 @@ trigger_config_init ()
{
struct t_config_section *ptr_section;
trigger_config_file = weechat_config_new (TRIGGER_CONFIG_NAME,
&trigger_config_reload_cb, NULL);
trigger_config_file = weechat_config_new (
TRIGGER_CONFIG_NAME, &trigger_config_reload_cb, NULL, NULL);
if (!trigger_config_file)
return 0;
/* look */
ptr_section = weechat_config_new_section (trigger_config_file, "look",
0, 0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL);
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (trigger_config_file);
@@ -595,21 +621,25 @@ trigger_config_init ()
trigger_config_file, ptr_section,
"enabled", "boolean",
N_("enable trigger support"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&trigger_config_change_enabled, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL,
&trigger_config_change_enabled, NULL, NULL,
NULL, NULL, NULL);
trigger_config_look_monitor_strip_colors = weechat_config_new_option (
trigger_config_file, ptr_section,
"monitor_strip_colors", "boolean",
N_("strip colors in hashtable values displayed on monitor buffer"),
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
NULL, 0, 0, "off", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* color */
ptr_section = weechat_config_new_section (trigger_config_file, "color",
0, 0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL);
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (trigger_config_file);
@@ -621,59 +651,60 @@ trigger_config_init ()
"flag_command", "color",
N_("text color for command flag (in /trigger list)"),
NULL, 0, 0, "lightgreen", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_flag_conditions = weechat_config_new_option (
trigger_config_file, ptr_section,
"flag_conditions", "color",
N_("text color for conditions flag (in /trigger list)"),
NULL, 0, 0, "yellow", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_flag_regex = weechat_config_new_option (
trigger_config_file, ptr_section,
"flag_regex", "color",
N_("text color for regex flag (in /trigger list)"),
NULL, 0, 0, "lightcyan", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_flag_return_code = weechat_config_new_option (
trigger_config_file, ptr_section,
"flag_return_code", "color",
N_("text color for return code flag (in /trigger list)"),
NULL, 0, 0, "lightmagenta", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_regex = weechat_config_new_option (
trigger_config_file, ptr_section,
"regex", "color",
N_("text color for regular expressions"),
NULL, 0, 0, "white", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_replace = weechat_config_new_option (
trigger_config_file, ptr_section,
"replace", "color",
N_("text color for replacement text (for regular expressions)"),
NULL, 0, 0, "cyan", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_trigger = weechat_config_new_option (
trigger_config_file, ptr_section,
"trigger", "color",
N_("text color for trigger name"),
NULL, 0, 0, "green", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
trigger_config_color_trigger_disabled = weechat_config_new_option (
trigger_config_file, ptr_section,
"trigger_disabled", "color",
N_("text color for disabled trigger name"),
NULL, 0, 0, "red", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
/* trigger */
ptr_section = weechat_config_new_section (trigger_config_file,
TRIGGER_CONFIG_SECTION_TRIGGER,
0, 0,
&trigger_config_trigger_read_cb, NULL,
NULL, NULL,
&trigger_config_trigger_write_default_cb, NULL,
NULL, NULL,
NULL, NULL);
ptr_section = weechat_config_new_section (
trigger_config_file,
TRIGGER_CONFIG_SECTION_TRIGGER,
0, 0,
&trigger_config_trigger_read_cb, NULL, NULL,
NULL, NULL, NULL,
&trigger_config_trigger_write_default_cb, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (trigger_config_file);
+13 -11
View File
@@ -266,7 +266,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_signal (
argv[i],
&trigger_callback_signal_cb,
trigger);
trigger, NULL);
}
}
}
@@ -283,7 +283,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_hsignal (
argv[i],
&trigger_callback_hsignal_cb,
trigger);
trigger, NULL);
}
}
}
@@ -300,7 +300,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_modifier (
argv[i],
&trigger_callback_modifier_cb,
trigger);
trigger, NULL);
}
}
}
@@ -330,7 +330,7 @@ trigger_hook (struct t_trigger *trigger)
message,
strip_colors,
&trigger_callback_print_cb,
trigger);
trigger, NULL);
}
break;
case TRIGGER_HOOK_COMMAND:
@@ -347,7 +347,7 @@ trigger_hook (struct t_trigger *trigger)
(argc > 3) ? argv[3] : "", /* description of args */
(argc > 4) ? argv[4] : "", /* completion */
&trigger_callback_command_cb,
trigger);
trigger, NULL);
}
}
break;
@@ -363,7 +363,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_command_run (
argv[i],
&trigger_callback_command_run_cb,
trigger);
trigger, NULL);
}
}
}
@@ -393,7 +393,7 @@ trigger_hook (struct t_trigger *trigger)
(int)align_second,
(int)max_calls,
&trigger_callback_timer_cb,
trigger);
trigger, NULL);
}
}
}
@@ -410,7 +410,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_config (
argv[i],
&trigger_callback_config_cb,
trigger);
trigger, NULL);
}
}
}
@@ -427,7 +427,7 @@ trigger_hook (struct t_trigger *trigger)
trigger->hooks[i] = weechat_hook_focus (
argv[i],
&trigger_callback_focus_cb,
trigger);
trigger, NULL);
}
}
}
@@ -1151,10 +1151,12 @@ trigger_print_log ()
*/
int
trigger_debug_dump_cb (void *data, const char *signal, const char *type_data,
trigger_debug_dump_cb (const void *pointer, void *data,
const char *signal, const char *type_data,
void *signal_data)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) signal;
(void) type_data;
@@ -1197,7 +1199,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
trigger_config_read ();
/* hook some signals */
weechat_hook_signal ("debug_dump", &trigger_debug_dump_cb, NULL);
weechat_hook_signal ("debug_dump", &trigger_debug_dump_cb, NULL, NULL);
/* hook completions */
trigger_completion_init ();