summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/guile/weechat-guile-api.c2
-rw-r--r--src/plugins/guile/weechat-guile.c17
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp2
-rw-r--r--src/plugins/javascript/weechat-js.cpp14
-rw-r--r--src/plugins/lua/weechat-lua-api.c2
-rw-r--r--src/plugins/lua/weechat-lua.c18
-rw-r--r--src/plugins/perl/weechat-perl-api.c2
-rw-r--r--src/plugins/perl/weechat-perl.c8
-rw-r--r--src/plugins/php/weechat-php-api.c2
-rw-r--r--src/plugins/php/weechat-php.c7
-rw-r--r--src/plugins/plugin-script.h1
-rw-r--r--src/plugins/python/weechat-python-api.c2
-rw-r--r--src/plugins/python/weechat-python.c32
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c2
-rw-r--r--src/plugins/ruby/weechat-ruby.c13
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c2
-rw-r--r--src/plugins/tcl/weechat-tcl.c12
18 files changed, 129 insertions, 10 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 78e0dbe50..5c36d5d26 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -37,6 +37,7 @@ Bug fixes::
* php: fix return code of functions config_write_option and config_write_line
* php: fix memory leak in 72 functions returning allocated strings
* ruby: fix memory leak in 7 functions returning allocated strings
+ * scripts: fix return value of hook_infolist callback (pointer instead of string)
* scripts: return long integer instead of string in function infolist_time
* xfer: set option TCP_NODELAY on socket when receiving a file via DCC (issue #1171)
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index 90af55799..ce5b2166d 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -3001,7 +3001,7 @@ weechat_guile_api_hook_infolist_cb (const void *pointer, void *data,
result = (struct t_infolist *)weechat_guile_exec (
script,
- WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
ptr_function,
"ssss", func_argv);
diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c
index 1019aba5f..36112fb85 100644
--- a/src/plugins/guile/weechat-guile.c
+++ b/src/plugins/guile/weechat-guile.c
@@ -337,7 +337,7 @@ weechat_guile_exec (struct t_plugin_script *script,
{
struct t_plugin_script *old_guile_current_script;
SCM rc, old_current_module;
- void *argv2[17], *ret_value;
+ void *argv2[17], *ret_value, *ret_temp;
int i, argc, *ret_int;
ret_value = NULL;
@@ -386,6 +386,21 @@ weechat_guile_exec (struct t_plugin_script *script,
{
ret_value = scm_to_locale_string (rc);
}
+ else if ((ret_type == WEECHAT_SCRIPT_EXEC_POINTER) && (scm_is_string (rc)))
+ {
+ ret_temp = scm_to_locale_string (rc);
+ if (ret_temp)
+ {
+ ret_value = plugin_script_str2ptr (weechat_guile_plugin,
+ script->name, function,
+ ret_temp);
+ free (ret_temp);
+ }
+ else
+ {
+ ret_value = NULL;
+ }
+ }
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (scm_is_integer (rc)))
{
ret_int = malloc (sizeof (*ret_int));
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index 307dd886c..ed047c66f 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -2909,7 +2909,7 @@ weechat_js_api_hook_infolist_cb (const void *pointer, void *data,
result = (struct t_infolist *)weechat_js_exec (
script,
- WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
ptr_function,
"ssss", func_argv);
diff --git a/src/plugins/javascript/weechat-js.cpp b/src/plugins/javascript/weechat-js.cpp
index 72e1217e0..cd07f2bc7 100644
--- a/src/plugins/javascript/weechat-js.cpp
+++ b/src/plugins/javascript/weechat-js.cpp
@@ -231,6 +231,20 @@ weechat_js_exec (struct t_plugin_script *script,
v8::String::Utf8Value temp_str(ret_js);
ret_value = (*temp_str) ? strdup(*temp_str) : NULL;
}
+ else if ((ret_type == WEECHAT_SCRIPT_EXEC_POINTER) && (ret_js->IsString()))
+ {
+ v8::String::Utf8Value temp_str(ret_js);
+ if (*temp_str)
+ {
+ ret_value = plugin_script_str2ptr (weechat_js_plugin,
+ script->name, function,
+ *temp_str);
+ }
+ else
+ {
+ ret_value = NULL;
+ }
+ }
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (ret_js->IsInt32()))
{
ret_int = (int *)malloc (sizeof (*ret_int));
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index 418fbf811..8938522e3 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -3124,7 +3124,7 @@ weechat_lua_api_hook_infolist_cb (const void *pointer, void *data,
result = (struct t_infolist *)weechat_lua_exec (
script,
- WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
ptr_function,
"ssss", func_argv);
diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c
index c7c86b76c..f2c9240cf 100644
--- a/src/plugins/lua/weechat-lua.c
+++ b/src/plugins/lua/weechat-lua.c
@@ -346,6 +346,24 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
function);
}
}
+ else if (ret_type == WEECHAT_SCRIPT_EXEC_POINTER)
+ {
+ ret_value = (char *) lua_tostring (lua_current_interpreter, -1);
+ if (ret_value)
+ {
+ ret_value = plugin_script_str2ptr (weechat_lua_plugin,
+ script->name, function,
+ ret_value);
+ }
+ else
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: function \"%s\" must "
+ "return a valid value"),
+ weechat_prefix ("error"), LUA_PLUGIN_NAME,
+ function);
+ }
+ }
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
{
ret_i = malloc (sizeof (*ret_i));
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index bc57e2e0a..c267b3aca 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -3050,7 +3050,7 @@ weechat_perl_api_hook_infolist_cb (const void *pointer, void *data,
result = (struct t_infolist *)weechat_perl_exec (
script,
- WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
ptr_function,
"ssss", func_argv);
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c
index f5ca29a0f..b63d2ccb1 100644
--- a/src/plugins/perl/weechat-perl.c
+++ b/src/plugins/perl/weechat-perl.c
@@ -413,6 +413,14 @@ weechat_perl_exec (struct t_plugin_script *script,
ret_value = strdup (SvPV_nolen (ret_s));
SvREFCNT_dec (ret_s);
}
+ else if (ret_type == WEECHAT_SCRIPT_EXEC_POINTER)
+ {
+ ret_s = newSVsv (POPs);
+ ret_value = plugin_script_str2ptr (weechat_perl_plugin,
+ script->name, function,
+ SvPV_nolen (ret_s));
+ SvREFCNT_dec (ret_s);
+ }
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
{
ret_i = malloc (sizeof (*ret_i));
diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c
index 1801e79b1..4a30850aa 100644
--- a/src/plugins/php/weechat-php-api.c
+++ b/src/plugins/php/weechat-php-api.c
@@ -2930,7 +2930,7 @@ weechat_php_api_hook_infolist_cb (const void *pointer, void *data,
func_argv[3] = (arguments) ? (char *)arguments : weechat_php_empty_arg;
weechat_php_cb (pointer, data, func_argv, "ssss",
- WEECHAT_SCRIPT_EXEC_STRING, &rc);
+ WEECHAT_SCRIPT_EXEC_POINTER, &rc);
return rc;
}
diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c
index 439e04d6b..aefcbcf0d 100644
--- a/src/plugins/php/weechat-php.c
+++ b/src/plugins/php/weechat-php.c
@@ -589,6 +589,13 @@ weechat_php_exec (struct t_plugin_script *script, int ret_type,
convert_to_string (&zretval);
ret_value = strdup ((char *)Z_STRVAL(zretval));
}
+ else if (ret_type == WEECHAT_SCRIPT_EXEC_POINTER)
+ {
+ convert_to_string (&zretval);
+ ret_value = plugin_script_str2ptr (weechat_php_plugin,
+ script->name, function,
+ (char *)Z_STRVAL(zretval));
+ }
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
{
convert_to_long (&zretval);
diff --git a/src/plugins/plugin-script.h b/src/plugins/plugin-script.h
index cb226876c..b40e0a69a 100644
--- a/src/plugins/plugin-script.h
+++ b/src/plugins/plugin-script.h
@@ -26,6 +26,7 @@ enum t_weechat_script_exec_type
{
WEECHAT_SCRIPT_EXEC_INT = 0,
WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
WEECHAT_SCRIPT_EXEC_IGNORE,
};
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 905795ab4..8d8718c80 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -3086,7 +3086,7 @@ weechat_python_api_hook_infolist_cb (const void *pointer, void *data,
result = (struct t_infolist *)weechat_python_exec (
script,
- WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
ptr_function,
"ssss", func_argv);
diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c
index 59e383c5d..f95577060 100644
--- a/src/plugins/python/weechat-python.c
+++ b/src/plugins/python/weechat-python.c
@@ -440,7 +440,7 @@ weechat_python_exec (struct t_plugin_script *script,
struct t_plugin_script *old_python_current_script;
PyThreadState *old_interpreter;
PyObject *evMain, *evDict, *evFunc, *rc;
- void *argv2[16], *ret_value;
+ void *argv2[16], *ret_value, *ret_temp;
int i, argc, *ret_int;
ret_value = NULL;
@@ -518,6 +518,36 @@ weechat_python_exec (struct t_plugin_script *script,
ret_value = NULL;
Py_XDECREF(rc);
}
+ else if ((ret_type == WEECHAT_SCRIPT_EXEC_POINTER) && (PyUnicode_Check (rc)))
+ {
+ ret_temp = weechat_python_unicode_to_string (rc);
+ if (ret_temp)
+ {
+ ret_value = plugin_script_str2ptr (weechat_python_plugin,
+ script->name, function,
+ ret_temp);
+ free (ret_temp);
+ }
+ else
+ {
+ ret_value = NULL;
+ }
+ Py_XDECREF(rc);
+ }
+ else if ((ret_type == WEECHAT_SCRIPT_EXEC_POINTER) && (PyBytes_Check (rc)))
+ {
+ if (PyBytes_AsString (rc))
+ {
+ ret_value = plugin_script_str2ptr (weechat_python_plugin,
+ script->name, function,
+ PyBytes_AsString (rc));
+ }
+ else
+ {
+ ret_value = NULL;
+ }
+ Py_XDECREF(rc);
+ }
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (PY_INTEGER_CHECK(rc)))
{
ret_int = malloc (sizeof (*ret_int));
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index f440c599c..e8d3b10a6 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -3667,7 +3667,7 @@ weechat_ruby_api_hook_infolist_cb (const void *pointer, void *data,
result = (struct t_infolist *)weechat_ruby_exec (
script,
- WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
ptr_function,
"ssss", func_argv);
diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c
index 64ea33640..7d0da943a 100644
--- a/src/plugins/ruby/weechat-ruby.c
+++ b/src/plugins/ruby/weechat-ruby.c
@@ -527,6 +527,19 @@ weechat_ruby_exec (struct t_plugin_script *script,
else
ret_value = NULL;
}
+ else if ((TYPE(rc) == T_STRING) && (ret_type == WEECHAT_SCRIPT_EXEC_POINTER))
+ {
+ if (StringValuePtr (rc))
+ {
+ ret_value = plugin_script_str2ptr (weechat_ruby_plugin,
+ script->name, function,
+ StringValuePtr (rc));
+ }
+ else
+ {
+ ret_value = NULL;
+ }
+ }
else if ((TYPE(rc) == T_FIXNUM) && (ret_type == WEECHAT_SCRIPT_EXEC_INT))
{
ret_i = malloc (sizeof (*ret_i));
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index c292871b7..250f3f7f7 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -3343,7 +3343,7 @@ weechat_tcl_api_hook_infolist_cb (const void *pointer, void *data,
result = (struct t_infolist *)weechat_tcl_exec (
script,
- WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
ptr_function,
"ssss", func_argv);
diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c
index 7af80f514..83b4967df 100644
--- a/src/plugins/tcl/weechat-tcl.c
+++ b/src/plugins/tcl/weechat-tcl.c
@@ -263,6 +263,18 @@ weechat_tcl_exec (struct t_plugin_script *script,
else
ret_val = NULL;
}
+ else if (ret_type == WEECHAT_SCRIPT_EXEC_POINTER)
+ {
+ ret_cv = Tcl_GetStringFromObj (Tcl_GetObjResult (interp), &i);
+ if (ret_cv)
+ {
+ ret_val = plugin_script_str2ptr (weechat_tcl_plugin,
+ script->name, function,
+ ret_cv);
+ }
+ else
+ ret_val = NULL;
+ }
else if ( ret_type == WEECHAT_SCRIPT_EXEC_INT
&& Tcl_GetIntFromObj (interp, Tcl_GetObjResult (interp), &i) == TCL_OK)
{