diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-12-26 18:37:21 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-12-26 19:44:37 +0100 |
commit | 9fb3d3f14c17f8307f04907d5f57034410dc7010 (patch) | |
tree | 239415921e803382adf1abb9a334456c5d96711b /src/plugins/php | |
parent | 57f80a4c1fac3d5b3c194206c900b1066f9a565e (diff) | |
download | weechat-9fb3d3f14c17f8307f04907d5f57034410dc7010.zip |
core: store microseconds in buffer lines (closes #649)
Diffstat (limited to 'src/plugins/php')
-rw-r--r-- | src/plugins/php/weechat-php-api.c | 73 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.h | 2 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.c | 2 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.stub.php | 2 | ||||
-rw-r--r-- | src/plugins/php/weechat-php_arginfo.h | 17 | ||||
-rw-r--r-- | src/plugins/php/weechat-php_legacy_arginfo.h | 46 |
6 files changed, 117 insertions, 25 deletions
diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index fbd1ce5db..b23c86bf9 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -2183,6 +2183,38 @@ API_FUNC(print_date_tags) API_RETURN_OK; } +API_FUNC(print_datetime_tags) +{ + zend_string *z_buffer, *z_tags, *z_message; + zend_long z_date, z_date_usec; + struct t_gui_buffer *buffer; + time_t date; + int date_usec; + char *tags, *message; + + API_INIT_FUNC(1, "print_datetime_tags", API_RETURN_ERROR); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SllSS", &z_buffer, &z_date, + &z_date_usec, &z_tags, &z_message) == FAILURE) + API_WRONG_ARGS(API_RETURN_ERROR); + + buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); + date = (time_t)z_date; + date_usec = (int)z_date_usec; + tags = ZSTR_VAL(z_tags); + message = ZSTR_VAL(z_message); + + plugin_script_api_printf_datetime_tags (weechat_php_plugin, + php_current_script, + buffer, + date, + date_usec, + (const char *)tags, + "%s", + message); + + API_RETURN_OK; +} + API_FUNC(print_y) { zend_string *z_buffer, *z_message; @@ -2242,6 +2274,41 @@ API_FUNC(print_y_date_tags) API_RETURN_OK; } +API_FUNC(print_y_datetime_tags) +{ + zend_string *z_buffer, *z_tags, *z_message; + zend_long z_y, z_date, z_date_usec; + struct t_gui_buffer *buffer; + int y, date_usec; + time_t date; + char *tags, *message; + + API_INIT_FUNC(1, "print_y_datetime_tags", API_RETURN_ERROR); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SlllSS", &z_buffer, &z_y, + &z_date, &z_date_usec, &z_tags, + &z_message) == FAILURE) + API_WRONG_ARGS(API_RETURN_ERROR); + + buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer)); + y = (int)z_y; + date = (time_t)z_date; + date_usec = (int)z_date_usec; + tags = ZSTR_VAL(z_tags); + message = ZSTR_VAL(z_message); + + plugin_script_api_printf_y_datetime_tags (weechat_php_plugin, + php_current_script, + buffer, + y, + date, + date_usec, + (const char *)tags, + "%s", + message); + + API_RETURN_OK; +} + API_FUNC(log_print) { zend_string *z_message; @@ -2871,7 +2938,8 @@ API_FUNC(hook_line) static int weechat_php_api_hook_print_cb (const void *pointer, void *data, - struct t_gui_buffer *buffer, time_t date, + struct t_gui_buffer *buffer, + time_t date, int date_usec, int tags_count, const char **tags, int displayed, int highlight, const char *prefix, const char *message) @@ -2879,6 +2947,9 @@ weechat_php_api_hook_print_cb (const void *pointer, void *data, int rc; void *func_argv[9]; + /* make C compiler happy */ + (void) date_usec; + func_argv[1] = (char *)API_PTR2STR(buffer); func_argv[2] = &date; func_argv[3] = &tags_count; diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index d223b6f56..0d0057705 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -129,8 +129,10 @@ PHP_FUNCTION(weechat_prefix); PHP_FUNCTION(weechat_color); PHP_FUNCTION(weechat_print); PHP_FUNCTION(weechat_print_date_tags); +PHP_FUNCTION(weechat_print_datetime_tags); PHP_FUNCTION(weechat_print_y); PHP_FUNCTION(weechat_print_y_date_tags); +PHP_FUNCTION(weechat_print_y_datetime_tags); PHP_FUNCTION(weechat_log_print); PHP_FUNCTION(weechat_hook_command); PHP_FUNCTION(weechat_hook_completion); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 8a5534916..e97abaf03 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -187,8 +187,10 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_color, arginfo_weechat_color) PHP_FE(weechat_print, arginfo_weechat_print) PHP_FE(weechat_print_date_tags, arginfo_weechat_print_date_tags) + PHP_FE(weechat_print_datetime_tags, arginfo_weechat_print_datetime_tags) PHP_FE(weechat_print_y, arginfo_weechat_print_y) PHP_FE(weechat_print_y_date_tags, arginfo_weechat_print_y_date_tags) + PHP_FE(weechat_print_y_datetime_tags, arginfo_weechat_print_y_datetime_tags) PHP_FE(weechat_log_print, arginfo_weechat_log_print) PHP_FE(weechat_hook_command, arginfo_weechat_hook_command) PHP_FE(weechat_hook_completion, arginfo_weechat_hook_completion) diff --git a/src/plugins/php/weechat-php.stub.php b/src/plugins/php/weechat-php.stub.php index 9343075af..3fa47053b 100644 --- a/src/plugins/php/weechat-php.stub.php +++ b/src/plugins/php/weechat-php.stub.php @@ -95,8 +95,10 @@ function weechat_prefix(string $p0): string {} function weechat_color(string $p0): string {} function weechat_print(string $p0, string $p1): int {} function weechat_print_date_tags(string $p0, int $p1, string $p2, string $p3): int {} +function weechat_print_datetime_tags(string $p0, int $p1, int $p2, string $p3, string $p4): int {} function weechat_print_y(string $p0, int $p1, string $p2): int {} function weechat_print_y_date_tags(string $p0, int $p1, int $p2, string $p3, string $p4): int {} +function weechat_print_y_datetime_tags(string $p0, int $p1, int $p2, int $p3, string $p4, string $p5): int {} function weechat_log_print(string $p0): int {} function weechat_hook_command(string $p0, string $p1, string $p2, string $p3, string $p4, mixed $p5, string $p6): string {} function weechat_hook_completion(string $p0, string $p1, mixed $p2, string $p3): string {} diff --git a/src/plugins/php/weechat-php_arginfo.h b/src/plugins/php/weechat-php_arginfo.h index e2b345a3e..250d2ea5f 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: 614392b6be26030a5d7b12437562aec08ad7052c */ + * Stub hash: b6e9e3f12ed24566eb77aa0c08bf3e7c5d866b76 */ 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) @@ -239,18 +239,29 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_date_tags, 0, 4, I ZEND_ARG_TYPE_INFO(0, p3, IS_STRING, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_datetime_tags, 0, 5, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, p1, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, p2, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, p3, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, p4, IS_STRING, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_y, 0, 3, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, p1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, p2, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_y_date_tags, 0, 5, IS_LONG, 0) +#define arginfo_weechat_print_y_date_tags arginfo_weechat_print_datetime_tags + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_y_datetime_tags, 0, 6, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, p1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, p2, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, p3, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, p3, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, p4, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, p5, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_weechat_log_print arginfo_weechat_charset_set diff --git a/src/plugins/php/weechat-php_legacy_arginfo.h b/src/plugins/php/weechat-php_legacy_arginfo.h index de2cb031e..2622d66b0 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: 614392b6be26030a5d7b12437562aec08ad7052c */ + * Stub hash: b6e9e3f12ed24566eb77aa0c08bf3e7c5d866b76 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7) ZEND_ARG_INFO(0, p0) @@ -192,14 +192,25 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_print_date_tags arginfo_weechat_string_eval_expression +ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_print_datetime_tags, 0, 0, 5) + ZEND_ARG_INFO(0, p0) + ZEND_ARG_INFO(0, p1) + ZEND_ARG_INFO(0, p2) + ZEND_ARG_INFO(0, p3) + ZEND_ARG_INFO(0, p4) +ZEND_END_ARG_INFO() + #define arginfo_weechat_print_y arginfo_weechat_ngettext -ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_print_y_date_tags, 0, 0, 5) +#define arginfo_weechat_print_y_date_tags arginfo_weechat_print_datetime_tags + +ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_print_y_datetime_tags, 0, 0, 6) ZEND_ARG_INFO(0, p0) ZEND_ARG_INFO(0, p1) ZEND_ARG_INFO(0, p2) ZEND_ARG_INFO(0, p3) ZEND_ARG_INFO(0, p4) + ZEND_ARG_INFO(0, p5) ZEND_END_ARG_INFO() #define arginfo_weechat_log_print arginfo_weechat_plugin_get_name @@ -214,28 +225,21 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_hook_command_run arginfo_weechat_ngettext -#define arginfo_weechat_hook_timer arginfo_weechat_print_y_date_tags +#define arginfo_weechat_hook_timer arginfo_weechat_print_datetime_tags -ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_hook_fd, 0, 0, 6) - ZEND_ARG_INFO(0, p0) - ZEND_ARG_INFO(0, p1) - ZEND_ARG_INFO(0, p2) - ZEND_ARG_INFO(0, p3) - ZEND_ARG_INFO(0, p4) - ZEND_ARG_INFO(0, p5) -ZEND_END_ARG_INFO() +#define arginfo_weechat_hook_fd arginfo_weechat_print_y_datetime_tags #define arginfo_weechat_hook_process arginfo_weechat_string_eval_expression -#define arginfo_weechat_hook_process_hashtable arginfo_weechat_print_y_date_tags +#define arginfo_weechat_hook_process_hashtable arginfo_weechat_print_datetime_tags -#define arginfo_weechat_hook_url arginfo_weechat_print_y_date_tags +#define arginfo_weechat_hook_url arginfo_weechat_print_datetime_tags #define arginfo_weechat_hook_connect arginfo_weechat_list_new -#define arginfo_weechat_hook_line arginfo_weechat_print_y_date_tags +#define arginfo_weechat_hook_line arginfo_weechat_print_datetime_tags -#define arginfo_weechat_hook_print arginfo_weechat_hook_fd +#define arginfo_weechat_hook_print arginfo_weechat_print_y_datetime_tags #define arginfo_weechat_hook_signal arginfo_weechat_ngettext @@ -251,11 +255,11 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_hook_modifier_exec arginfo_weechat_ngettext -#define arginfo_weechat_hook_info arginfo_weechat_print_y_date_tags +#define arginfo_weechat_hook_info arginfo_weechat_print_datetime_tags #define arginfo_weechat_hook_info_hashtable arginfo_weechat_register -#define arginfo_weechat_hook_infolist arginfo_weechat_hook_fd +#define arginfo_weechat_hook_infolist arginfo_weechat_print_y_datetime_tags #define arginfo_weechat_hook_focus arginfo_weechat_ngettext @@ -265,9 +269,9 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_unhook_all arginfo_weechat_plugin_get_name -#define arginfo_weechat_buffer_new arginfo_weechat_print_y_date_tags +#define arginfo_weechat_buffer_new arginfo_weechat_print_datetime_tags -#define arginfo_weechat_buffer_new_props arginfo_weechat_hook_fd +#define arginfo_weechat_buffer_new_props arginfo_weechat_print_y_datetime_tags #define arginfo_weechat_buffer_search arginfo_weechat_iconv_to_internal @@ -307,7 +311,7 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_window_set_title arginfo_weechat_plugin_get_name -#define arginfo_weechat_nicklist_add_group arginfo_weechat_print_y_date_tags +#define arginfo_weechat_nicklist_add_group arginfo_weechat_print_datetime_tags #define arginfo_weechat_nicklist_search_group arginfo_weechat_ngettext @@ -441,7 +445,7 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_hdata_hashtable arginfo_weechat_ngettext -#define arginfo_weechat_hdata_compare arginfo_weechat_print_y_date_tags +#define arginfo_weechat_hdata_compare arginfo_weechat_print_datetime_tags #define arginfo_weechat_hdata_update arginfo_weechat_ngettext |