mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 03:03:12 +02:00
api: add support of functions in hook_process
This commit is contained in:
@@ -2171,14 +2171,33 @@ weechat_guile_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_guile_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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2268,14 +2268,33 @@ weechat_lua_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_lua_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;
|
||||
|
||||
@@ -2198,14 +2198,33 @@ weechat_perl_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_perl_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;
|
||||
|
||||
@@ -2208,14 +2208,33 @@ weechat_python_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_python_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;
|
||||
|
||||
@@ -2682,14 +2682,33 @@ weechat_ruby_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_ruby_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;
|
||||
|
||||
@@ -2450,14 +2450,33 @@ weechat_tcl_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_tcl_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;
|
||||
|
||||
@@ -57,7 +57,7 @@ struct timeval;
|
||||
* please change the date with current one; for a second change at same
|
||||
* date, increment the 01, otherwise please keep 01.
|
||||
*/
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20160324-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20160423-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -138,11 +138,16 @@ struct timeval;
|
||||
|
||||
/*
|
||||
* process return code (for callback):
|
||||
* if >= 0, then process ended and it's return code of command
|
||||
* if < 0, then it's running or error
|
||||
* if >= 0, the process ended and it's return code of command
|
||||
* if -1, the process is still running
|
||||
* if -2, the process ended with an error
|
||||
* if -3, the callback is called in the child process (exec of function)
|
||||
* (note: the return code -3 is NEVER sent to script plugins,
|
||||
* it can be used only in C API)
|
||||
*/
|
||||
#define WEECHAT_HOOK_PROCESS_RUNNING -1
|
||||
#define WEECHAT_HOOK_PROCESS_ERROR -2
|
||||
#define WEECHAT_HOOK_PROCESS_CHILD -3
|
||||
|
||||
/* connect status for connection hooked */
|
||||
#define WEECHAT_HOOK_CONNECT_OK 0
|
||||
|
||||
Reference in New Issue
Block a user