From c3eff15a566da40e1919b034cd5580378dd3bda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 3 Mar 2024 10:32:11 +0100 Subject: api: add functions config_option_get_string and config_option_get_pointer in scripting API --- src/plugins/php/weechat-php-api.c | 43 +++++++++++++++++++++++++++- src/plugins/php/weechat-php-api.h | 2 ++ src/plugins/php/weechat-php.c | 2 ++ src/plugins/php/weechat-php.stub.php | 2 ++ src/plugins/php/weechat-php_arginfo.h | 7 ++++- src/plugins/php/weechat-php_legacy_arginfo.h | 7 ++++- 6 files changed, 60 insertions(+), 3 deletions(-) (limited to 'src/plugins/php') diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index d4cc5a352..bc6328f42 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -1570,6 +1570,47 @@ API_FUNC(config_option_rename) API_RETURN_OK; } +API_FUNC(config_option_get_string) +{ + zend_string *z_option, *z_property; + struct t_config_option *option; + char *property; + const char *result; + + API_INIT_FUNC(1, "config_option_get_string", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SS", &z_option, + &z_property) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + property = ZSTR_VAL(z_property); + + result = weechat_config_option_get_string (option, (const char *)property); + + API_RETURN_STRING(result); +} + +API_FUNC(config_option_get_pointer) +{ + zend_string *z_option, *z_property; + struct t_config_option *option; + char *property; + const char *result; + + API_INIT_FUNC(1, "config_option_get_pointer", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SS", &z_option, + &z_property) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option)); + property = ZSTR_VAL(z_property); + + result = API_PTR2STR( + weechat_config_option_get_pointer (option, (const char *)property)); + + API_RETURN_STRING(result); +} + API_FUNC(config_option_is_null) { zend_string *z_option; @@ -3764,9 +3805,9 @@ API_FUNC(buffer_get_integer) API_FUNC(buffer_get_string) { zend_string *z_buffer, *z_property; - const char *result; struct t_gui_buffer *buffer; char *property; + const char *result; API_INIT_FUNC(1, "buffer_get_string", API_RETURN_EMPTY); if (zend_parse_parameters (ZEND_NUM_ARGS(), "SS", &z_buffer, diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index dceb64f6f..40b8dd1aa 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -96,6 +96,8 @@ PHP_FUNCTION(weechat_config_option_set); PHP_FUNCTION(weechat_config_option_set_null); PHP_FUNCTION(weechat_config_option_unset); PHP_FUNCTION(weechat_config_option_rename); +PHP_FUNCTION(weechat_config_option_get_string); +PHP_FUNCTION(weechat_config_option_get_pointer); PHP_FUNCTION(weechat_config_option_is_null); PHP_FUNCTION(weechat_config_option_default_is_null); PHP_FUNCTION(weechat_config_boolean); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 9ea05d4cb..5324d8320 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -154,6 +154,8 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_config_option_set_null, arginfo_weechat_config_option_set_null) PHP_FE(weechat_config_option_unset, arginfo_weechat_config_option_unset) PHP_FE(weechat_config_option_rename, arginfo_weechat_config_option_rename) + PHP_FE(weechat_config_option_get_string, arginfo_weechat_config_option_get_string) + PHP_FE(weechat_config_option_get_pointer, arginfo_weechat_config_option_get_pointer) PHP_FE(weechat_config_option_is_null, arginfo_weechat_config_option_is_null) PHP_FE(weechat_config_option_default_is_null, arginfo_weechat_config_option_default_is_null) PHP_FE(weechat_config_boolean, arginfo_weechat_config_boolean) diff --git a/src/plugins/php/weechat-php.stub.php b/src/plugins/php/weechat-php.stub.php index 3fa47053b..32ef0dcca 100644 --- a/src/plugins/php/weechat-php.stub.php +++ b/src/plugins/php/weechat-php.stub.php @@ -62,6 +62,8 @@ function weechat_config_option_set(string $p0, string $p1, int $p2): int {} function weechat_config_option_set_null(string $p0, int $p1): int {} function weechat_config_option_unset(string $p0): int {} function weechat_config_option_rename(string $p0, string $p1): int {} +function weechat_config_option_get_string(string $p0, string $p1): string {} +function weechat_config_option_get_pointer(string $p0, string $p1): string {} function weechat_config_option_is_null(string $p0): int {} function weechat_config_option_default_is_null(string $p0): int {} function weechat_config_boolean(string $p0): int {} diff --git a/src/plugins/php/weechat-php_arginfo.h b/src/plugins/php/weechat-php_arginfo.h index 250d2ea5f..225a00abe 100644 --- a/src/plugins/php/weechat-php_arginfo.h +++ b/src/plugins/php/weechat-php_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: b6e9e3f12ed24566eb77aa0c08bf3e7c5d866b76 */ + * Stub hash: 2c52caa5a78009856a6e6ced63555d1b1e2be0fe */ 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) @@ -161,6 +161,10 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_config_option_rename arginfo_weechat_string_has_highlight +#define arginfo_weechat_config_option_get_string arginfo_weechat_iconv_to_internal + +#define arginfo_weechat_config_option_get_pointer arginfo_weechat_iconv_to_internal + #define arginfo_weechat_config_option_is_null arginfo_weechat_charset_set #define arginfo_weechat_config_option_default_is_null arginfo_weechat_charset_set @@ -639,3 +643,4 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_forget_class, 0, 1, _IS_BOOL, 0) ZEND_END_ARG_INFO() #define arginfo_forget_function arginfo_forget_class + diff --git a/src/plugins/php/weechat-php_legacy_arginfo.h b/src/plugins/php/weechat-php_legacy_arginfo.h index 2622d66b0..9b620112b 100644 --- a/src/plugins/php/weechat-php_legacy_arginfo.h +++ b/src/plugins/php/weechat-php_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: b6e9e3f12ed24566eb77aa0c08bf3e7c5d866b76 */ + * Stub hash: 2c52caa5a78009856a6e6ced63555d1b1e2be0fe */ ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7) ZEND_ARG_INFO(0, p0) @@ -126,6 +126,10 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_config_option_rename arginfo_weechat_iconv_to_internal +#define arginfo_weechat_config_option_get_string arginfo_weechat_iconv_to_internal + +#define arginfo_weechat_config_option_get_pointer arginfo_weechat_iconv_to_internal + #define arginfo_weechat_config_option_is_null arginfo_weechat_plugin_get_name #define arginfo_weechat_config_option_default_is_null arginfo_weechat_plugin_get_name @@ -462,3 +466,4 @@ ZEND_END_ARG_INFO() #define arginfo_forget_class arginfo_weechat_plugin_get_name #define arginfo_forget_function arginfo_weechat_plugin_get_name + -- cgit v1.2.3