summaryrefslogtreecommitdiff
path: root/src/plugins/javascript
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2016-04-23 13:59:20 +0200
committerSébastien Helleu <flashcode@flashtux.org>2016-04-23 13:59:20 +0200
commit51c3e0b9ec7ff5720d860168b7a5d60fb69226b8 (patch)
tree09bda734cf84ba120f9d19e18086c7f9936fa250 /src/plugins/javascript
parentae89d28462f5761bba7ccf647eaa7ed4a51f5fb4 (diff)
downloadweechat-51c3e0b9ec7ff5720d860168b7a5d60fb69226b8.zip
api: add support of functions in hook_process
Diffstat (limited to 'src/plugins/javascript')
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index e2cad59f4..4a09b130b 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -2085,14 +2085,33 @@ weechat_js_api_hook_process_cb (const void *pointer, void *data,
{
struct t_plugin_script *script;
void *func_argv[5];
- char empty_arg[1] = { '\0' };
+ char empty_arg[1] = { '\0' }, *result;
const char *ptr_function, *ptr_data;
int *rc, ret;
script = (struct t_plugin_script *)pointer;
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
- if (ptr_function && ptr_function[0])
+ if (return_code == WEECHAT_HOOK_PROCESS_CHILD)
+ {
+ if (strncmp (command, "func:", 5) == 0)
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+
+ result = (char *) weechat_js_exec (script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ command + 5,
+ "s", func_argv);
+ if (result)
+ {
+ printf ("%s", result);
+ free (result);
+ return 0;
+ }
+ }
+ return 1;
+ }
+ else if (ptr_function && ptr_function[0])
{
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = (command) ? (char *)command : empty_arg;