mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
api: use a struct for arguments of function script_init (callbacks)
This commit is contained in:
@@ -850,6 +850,8 @@ weechat_guile_port_write (SCM port, const void *data, size_t size)
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
struct t_plugin_script_init init;
|
||||
|
||||
weechat_guile_plugin = plugin;
|
||||
|
||||
guile_stdout = NULL;
|
||||
@@ -862,17 +864,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
scm_c_use_module ("weechat");
|
||||
weechat_guile_catch (scm_gc_protect_object, (void *)guile_module_weechat);
|
||||
|
||||
init.callback_command = &weechat_guile_command_cb;
|
||||
init.callback_completion = &weechat_guile_completion_cb;
|
||||
init.callback_infolist = &weechat_guile_infolist_cb;
|
||||
init.callback_signal_debug_dump = &weechat_guile_signal_debug_dump_cb;
|
||||
init.callback_signal_buffer_closed = &weechat_guile_signal_buffer_closed_cb;
|
||||
init.callback_signal_script_action = &weechat_guile_signal_script_action_cb;
|
||||
init.callback_load_file = &weechat_guile_load_cb;
|
||||
|
||||
guile_quiet = 1;
|
||||
script_init (weechat_guile_plugin,
|
||||
argc,
|
||||
argv,
|
||||
&weechat_guile_command_cb,
|
||||
&weechat_guile_completion_cb,
|
||||
&weechat_guile_infolist_cb,
|
||||
&weechat_guile_signal_debug_dump_cb,
|
||||
&weechat_guile_signal_buffer_closed_cb,
|
||||
&weechat_guile_signal_script_action_cb,
|
||||
&weechat_guile_load_cb);
|
||||
script_init (weechat_guile_plugin, argc, argv, &init);
|
||||
guile_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_guile_plugin,
|
||||
|
||||
@@ -730,19 +730,20 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
struct t_plugin_script_init init;
|
||||
|
||||
weechat_lua_plugin = plugin;
|
||||
|
||||
init.callback_command = &weechat_lua_command_cb;
|
||||
init.callback_completion = &weechat_lua_completion_cb;
|
||||
init.callback_infolist = &weechat_lua_infolist_cb;
|
||||
init.callback_signal_debug_dump = &weechat_lua_signal_debug_dump_cb;
|
||||
init.callback_signal_buffer_closed = &weechat_lua_signal_buffer_closed_cb;
|
||||
init.callback_signal_script_action = &weechat_lua_signal_script_action_cb;
|
||||
init.callback_load_file = &weechat_lua_load_cb;
|
||||
|
||||
lua_quiet = 1;
|
||||
script_init (weechat_lua_plugin,
|
||||
argc,
|
||||
argv,
|
||||
&weechat_lua_command_cb,
|
||||
&weechat_lua_completion_cb,
|
||||
&weechat_lua_infolist_cb,
|
||||
&weechat_lua_signal_debug_dump_cb,
|
||||
&weechat_lua_signal_buffer_closed_cb,
|
||||
&weechat_lua_signal_script_action_cb,
|
||||
&weechat_lua_load_cb);
|
||||
script_init (weechat_lua_plugin, argc, argv, &init);
|
||||
lua_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_lua_plugin,
|
||||
|
||||
@@ -939,6 +939,7 @@ weechat_perl_signal_quit_upgrade_cb (void *data, const char *signal,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
struct t_plugin_script_init init;
|
||||
#ifdef PERL_SYS_INIT3
|
||||
int a;
|
||||
char **perl_args_local;
|
||||
@@ -971,17 +972,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
eval_pv (perl_weechat_code, TRUE);
|
||||
#endif
|
||||
|
||||
init.callback_command = &weechat_perl_command_cb;
|
||||
init.callback_completion = &weechat_perl_completion_cb;
|
||||
init.callback_infolist = &weechat_perl_infolist_cb;
|
||||
init.callback_signal_debug_dump = &weechat_perl_signal_debug_dump_cb;
|
||||
init.callback_signal_buffer_closed = &weechat_perl_signal_buffer_closed_cb;
|
||||
init.callback_signal_script_action = &weechat_perl_signal_script_action_cb;
|
||||
init.callback_load_file = &weechat_perl_load_cb;
|
||||
|
||||
perl_quiet = 1;
|
||||
script_init (weechat_perl_plugin,
|
||||
argc,
|
||||
argv,
|
||||
&weechat_perl_command_cb,
|
||||
&weechat_perl_completion_cb,
|
||||
&weechat_perl_infolist_cb,
|
||||
&weechat_perl_signal_debug_dump_cb,
|
||||
&weechat_perl_signal_buffer_closed_cb,
|
||||
&weechat_perl_signal_script_action_cb,
|
||||
&weechat_perl_load_cb);
|
||||
script_init (weechat_perl_plugin, argc, argv, &init);
|
||||
perl_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_perl_plugin,
|
||||
|
||||
@@ -1140,6 +1140,8 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
struct t_plugin_script_init init;
|
||||
|
||||
weechat_python_plugin = plugin;
|
||||
|
||||
/*
|
||||
@@ -1182,17 +1184,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
init.callback_command = &weechat_python_command_cb;
|
||||
init.callback_completion = &weechat_python_completion_cb;
|
||||
init.callback_infolist = &weechat_python_infolist_cb;
|
||||
init.callback_signal_debug_dump = &weechat_python_signal_debug_dump_cb;
|
||||
init.callback_signal_buffer_closed = &weechat_python_signal_buffer_closed_cb;
|
||||
init.callback_signal_script_action = &weechat_python_signal_script_action_cb;
|
||||
init.callback_load_file = &weechat_python_load_cb;
|
||||
|
||||
python_quiet = 1;
|
||||
script_init (weechat_python_plugin,
|
||||
argc,
|
||||
argv,
|
||||
&weechat_python_command_cb,
|
||||
&weechat_python_completion_cb,
|
||||
&weechat_python_infolist_cb,
|
||||
&weechat_python_signal_debug_dump_cb,
|
||||
&weechat_python_signal_buffer_closed_cb,
|
||||
&weechat_python_signal_script_action_cb,
|
||||
&weechat_python_load_cb);
|
||||
script_init (weechat_python_plugin, argc, argv, &init);
|
||||
python_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_python_plugin,
|
||||
|
||||
@@ -968,6 +968,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
struct t_plugin_script_init init;
|
||||
int ruby_error;
|
||||
char *weechat_ruby_code =
|
||||
{
|
||||
@@ -1069,17 +1070,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
init.callback_command = &weechat_ruby_command_cb;
|
||||
init.callback_completion = &weechat_ruby_completion_cb;
|
||||
init.callback_infolist = &weechat_ruby_infolist_cb;
|
||||
init.callback_signal_debug_dump = &weechat_ruby_signal_debug_dump_cb;
|
||||
init.callback_signal_buffer_closed = &weechat_ruby_signal_buffer_closed_cb;
|
||||
init.callback_signal_script_action = &weechat_ruby_signal_script_action_cb;
|
||||
init.callback_load_file = &weechat_ruby_load_cb;
|
||||
|
||||
ruby_quiet = 1;
|
||||
script_init (weechat_ruby_plugin,
|
||||
argc,
|
||||
argv,
|
||||
&weechat_ruby_command_cb,
|
||||
&weechat_ruby_completion_cb,
|
||||
&weechat_ruby_infolist_cb,
|
||||
&weechat_ruby_signal_debug_dump_cb,
|
||||
&weechat_ruby_signal_buffer_closed_cb,
|
||||
&weechat_ruby_signal_script_action_cb,
|
||||
&weechat_ruby_load_cb);
|
||||
script_init (weechat_ruby_plugin, argc, argv, &init);
|
||||
ruby_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_ruby_plugin,
|
||||
|
||||
@@ -84,30 +84,8 @@ script_config_cb (void *data, const char *option, const char *value)
|
||||
*/
|
||||
|
||||
void
|
||||
script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
int argc,
|
||||
char *argv[],
|
||||
int (*callback_command)(void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
int argc, char **argv,
|
||||
char **argv_eol),
|
||||
int (*callback_completion)(void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion),
|
||||
struct t_infolist *(*callback_infolist)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
const char *arguments),
|
||||
int (*callback_signal_debug_dump)(void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data),
|
||||
int (*callback_signal_buffer_closed)(void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data),
|
||||
int (*callback_signal_script_action)(void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data),
|
||||
void (*callback_load_file)(void *data, const char *filename))
|
||||
script_init (struct t_weechat_plugin *weechat_plugin, int argc, char *argv[],
|
||||
struct t_plugin_script_init *init)
|
||||
{
|
||||
char *string, *completion;
|
||||
char signal_name[128];
|
||||
@@ -177,7 +155,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
"Without argument, this command "
|
||||
"lists all loaded scripts."),
|
||||
completion,
|
||||
callback_command, NULL);
|
||||
init->callback_command, NULL);
|
||||
if (string)
|
||||
free (string);
|
||||
if (completion)
|
||||
@@ -190,27 +168,30 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
{
|
||||
snprintf (string, length, "%s_script", weechat_plugin->name);
|
||||
weechat_hook_completion (string, N_("list of scripts"),
|
||||
callback_completion, NULL);
|
||||
init->callback_completion, NULL);
|
||||
weechat_hook_infolist (string, N_("list of scripts"),
|
||||
N_("script pointer (optional)"),
|
||||
N_("script name (can start or end with \"*\" as wildcard) (optional)"),
|
||||
callback_infolist, NULL);
|
||||
init->callback_infolist, NULL);
|
||||
free (string);
|
||||
}
|
||||
|
||||
/* add signal for "debug_dump" */
|
||||
weechat_hook_signal ("debug_dump", callback_signal_debug_dump, NULL);
|
||||
weechat_hook_signal ("debug_dump", init->callback_signal_debug_dump, NULL);
|
||||
|
||||
/* add signal for "buffer_closed" */
|
||||
weechat_hook_signal ("buffer_closed", callback_signal_buffer_closed, NULL);
|
||||
weechat_hook_signal ("buffer_closed",
|
||||
init->callback_signal_buffer_closed, NULL);
|
||||
|
||||
/* add signal for a script action (install/remove) */
|
||||
snprintf (signal_name, sizeof (signal_name), "%s_script_install",
|
||||
weechat_plugin->name);
|
||||
weechat_hook_signal (signal_name, callback_signal_script_action, NULL);
|
||||
weechat_hook_signal (signal_name,
|
||||
init->callback_signal_script_action, NULL);
|
||||
snprintf (signal_name, sizeof (signal_name), "%s_script_remove",
|
||||
weechat_plugin->name);
|
||||
weechat_hook_signal (signal_name, callback_signal_script_action, NULL);
|
||||
weechat_hook_signal (signal_name,
|
||||
init->callback_signal_script_action, NULL);
|
||||
|
||||
/* parse arguments */
|
||||
auto_load_scripts = 1;
|
||||
@@ -226,7 +207,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
/* autoload scripts */
|
||||
if (auto_load_scripts)
|
||||
{
|
||||
script_auto_load (weechat_plugin, callback_load_file);
|
||||
script_auto_load (weechat_plugin, init->callback_load_file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,34 +68,32 @@ struct t_plugin_script
|
||||
struct t_plugin_script *next_script; /* link to next script */
|
||||
};
|
||||
|
||||
struct t_plugin_script_init
|
||||
{
|
||||
int (*callback_command)(void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol);
|
||||
int (*callback_completion)(void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion);
|
||||
struct t_infolist *(*callback_infolist)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
const char *arguments);
|
||||
int (*callback_signal_debug_dump)(void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data);
|
||||
int (*callback_signal_buffer_closed)(void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data);
|
||||
int (*callback_signal_script_action)(void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data);
|
||||
void (*callback_load_file)(void *data, const char *filename);
|
||||
};
|
||||
|
||||
extern void script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
int argc,
|
||||
char *argv[],
|
||||
int (*callback_command)(void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
int argc, char **argv,
|
||||
char **argv_eol),
|
||||
int (*callback_completion)(void *data,
|
||||
const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion),
|
||||
struct t_infolist *(*callback_infolist)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
const char *arguments),
|
||||
int (*callback_signal_debug_dump)(void *data,
|
||||
const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data),
|
||||
int (*callback_signal_buffer_closed)(void *data,
|
||||
const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data),
|
||||
int (*callback_signal_script_action)(void *data,
|
||||
const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data),
|
||||
void (*callback_load_file)(void *data, const char *filename));
|
||||
int argc, char *argv[],
|
||||
struct t_plugin_script_init *init);
|
||||
extern int script_valid (struct t_plugin_script *scripts,
|
||||
struct t_plugin_script *script);
|
||||
extern char *script_ptr2str (void *pointer);
|
||||
|
||||
@@ -714,19 +714,20 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
struct t_plugin_script_init init;
|
||||
|
||||
weechat_tcl_plugin = plugin;
|
||||
|
||||
init.callback_command = &weechat_tcl_command_cb;
|
||||
init.callback_completion = &weechat_tcl_completion_cb;
|
||||
init.callback_infolist = &weechat_tcl_infolist_cb;
|
||||
init.callback_signal_debug_dump = &weechat_tcl_signal_debug_dump_cb;
|
||||
init.callback_signal_buffer_closed = &weechat_tcl_signal_buffer_closed_cb;
|
||||
init.callback_signal_script_action = &weechat_tcl_signal_script_action_cb;
|
||||
init.callback_load_file = &weechat_tcl_load_cb;
|
||||
|
||||
tcl_quiet = 1;
|
||||
script_init (weechat_tcl_plugin,
|
||||
argc,
|
||||
argv,
|
||||
&weechat_tcl_command_cb,
|
||||
&weechat_tcl_completion_cb,
|
||||
&weechat_tcl_infolist_cb,
|
||||
&weechat_tcl_signal_debug_dump_cb,
|
||||
&weechat_tcl_signal_buffer_closed_cb,
|
||||
&weechat_tcl_signal_script_action_cb,
|
||||
&weechat_tcl_load_cb);
|
||||
script_init (weechat_tcl_plugin, argc, argv, &init);
|
||||
tcl_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_tcl_plugin,
|
||||
|
||||
Reference in New Issue
Block a user