summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--ReleaseNotes.adoc11
-rw-r--r--doc/en/weechat_plugin_api.en.adoc8
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc9
-rw-r--r--doc/it/weechat_plugin_api.it.adoc9
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc10
-rw-r--r--src/plugins/guile/weechat-guile-api.c8
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp8
-rw-r--r--src/plugins/lua/weechat-lua-api.c8
-rw-r--r--src/plugins/perl/weechat-perl-api.c8
-rw-r--r--src/plugins/python/weechat-python-api.c8
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c8
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c8
13 files changed, 65 insertions, 39 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index c2e1c211e..79e7acb53 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -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)
diff --git a/ReleaseNotes.adoc b/ReleaseNotes.adoc
index e263abb49..aee087e87 100644
--- a/ReleaseNotes.adoc
+++ b/ReleaseNotes.adoc
@@ -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)
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index 74729777b..dfcd28dc0 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -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]
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index 342418aef..3c21d3709 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -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]
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index e8cdf9e1f..f74413ceb 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -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]
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index e9b533af0..d013f56aa 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -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]
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index 6aefa3bd2..3f1182856 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -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;
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index ee3cfdbbf..c41c613f9 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -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;
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index a8d07e5bd..9148bfb2c 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -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;
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 084400f71..982aeaba2 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -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;
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index cddaf1691..f3384bd4e 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -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;
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index 8a819e622..488ec9193 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -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;
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index dab21c51e..90a21566d 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -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;