mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 04:16:38 +02:00
Added some missing functions in Perl plugin API
This commit is contained in:
@@ -19,7 +19,11 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
|
||||
noinst_LTLIBRARIES = lib_weechat_plugins_scripts.la
|
||||
|
||||
lib_weechat_plugins_scripts_la_SOURCES = script.c \
|
||||
script.h
|
||||
script.h \
|
||||
script-callback.c \
|
||||
script-callback.h \
|
||||
script-api.c \
|
||||
script-api.h
|
||||
|
||||
if PLUGIN_PERL
|
||||
perl_dir = perl
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -149,7 +149,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: error: %s"),
|
||||
weechat_prefix ("error"), "perl", SvPV_nolen (ERRSV));
|
||||
weechat_prefix ("error"), "Perl", SvPV_nolen (ERRSV));
|
||||
(void) POPs; /* poping the 'undef' */
|
||||
mem_err = 0;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" must "
|
||||
"return one valid value (%d)"),
|
||||
weechat_prefix ("error"), "perl", function, count);
|
||||
weechat_prefix ("error"), "Perl", function, count);
|
||||
mem_err = 0;
|
||||
}
|
||||
else
|
||||
@@ -183,7 +183,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" is "
|
||||
"internally misused"),
|
||||
weechat_prefix ("error"), "perl", function);
|
||||
weechat_prefix ("error"), "Perl", function);
|
||||
mem_err = 0;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ weechat_perl_exec (struct t_plugin_script *script,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: not enough memory in function "
|
||||
"\"%s\""),
|
||||
weechat_prefix ("error"), "perl", function);
|
||||
weechat_prefix ("error"), "Perl", function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -231,13 +231,13 @@ weechat_perl_load (char *filename)
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: loading Perl script \"%s\""),
|
||||
weechat_prefix ("info"), "perl", filename);
|
||||
weechat_prefix ("info"), "Perl", filename);
|
||||
|
||||
if (stat (filename, &buf) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" not found"),
|
||||
weechat_prefix ("error"), "perl", filename);
|
||||
weechat_prefix ("error"), "Perl", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ weechat_perl_load (char *filename)
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to create new "
|
||||
"sub-interpreter"),
|
||||
weechat_prefix ("error"), "perl");
|
||||
weechat_prefix ("error"), "Perl");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ weechat_perl_load (char *filename)
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: not enough memory to parse "
|
||||
"file \"%s\""),
|
||||
weechat_prefix ("error"), "perl", filename);
|
||||
weechat_prefix ("error"), "Perl", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -297,10 +297,10 @@ weechat_perl_load (char *filename)
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to parse file "
|
||||
"\"%s\""),
|
||||
weechat_prefix ("error"), "perl", filename);
|
||||
weechat_prefix ("error"), "Perl", filename);
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: error: %s"),
|
||||
weechat_prefix ("error"), "perl",
|
||||
weechat_prefix ("error"), "Perl",
|
||||
#ifndef MULTIPLICITY
|
||||
SvPV(perl_get_sv("WeechatPerlScriptLoader::"
|
||||
"weechat_perl_load_eval_file_error",
|
||||
@@ -315,22 +315,24 @@ weechat_perl_load (char *filename)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to run file \"%s\""),
|
||||
weechat_prefix ("error"), "perl", filename);
|
||||
weechat_prefix ("error"), "Perl", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unknown error while "
|
||||
"loading file \"%s\""),
|
||||
weechat_prefix ("error"), "perl", filename);
|
||||
weechat_prefix ("error"), "Perl", filename);
|
||||
}
|
||||
#ifdef MULTIPLICITY
|
||||
perl_destruct (perl_current_interpreter);
|
||||
perl_free (perl_current_interpreter);
|
||||
#endif
|
||||
if (perl_current_script && (perl_current_script != &tempscript))
|
||||
weechat_script_remove (weechat_perl_plugin,
|
||||
&perl_scripts, perl_current_script);
|
||||
{
|
||||
script_remove (weechat_perl_plugin,
|
||||
&perl_scripts, perl_current_script);
|
||||
}
|
||||
|
||||
free (eval);
|
||||
return 0;
|
||||
@@ -343,7 +345,7 @@ weechat_perl_load (char *filename)
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"register\" not "
|
||||
"found (or failed) in file \"%s\""),
|
||||
weechat_prefix ("error"), "perl", filename);
|
||||
weechat_prefix ("error"), "Perl", filename);
|
||||
#ifdef MULTIPLICITY
|
||||
perl_destruct (perl_current_interpreter);
|
||||
perl_free (perl_current_interpreter);
|
||||
@@ -385,7 +387,7 @@ weechat_perl_unload (struct t_plugin_script *script)
|
||||
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unloading script \"%s\""),
|
||||
weechat_prefix ("info"), "perl", script->name);
|
||||
weechat_prefix ("info"), "Perl", script->name);
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
eval_pv (script->interpreter, TRUE);
|
||||
@@ -411,7 +413,7 @@ weechat_perl_unload (struct t_plugin_script *script)
|
||||
perl_free (script->interpreter);
|
||||
#endif
|
||||
|
||||
weechat_script_remove (weechat_perl_plugin, &perl_scripts, script);
|
||||
script_remove (weechat_perl_plugin, &perl_scripts, script);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -423,20 +425,19 @@ weechat_perl_unload_name (char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
ptr_script = weechat_script_search (weechat_perl_plugin,
|
||||
&perl_scripts, name);
|
||||
ptr_script = script_search (weechat_perl_plugin, &perl_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
weechat_perl_unload (ptr_script);
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" unloaded"),
|
||||
weechat_prefix ("info"), "perl", name);
|
||||
weechat_prefix ("info"), "Perl", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" not loaded"),
|
||||
weechat_prefix ("error"), "perl", name);
|
||||
weechat_prefix ("error"), "Perl", name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,14 +619,14 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "autoload") == 0)
|
||||
{
|
||||
weechat_script_auto_load (weechat_perl_plugin,
|
||||
"perl", &weechat_perl_load_cb);
|
||||
script_auto_load (weechat_perl_plugin, "perl",
|
||||
&weechat_perl_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "reload") == 0)
|
||||
{
|
||||
weechat_perl_unload_all ();
|
||||
weechat_script_auto_load (weechat_perl_plugin,
|
||||
"perl", &weechat_perl_load_cb);
|
||||
script_auto_load (weechat_perl_plugin,
|
||||
"perl", &weechat_perl_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "unload") == 0)
|
||||
{
|
||||
@@ -637,8 +638,8 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
if (weechat_strcasecmp (argv[1], "load") == 0)
|
||||
{
|
||||
/* load Perl script */
|
||||
path_script = weechat_script_search_full_name (weechat_perl_plugin,
|
||||
"perl", argv_eol[2]);
|
||||
path_script = script_search_full_name (weechat_perl_plugin,
|
||||
"perl", argv_eol[2]);
|
||||
weechat_perl_load ((path_script) ? path_script : argv_eol[2]);
|
||||
if (path_script)
|
||||
free (path_script);
|
||||
@@ -653,7 +654,7 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unknown option for "
|
||||
"command \"%s\""),
|
||||
weechat_prefix ("error"), "perl", "perl");
|
||||
weechat_prefix ("error"), "Perl", "perl");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +679,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to initialize Perl"),
|
||||
weechat_prefix ("error"), "perl");
|
||||
weechat_prefix ("error"), "Perl");
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
@@ -702,8 +703,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
weechat_mkdir_home ("perl", 0644);
|
||||
weechat_mkdir_home ("perl/autoload", 0644);
|
||||
|
||||
weechat_script_auto_load (weechat_perl_plugin,
|
||||
"perl", &weechat_perl_load_cb);
|
||||
script_auto_load (weechat_perl_plugin, "perl", &weechat_perl_load_cb);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -0,0 +1,574 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 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/>.
|
||||
*/
|
||||
|
||||
/* script-api.c: script API */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "script.h"
|
||||
#include "script-callback.h"
|
||||
|
||||
|
||||
/*
|
||||
* script_api_charset_set: set charset for script
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_charset_set (struct t_plugin_script *script,
|
||||
char *charset)
|
||||
{
|
||||
if (script->charset)
|
||||
free (script->charset);
|
||||
|
||||
script->charset = (charset) ? strdup (charset) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_printf: print a message
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer, char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[8192];
|
||||
char *buf2;
|
||||
|
||||
va_start (argptr, format);
|
||||
vsnprintf (buf, sizeof (buf) - 1, format, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, buf) : NULL;
|
||||
weechat_printf (buffer, "%s", (buf2) ? buf2 : buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_infobar_printf: print a message in infobar
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_infobar_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int delay, char *color_name,
|
||||
char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[1024];
|
||||
char *buf2;
|
||||
|
||||
va_start (argptr, format);
|
||||
vsnprintf (buf, sizeof (buf) - 1, format, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, buf) : NULL;
|
||||
weechat_infobar_printf (delay, color_name, "%s", (buf2) ? buf2 : buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_log_printf: add a message in WeeChat log file
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_log_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[1024];
|
||||
char *buf2;
|
||||
|
||||
va_start (argptr, format);
|
||||
vsnprintf (buf, sizeof (buf) - 1, format, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, buf) : NULL;
|
||||
weechat_log_printf ("%s", (buf2) ? buf2 : buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_command: hook a command
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_hook_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return 0;
|
||||
|
||||
new_script_callback->script = NULL;
|
||||
new_script_callback->function = NULL;
|
||||
new_script_callback->hook = NULL;
|
||||
|
||||
new_hook = weechat_hook_command (command, description, args,
|
||||
args_description, completion,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_timer: hook a timer
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_hook_timer (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int interval, int align_second, int max_calls,
|
||||
int (*callback)(void *data),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return 0;
|
||||
|
||||
new_hook = weechat_hook_timer (interval, align_second, max_calls,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_fd: hook a fd
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_hook_fd (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int fd, int flag_read, int flag_write,
|
||||
int flag_exception,
|
||||
int (*callback)(void *data),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return 0;
|
||||
|
||||
new_hook = weechat_hook_fd (fd, flag_read, flag_write, flag_exception,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_print: hook a print
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return 0;
|
||||
|
||||
new_hook = weechat_hook_print (buffer, message, strip_colors,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_signal: hook a signal
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_hook_signal (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *signal,
|
||||
int (*callback)(void *data, char *signal,
|
||||
char *type_data,
|
||||
void *signal_data),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return 0;
|
||||
|
||||
new_hook = weechat_hook_signal (signal, callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_config: hook a config option
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *type, char *option,
|
||||
int (*callback)(void *data, char *type,
|
||||
char *option, char *value),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return 0;
|
||||
|
||||
new_hook = weechat_hook_config (type, option, callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_completion: hook a completion
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *completion,
|
||||
int (*callback)(void *data, char *completion,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_weelist *list),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return 0;
|
||||
|
||||
new_hook = weechat_hook_completion (completion, callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_unhook: unhook something
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_unhook (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_hook *hook)
|
||||
{
|
||||
struct t_script_callback *ptr_script_callback;
|
||||
|
||||
if (!weechat_plugin || !script || !hook)
|
||||
return;
|
||||
|
||||
for (ptr_script_callback = script->callbacks; ptr_script_callback;
|
||||
ptr_script_callback = ptr_script_callback->next_callback)
|
||||
{
|
||||
if (ptr_script_callback->hook == hook)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ptr_script_callback)
|
||||
{
|
||||
script_callback_remove (weechat_plugin, script, ptr_script_callback);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_unhook_all: remove all hooks from a script
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_unhook_all (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
struct t_script_callback *ptr_callback, *next_callback;
|
||||
|
||||
ptr_callback = script->callbacks;
|
||||
while (ptr_callback)
|
||||
{
|
||||
next_callback = ptr_callback->next_callback;
|
||||
|
||||
script_callback_remove (weechat_plugin, script, ptr_callback);
|
||||
|
||||
ptr_callback = next_callback;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_buffer_new: create a new buffer
|
||||
*/
|
||||
|
||||
struct t_gui_buffer *
|
||||
script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *category, char *name,
|
||||
int (*callback)(void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
char *input_data),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_gui_buffer *new_buffer;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_buffer = weechat_buffer_new (category, name,
|
||||
callback, new_script_callback);
|
||||
if (!new_buffer)
|
||||
{
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->buffer = new_buffer;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return new_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_buffer_close: close a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
int switch_to_another)
|
||||
{
|
||||
struct t_script_callback *ptr_script_callback;
|
||||
|
||||
if (!weechat_plugin || !script || !buffer)
|
||||
return;
|
||||
|
||||
weechat_buffer_close (buffer, switch_to_another);
|
||||
|
||||
for (ptr_script_callback = script->callbacks; ptr_script_callback;
|
||||
ptr_script_callback = ptr_script_callback->next_callback)
|
||||
{
|
||||
if (ptr_script_callback->buffer == buffer)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ptr_script_callback)
|
||||
{
|
||||
script_callback_remove (weechat_plugin, script, ptr_script_callback);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_command: execute a command (simulate user entry)
|
||||
*/
|
||||
|
||||
void
|
||||
script_api_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer, char *command)
|
||||
{
|
||||
char *command2;
|
||||
|
||||
command2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, command) : NULL;
|
||||
weechat_command (buffer, (command2) ? command2 : command);
|
||||
if (command2)
|
||||
free (command2);
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_config_get_plugin: get a value of a script option
|
||||
* format in file is: plugin.script.option=value
|
||||
*/
|
||||
|
||||
char *
|
||||
script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option)
|
||||
{
|
||||
char *option_fullname, *return_value;
|
||||
|
||||
option_fullname = (char *)malloc (strlen (script->name) +
|
||||
strlen (option) + 2);
|
||||
if (!option_fullname)
|
||||
return NULL;
|
||||
|
||||
strcpy (option_fullname, script->name);
|
||||
strcat (option_fullname, ".");
|
||||
strcat (option_fullname, option);
|
||||
|
||||
return_value = weechat_config_get_plugin (option_fullname);
|
||||
free (option_fullname);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_config_set_plugin: set value of a script config option
|
||||
* format in file is: plugin.script.option=value
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option, char *value)
|
||||
{
|
||||
char *option_fullname;
|
||||
int return_code;
|
||||
|
||||
option_fullname = (char *)malloc (strlen (script->name) +
|
||||
strlen (option) + 2);
|
||||
if (!option_fullname)
|
||||
return 0;
|
||||
|
||||
strcpy (option_fullname, script->name);
|
||||
strcat (option_fullname, ".");
|
||||
strcat (option_fullname, option);
|
||||
|
||||
return_code = weechat_config_set_plugin (option_fullname, value);
|
||||
free (option_fullname);
|
||||
|
||||
return return_code;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 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_SCRIPT_API_H
|
||||
#define __WEECHAT_SCRIPT_API_H 1
|
||||
|
||||
extern void script_api_charset_set (struct t_plugin_script *script,
|
||||
char *charset);
|
||||
extern void script_api_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
char *format, ...);
|
||||
extern void script_api_infobar_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int delay, char *color_name,
|
||||
char *format, ...);
|
||||
extern void script_api_log_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *format, ...);
|
||||
extern int script_api_hook_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function);
|
||||
extern int script_api_hook_timer (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int interval, int align_second,
|
||||
int max_calls,
|
||||
int (*callback)(void *data),
|
||||
char *function);
|
||||
extern int script_api_hook_fd (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int fd, int flag_read, int flag_write,
|
||||
int flag_exception,
|
||||
int (*callback)(void *data),
|
||||
char *function);
|
||||
extern int script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function);
|
||||
extern int script_api_hook_signal (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *signal,
|
||||
int (*callback)(void *data,
|
||||
char *signal,
|
||||
char *type_data,
|
||||
void *signal_data),
|
||||
char *function);
|
||||
extern int script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *type, char *option,
|
||||
int (*callback)(void *data, char *type,
|
||||
char *option,
|
||||
char *value),
|
||||
char *function);
|
||||
extern int script_api_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *completion,
|
||||
int (*callback)(void *data,
|
||||
char *completion,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_weelist *list),
|
||||
char *function);
|
||||
extern void script_api_unhook (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_hook *hook);
|
||||
extern void script_api_unhook_all (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script);
|
||||
struct t_gui_buffer *script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *category, char *name,
|
||||
int (*callback)(void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
char *input_data),
|
||||
char *function);
|
||||
extern void script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
int switch_to_another);
|
||||
extern void script_api_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
char *command);
|
||||
extern char *script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option);
|
||||
extern int script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option, char *value);
|
||||
|
||||
#endif /* script-api.h */
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 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/>.
|
||||
*/
|
||||
|
||||
/* script-callback.c: script callbacks */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "script.h"
|
||||
#include "script-callback.h"
|
||||
|
||||
|
||||
/*
|
||||
* script_callback_alloc: allocate a new callback and initializes it
|
||||
*/
|
||||
|
||||
struct t_script_callback *
|
||||
script_callback_alloc ()
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
|
||||
new_script_callback = (struct t_script_callback *)malloc (sizeof (struct t_script_callback));
|
||||
if (new_script_callback)
|
||||
{
|
||||
new_script_callback->script = NULL;
|
||||
new_script_callback->function = NULL;
|
||||
new_script_callback->hook = NULL;
|
||||
new_script_callback->buffer = NULL;
|
||||
return new_script_callback;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_callback_add: add a callback to list
|
||||
*/
|
||||
|
||||
void
|
||||
script_callback_add (struct t_plugin_script *script,
|
||||
struct t_script_callback *callback)
|
||||
{
|
||||
if (script->callbacks)
|
||||
script->callbacks->prev_callback = callback;
|
||||
callback->prev_callback = NULL;
|
||||
callback->next_callback = script->callbacks;
|
||||
script->callbacks = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_callback_remove: remove a callback from a script
|
||||
*/
|
||||
|
||||
void
|
||||
script_callback_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_script_callback *script_callback)
|
||||
{
|
||||
/* remove callback from list */
|
||||
if (script_callback->prev_callback)
|
||||
script_callback->prev_callback->next_callback =
|
||||
script_callback->next_callback;
|
||||
if (script_callback->next_callback)
|
||||
script_callback->next_callback->prev_callback =
|
||||
script_callback->prev_callback;
|
||||
if (script->callbacks == script_callback)
|
||||
script->callbacks = script_callback->next_callback;
|
||||
|
||||
/* unhook and free data */
|
||||
if (script_callback->function)
|
||||
free (script_callback->function);
|
||||
if (script_callback->hook)
|
||||
weechat_unhook (script_callback->hook);
|
||||
|
||||
free (script_callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* script_callback_remove_all: remove all callbacks from a script
|
||||
*/
|
||||
|
||||
void
|
||||
script_callback_remove_all (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
while (script->callbacks)
|
||||
{
|
||||
script_callback_remove (weechat_plugin, script, script->callbacks);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 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_SCRIPT_CALLBACK_H
|
||||
#define __WEECHAT_SCRIPT_CALLBACK_H 1
|
||||
|
||||
struct t_script_callback
|
||||
{
|
||||
void *script; /* pointer to script */
|
||||
char *function; /* script function called */
|
||||
struct t_hook *hook; /* not NULL if hook */
|
||||
struct t_gui_buffer *buffer; /* not NULL if buffer callback */
|
||||
struct t_script_callback *prev_callback; /* link to next callback */
|
||||
struct t_script_callback *next_callback; /* link to previous callback */
|
||||
};
|
||||
|
||||
extern struct t_script_callback *script_callback_alloc ();
|
||||
extern void script_callback_add (struct t_plugin_script *script,
|
||||
struct t_script_callback *callback);
|
||||
extern void script_callback_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_script_callback *script_callback);
|
||||
extern void script_callback_remove_all (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script);
|
||||
|
||||
#endif /* script-callback.h */
|
||||
+33
-574
@@ -20,8 +20,6 @@
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
@@ -30,16 +28,17 @@
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "script.h"
|
||||
#include "script-callback.h"
|
||||
|
||||
|
||||
/*
|
||||
* weechat_script_pointer_to_string: convert pointer to string for usage
|
||||
* in a script (any language)
|
||||
* WARNING: result has to be free() after use
|
||||
* script_pointer_to_string: convert pointer to string for usage
|
||||
* in a script (any language)
|
||||
* WARNING: result has to be free() after use
|
||||
*/
|
||||
|
||||
char *
|
||||
weechat_script_pointer_to_string (void *pointer)
|
||||
script_pointer_to_string (void *pointer)
|
||||
{
|
||||
char pointer_str[128];
|
||||
|
||||
@@ -53,16 +52,16 @@ weechat_script_pointer_to_string (void *pointer)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_string_to_pointer: convert stirng to pointer for usage
|
||||
* outside script
|
||||
* script_string_to_pointer: convert stirng to pointer for usage
|
||||
* outside script
|
||||
*/
|
||||
|
||||
void *
|
||||
weechat_script_string_to_pointer (char *pointer_str)
|
||||
script_string_to_pointer (char *pointer_str)
|
||||
{
|
||||
unsigned int value;
|
||||
|
||||
if (!pointer_str || (pointer_str[0] != '0') || (pointer_str[0] != 'x'))
|
||||
if (!pointer_str || (pointer_str[0] != '0') || (pointer_str[1] != 'x'))
|
||||
return NULL;
|
||||
|
||||
sscanf (pointer_str + 2, "%x", &value);
|
||||
@@ -71,13 +70,13 @@ weechat_script_string_to_pointer (char *pointer_str)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_auto_load: auto-load all scripts in a directory
|
||||
* script_auto_load: auto-load all scripts in a directory
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language,
|
||||
int (*callback)(void *data, char *filename))
|
||||
script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language,
|
||||
int (*callback)(void *data, char *filename))
|
||||
{
|
||||
char *dir_home, *dir_name;
|
||||
int dir_length;
|
||||
@@ -98,12 +97,12 @@ weechat_script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_search: search a script in list
|
||||
* script_search: search a script in list
|
||||
*/
|
||||
|
||||
struct t_plugin_script *
|
||||
weechat_script_search (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **list, char *name)
|
||||
script_search (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **list, char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
@@ -119,12 +118,12 @@ weechat_script_search (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_search_full_name: search the full path name of a script
|
||||
* script_search_full_name: search the full path name of a script
|
||||
*/
|
||||
|
||||
char *
|
||||
weechat_script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language, char *filename)
|
||||
script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language, char *filename)
|
||||
{
|
||||
char *final_name, *dir_home, *dir_system;
|
||||
int length;
|
||||
@@ -205,16 +204,16 @@ weechat_script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_add: add a script to list of scripts
|
||||
* script_add: add a script to list of scripts
|
||||
*/
|
||||
|
||||
struct t_plugin_script *
|
||||
weechat_script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **script_list,
|
||||
char *filename,
|
||||
char *name, char *version,
|
||||
char *shutdown_func, char *description,
|
||||
char *charset)
|
||||
script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **script_list,
|
||||
char *filename,
|
||||
char *name, char *version,
|
||||
char *shutdown_func, char *description,
|
||||
char *charset)
|
||||
{
|
||||
struct t_plugin_script *new_script;
|
||||
|
||||
@@ -238,7 +237,7 @@ weechat_script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
new_script->description = strdup (description);
|
||||
new_script->charset = (charset) ? strdup (charset) : NULL;
|
||||
|
||||
new_script->hooks = NULL;
|
||||
new_script->callbacks = NULL;
|
||||
|
||||
/* add new script to list */
|
||||
if ((*script_list))
|
||||
@@ -258,45 +257,16 @@ weechat_script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_remove_script_hook: remove a script_hook from script
|
||||
* script_remove: remove a script from list of scripts
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_remove_script_hook (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_script_hook *script_hook)
|
||||
script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **script_list,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
/* remove script_hook from list */
|
||||
if (script_hook->prev_hook)
|
||||
script_hook->prev_hook->next_hook = script_hook->next_hook;
|
||||
if (script_hook->next_hook)
|
||||
script_hook->next_hook->prev_hook = script_hook->prev_hook;
|
||||
if (script->hooks == script_hook)
|
||||
script->hooks = script_hook->next_hook;
|
||||
|
||||
/* unhook and free data */
|
||||
if (script_hook->hook)
|
||||
weechat_unhook (script_hook->hook);
|
||||
if (script_hook->function)
|
||||
free (script_hook->function);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_remove: remove a script from list of scripts
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **script_list,
|
||||
struct t_plugin_script *script)
|
||||
{
|
||||
/* remove all hooks created by this script */
|
||||
while (script->hooks)
|
||||
{
|
||||
weechat_script_remove_script_hook (weechat_plugin,
|
||||
script,
|
||||
script->hooks);
|
||||
}
|
||||
/* remove all callbacks created by this script */
|
||||
script_callback_remove_all (weechat_plugin, script);
|
||||
|
||||
/* free data */
|
||||
if (script->filename)
|
||||
@@ -323,514 +293,3 @@ weechat_script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
/* free script */
|
||||
free (script);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_charset_set: set charset for script
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_charset_set (struct t_plugin_script *script,
|
||||
char *charset)
|
||||
{
|
||||
if (script->charset)
|
||||
free (script->charset);
|
||||
|
||||
script->charset = (charset) ? strdup (charset) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_printf: print a message
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer, char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[8192];
|
||||
char *buf2;
|
||||
|
||||
va_start (argptr, format);
|
||||
vsnprintf (buf, sizeof (buf) - 1, format, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, buf) : NULL;
|
||||
weechat_printf (buffer, "%s", (buf2) ? buf2 : buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_infobar_printf: print a message in infobar
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_infobar_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int delay, char *color_name, char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[1024];
|
||||
char *buf2;
|
||||
|
||||
va_start (argptr, format);
|
||||
vsnprintf (buf, sizeof (buf) - 1, format, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, buf) : NULL;
|
||||
weechat_infobar_printf (delay, color_name, "%s", (buf2) ? buf2 : buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_log_printf: add a message in WeeChat log file
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_log_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[1024];
|
||||
char *buf2;
|
||||
|
||||
va_start (argptr, format);
|
||||
vsnprintf (buf, sizeof (buf) - 1, format, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, buf) : NULL;
|
||||
weechat_log_printf ("%s", (buf2) ? buf2 : buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_hook_command: hook a command
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_hook_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_hook *new_script_hook;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_hook = (struct t_script_hook *)malloc (sizeof (struct t_script_hook));
|
||||
if (!new_script_hook)
|
||||
return 0;
|
||||
|
||||
new_script_hook->hook = NULL;
|
||||
new_script_hook->function = NULL;
|
||||
new_script_hook->script = NULL;
|
||||
|
||||
new_hook = weechat_hook_command (command, description, args,
|
||||
args_description, completion,
|
||||
callback, new_script_hook);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_hook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_hook->hook = new_hook;
|
||||
new_script_hook->function = strdup (function);
|
||||
new_script_hook->script = script;
|
||||
|
||||
/* add script_hook to list of hooks for current script */
|
||||
if (script->hooks)
|
||||
script->hooks->prev_hook = new_script_hook;
|
||||
new_script_hook->prev_hook = NULL;
|
||||
new_script_hook->next_hook = script->hooks;
|
||||
script->hooks = new_script_hook;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_hook_timer: hook a timer
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_hook_timer (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int interval, int align_second, int max_calls,
|
||||
int (*callback)(void *data),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_hook *new_script_hook;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_hook = (struct t_script_hook *)malloc (sizeof (struct t_script_hook));
|
||||
if (!new_script_hook)
|
||||
return 0;
|
||||
|
||||
new_script_hook->hook = NULL;
|
||||
new_script_hook->function = NULL;
|
||||
new_script_hook->script = NULL;
|
||||
|
||||
new_hook = weechat_hook_timer (interval, align_second, max_calls,
|
||||
callback, new_script_hook);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_hook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_hook->hook = new_hook;
|
||||
new_script_hook->function = strdup (function);
|
||||
new_script_hook->script = script;
|
||||
|
||||
/* add script_hook to list of hooks for current script */
|
||||
if (script->hooks)
|
||||
script->hooks->prev_hook = new_script_hook;
|
||||
new_script_hook->prev_hook = NULL;
|
||||
new_script_hook->next_hook = script->hooks;
|
||||
script->hooks = new_script_hook;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_hook_fd: hook a fd
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_hook_fd (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int fd, int flag_read, int flag_write,
|
||||
int flag_exception,
|
||||
int (*callback)(void *data),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_hook *new_script_hook;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_hook = (struct t_script_hook *)malloc (sizeof (struct t_script_hook));
|
||||
if (!new_script_hook)
|
||||
return 0;
|
||||
|
||||
new_script_hook->hook = NULL;
|
||||
new_script_hook->function = NULL;
|
||||
new_script_hook->script = NULL;
|
||||
|
||||
new_hook = weechat_hook_fd (fd, flag_read, flag_write, flag_exception,
|
||||
callback, new_script_hook);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_hook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_hook->hook = new_hook;
|
||||
new_script_hook->function = strdup (function);
|
||||
new_script_hook->script = script;
|
||||
|
||||
/* add script_hook to list of hooks for current script */
|
||||
if (script->hooks)
|
||||
script->hooks->prev_hook = new_script_hook;
|
||||
new_script_hook->prev_hook = NULL;
|
||||
new_script_hook->next_hook = script->hooks;
|
||||
script->hooks = new_script_hook;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_hook_print: hook a print
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_hook *new_script_hook;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_hook = (struct t_script_hook *)malloc (sizeof (struct t_script_hook));
|
||||
if (!new_script_hook)
|
||||
return 0;
|
||||
|
||||
new_script_hook->hook = NULL;
|
||||
new_script_hook->function = NULL;
|
||||
new_script_hook->script = NULL;
|
||||
|
||||
new_hook = weechat_hook_print (buffer, message, strip_colors,
|
||||
callback, new_script_hook);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_hook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_hook->hook = new_hook;
|
||||
new_script_hook->function = strdup (function);
|
||||
new_script_hook->script = script;
|
||||
|
||||
/* add script_hook to list of hooks for current script */
|
||||
if (script->hooks)
|
||||
script->hooks->prev_hook = new_script_hook;
|
||||
new_script_hook->prev_hook = NULL;
|
||||
new_script_hook->next_hook = script->hooks;
|
||||
script->hooks = new_script_hook;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_hook_signal: hook a signal
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_hook_signal (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *signal,
|
||||
int (*callback)(void *data, char *signal,
|
||||
char *type_data,
|
||||
void *signal_data),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_hook *new_script_hook;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_hook = (struct t_script_hook *)malloc (sizeof (struct t_script_hook));
|
||||
if (!new_script_hook)
|
||||
return 0;
|
||||
|
||||
new_script_hook->hook = NULL;
|
||||
new_script_hook->function = NULL;
|
||||
new_script_hook->script = NULL;
|
||||
|
||||
new_hook = weechat_hook_signal (signal, callback, new_script_hook);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_hook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_hook->hook = new_hook;
|
||||
new_script_hook->function = strdup (function);
|
||||
new_script_hook->script = script;
|
||||
|
||||
/* add script_hook to list of hooks for current script */
|
||||
if (script->hooks)
|
||||
script->hooks->prev_hook = new_script_hook;
|
||||
new_script_hook->prev_hook = NULL;
|
||||
new_script_hook->next_hook = script->hooks;
|
||||
script->hooks = new_script_hook;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_hook_config: hook a config option
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_hook_config (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *type, char *option,
|
||||
int (*callback)(void *data, char *type,
|
||||
char *option, char *value),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_hook *new_script_hook;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_hook = (struct t_script_hook *)malloc (sizeof (struct t_script_hook));
|
||||
if (!new_script_hook)
|
||||
return 0;
|
||||
|
||||
new_script_hook->hook = NULL;
|
||||
new_script_hook->function = NULL;
|
||||
new_script_hook->script = NULL;
|
||||
|
||||
new_hook = weechat_hook_config (type, option, callback, new_script_hook);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_hook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_hook->hook = new_hook;
|
||||
new_script_hook->function = strdup (function);
|
||||
new_script_hook->script = script;
|
||||
|
||||
/* add script_hook to list of hooks for current script */
|
||||
if (script->hooks)
|
||||
script->hooks->prev_hook = new_script_hook;
|
||||
new_script_hook->prev_hook = NULL;
|
||||
new_script_hook->next_hook = script->hooks;
|
||||
script->hooks = new_script_hook;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_hook_completion: hook a completion
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *completion,
|
||||
int (*callback)(void *data, char *completion,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_weelist *list),
|
||||
char *function)
|
||||
{
|
||||
struct t_script_hook *new_script_hook;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_hook = (struct t_script_hook *)malloc (sizeof (struct t_script_hook));
|
||||
if (!new_script_hook)
|
||||
return 0;
|
||||
|
||||
new_script_hook->hook = NULL;
|
||||
new_script_hook->function = NULL;
|
||||
new_script_hook->script = NULL;
|
||||
|
||||
new_hook = weechat_hook_completion (completion, callback, new_script_hook);
|
||||
if (!new_hook)
|
||||
{
|
||||
free (new_script_hook);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_script_hook->hook = new_hook;
|
||||
new_script_hook->function = strdup (function);
|
||||
new_script_hook->script = script;
|
||||
|
||||
/* add script_hook to list of hooks for current script */
|
||||
if (script->hooks)
|
||||
script->hooks->prev_hook = new_script_hook;
|
||||
new_script_hook->prev_hook = NULL;
|
||||
new_script_hook->next_hook = script->hooks;
|
||||
script->hooks = new_script_hook;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_unhook: unhook something
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_unhook (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_hook *hook)
|
||||
{
|
||||
struct t_script_hook *ptr_script_hook;
|
||||
|
||||
for (ptr_script_hook = script->hooks; ptr_script_hook;
|
||||
ptr_script_hook = ptr_script_hook->next_hook)
|
||||
{
|
||||
if (ptr_script_hook->hook == hook)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ptr_script_hook)
|
||||
weechat_script_remove_script_hook (weechat_plugin,
|
||||
script,
|
||||
ptr_script_hook);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_command: execute a command (simulate user entry)
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer, char *command)
|
||||
{
|
||||
char *command2;
|
||||
|
||||
command2 = (script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, command) : NULL;
|
||||
weechat_command (buffer, (command2) ? command2 : command);
|
||||
if (command2)
|
||||
free (command2);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_config_get_plugin: get a value of a script option
|
||||
* format in file is: plugin.script.option=value
|
||||
*/
|
||||
|
||||
char *
|
||||
weechat_script_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option)
|
||||
{
|
||||
char *option_fullname, *return_value;
|
||||
|
||||
option_fullname = (char *)malloc (strlen (script->name) +
|
||||
strlen (option) + 2);
|
||||
if (!option_fullname)
|
||||
return NULL;
|
||||
|
||||
strcpy (option_fullname, script->name);
|
||||
strcat (option_fullname, ".");
|
||||
strcat (option_fullname, option);
|
||||
|
||||
return_value = weechat_config_get_plugin (option_fullname);
|
||||
free (option_fullname);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_config_set_plugin: set value of a script config option
|
||||
* format in file is: plugin.script.option=value
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_script_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option, char *value)
|
||||
{
|
||||
char *option_fullname;
|
||||
int return_code;
|
||||
|
||||
option_fullname = (char *)malloc (strlen (script->name) +
|
||||
strlen (option) + 2);
|
||||
if (!option_fullname)
|
||||
return 0;
|
||||
|
||||
strcpy (option_fullname, script->name);
|
||||
strcat (option_fullname, ".");
|
||||
strcat (option_fullname, option);
|
||||
|
||||
return_code = weechat_config_set_plugin (option_fullname, value);
|
||||
free (option_fullname);
|
||||
|
||||
return return_code;
|
||||
}
|
||||
|
||||
+21
-114
@@ -16,9 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* This header is designed to be distributed with WeeChat plugins, if scripts
|
||||
management is needed */
|
||||
|
||||
#ifndef __WEECHAT_SCRIPT_H
|
||||
#define __WEECHAT_SCRIPT_H 1
|
||||
|
||||
@@ -38,15 +35,6 @@
|
||||
"function \"%s\""), \
|
||||
weechat_prefix ("error"), __language, __function)
|
||||
|
||||
struct t_script_hook
|
||||
{
|
||||
struct t_hook *hook; /* pointer to hook */
|
||||
char *function; /* script function called */
|
||||
void *script; /* pointer to script */
|
||||
struct t_script_hook *prev_hook; /* link to next script hook */
|
||||
struct t_script_hook *next_hook; /* link to previous hook */
|
||||
};
|
||||
|
||||
struct t_plugin_script
|
||||
{
|
||||
/* script variables */
|
||||
@@ -58,112 +46,31 @@ struct t_plugin_script
|
||||
char *shutdown_func; /* function when script is unloaded*/
|
||||
char *charset; /* script charset */
|
||||
|
||||
struct t_script_hook *hooks; /* hooks for script */
|
||||
struct t_script_callback *callbacks; /* callbacks for script */
|
||||
|
||||
struct t_plugin_script *prev_script; /* link to previous script */
|
||||
struct t_plugin_script *next_script; /* link to next script */
|
||||
};
|
||||
|
||||
extern char *weechat_script_pointer_to_string (void *pointer);
|
||||
extern void *weechat_script_string_to_pointer (char *pointer_str);
|
||||
extern void weechat_script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language,
|
||||
int (*callback)(void *data, char *filename));
|
||||
extern struct t_plugin_script *weechat_script_search (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **list,
|
||||
char *name);
|
||||
extern char *weechat_script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language, char *filename);
|
||||
extern struct t_plugin_script *weechat_script_add (struct t_weechat_plugin *weechat_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 *weechat_plugin,
|
||||
struct t_plugin_script **script_list,
|
||||
struct t_plugin_script *script);
|
||||
extern void weechat_script_charset_set (struct t_plugin_script *script,
|
||||
char *charset);
|
||||
extern void weechat_script_printf (struct t_weechat_plugin *plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
char *format, ...);
|
||||
extern void weechat_script_infobar_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int delay, char *color_name,
|
||||
char *format, ...);
|
||||
extern void weechat_script_log_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *format, ...);
|
||||
extern int weechat_script_hook_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function);
|
||||
extern int weechat_script_hook_timer (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int interval, int align_second,
|
||||
int max_calls,
|
||||
int (*callback)(void *data),
|
||||
char *function);
|
||||
extern int weechat_script_hook_fd (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
int fd, int flag_read, int flag_write,
|
||||
int flag_exception,
|
||||
int (*callback)(void *data),
|
||||
char *function);
|
||||
extern int weechat_script_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
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),
|
||||
char *function);
|
||||
extern int weechat_script_hook_signal (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *signal,
|
||||
int (*callback)(void *data,
|
||||
char *signal,
|
||||
char *type_data,
|
||||
void *signal_data),
|
||||
char *function);
|
||||
extern int weechat_script_hook_config (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *type, char *option,
|
||||
int (*callback)(void *data, char *type,
|
||||
char *option,
|
||||
char *value),
|
||||
char *function);
|
||||
extern int weechat_script_hook_completion (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *completion,
|
||||
int (*callback)(void *data,
|
||||
char *completion,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_weelist *list),
|
||||
char *function);
|
||||
extern void weechat_script_unhook (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_hook *hook);
|
||||
extern void weechat_script_command (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
char *command);
|
||||
extern char *weechat_script_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option);
|
||||
extern int weechat_script_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
char *option, char *value);
|
||||
extern char *script_pointer_to_string (void *pointer);
|
||||
extern void *script_string_to_pointer (char *pointer_str);
|
||||
extern void script_auto_load (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language,
|
||||
int (*callback)(void *data, char *filename));
|
||||
extern struct t_plugin_script *script_search (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **list,
|
||||
char *name);
|
||||
extern char *script_search_full_name (struct t_weechat_plugin *weechat_plugin,
|
||||
char *language, char *filename);
|
||||
extern struct t_plugin_script *script_add (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **script_list,
|
||||
char *filename, char *name,
|
||||
char *version,
|
||||
char *shutdown_func,
|
||||
char *description,
|
||||
char *charset);
|
||||
extern void script_remove (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script **script_list,
|
||||
struct t_plugin_script *script);
|
||||
|
||||
#endif /* script.h */
|
||||
|
||||
Reference in New Issue
Block a user