1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 12:26:40 +02:00

scripts: add function hook_url in scripting API

This commit is contained in:
Sébastien Helleu
2023-09-08 17:07:03 +02:00
parent 24d2ba3338
commit fb00bc1f4b
16 changed files with 705 additions and 2 deletions
+62
View File
@@ -2685,6 +2685,68 @@ API_FUNC(hook_process_hashtable)
API_RETURN_STRING(result);
}
static int
weechat_php_api_hook_url_cb (const void *pointer, void *data,
const char *url,
struct t_hashtable *options,
struct t_hashtable *output)
{
int rc;
void *func_argv[4];
func_argv[1] = url ? (char *)url : weechat_php_empty_arg;
func_argv[2] = options;
func_argv[3] = output;
weechat_php_cb (pointer, data, func_argv, "sshh",
WEECHAT_SCRIPT_EXEC_INT, &rc);
return rc;
}
API_FUNC(hook_url)
{
zend_string *z_url, *z_data;
zval *z_options, *z_callback;
zend_long z_timeout;
char *url, *data;
struct t_hashtable *options;
int timeout;
const char *result;
API_INIT_FUNC(1, "hook_url", API_RETURN_EMPTY);
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SalzS", &z_url,
&z_options, &z_timeout, &z_callback,
&z_data) == FAILURE)
API_WRONG_ARGS(API_RETURN_EMPTY);
url = ZSTR_VAL(z_url);
options = weechat_php_array_to_hashtable (
z_options,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
timeout = (int)z_timeout;
weechat_php_get_function_name (z_callback, callback_name);
data = ZSTR_VAL(z_data);
result = API_PTR2STR(
plugin_script_api_hook_url (
weechat_php_plugin,
php_current_script,
(const char *)url,
options,
timeout,
&weechat_php_api_hook_url_cb,
(const char *)callback_name,
(const char *)data));
if (options)
weechat_hashtable_free (options);
API_RETURN_STRING(result);
}
static int
weechat_php_api_hook_connect_cb (const void *pointer, void *data, int status,
int gnutls_rc, int sock, const char *error,
+1
View File
@@ -141,6 +141,7 @@ PHP_FUNCTION(weechat_hook_timer);
PHP_FUNCTION(weechat_hook_fd);
PHP_FUNCTION(weechat_hook_process);
PHP_FUNCTION(weechat_hook_process_hashtable);
PHP_FUNCTION(weechat_hook_url);
PHP_FUNCTION(weechat_hook_connect);
PHP_FUNCTION(weechat_hook_line);
PHP_FUNCTION(weechat_hook_print);
+1
View File
@@ -199,6 +199,7 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_hook_fd, arginfo_weechat_hook_fd)
PHP_FE(weechat_hook_process, arginfo_weechat_hook_process)
PHP_FE(weechat_hook_process_hashtable, arginfo_weechat_hook_process_hashtable)
PHP_FE(weechat_hook_url, arginfo_weechat_hook_url)
PHP_FE(weechat_hook_connect, arginfo_weechat_hook_connect)
PHP_FE(weechat_hook_line, arginfo_weechat_hook_line)
PHP_FE(weechat_hook_print, arginfo_weechat_hook_print)
+1
View File
@@ -107,6 +107,7 @@ function weechat_hook_timer(int $p0, int $p1, int $p2, mixed $p3, string $p4): s
function weechat_hook_fd(int $p0, int $p1, int $p2, int $p3, mixed $p4, string $p5): string {}
function weechat_hook_process(string $p0, int $p1, mixed $p2, string $p3): string {}
function weechat_hook_process_hashtable(string $p0, array $p1, int $p2, mixed $p3, string $p4): string {}
function weechat_hook_url(string $p0, array $p1, int $p2, mixed $p3, string $p4): string {}
function weechat_hook_connect(): string {}
function weechat_hook_line(string $p0, string $p1, string $p2, mixed $p3, string $p4): string {}
function weechat_hook_print(string $p0, string $p1, string $p2, int $p3, mixed $p4, string $p5): string {}
+3 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: d9a98a051023d3904f6e6f94b776386b3b67a5f6 */
* Stub hash: 614392b6be26030a5d7b12437562aec08ad7052c */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_register, 0, 7, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
@@ -315,6 +315,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_hook_process_hashtable,
ZEND_ARG_TYPE_INFO(0, p4, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_weechat_hook_url arginfo_weechat_hook_process_hashtable
#define arginfo_weechat_hook_connect arginfo_weechat_list_new
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_hook_line, 0, 5, IS_STRING, 0)
+3 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: d9a98a051023d3904f6e6f94b776386b3b67a5f6 */
* Stub hash: 614392b6be26030a5d7b12437562aec08ad7052c */
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7)
ZEND_ARG_INFO(0, p0)
@@ -229,6 +229,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_hook_process_hashtable arginfo_weechat_print_y_date_tags
#define arginfo_weechat_hook_url arginfo_weechat_print_y_date_tags
#define arginfo_weechat_hook_connect arginfo_weechat_list_new
#define arginfo_weechat_hook_line arginfo_weechat_print_y_date_tags