mirror of
https://github.com/weechat/weechat.git
synced 2026-06-24 03:46:39 +02:00
api: add function hook_line
This commit is contained in:
@@ -2361,6 +2361,62 @@ API_FUNC(hook_connect)
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_js_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
struct t_hashtable *ret_hashtable;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = line;
|
||||
|
||||
ret_hashtable = (struct t_hashtable *)weechat_js_exec (
|
||||
script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sh", func_argv);
|
||||
|
||||
return ret_hashtable;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
API_FUNC(hook_line)
|
||||
{
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", "sssss", API_RETURN_EMPTY);
|
||||
|
||||
v8::String::Utf8Value buffer_type(args[0]);
|
||||
v8::String::Utf8Value buffer_name(args[1]);
|
||||
v8::String::Utf8Value tags(args[2]);
|
||||
v8::String::Utf8Value function(args[3]);
|
||||
v8::String::Utf8Value data(args[4]);
|
||||
|
||||
result = API_PTR2STR(
|
||||
plugin_script_api_hook_line (
|
||||
weechat_js_plugin,
|
||||
js_current_script,
|
||||
*buffer_type,
|
||||
*buffer_name,
|
||||
*tags,
|
||||
&weechat_js_api_hook_line_cb,
|
||||
*function,
|
||||
*data));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_js_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@@ -4831,6 +4887,7 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(hook_process);
|
||||
API_DEF_FUNC(hook_process_hashtable);
|
||||
API_DEF_FUNC(hook_connect);
|
||||
API_DEF_FUNC(hook_line);
|
||||
API_DEF_FUNC(hook_print);
|
||||
API_DEF_FUNC(hook_signal);
|
||||
API_DEF_FUNC(hook_signal_send);
|
||||
|
||||
Reference in New Issue
Block a user