api: send file descriptor as integer instead of string to the callback of hook_fd

v2.8-utf8proc
Sébastien Helleu 2017-08-13 09:29:39 +02:00
parent 2b7ea69d00
commit 5392e3078f
13 changed files with 65 additions and 39 deletions

View File

@ -34,6 +34,7 @@ Bug fixes::
* core: fix cast of time_t (to "long long" instead of "long") (issue #1051)
* core: call the config hook when options are renamed or removed
* api: send file descriptor as integer instead of string to the callback of hook_fd
* buflist: fix crash in auto-scroll of bar when the buflist item is not the first item in the bar
* relay: fix send of "PART" command in backlog (irc protocol)
* relay: fix parsing of CAP command without arguments in irc protocol, send ACK only if all capabilities received are OK and NAK otherwise (issue #1040)

View File

@ -17,6 +17,17 @@ https://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog]
(file _ChangeLog.adoc_ in sources).
[[v2.0]]
== Version 2.0 (under dev)
[[v2.0_hook_fd]]
=== Function hook_fd
The argument _fd_ sent to the callback of _hook_fd_ is now an integer
(it was a string in older releases). +
To be compatible with all versions, it is recommended to convert the argument
to integer before using it, for example in Python: `int(fd)`.
[[v1.9]]
== Version 1.9 (2017-06-25)

View File

@ -8275,7 +8275,7 @@ hook = weechat.hook_timer(20 * 1000, 0, 0, "my_timer_cb", "")
==== hook_fd
_Updated in 1.3, 1.5._
_Updated in 1.3, 1.5, 2.0._
Hook a file descriptor (file or socket).
@ -8318,6 +8318,12 @@ Return value:
* pointer to new hook, NULL if error occurred
[IMPORTANT]
In scripts, with WeeChat ≥ 2.0, the callback argument _fd_ is an integer
(with WeeChat ≤ 1.9, it was a string). +
To be compatible with all versions, it is recommended to convert the argument
to integer before using it, for example in Python: `int(fd)`.
C example:
[source,C]

View File

@ -8422,7 +8422,7 @@ hook = weechat.hook_timer(20 * 1000, 0, 0, "my_timer_cb", "")
==== hook_fd
_Mis à jour dans la 1.3, 1.5._
_Mis à jour dans la 1.3, 1.5, 2.0._
Accrocher un descripteur de fichier (fichier ou socket).
@ -8467,6 +8467,13 @@ Valeur de retour :
* pointeur vers le nouveau "hook", NULL en cas d'erreur
// TRANSLATION MISSING
[IMPORTANT]
Dans les scripts, avec WeeChat ≥ 2.0, le paramètre de la fonction de rappel _fd_
est un entier (avec WeeChat ≤ 1.9, il était une chaîne). +
Pour être compatible avec toutes les versions, il est recommandé de convertir le
paramètre en entier avant de l'utiliser, par exemple en Python : `int(fd)`.
Exemple en C :
[source,C]

View File

@ -8518,7 +8518,7 @@ hook = weechat.hook_timer(20 * 1000, 0, 0, "my_timer_cb", "")
==== hook_fd
// TRANSLATION MISSING
_Updated in 1.3, 1.5._
_Updated in 1.3, 1.5, 2.0._
Hook su un descrittore file (file oppure socket).
@ -8563,6 +8563,13 @@ Valore restituito:
* puntatore al nuovo hook, NULL in caso di errore
// TRANSLATION MISSING
[IMPORTANT]
In scripts, with WeeChat ≥ 2.0, the callback argument _fd_ is an integer
(with WeeChat ≤ 1.9, it was a string). +
To be compatible with all versions, it is recommended to convert the argument
to integer before using it, for example in Python: `int(fd)`.
Esempio in C:
[source,C]

View File

@ -8279,7 +8279,8 @@ hook = weechat.hook_timer(20 * 1000, 0, 0, "my_timer_cb", "")
==== hook_fd
_WeeChat バージョン 1.3 と 1.5 で更新。_
// TRANSLATION MISSING
_Updated in 1.3, 1.5, 2.0._
ファイルディスクリプタ (ファイルやソケット) をフック。
@ -8322,6 +8323,13 @@ struct t_hook *weechat_hook_fd (int fd,
* 新しいフックへのポインタ、エラーが起きた場合は NULL
// TRANSLATION MISSING
[IMPORTANT]
In scripts, with WeeChat ≥ 2.0, the callback argument _fd_ is an integer
(with WeeChat ≤ 1.9, it was a string). +
To be compatible with all versions, it is recommended to convert the argument
to integer before using it, for example in Python: `int(fd)`.
C 言語での使用例:
[source,C]

View File

@ -2206,7 +2206,7 @@ weechat_guile_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
int *rc, ret;
@ -2215,15 +2215,13 @@ weechat_guile_api_hook_fd_cb (const void *pointer, void *data, int fd)
if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
func_argv[1] = &fd;
rc = (int *) weechat_guile_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
ptr_function,
"ss", func_argv);
"si", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;

View File

@ -2121,7 +2121,7 @@ weechat_js_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
int *rc, ret;
@ -2130,15 +2130,13 @@ weechat_js_api_hook_fd_cb (const void *pointer, void *data, int fd)
if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
func_argv[1] = &fd;
rc = (int *)weechat_js_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
ptr_function,
"ss", func_argv);
"si", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;

View File

@ -2316,7 +2316,7 @@ weechat_lua_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
int *rc, ret;
@ -2325,15 +2325,13 @@ weechat_lua_api_hook_fd_cb (const void *pointer, void *data, int fd)
if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
func_argv[1] = &fd;
rc = (int *) weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
ptr_function,
"ss", func_argv);
"si", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;

View File

@ -2246,7 +2246,7 @@ weechat_perl_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
int *rc, ret;
@ -2255,15 +2255,13 @@ weechat_perl_api_hook_fd_cb (const void *pointer, void *data, int fd)
if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
func_argv[1] = &fd;
rc = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
ptr_function,
"ss", func_argv);
"si", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;

View File

@ -2247,7 +2247,7 @@ weechat_python_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
int *rc, ret;
@ -2256,15 +2256,13 @@ weechat_python_api_hook_fd_cb (const void *pointer, void *data, int fd)
if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
func_argv[1] = &fd;
rc = (int *) weechat_python_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
ptr_function,
"ss", func_argv);
"si", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;

View File

@ -2735,7 +2735,7 @@ weechat_ruby_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
int *rc, ret;
@ -2744,15 +2744,13 @@ weechat_ruby_api_hook_fd_cb (const void *pointer, void *data, int fd)
if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
func_argv[1] = &fd;
rc = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
ptr_function,
"ss", func_argv);
"si", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;

View File

@ -2497,7 +2497,7 @@ weechat_tcl_api_hook_fd_cb (const void *pointer, void *data, int fd)
{
struct t_plugin_script *script;
void *func_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
char empty_arg[1] = { '\0' };
const char *ptr_function, *ptr_data;
int *rc, ret;
@ -2506,15 +2506,13 @@ weechat_tcl_api_hook_fd_cb (const void *pointer, void *data, int fd)
if (ptr_function && ptr_function[0])
{
snprintf (str_fd, sizeof (str_fd), "%d", fd);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = str_fd;
func_argv[1] = &fd;
rc = (int *) weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
ptr_function,
"ss", func_argv);
"si", func_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;