diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/CMakeLists.txt | 54 | ||||
-rw-r--r-- | src/plugins/Makefile.am | 32 | ||||
-rw-r--r-- | src/plugins/guile/CMakeLists.txt (renamed from src/plugins/scripts/guile/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | src/plugins/guile/Makefile.am (renamed from src/plugins/scripts/guile/Makefile.am) | 0 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c (renamed from src/plugins/scripts/guile/weechat-guile-api.c) | 821 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile-api.h (renamed from src/plugins/scripts/guile/weechat-guile-api.h) | 0 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile.c (renamed from src/plugins/scripts/guile/weechat-guile.c) | 102 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile.h (renamed from src/plugins/scripts/guile/weechat-guile.h) | 0 | ||||
-rw-r--r-- | src/plugins/lua/CMakeLists.txt (renamed from src/plugins/scripts/lua/CMakeLists.txt) | 4 | ||||
-rw-r--r-- | src/plugins/lua/Makefile.am (renamed from src/plugins/scripts/lua/Makefile.am) | 0 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c (renamed from src/plugins/scripts/lua/weechat-lua-api.c) | 823 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.h (renamed from src/plugins/scripts/lua/weechat-lua-api.h) | 0 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua.c (renamed from src/plugins/scripts/lua/weechat-lua.c) | 100 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua.h (renamed from src/plugins/scripts/lua/weechat-lua.h) | 0 | ||||
-rw-r--r-- | src/plugins/perl/CMakeLists.txt (renamed from src/plugins/scripts/perl/CMakeLists.txt) | 4 | ||||
-rw-r--r-- | src/plugins/perl/Makefile.am (renamed from src/plugins/scripts/perl/Makefile.am) | 0 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c (renamed from src/plugins/scripts/perl/weechat-perl-api.c) | 813 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.h (renamed from src/plugins/scripts/perl/weechat-perl-api.h) | 0 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl.c (renamed from src/plugins/scripts/perl/weechat-perl.c) | 102 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl.h (renamed from src/plugins/scripts/perl/weechat-perl.h) | 0 | ||||
-rw-r--r-- | src/plugins/plugin-script-api.c | 1482 | ||||
-rw-r--r-- | src/plugins/plugin-script-api.h | 359 | ||||
-rw-r--r-- | src/plugins/plugin-script-callback.c (renamed from src/plugins/scripts/script-callback.c) | 48 | ||||
-rw-r--r-- | src/plugins/plugin-script-callback.h (renamed from src/plugins/scripts/script-callback.h) | 22 | ||||
-rw-r--r-- | src/plugins/plugin-script.c (renamed from src/plugins/scripts/script.c) | 313 | ||||
-rw-r--r-- | src/plugins/plugin-script.h (renamed from src/plugins/scripts/script.h) | 139 | ||||
-rw-r--r-- | src/plugins/python/CMakeLists.txt (renamed from src/plugins/scripts/python/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | src/plugins/python/Makefile.am (renamed from src/plugins/scripts/python/Makefile.am) | 0 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c (renamed from src/plugins/scripts/python/weechat-python-api.c) | 813 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.h (renamed from src/plugins/scripts/python/weechat-python-api.h) | 0 | ||||
-rw-r--r-- | src/plugins/python/weechat-python.c (renamed from src/plugins/scripts/python/weechat-python.c) | 102 | ||||
-rw-r--r-- | src/plugins/python/weechat-python.h (renamed from src/plugins/scripts/python/weechat-python.h) | 0 | ||||
-rw-r--r-- | src/plugins/ruby/CMakeLists.txt (renamed from src/plugins/scripts/ruby/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | src/plugins/ruby/Makefile.am (renamed from src/plugins/scripts/ruby/Makefile.am) | 0 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c (renamed from src/plugins/scripts/ruby/weechat-ruby-api.c) | 807 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.h (renamed from src/plugins/scripts/ruby/weechat-ruby-api.h) | 0 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby.c (renamed from src/plugins/scripts/ruby/weechat-ruby.c) | 102 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby.h (renamed from src/plugins/scripts/ruby/weechat-ruby.h) | 0 | ||||
-rw-r--r-- | src/plugins/scripts/CMakeLists.txt | 67 | ||||
-rw-r--r-- | src/plugins/scripts/Makefile.am | 57 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.c | 1479 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.h | 359 | ||||
-rw-r--r-- | src/plugins/tcl/CMakeLists.txt (renamed from src/plugins/scripts/tcl/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | src/plugins/tcl/Makefile.am (renamed from src/plugins/scripts/tcl/Makefile.am) | 0 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c (renamed from src/plugins/scripts/tcl/weechat-tcl-api.c) | 811 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.h (renamed from src/plugins/scripts/tcl/weechat-tcl-api.h) | 0 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl.c (renamed from src/plugins/scripts/tcl/weechat-tcl.c) | 94 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl.h (renamed from src/plugins/scripts/tcl/weechat-tcl.h) | 0 |
48 files changed, 4940 insertions, 4977 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index b7377f563..7e3b84bf4 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -24,9 +24,17 @@ plugin.c plugin.h plugin-api.c plugin-api.h plugin-config.h plugin-config.c) +SET(LIB_PLUGINS_SCRIPTS_SRC +plugin-script.c plugin-script.h +plugin-script-api.c plugin-script-api.h +plugin-script-callback.c plugin-script-callback.h) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) ADD_LIBRARY(weechat_plugins STATIC ${LIB_PLUGINS_SRC}) +ADD_DEFINITIONS(${CMAKE_SHARED_LIBRARY_C_FLAGS}) +ADD_LIBRARY(weechat_plugins_scripts STATIC ${LIB_PLUGINS_SCRIPTS_SRC}) + INCLUDE(CheckIncludeFiles) INCLUDE(CheckFunctionExists) INCLUDE(CheckLibraryExists) @@ -74,12 +82,50 @@ IF(ENABLE_RMODIFIER) ADD_SUBDIRECTORY( rmodifier ) ENDIF(ENABLE_RMODIFIER) -IF(ENABLE_SCRIPTS OR ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_LUA OR ENABLE_TCL OR ENABLE_GUILE) - ADD_SUBDIRECTORY( scripts ) -ENDIF(ENABLE_SCRIPTS OR ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_LUA OR ENABLE_TCL OR ENABLE_GUILE) - IF(ENABLE_XFER) ADD_SUBDIRECTORY( xfer ) ENDIF(ENABLE_XFER) +IF(ENABLE_SCRIPTS AND ENABLE_PERL) + FIND_PACKAGE(Perl) + IF(PERL_FOUND) + ADD_SUBDIRECTORY( perl ) + ENDIF(PERL_FOUND) +ENDIF(ENABLE_SCRIPTS AND ENABLE_PERL) + +IF(ENABLE_SCRIPTS AND ENABLE_PYTHON) + FIND_PACKAGE(Python) + IF(PYTHON_FOUND) + ADD_SUBDIRECTORY( python ) + ENDIF(PYTHON_FOUND) +ENDIF(ENABLE_SCRIPTS AND ENABLE_PYTHON) + +IF(ENABLE_SCRIPTS AND ENABLE_RUBY) + FIND_PACKAGE(Ruby) + IF(RUBY_FOUND) + ADD_SUBDIRECTORY( ruby ) + ENDIF(RUBY_FOUND) +ENDIF(ENABLE_SCRIPTS AND ENABLE_RUBY) + +IF(ENABLE_SCRIPTS AND ENABLE_LUA) + FIND_PACKAGE(Lua) + IF(LUA_FOUND) + ADD_SUBDIRECTORY( lua ) + ENDIF(LUA_FOUND) +ENDIF(ENABLE_SCRIPTS AND ENABLE_LUA) + +IF(ENABLE_SCRIPTS AND ENABLE_TCL) + FIND_PACKAGE(TCL) + IF(TCL_FOUND) + ADD_SUBDIRECTORY( tcl ) + ENDIF(TCL_FOUND) +ENDIF(ENABLE_SCRIPTS AND ENABLE_TCL) + +IF(ENABLE_SCRIPTS AND ENABLE_GUILE) + FIND_PACKAGE(Guile) + IF(GUILE_FOUND) + ADD_SUBDIRECTORY( guile ) + ENDIF(GUILE_FOUND) +ENDIF(ENABLE_SCRIPTS AND ENABLE_GUILE) + INSTALL(FILES weechat-plugin.h DESTINATION ${INCLUDEDIR}) diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 8aa5761d5..977b657e2 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -30,6 +30,15 @@ lib_weechat_plugins_a_SOURCES = weechat-plugin.h \ plugin-config.c \ plugin-config.h +noinst_LTLIBRARIES = lib_weechat_plugins_scripts.la + +lib_weechat_plugins_scripts_la_SOURCES = plugin-script.c \ + plugin-script.h \ + plugin-script-callback.c \ + plugin-script-callback.h \ + plugin-script-api.c \ + plugin-script-api.h + if PLUGIN_ALIAS alias_dir = alias endif @@ -66,37 +75,38 @@ if PLUGIN_RMODIFIER rmodifier_dir = rmodifier endif +if PLUGIN_XFER +xfer_dir = xfer +endif + if PLUGIN_PERL -script_dir = scripts +perl_dir = perl endif if PLUGIN_PYTHON -script_dir = scripts +python_dir = python endif if PLUGIN_RUBY -script_dir = scripts +ruby_dir = ruby endif if PLUGIN_LUA -script_dir = scripts +lua_dir = lua endif if PLUGIN_TCL -script_dir = scripts +tcl_dir = tcl endif if PLUGIN_GUILE -script_dir = scripts -endif - -if PLUGIN_XFER -xfer_dir = xfer +guile_dir = guile endif SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(demo_dir) $(fifo_dir) \ $(irc_dir) $(logger_dir) $(relay_dir) $(rmodifier_dir) \ - $(script_dir) $(xfer_dir) + $(xfer_dir) $(perl_dir) $(python_dir) $(ruby_dir) $(lua_dir) \ + $(tcl_dir) $(guile_dir) EXTRA_DIST = CMakeLists.txt diff --git a/src/plugins/scripts/guile/CMakeLists.txt b/src/plugins/guile/CMakeLists.txt index 2092f4e49..3fb5a481f 100644 --- a/src/plugins/scripts/guile/CMakeLists.txt +++ b/src/plugins/guile/CMakeLists.txt @@ -25,7 +25,7 @@ SET_TARGET_PROPERTIES(guile PROPERTIES PREFIX "") IF(GUILE_FOUND) INCLUDE_DIRECTORIES(${GUILE_INCLUDE_DIRS}) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GUILE_LFLAGS}") - TARGET_LINK_LIBRARIES(guile ${GUILE_LIBRARY} weechat_scripts) + TARGET_LINK_LIBRARIES(guile ${GUILE_LIBRARY} weechat_plugins_scripts) ENDIF(GUILE_FOUND) INSTALL(TARGETS guile LIBRARY DESTINATION ${LIBDIR}/plugins) diff --git a/src/plugins/scripts/guile/Makefile.am b/src/plugins/guile/Makefile.am index 47571527d..47571527d 100644 --- a/src/plugins/scripts/guile/Makefile.am +++ b/src/plugins/guile/Makefile.am diff --git a/src/plugins/scripts/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index f2523ea4e..3f5805b8f 100644 --- a/src/plugins/scripts/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -26,10 +26,10 @@ #include <libguile.h> #include <time.h> -#include "../../weechat-plugin.h" -#include "../script.h" -#include "../script-api.h" -#include "../script-callback.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" +#include "../plugin-script-api.h" +#include "../plugin-script-callback.h" #include "weechat-guile.h" @@ -48,9 +48,12 @@ guile_function_name); \ __ret; \ } +#define API_PTR2STR(__pointer) \ + plugin_script_ptr2str (__pointer) #define API_STR2PTR(__string) \ - script_str2ptr (weechat_guile_plugin, GUILE_CURRENT_SCRIPT_NAME, \ - guile_function_name, __string) + plugin_script_str2ptr (weechat_guile_plugin, \ + GUILE_CURRENT_SCRIPT_NAME, \ + guile_function_name, __string) #define API_RETURN_OK return SCM_BOOL_T; #define API_RETURN_ERROR return SCM_BOOL_F; #define API_RETURN_EMPTY \ @@ -105,8 +108,8 @@ weechat_guile_api_register (SCM name, SCM author, SCM version, SCM license, || !scm_is_string (charset)) API_WRONG_ARGS(API_RETURN_ERROR); - if (script_search (weechat_guile_plugin, guile_scripts, - scm_i_string_chars (name))) + if (plugin_script_search (weechat_guile_plugin, guile_scripts, + scm_i_string_chars (name))) { /* another script already exists with same name */ weechat_printf (NULL, @@ -118,17 +121,17 @@ weechat_guile_api_register (SCM name, SCM author, SCM version, SCM license, } /* register script */ - guile_current_script = script_add (weechat_guile_plugin, - &guile_scripts, &last_guile_script, - (guile_current_script_filename) ? - guile_current_script_filename : "", - scm_i_string_chars (name), - scm_i_string_chars (author), - scm_i_string_chars (version), - scm_i_string_chars (license), - scm_i_string_chars (description), - scm_i_string_chars (shutdown_func), - scm_i_string_chars (charset)); + guile_current_script = plugin_script_add (weechat_guile_plugin, + &guile_scripts, &last_guile_script, + (guile_current_script_filename) ? + guile_current_script_filename : "", + scm_i_string_chars (name), + scm_i_string_chars (author), + scm_i_string_chars (version), + scm_i_string_chars (license), + scm_i_string_chars (description), + scm_i_string_chars (shutdown_func), + scm_i_string_chars (charset)); if (guile_current_script) { guile_registered_script = guile_current_script; @@ -181,7 +184,7 @@ weechat_guile_api_charset_set (SCM charset) if (!scm_is_string (charset)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_charset_set (guile_current_script, scm_i_string_chars (charset)); + plugin_script_api_charset_set (guile_current_script, scm_i_string_chars (charset)); API_RETURN_OK; } @@ -479,7 +482,7 @@ weechat_guile_api_list_new () API_FUNC(1, "list_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_new ()); + result = API_PTR2STR(weechat_list_new ()); API_RETURN_STRING(result); } @@ -498,10 +501,10 @@ weechat_guile_api_list_add (SCM weelist, SCM data, SCM where, SCM user_data) || !scm_is_string (where) || !scm_is_string (user_data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_add (API_STR2PTR(scm_i_string_chars (weelist)), - scm_i_string_chars (data), - scm_i_string_chars (where), - API_STR2PTR(scm_i_string_chars (user_data)))); + result = API_PTR2STR(weechat_list_add (API_STR2PTR(scm_i_string_chars (weelist)), + scm_i_string_chars (data), + scm_i_string_chars (where), + API_STR2PTR(scm_i_string_chars (user_data)))); API_RETURN_STRING(result); } @@ -519,8 +522,8 @@ weechat_guile_api_list_search (SCM weelist, SCM data) if (!scm_is_string (weelist) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_search (API_STR2PTR(scm_i_string_chars (weelist)), - scm_i_string_chars (data))); + result = API_PTR2STR(weechat_list_search (API_STR2PTR(scm_i_string_chars (weelist)), + scm_i_string_chars (data))); API_RETURN_STRING(result); } @@ -557,8 +560,8 @@ weechat_guile_api_list_casesearch (SCM weelist, SCM data) if (!scm_is_string (weelist) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_casesearch (API_STR2PTR(scm_i_string_chars (weelist)), - scm_i_string_chars (data))); + result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(scm_i_string_chars (weelist)), + scm_i_string_chars (data))); API_RETURN_STRING(result); } @@ -596,8 +599,8 @@ weechat_guile_api_list_get (SCM weelist, SCM position) if (!scm_is_string (weelist) || !scm_is_integer (position)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_get (API_STR2PTR(scm_i_string_chars (weelist)), - scm_to_int (position))); + result = API_PTR2STR(weechat_list_get (API_STR2PTR(scm_i_string_chars (weelist)), + scm_to_int (position))); API_RETURN_STRING(result); } @@ -632,7 +635,7 @@ weechat_guile_api_list_next (SCM item) if (!scm_is_string (item)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_next (API_STR2PTR(scm_i_string_chars (item)))); + result = API_PTR2STR(weechat_list_next (API_STR2PTR(scm_i_string_chars (item)))); API_RETURN_STRING(result); } @@ -650,7 +653,7 @@ weechat_guile_api_list_prev (SCM item) if (!scm_is_string (item)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_prev (API_STR2PTR(scm_i_string_chars (item)))); + result = API_PTR2STR(weechat_list_prev (API_STR2PTR(scm_i_string_chars (item)))); API_RETURN_STRING(result); } @@ -758,7 +761,7 @@ weechat_guile_api_config_reload_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); rc = (int *) weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -796,12 +799,12 @@ weechat_guile_api_config_new (SCM name, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_config_new (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (name), - &weechat_guile_api_config_reload_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_config_new (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (name), + &weechat_guile_api_config_reload_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -826,8 +829,8 @@ weechat_guile_api_config_read_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -873,7 +876,7 @@ weechat_guile_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_guile_exec (script_callback->script, @@ -917,7 +920,7 @@ weechat_guile_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_guile_exec (script_callback->script, @@ -963,8 +966,8 @@ weechat_guile_api_config_section_create_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1012,9 +1015,9 @@ weechat_guile_api_config_section_delete_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); - func_argv[3] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); + func_argv[3] = API_PTR2STR(option); rc = (int *) weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1083,27 +1086,27 @@ weechat_guile_api_config_new_section (SCM args) || !scm_is_string (function_delete_option) || !scm_is_string (data_delete_option)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_config_new_section (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (config_file)), - scm_i_string_chars (name), - scm_to_int (user_can_add_options), - scm_to_int (user_can_delete_options), - &weechat_guile_api_config_read_cb, - scm_i_string_chars (function_read), - scm_i_string_chars (data_read), - &weechat_guile_api_config_section_write_cb, - scm_i_string_chars (function_write), - scm_i_string_chars (data_write), - &weechat_guile_api_config_section_write_default_cb, - scm_i_string_chars (function_write_default), - scm_i_string_chars (data_write_default), - &weechat_guile_api_config_section_create_option_cb, - scm_i_string_chars (function_create_option), - scm_i_string_chars (data_create_option), - &weechat_guile_api_config_section_delete_option_cb, - scm_i_string_chars (function_delete_option), - scm_i_string_chars (data_delete_option))); + result = API_PTR2STR(plugin_script_api_config_new_section (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (config_file)), + scm_i_string_chars (name), + scm_to_int (user_can_add_options), + scm_to_int (user_can_delete_options), + &weechat_guile_api_config_read_cb, + scm_i_string_chars (function_read), + scm_i_string_chars (data_read), + &weechat_guile_api_config_section_write_cb, + scm_i_string_chars (function_write), + scm_i_string_chars (data_write), + &weechat_guile_api_config_section_write_default_cb, + scm_i_string_chars (function_write_default), + scm_i_string_chars (data_write_default), + &weechat_guile_api_config_section_create_option_cb, + scm_i_string_chars (function_create_option), + scm_i_string_chars (data_create_option), + &weechat_guile_api_config_section_delete_option_cb, + scm_i_string_chars (function_delete_option), + scm_i_string_chars (data_delete_option))); API_RETURN_STRING_FREE(result); } @@ -1122,8 +1125,8 @@ weechat_guile_api_config_search_section (SCM config_file, SCM section_name) if (!scm_is_string (config_file) || !scm_is_string (section_name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_search_section (API_STR2PTR(scm_i_string_chars (config_file)), - scm_i_string_chars (section_name))); + result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(scm_i_string_chars (config_file)), + scm_i_string_chars (section_name))); API_RETURN_STRING_FREE(result); } @@ -1148,7 +1151,7 @@ weechat_guile_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_guile_exec (script_callback->script, @@ -1190,7 +1193,7 @@ weechat_guile_api_config_option_change_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1223,7 +1226,7 @@ weechat_guile_api_config_option_delete_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1286,28 +1289,28 @@ weechat_guile_api_config_new_option (SCM args) || !scm_is_string (function_delete) || !scm_is_string (data_delete)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_config_new_option (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (config_file)), - API_STR2PTR(scm_i_string_chars (section)), - scm_i_string_chars (name), - scm_i_string_chars (type), - scm_i_string_chars (description), - scm_i_string_chars (string_values), - scm_to_int (min), - scm_to_int (max), - scm_i_string_chars (default_value), - scm_i_string_chars (value), - scm_to_int (null_value_allowed), - &weechat_guile_api_config_option_check_value_cb, - scm_i_string_chars (function_check_value), - scm_i_string_chars (data_check_value), - &weechat_guile_api_config_option_change_cb, - scm_i_string_chars (function_change), - scm_i_string_chars (data_change), - &weechat_guile_api_config_option_delete_cb, - scm_i_string_chars (function_delete), - scm_i_string_chars (data_delete))); + result = API_PTR2STR(plugin_script_api_config_new_option (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (config_file)), + API_STR2PTR(scm_i_string_chars (section)), + scm_i_string_chars (name), + scm_i_string_chars (type), + scm_i_string_chars (description), + scm_i_string_chars (string_values), + scm_to_int (min), + scm_to_int (max), + scm_i_string_chars (default_value), + scm_i_string_chars (value), + scm_to_int (null_value_allowed), + &weechat_guile_api_config_option_check_value_cb, + scm_i_string_chars (function_check_value), + scm_i_string_chars (data_check_value), + &weechat_guile_api_config_option_change_cb, + scm_i_string_chars (function_change), + scm_i_string_chars (data_change), + &weechat_guile_api_config_option_delete_cb, + scm_i_string_chars (function_delete), + scm_i_string_chars (data_delete))); API_RETURN_STRING_FREE(result); } @@ -1329,9 +1332,9 @@ weechat_guile_api_config_search_option (SCM config_file, SCM section, || !scm_is_string (option_name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_search_option (API_STR2PTR(scm_i_string_chars (config_file)), - API_STR2PTR(scm_i_string_chars (section)), - scm_i_string_chars (option_name))); + result = API_PTR2STR(weechat_config_search_option (API_STR2PTR(scm_i_string_chars (config_file)), + API_STR2PTR(scm_i_string_chars (section)), + scm_i_string_chars (option_name))); API_RETURN_STRING_FREE(result); } @@ -1733,9 +1736,9 @@ weechat_guile_api_config_option_free (SCM option) if (!scm_is_string (option)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_option_free (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (option))); + plugin_script_api_config_option_free (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (option))); API_RETURN_OK; } @@ -1752,9 +1755,9 @@ weechat_guile_api_config_section_free_options (SCM section) if (!scm_is_string (section)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free_options (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (section))); + plugin_script_api_config_section_free_options (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (section))); API_RETURN_OK; } @@ -1770,9 +1773,9 @@ weechat_guile_api_config_section_free (SCM section) if (!scm_is_string (section)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (section))); + plugin_script_api_config_section_free (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (section))); API_RETURN_OK; } @@ -1788,9 +1791,9 @@ weechat_guile_api_config_free (SCM config_file) if (!scm_is_string (config_file)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_free (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (config_file))); + plugin_script_api_config_free (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (config_file))); API_RETURN_OK; } @@ -1809,7 +1812,7 @@ weechat_guile_api_config_get (SCM option) if (!scm_is_string (option)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_get (scm_i_string_chars (option))); + result = API_PTR2STR(weechat_config_get (scm_i_string_chars (option))); API_RETURN_STRING_FREE(result); } @@ -1827,9 +1830,9 @@ weechat_guile_api_config_get_plugin (SCM option) if (!scm_is_string (option)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_api_config_get_plugin (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (option)); + result = plugin_script_api_config_get_plugin (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (option)); API_RETURN_STRING(result); } @@ -1847,9 +1850,9 @@ weechat_guile_api_config_is_set_plugin (SCM option) if (!scm_is_string (option)) API_WRONG_ARGS(API_RETURN_INT(0)); - rc = script_api_config_is_set_plugin (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (option)); + rc = plugin_script_api_config_is_set_plugin (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (option)); API_RETURN_INT(rc); } @@ -1867,10 +1870,10 @@ weechat_guile_api_config_set_plugin (SCM option, SCM value) if (!scm_is_string (option) || !scm_is_string (value)) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR)); - rc = script_api_config_set_plugin (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (option), - scm_i_string_chars (value)); + rc = plugin_script_api_config_set_plugin (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (option), + scm_i_string_chars (value)); API_RETURN_INT(rc); } @@ -1886,10 +1889,10 @@ weechat_guile_api_config_set_desc_plugin (SCM option, SCM description) if (!scm_is_string (option) || !scm_is_string (description)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_set_desc_plugin (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (option), - scm_i_string_chars (description)); + plugin_script_api_config_set_desc_plugin (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (option), + scm_i_string_chars (description)); API_RETURN_OK; } @@ -1907,9 +1910,9 @@ weechat_guile_api_config_unset_plugin (SCM option) if (!scm_is_string (option)) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); - rc = script_api_config_unset_plugin (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (option)); + rc = plugin_script_api_config_unset_plugin (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (option)); API_RETURN_INT(rc); } @@ -2005,10 +2008,10 @@ weechat_guile_api_print (SCM buffer, SCM message) if (!scm_is_string (buffer) || !scm_is_string (message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_printf (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (buffer)), - "%s", scm_i_string_chars (message)); + plugin_script_api_printf (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (buffer)), + "%s", scm_i_string_chars (message)); API_RETURN_OK; } @@ -2026,12 +2029,12 @@ weechat_guile_api_print_date_tags (SCM buffer, SCM date, SCM tags, SCM message) || !scm_is_string (tags) || !scm_is_string (message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_printf_date_tags (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (buffer)), - scm_to_int (date), - scm_i_string_chars (tags), - "%s", scm_i_string_chars (message)); + plugin_script_api_printf_date_tags (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (buffer)), + scm_to_int (date), + scm_i_string_chars (tags), + "%s", scm_i_string_chars (message)); API_RETURN_OK; } @@ -2048,11 +2051,11 @@ weechat_guile_api_print_y (SCM buffer, SCM y, SCM message) || !scm_is_string (message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_printf_y (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (buffer)), - scm_to_int (y), - "%s", scm_i_string_chars (message)); + plugin_script_api_printf_y (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (buffer)), + scm_to_int (y), + "%s", scm_i_string_chars (message)); API_RETURN_OK; } @@ -2068,9 +2071,9 @@ weechat_guile_api_log_print (SCM message) if (!scm_is_string (message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_log_printf (weechat_guile_plugin, - guile_current_script, - "%s", scm_i_string_chars (message)); + plugin_script_api_log_printf (weechat_guile_plugin, + guile_current_script, + "%s", scm_i_string_chars (message)); API_RETURN_OK; } @@ -2096,7 +2099,7 @@ weechat_guile_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_guile_exec (script_callback->script, @@ -2139,16 +2142,16 @@ weechat_guile_api_hook_command (SCM command, SCM description, SCM args, || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_ERROR); - result = script_ptr2str (script_api_hook_command (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (command), - scm_i_string_chars (description), - scm_i_string_chars (args), - scm_i_string_chars (args_description), - scm_i_string_chars (completion), - &weechat_guile_api_hook_command_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_command (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (command), + scm_i_string_chars (description), + scm_i_string_chars (args), + scm_i_string_chars (args_description), + scm_i_string_chars (completion), + &weechat_guile_api_hook_command_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2171,7 +2174,7 @@ weechat_guile_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_guile_exec (script_callback->script, @@ -2210,12 +2213,12 @@ weechat_guile_api_hook_command_run (SCM command, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_command_run (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (command), - &weechat_guile_api_hook_command_run_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_command_run (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (command), + &weechat_guile_api_hook_command_run_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2278,14 +2281,14 @@ weechat_guile_api_hook_timer (SCM interval, SCM align_second, SCM max_calls, || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_timer (weechat_guile_plugin, - guile_current_script, - scm_to_int (interval), - scm_to_int (align_second), - scm_to_int (max_calls), - &weechat_guile_api_hook_timer_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_timer (weechat_guile_plugin, + guile_current_script, + scm_to_int (interval), + scm_to_int (align_second), + scm_to_int (max_calls), + &weechat_guile_api_hook_timer_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2347,15 +2350,15 @@ weechat_guile_api_hook_fd (SCM fd, SCM read, SCM write, SCM exception, || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_fd (weechat_guile_plugin, - guile_current_script, - scm_to_int (fd), - scm_to_int (read), - scm_to_int (write), - scm_to_int (exception), - &weechat_guile_api_hook_fd_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_fd (weechat_guile_plugin, + guile_current_script, + scm_to_int (fd), + scm_to_int (read), + scm_to_int (write), + scm_to_int (exception), + &weechat_guile_api_hook_fd_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2419,13 +2422,13 @@ weechat_guile_api_hook_process (SCM command, SCM timeout, SCM function, || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_process (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (command), - scm_to_int (timeout), - &weechat_guile_api_hook_process_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_process (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (command), + scm_to_int (timeout), + &weechat_guile_api_hook_process_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2452,14 +2455,14 @@ weechat_guile_api_hook_process_hashtable (SCM command, SCM options, SCM timeout, c_options = weechat_guile_alist_to_hashtable (options, WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE); - result = script_ptr2str (script_api_hook_process_hashtable (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (command), - c_options, - scm_to_int (timeout), - &weechat_guile_api_hook_process_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (command), + c_options, + scm_to_int (timeout), + &weechat_guile_api_hook_process_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); if (c_options) weechat_hashtable_free (c_options); @@ -2532,21 +2535,21 @@ weechat_guile_api_hook_connect (SCM proxy, SCM address, SCM port, SCM sock, || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_connect (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (proxy), - scm_i_string_chars (address), - scm_to_int (port), - scm_to_int (sock), - scm_to_int (ipv6), - NULL, /* gnutls session */ - NULL, /* gnutls callback */ - 0, /* gnutls DH key size */ - NULL, /* gnutls priorities */ - scm_i_string_chars (local_hostname), - &weechat_guile_api_hook_connect_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_connect (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (proxy), + scm_i_string_chars (address), + scm_to_int (port), + scm_to_int (sock), + scm_to_int (ipv6), + NULL, /* gnutls session */ + NULL, /* gnutls callback */ + 0, /* gnutls DH key size */ + NULL, /* gnutls priorities */ + scm_i_string_chars (local_hostname), + &weechat_guile_api_hook_connect_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2578,7 +2581,7 @@ weechat_guile_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2632,15 +2635,15 @@ weechat_guile_api_hook_print (SCM buffer, SCM tags, SCM message, || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_print (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (buffer)), - scm_i_string_chars (tags), - scm_i_string_chars (message), - scm_to_int (strip_colors), - &weechat_guile_api_hook_print_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_print (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (buffer)), + scm_i_string_chars (tags), + scm_i_string_chars (message), + scm_to_int (strip_colors), + &weechat_guile_api_hook_print_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2678,7 +2681,7 @@ weechat_guile_api_hook_signal_cb (void *data, const char *signal, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = script_ptr2str (signal_data); + func_argv[2] = API_PTR2STR(signal_data); free_needed = 1; } else @@ -2719,12 +2722,12 @@ weechat_guile_api_hook_signal (SCM signal, SCM function, SCM data) if (!scm_is_string (signal) || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_signal (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (signal), - &weechat_guile_api_hook_signal_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_signal (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (signal), + &weechat_guile_api_hook_signal_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2830,12 +2833,12 @@ weechat_guile_api_hook_hsignal (SCM signal, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_hsignal (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (signal), - &weechat_guile_api_hook_hsignal_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_hsignal (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (signal), + &weechat_guile_api_hook_hsignal_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2918,12 +2921,12 @@ weechat_guile_api_hook_config (SCM option, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_config (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (option), - &weechat_guile_api_hook_config_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_config (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (option), + &weechat_guile_api_hook_config_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -2948,8 +2951,8 @@ weechat_guile_api_hook_completion_cb (void *data, const char *completion_item, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = script_ptr2str (buffer); - func_argv[3] = script_ptr2str (completion); + func_argv[2] = API_PTR2STR(buffer); + func_argv[3] = API_PTR2STR(completion); rc = (int *) weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2990,13 +2993,13 @@ weechat_guile_api_hook_completion (SCM completion, SCM description, || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_completion (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (completion), - scm_i_string_chars (description), - &weechat_guile_api_hook_completion_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_completion (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (completion), + scm_i_string_chars (description), + &weechat_guile_api_hook_completion_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -3067,12 +3070,12 @@ weechat_guile_api_hook_modifier (SCM modifier, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_modifier (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (modifier), - &weechat_guile_api_hook_modifier_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_modifier (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (modifier), + &weechat_guile_api_hook_modifier_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -3146,14 +3149,14 @@ weechat_guile_api_hook_info (SCM info_name, SCM description, || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_info (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (info_name), - scm_i_string_chars (description), - scm_i_string_chars (args_description), - &weechat_guile_api_hook_info_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_info (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (info_name), + scm_i_string_chars (description), + scm_i_string_chars (args_description), + &weechat_guile_api_hook_info_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -3206,15 +3209,15 @@ weechat_guile_api_hook_info_hashtable (SCM info_name, SCM description, || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_info_hashtable (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (info_name), - scm_i_string_chars (description), - scm_i_string_chars (args_description), - scm_i_string_chars (output_description), - &weechat_guile_api_hook_info_hashtable_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_info_hashtable (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (info_name), + scm_i_string_chars (description), + scm_i_string_chars (args_description), + scm_i_string_chars (output_description), + &weechat_guile_api_hook_info_hashtable_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -3238,7 +3241,7 @@ weechat_guile_api_hook_infolist_cb (void *data, const char *infolist_name, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = script_ptr2str (pointer); + func_argv[2] = API_PTR2STR(pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_guile_exec (script_callback->script, @@ -3273,15 +3276,15 @@ weechat_guile_api_hook_infolist (SCM infolist_name, SCM description, || !scm_is_string (function) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_infolist (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (infolist_name), - scm_i_string_chars (description), - scm_i_string_chars (pointer_description), - scm_i_string_chars (args_description), - &weechat_guile_api_hook_infolist_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_infolist (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (infolist_name), + scm_i_string_chars (description), + scm_i_string_chars (pointer_description), + scm_i_string_chars (args_description), + &weechat_guile_api_hook_infolist_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -3328,12 +3331,12 @@ weechat_guile_api_hook_focus (SCM area, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_focus (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (area), - &weechat_guile_api_hook_focus_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_hook_focus (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (area), + &weechat_guile_api_hook_focus_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -3349,9 +3352,9 @@ weechat_guile_api_unhook (SCM hook) if (!scm_is_string (hook)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_unhook (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (hook))); + plugin_script_api_unhook (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (hook))); API_RETURN_OK; } @@ -3365,7 +3368,7 @@ weechat_guile_api_unhook_all () { API_FUNC(1, "unhook_all", API_RETURN_ERROR); - script_api_unhook_all (weechat_guile_plugin, guile_current_script); + plugin_script_api_unhook_all (weechat_guile_plugin, guile_current_script); API_RETURN_OK; } @@ -3388,7 +3391,7 @@ weechat_guile_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_guile_exec (script_callback->script, @@ -3429,7 +3432,7 @@ weechat_guile_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); rc = (int *) weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3469,15 +3472,15 @@ weechat_guile_api_buffer_new (SCM name, SCM function_input, SCM data_input, || !scm_is_string (data_close)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_buffer_new (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (name), - &weechat_guile_api_buffer_input_data_cb, - scm_i_string_chars (function_input), - scm_i_string_chars (data_input), - &weechat_guile_api_buffer_close_cb, - scm_i_string_chars (function_close), - scm_i_string_chars (data_close))); + result = API_PTR2STR(plugin_script_api_buffer_new (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (name), + &weechat_guile_api_buffer_input_data_cb, + scm_i_string_chars (function_input), + scm_i_string_chars (data_input), + &weechat_guile_api_buffer_close_cb, + scm_i_string_chars (function_close), + scm_i_string_chars (data_close))); API_RETURN_STRING_FREE(result); } @@ -3496,8 +3499,8 @@ weechat_guile_api_buffer_search (SCM plugin, SCM name) if (!scm_is_string (plugin) || !scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search (scm_i_string_chars (plugin), - scm_i_string_chars (name))); + result = API_PTR2STR(weechat_buffer_search (scm_i_string_chars (plugin), + scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -3514,7 +3517,7 @@ weechat_guile_api_buffer_search_main () API_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search_main ()); + result = API_PTR2STR(weechat_buffer_search_main ()); API_RETURN_STRING_FREE(result); } @@ -3531,7 +3534,7 @@ weechat_guile_api_current_buffer () API_FUNC(1, "current_buffer", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_buffer ()); + result = API_PTR2STR(weechat_current_buffer ()); API_RETURN_STRING_FREE(result); } @@ -3563,9 +3566,9 @@ weechat_guile_api_buffer_close (SCM buffer) if (!scm_is_string (buffer)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_buffer_close (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (buffer))); + plugin_script_api_buffer_close (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (buffer))); API_RETURN_OK; } @@ -3657,8 +3660,8 @@ weechat_guile_api_buffer_get_pointer (SCM buffer, SCM property) if (!scm_is_string (buffer) || !scm_is_string (property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_get_pointer (API_STR2PTR(scm_i_string_chars (buffer)), - scm_i_string_chars (property))); + result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(scm_i_string_chars (buffer)), + scm_i_string_chars (property))); API_RETURN_STRING_FREE(result); } @@ -3735,7 +3738,7 @@ weechat_guile_api_current_window () API_FUNC(1, "current_window", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_window ()); + result = API_PTR2STR(weechat_current_window ()); API_RETURN_STRING_FREE(result); } @@ -3755,7 +3758,7 @@ weechat_guile_api_window_search_with_buffer (SCM buffer) if (!scm_is_string (buffer)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_window_search_with_buffer (API_STR2PTR(scm_i_string_chars (buffer)))); + result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(scm_i_string_chars (buffer)))); API_RETURN_STRING_FREE(result); } @@ -3812,8 +3815,8 @@ weechat_guile_api_window_get_pointer (SCM window, SCM property) if (!scm_is_string (window) || !scm_is_string (property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_window_get_pointer (API_STR2PTR(scm_i_string_chars (window)), - scm_i_string_chars (property))); + result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(scm_i_string_chars (window)), + scm_i_string_chars (property))); API_RETURN_STRING_FREE(result); } @@ -3851,11 +3854,11 @@ weechat_guile_api_nicklist_add_group (SCM buffer, SCM parent_group, SCM name, || !scm_is_integer (visible)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_add_group (API_STR2PTR(scm_i_string_chars (buffer)), - API_STR2PTR(scm_i_string_chars (parent_group)), - scm_i_string_chars (name), - scm_i_string_chars (color), - scm_to_int (visible))); + result = API_PTR2STR(weechat_nicklist_add_group (API_STR2PTR(scm_i_string_chars (buffer)), + API_STR2PTR(scm_i_string_chars (parent_group)), + scm_i_string_chars (name), + scm_i_string_chars (color), + scm_to_int (visible))); API_RETURN_STRING_FREE(result); } @@ -3875,9 +3878,9 @@ weechat_guile_api_nicklist_search_group (SCM buffer, SCM from_group, SCM name) || !scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_search_group (API_STR2PTR(scm_i_string_chars (buffer)), - API_STR2PTR(scm_i_string_chars (from_group)), - scm_i_string_chars (name))); + result = API_PTR2STR(weechat_nicklist_search_group (API_STR2PTR(scm_i_string_chars (buffer)), + API_STR2PTR(scm_i_string_chars (from_group)), + scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -3901,13 +3904,13 @@ weechat_guile_api_nicklist_add_nick (SCM buffer, SCM group, SCM name, || !scm_is_integer (visible)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_add_nick (API_STR2PTR(scm_i_string_chars (buffer)), - API_STR2PTR(scm_i_string_chars (group)), - scm_i_string_chars (name), - scm_i_string_chars (color), - scm_i_string_chars (prefix), - scm_i_string_chars (prefix_color), - scm_to_int (visible))); + result = API_PTR2STR(weechat_nicklist_add_nick (API_STR2PTR(scm_i_string_chars (buffer)), + API_STR2PTR(scm_i_string_chars (group)), + scm_i_string_chars (name), + scm_i_string_chars (color), + scm_i_string_chars (prefix), + scm_i_string_chars (prefix_color), + scm_to_int (visible))); API_RETURN_STRING_FREE(result); } @@ -3927,9 +3930,9 @@ weechat_guile_api_nicklist_search_nick (SCM buffer, SCM from_group, SCM name) || !scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_search_nick (API_STR2PTR(scm_i_string_chars (buffer)), - API_STR2PTR(scm_i_string_chars (from_group)), - scm_i_string_chars (name))); + result = API_PTR2STR(weechat_nicklist_search_nick (API_STR2PTR(scm_i_string_chars (buffer)), + API_STR2PTR(scm_i_string_chars (from_group)), + scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -4044,9 +4047,9 @@ weechat_guile_api_nicklist_group_get_pointer (SCM buffer, SCM group, || !scm_is_string (property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_group_get_pointer (API_STR2PTR(scm_i_string_chars (buffer)), - API_STR2PTR(scm_i_string_chars (group)), - scm_i_string_chars (property))); + result = API_PTR2STR(weechat_nicklist_group_get_pointer (API_STR2PTR(scm_i_string_chars (buffer)), + API_STR2PTR(scm_i_string_chars (group)), + scm_i_string_chars (property))); API_RETURN_STRING_FREE(result); } @@ -4128,9 +4131,9 @@ weechat_guile_api_nicklist_nick_get_pointer (SCM buffer, SCM nick, SCM property) || !scm_is_string (property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_nick_get_pointer (API_STR2PTR(scm_i_string_chars (buffer)), - API_STR2PTR(scm_i_string_chars (nick)), - scm_i_string_chars (property))); + result = API_PTR2STR(weechat_nicklist_nick_get_pointer (API_STR2PTR(scm_i_string_chars (buffer)), + API_STR2PTR(scm_i_string_chars (nick)), + scm_i_string_chars (property))); API_RETURN_STRING_FREE(result); } @@ -4170,7 +4173,7 @@ weechat_guile_api_bar_item_search (SCM name) if (!scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_item_search (scm_i_string_chars (name))); + result = API_PTR2STR(weechat_bar_item_search (scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -4192,8 +4195,8 @@ weechat_guile_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (item); - func_argv[2] = script_ptr2str (window); + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); ret = (char *)weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4226,12 +4229,12 @@ weechat_guile_api_bar_item_new (SCM name, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_bar_item_new (weechat_guile_plugin, - guile_current_script, - scm_i_string_chars (name), - &weechat_guile_api_bar_item_build_cb, - scm_i_string_chars (function), - scm_i_string_chars (data))); + result = API_PTR2STR(plugin_script_api_bar_item_new (weechat_guile_plugin, + guile_current_script, + scm_i_string_chars (name), + &weechat_guile_api_bar_item_build_cb, + scm_i_string_chars (function), + scm_i_string_chars (data))); API_RETURN_STRING_FREE(result); } @@ -4263,9 +4266,9 @@ weechat_guile_api_bar_item_remove (SCM item) if (!scm_is_string (item)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_bar_item_remove (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (item))); + plugin_script_api_bar_item_remove (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (item))); API_RETURN_OK; } @@ -4284,7 +4287,7 @@ weechat_guile_api_bar_search (SCM name) if (!scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_search (scm_i_string_chars (name))); + result = API_PTR2STR(weechat_bar_search (scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -4332,21 +4335,21 @@ weechat_guile_api_bar_new (SCM args) || !scm_is_string (items)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_new (scm_i_string_chars (name), - scm_i_string_chars (hidden), - scm_i_string_chars (priority), - scm_i_string_chars (type), - scm_i_string_chars (conditions), - scm_i_string_chars (position), - scm_i_string_chars (filling_top_bottom), - scm_i_string_chars (filling_left_right), - scm_i_string_chars (size), - scm_i_string_chars (size_max), - scm_i_string_chars (color_fg), - scm_i_string_chars (color_delim), - scm_i_string_chars (color_bg), - scm_i_string_chars (separator), - scm_i_string_chars (items))); + result = API_PTR2STR(weechat_bar_new (scm_i_string_chars (name), + scm_i_string_chars (hidden), + scm_i_string_chars (priority), + scm_i_string_chars (type), + scm_i_string_chars (conditions), + scm_i_string_chars (position), + scm_i_string_chars (filling_top_bottom), + scm_i_string_chars (filling_left_right), + scm_i_string_chars (size), + scm_i_string_chars (size_max), + scm_i_string_chars (color_fg), + scm_i_string_chars (color_delim), + scm_i_string_chars (color_bg), + scm_i_string_chars (separator), + scm_i_string_chars (items))); API_RETURN_STRING_FREE(result); } @@ -4413,10 +4416,10 @@ weechat_guile_api_command (SCM buffer, SCM command) if (!scm_is_string (buffer) || !scm_is_string (command)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_command (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (buffer)), - scm_i_string_chars (command)); + plugin_script_api_command (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (buffer)), + scm_i_string_chars (command)); API_RETURN_OK; } @@ -4481,7 +4484,7 @@ weechat_guile_api_infolist_new () API_FUNC(1, "infolist_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new ()); + result = API_PTR2STR(weechat_infolist_new ()); API_RETURN_STRING_FREE(result); } @@ -4500,7 +4503,7 @@ weechat_guile_api_infolist_new_item (SCM infolist) if (!scm_is_string (infolist)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_item (API_STR2PTR(scm_i_string_chars (infolist)))); + result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(scm_i_string_chars (infolist)))); API_RETURN_STRING_FREE(result); } @@ -4521,9 +4524,9 @@ weechat_guile_api_infolist_new_var_integer (SCM infolist, SCM name, SCM value) || !scm_is_integer (value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_integer (API_STR2PTR(scm_i_string_chars (infolist)), - scm_i_string_chars (name), - scm_to_int (value))); + result = API_PTR2STR(weechat_infolist_new_var_integer (API_STR2PTR(scm_i_string_chars (infolist)), + scm_i_string_chars (name), + scm_to_int (value))); API_RETURN_STRING_FREE(result); } @@ -4544,9 +4547,9 @@ weechat_guile_api_infolist_new_var_string (SCM infolist, SCM name, SCM value) || !scm_is_string (value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_string (API_STR2PTR(scm_i_string_chars (infolist)), - scm_i_string_chars (name), - scm_i_string_chars (value))); + result = API_PTR2STR(weechat_infolist_new_var_string (API_STR2PTR(scm_i_string_chars (infolist)), + scm_i_string_chars (name), + scm_i_string_chars (value))); API_RETURN_STRING_FREE(result); } @@ -4567,9 +4570,9 @@ weechat_guile_api_infolist_new_var_pointer (SCM infolist, SCM name, SCM value) || !scm_is_string (value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_pointer (API_STR2PTR(scm_i_string_chars (infolist)), - scm_i_string_chars (name), - API_STR2PTR(scm_i_string_chars (value)))); + result = API_PTR2STR(weechat_infolist_new_var_pointer (API_STR2PTR(scm_i_string_chars (infolist)), + scm_i_string_chars (name), + API_STR2PTR(scm_i_string_chars (value)))); API_RETURN_STRING_FREE(result); } @@ -4589,9 +4592,9 @@ weechat_guile_api_infolist_new_var_time (SCM infolist, SCM name, SCM value) || !scm_is_integer (value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_time (API_STR2PTR(scm_i_string_chars (infolist)), - scm_i_string_chars (name), - scm_to_int (value))); + result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(scm_i_string_chars (infolist)), + scm_i_string_chars (name), + scm_to_int (value))); API_RETURN_STRING_FREE(result); } @@ -4611,9 +4614,9 @@ weechat_guile_api_infolist_get (SCM name, SCM pointer, SCM arguments) || !scm_is_string (arguments)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_get (scm_i_string_chars (name), - API_STR2PTR(scm_i_string_chars (pointer)), - scm_i_string_chars (arguments))); + result = API_PTR2STR(weechat_infolist_get (scm_i_string_chars (name), + API_STR2PTR(scm_i_string_chars (pointer)), + scm_i_string_chars (arguments))); API_RETURN_STRING_FREE(result); } @@ -4744,8 +4747,8 @@ weechat_guile_api_infolist_pointer (SCM infolist, SCM variable) if (!scm_is_string (infolist) || !scm_is_string (variable)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_pointer (API_STR2PTR(scm_i_string_chars (infolist)), - scm_i_string_chars (variable))); + result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(scm_i_string_chars (infolist)), + scm_i_string_chars (variable))); API_RETURN_STRING_FREE(result); } @@ -4807,7 +4810,7 @@ weechat_guile_api_hdata_get (SCM name) if (!scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_get (scm_i_string_chars (name))); + result = API_PTR2STR(weechat_hdata_get (scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -4929,8 +4932,8 @@ weechat_guile_api_hdata_get_list (SCM hdata, SCM name) if (!scm_is_string (hdata) || !scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_get_list (API_STR2PTR(scm_i_string_chars (hdata)), - scm_i_string_chars (name))); + result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(scm_i_string_chars (hdata)), + scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -5082,9 +5085,9 @@ weechat_guile_api_hdata_pointer (SCM hdata, SCM pointer, SCM name) || !scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_pointer (API_STR2PTR(scm_i_string_chars (hdata)), - API_STR2PTR(scm_i_string_chars (pointer)), - scm_i_string_chars (name))); + result = API_PTR2STR(weechat_hdata_pointer (API_STR2PTR(scm_i_string_chars (hdata)), + API_STR2PTR(scm_i_string_chars (pointer)), + scm_i_string_chars (name))); API_RETURN_STRING_FREE(result); } @@ -5174,8 +5177,8 @@ weechat_guile_api_upgrade_new (SCM filename, SCM write) if (!scm_is_string (filename) || !scm_is_integer (write)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_upgrade_new (scm_i_string_chars (filename), - scm_to_int (write))); + result = API_PTR2STR(weechat_upgrade_new (scm_i_string_chars (filename), + scm_to_int (write))); API_RETURN_STRING_FREE(result); } @@ -5225,9 +5228,9 @@ weechat_guile_api_upgrade_read_cb (void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (upgrade_file); + func_argv[1] = API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = script_ptr2str (infolist); + func_argv[3] = API_PTR2STR(infolist); rc = (int *) weechat_guile_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -5266,12 +5269,12 @@ weechat_guile_api_upgrade_read (SCM upgrade_file, SCM function, SCM data) || !scm_is_string (data)) API_WRONG_ARGS(API_RETURN_INT(0)); - rc = script_api_upgrade_read (weechat_guile_plugin, - guile_current_script, - API_STR2PTR(scm_i_string_chars (upgrade_file)), - &weechat_guile_api_upgrade_read_cb, - scm_i_string_chars (function), - scm_i_string_chars (data)); + rc = plugin_script_api_upgrade_read (weechat_guile_plugin, + guile_current_script, + API_STR2PTR(scm_i_string_chars (upgrade_file)), + &weechat_guile_api_upgrade_read_cb, + scm_i_string_chars (function), + scm_i_string_chars (data)); API_RETURN_INT(rc); } diff --git a/src/plugins/scripts/guile/weechat-guile-api.h b/src/plugins/guile/weechat-guile-api.h index aaad60d54..aaad60d54 100644 --- a/src/plugins/scripts/guile/weechat-guile-api.h +++ b/src/plugins/guile/weechat-guile-api.h diff --git a/src/plugins/scripts/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c index a7dae1afe..704e0c086 100644 --- a/src/plugins/scripts/guile/weechat-guile.c +++ b/src/plugins/guile/weechat-guile.c @@ -29,8 +29,8 @@ #include <unistd.h> #include <libgen.h> -#include "../../weechat-plugin.h" -#include "../script.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" #include "weechat-guile.h" #include "weechat-guile-api.h" @@ -348,9 +348,9 @@ weechat_guile_module_init_script (void *data) /* if script was registered, remove it from list */ if (guile_current_script) { - script_remove (weechat_guile_plugin, - &guile_scripts, &last_guile_script, - guile_current_script); + plugin_script_remove (weechat_guile_plugin, + &guile_scripts, &last_guile_script, + guile_current_script); } guile_current_script = NULL; guile_registered_script = NULL; @@ -406,11 +406,11 @@ weechat_guile_load (const char *filename) * set input/close callbacks for buffers created by this script * (to restore callbacks after upgrade) */ - script_set_buffer_callbacks (weechat_guile_plugin, - guile_scripts, - guile_current_script, - &weechat_guile_api_buffer_input_data_cb, - &weechat_guile_api_buffer_close_cb); + plugin_script_set_buffer_callbacks (weechat_guile_plugin, + guile_scripts, + guile_current_script, + &weechat_guile_api_buffer_input_data_cb, + &weechat_guile_api_buffer_close_cb); return 1; } @@ -459,8 +459,8 @@ weechat_guile_unload (struct t_plugin_script *script) guile_current_script = (guile_current_script->prev_script) ? guile_current_script->prev_script : guile_current_script->next_script; - script_remove (weechat_guile_plugin, &guile_scripts, &last_guile_script, - script); + plugin_script_remove (weechat_guile_plugin, &guile_scripts, &last_guile_script, + script); if (interpreter) weechat_guile_catch (scm_gc_unprotect_object, interpreter); @@ -475,7 +475,7 @@ weechat_guile_unload_name (const char *name) { struct t_plugin_script *ptr_script; - ptr_script = script_search (weechat_guile_plugin, guile_scripts, name); + ptr_script = plugin_script_search (weechat_guile_plugin, guile_scripts, name); if (ptr_script) { weechat_guile_unload (ptr_script); @@ -514,7 +514,7 @@ weechat_guile_reload_name (const char *name) struct t_plugin_script *ptr_script; char *filename; - ptr_script = script_search (weechat_guile_plugin, guile_scripts, name); + ptr_script = plugin_script_search (weechat_guile_plugin, guile_scripts, name); if (ptr_script) { filename = strdup (ptr_script->filename); @@ -553,29 +553,29 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer, if (argc == 1) { - script_display_list (weechat_guile_plugin, guile_scripts, - NULL, 0); + plugin_script_display_list (weechat_guile_plugin, guile_scripts, + NULL, 0); } else if (argc == 2) { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_guile_plugin, guile_scripts, - NULL, 0); + plugin_script_display_list (weechat_guile_plugin, guile_scripts, + NULL, 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_guile_plugin, guile_scripts, - NULL, 1); + plugin_script_display_list (weechat_guile_plugin, guile_scripts, + NULL, 1); } else if (weechat_strcasecmp (argv[1], "autoload") == 0) { - script_auto_load (weechat_guile_plugin, &weechat_guile_load_cb); + plugin_script_auto_load (weechat_guile_plugin, &weechat_guile_load_cb); } else if (weechat_strcasecmp (argv[1], "reload") == 0) { weechat_guile_unload_all (); - script_auto_load (weechat_guile_plugin, &weechat_guile_load_cb); + plugin_script_auto_load (weechat_guile_plugin, &weechat_guile_load_cb); } else if (weechat_strcasecmp (argv[1], "unload") == 0) { @@ -586,19 +586,19 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer, { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_guile_plugin, guile_scripts, - argv_eol[2], 0); + plugin_script_display_list (weechat_guile_plugin, guile_scripts, + argv_eol[2], 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_guile_plugin, guile_scripts, - argv_eol[2], 1); + plugin_script_display_list (weechat_guile_plugin, guile_scripts, + argv_eol[2], 1); } else if (weechat_strcasecmp (argv[1], "load") == 0) { /* load Guile script */ - path_script = script_search_path (weechat_guile_plugin, - argv_eol[2]); + path_script = plugin_script_search_path (weechat_guile_plugin, + argv_eol[2]); weechat_guile_load ((path_script) ? path_script : argv_eol[2]); if (path_script) free (path_script); @@ -651,7 +651,7 @@ weechat_guile_completion_cb (void *data, const char *completion_item, (void) completion_item; (void) buffer; - script_completion (weechat_guile_plugin, completion, guile_scripts); + plugin_script_completion (weechat_guile_plugin, completion, guile_scripts); return WEECHAT_RC_OK; } @@ -672,9 +672,9 @@ weechat_guile_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "guile_script") == 0) { - return script_infolist_list_scripts (weechat_guile_plugin, - guile_scripts, pointer, - arguments); + return plugin_script_infolist_list_scripts (weechat_guile_plugin, + guile_scripts, pointer, + arguments); } return NULL; @@ -697,7 +697,7 @@ weechat_guile_signal_debug_dump_cb (void *data, const char *signal, if (!signal_data || (weechat_strcasecmp ((char *)signal_data, GUILE_PLUGIN_NAME) == 0)) { - script_print_log (weechat_guile_plugin, guile_scripts); + plugin_script_print_log (weechat_guile_plugin, guile_scripts); } return WEECHAT_RC_OK; @@ -719,7 +719,7 @@ weechat_guile_signal_buffer_closed_cb (void *data, const char *signal, (void) type_data; if (signal_data) - script_remove_buffer_callbacks (guile_scripts, signal_data); + plugin_script_remove_buffer_callbacks (guile_scripts, signal_data); return WEECHAT_RC_OK; } @@ -738,18 +738,18 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls) { if (data == &guile_action_install_list) { - script_action_install (weechat_guile_plugin, - guile_scripts, - &weechat_guile_unload, - &weechat_guile_load, - &guile_action_install_list); + plugin_script_action_install (weechat_guile_plugin, + guile_scripts, + &weechat_guile_unload, + &weechat_guile_load, + &guile_action_install_list); } else if (data == &guile_action_remove_list) { - script_action_remove (weechat_guile_plugin, - guile_scripts, - &weechat_guile_unload, - &guile_action_remove_list); + plugin_script_action_remove (weechat_guile_plugin, + guile_scripts, + &weechat_guile_unload, + &guile_action_remove_list); } } @@ -773,16 +773,16 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal, { if (strcmp (signal, "guile_script_install") == 0) { - script_action_add (&guile_action_install_list, - (const char *)signal_data); + plugin_script_action_add (&guile_action_install_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_guile_timer_action_cb, &guile_action_install_list); } else if (strcmp (signal, "guile_script_remove") == 0) { - script_action_add (&guile_action_remove_list, - (const char *)signal_data); + plugin_script_action_add (&guile_action_remove_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_guile_timer_action_cb, &guile_action_remove_list); @@ -877,11 +877,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) init.callback_load_file = &weechat_guile_load_cb; guile_quiet = 1; - script_init (weechat_guile_plugin, argc, argv, &init); + plugin_script_init (weechat_guile_plugin, argc, argv, &init); guile_quiet = 0; - script_display_short_list (weechat_guile_plugin, - guile_scripts); + plugin_script_display_short_list (weechat_guile_plugin, + guile_scripts); /* init ok */ return WEECHAT_RC_OK; @@ -896,7 +896,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) { /* unload all scripts */ guile_quiet = 1; - script_end (plugin, &guile_scripts, &weechat_guile_unload_all); + plugin_script_end (plugin, &guile_scripts, &weechat_guile_unload_all); guile_quiet = 0; /* unprotect module */ diff --git a/src/plugins/scripts/guile/weechat-guile.h b/src/plugins/guile/weechat-guile.h index b868a4c10..b868a4c10 100644 --- a/src/plugins/scripts/guile/weechat-guile.h +++ b/src/plugins/guile/weechat-guile.h diff --git a/src/plugins/scripts/lua/CMakeLists.txt b/src/plugins/lua/CMakeLists.txt index 7981a8ba0..1955b5849 100644 --- a/src/plugins/scripts/lua/CMakeLists.txt +++ b/src/plugins/lua/CMakeLists.txt @@ -26,9 +26,9 @@ SET_TARGET_PROPERTIES(lua PROPERTIES PREFIX "") IF(LUA_FOUND) INCLUDE_DIRECTORIES(${LUA_INCLUDE_PATH} ) IF(LUA_LIBRARY AND LUALIB_LIBRARY) - TARGET_LINK_LIBRARIES(lua ${LUA_LIBRARY} ${LUALIB_LIBRARY} weechat_scripts) + TARGET_LINK_LIBRARIES(lua ${LUA_LIBRARY} ${LUALIB_LIBRARY} weechat_plugins_scripts) ELSE(LUA_LIBRARY AND LUALIB_LIBRARY) - TARGET_LINK_LIBRARIES(lua ${LUA_LIBRARY} weechat_scripts) + TARGET_LINK_LIBRARIES(lua ${LUA_LIBRARY} weechat_plugins_scripts) ENDIF(LUA_LIBRARY AND LUALIB_LIBRARY) ENDIF(LUA_FOUND) diff --git a/src/plugins/scripts/lua/Makefile.am b/src/plugins/lua/Makefile.am index 336c2c33f..336c2c33f 100644 --- a/src/plugins/scripts/lua/Makefile.am +++ b/src/plugins/lua/Makefile.am diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 036de514c..3e7eb89a7 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -31,10 +31,10 @@ #include <string.h> #include <time.h> -#include "../../weechat-plugin.h" -#include "../script.h" -#include "../script-api.h" -#include "../script-callback.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" +#include "../plugin-script-api.h" +#include "../plugin-script-callback.h" #include "weechat-lua.h" @@ -54,9 +54,12 @@ lua_function_name); \ __ret; \ } +#define API_PTR2STR(__pointer) \ + plugin_script_ptr2str (__pointer) #define API_STR2PTR(__string) \ - script_str2ptr (weechat_lua_plugin, LUA_CURRENT_SCRIPT_NAME, \ - lua_function_name, __string) + plugin_script_str2ptr (weechat_lua_plugin, \ + LUA_CURRENT_SCRIPT_NAME, \ + lua_function_name, __string) #define API_RETURN_OK return 1 #define API_RETURN_ERROR return 0 #define API_RETURN_EMPTY \ @@ -117,7 +120,7 @@ weechat_lua_api_register (lua_State *L) shutdown_func = lua_tostring (lua_current_interpreter, -2); charset = lua_tostring (lua_current_interpreter, -1); - if (script_search (weechat_lua_plugin, lua_scripts, name)) + if (plugin_script_search (weechat_lua_plugin, lua_scripts, name)) { /* another script already exists with same name */ weechat_printf (NULL, @@ -129,17 +132,17 @@ weechat_lua_api_register (lua_State *L) } /* register script */ - lua_current_script = script_add (weechat_lua_plugin, - &lua_scripts, &last_lua_script, - (lua_current_script_filename) ? - lua_current_script_filename : "", - name, - author, - version, - license, - description, - shutdown_func, - charset); + lua_current_script = plugin_script_add (weechat_lua_plugin, + &lua_scripts, &last_lua_script, + (lua_current_script_filename) ? + lua_current_script_filename : "", + name, + author, + version, + license, + description, + shutdown_func, + charset); if (lua_current_script) { lua_registered_script = lua_current_script; @@ -195,8 +198,8 @@ weechat_lua_api_charset_set (lua_State *L) charset = lua_tostring (lua_current_interpreter, -1); - script_api_charset_set (lua_current_script, - charset); + plugin_script_api_charset_set (lua_current_script, + charset); API_RETURN_OK; } @@ -537,7 +540,7 @@ weechat_lua_api_list_new (lua_State *L) API_FUNC(1, "list_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_new ()); + result = API_PTR2STR(weechat_list_new ()); API_RETURN_STRING_FREE(result); } @@ -561,10 +564,10 @@ weechat_lua_api_list_add (lua_State *L) where = lua_tostring (lua_current_interpreter, -2); user_data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_list_add (API_STR2PTR(weelist), - data, - where, - API_STR2PTR(user_data))); + result = API_PTR2STR(weechat_list_add (API_STR2PTR(weelist), + data, + where, + API_STR2PTR(user_data))); API_RETURN_STRING_FREE(result); } @@ -586,8 +589,8 @@ weechat_lua_api_list_search (lua_State *L) weelist = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_list_search (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -631,8 +634,8 @@ weechat_lua_api_list_casesearch (lua_State *L) weelist = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_list_casesearch (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -678,8 +681,8 @@ weechat_lua_api_list_get (lua_State *L) weelist = lua_tostring (lua_current_interpreter, -2); position = lua_tonumber (lua_current_interpreter, -1); - result = script_ptr2str (weechat_list_get (API_STR2PTR(weelist), - position)); + result = API_PTR2STR(weechat_list_get (API_STR2PTR(weelist), + position)); API_RETURN_STRING_FREE(result); } @@ -722,7 +725,7 @@ weechat_lua_api_list_next (lua_State *L) item = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_list_next (API_STR2PTR(item))); + result = API_PTR2STR(weechat_list_next (API_STR2PTR(item))); API_RETURN_STRING_FREE(result); } @@ -743,7 +746,7 @@ weechat_lua_api_list_prev (lua_State *L) item = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_list_prev (API_STR2PTR(item))); + result = API_PTR2STR(weechat_list_prev (API_STR2PTR(item))); API_RETURN_STRING_FREE(result); } @@ -869,7 +872,7 @@ weechat_lua_api_config_reload_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -910,12 +913,12 @@ weechat_lua_api_config_new (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_config_new (weechat_lua_plugin, - lua_current_script, - name, - &weechat_lua_api_config_reload_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_config_new (weechat_lua_plugin, + lua_current_script, + name, + &weechat_lua_api_config_reload_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -940,8 +943,8 @@ weechat_lua_api_config_read_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -987,7 +990,7 @@ weechat_lua_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_lua_exec (script_callback->script, @@ -1031,7 +1034,7 @@ weechat_lua_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_lua_exec (script_callback->script, @@ -1076,8 +1079,8 @@ weechat_lua_api_config_section_create_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1124,9 +1127,9 @@ weechat_lua_api_config_section_delete_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); - func_argv[3] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); + func_argv[3] = API_PTR2STR(option); rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1187,27 +1190,27 @@ weechat_lua_api_config_new_section (lua_State *L) function_delete_option = lua_tostring (lua_current_interpreter, -2); data_delete_option = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_config_new_section (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(config_file), - name, - user_can_add_options, - user_can_delete_options, - &weechat_lua_api_config_read_cb, - function_read, - data_read, - &weechat_lua_api_config_section_write_cb, - function_write, - data_write, - &weechat_lua_api_config_section_write_default_cb, - function_write_default, - data_write_default, - &weechat_lua_api_config_section_create_option_cb, - function_create_option, - data_create_option, - &weechat_lua_api_config_section_delete_option_cb, - function_delete_option, - data_delete_option)); + result = API_PTR2STR(plugin_script_api_config_new_section (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(config_file), + name, + user_can_add_options, + user_can_delete_options, + &weechat_lua_api_config_read_cb, + function_read, + data_read, + &weechat_lua_api_config_section_write_cb, + function_write, + data_write, + &weechat_lua_api_config_section_write_default_cb, + function_write_default, + data_write_default, + &weechat_lua_api_config_section_create_option_cb, + function_create_option, + data_create_option, + &weechat_lua_api_config_section_delete_option_cb, + function_delete_option, + data_delete_option)); API_RETURN_STRING_FREE(result); } @@ -1229,8 +1232,8 @@ weechat_lua_api_config_search_section (lua_State *L) config_file = lua_tostring (lua_current_interpreter, -2); section_name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_config_search_section (API_STR2PTR(config_file), - section_name)); + result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), + section_name)); API_RETURN_STRING_FREE(result); } @@ -1255,7 +1258,7 @@ weechat_lua_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_lua_exec (script_callback->script, @@ -1297,7 +1300,7 @@ weechat_lua_api_config_option_change_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1330,7 +1333,7 @@ weechat_lua_api_config_option_delete_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1381,28 +1384,28 @@ weechat_lua_api_config_new_option (lua_State *L) function_delete = lua_tostring (lua_current_interpreter, -2); data_delete = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_config_new_option (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(config_file), - API_STR2PTR(section), - name, - type, - description, - string_values, - min, - max, - default_value, - value, - null_value_allowed, - &weechat_lua_api_config_option_check_value_cb, - function_check_value, - data_check_value, - &weechat_lua_api_config_option_change_cb, - function_change, - data_change, - &weechat_lua_api_config_option_delete_cb, - function_delete, - data_delete)); + result = API_PTR2STR(plugin_script_api_config_new_option (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(config_file), + API_STR2PTR(section), + name, + type, + description, + string_values, + min, + max, + default_value, + value, + null_value_allowed, + &weechat_lua_api_config_option_check_value_cb, + function_check_value, + data_check_value, + &weechat_lua_api_config_option_change_cb, + function_change, + data_change, + &weechat_lua_api_config_option_delete_cb, + function_delete, + data_delete)); API_RETURN_STRING_FREE(result); } @@ -1425,9 +1428,9 @@ weechat_lua_api_config_search_option (lua_State *L) section = lua_tostring (lua_current_interpreter, -2); option_name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_config_search_option (API_STR2PTR(config_file), - API_STR2PTR(section), - option_name)); + result = API_PTR2STR(weechat_config_search_option (API_STR2PTR(config_file), + API_STR2PTR(section), + option_name)); API_RETURN_STRING_FREE(result); } @@ -1900,9 +1903,9 @@ weechat_lua_api_config_option_free (lua_State *L) option = lua_tostring (lua_current_interpreter, -1); - script_api_config_option_free (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(option)); + plugin_script_api_config_option_free (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(option)); API_RETURN_OK; } @@ -1923,9 +1926,9 @@ weechat_lua_api_config_section_free_options (lua_State *L) section = lua_tostring (lua_current_interpreter, -1); - script_api_config_section_free_options (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(section)); + plugin_script_api_config_section_free_options (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(section)); API_RETURN_OK; } @@ -1945,9 +1948,9 @@ weechat_lua_api_config_section_free (lua_State *L) section = lua_tostring (lua_current_interpreter, -1); - script_api_config_section_free (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(section)); + plugin_script_api_config_section_free (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(section)); API_RETURN_OK; } @@ -1967,9 +1970,9 @@ weechat_lua_api_config_free (lua_State *L) config_file = lua_tostring (lua_current_interpreter, -1); - script_api_config_free (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(config_file)); + plugin_script_api_config_free (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(config_file)); API_RETURN_OK; } @@ -1990,7 +1993,7 @@ weechat_lua_api_config_get (lua_State *L) option = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_config_get (option)); + result = API_PTR2STR(weechat_config_get (option)); API_RETURN_STRING_FREE(result); } @@ -2010,9 +2013,9 @@ weechat_lua_api_config_get_plugin (lua_State *L) option = lua_tostring (lua_current_interpreter, -1); - result = script_api_config_get_plugin (weechat_lua_plugin, - lua_current_script, - option); + result = plugin_script_api_config_get_plugin (weechat_lua_plugin, + lua_current_script, + option); API_RETURN_STRING(result); } @@ -2033,9 +2036,9 @@ weechat_lua_api_config_is_set_plugin (lua_State *L) option = lua_tostring (lua_current_interpreter, -1); - rc = script_api_config_is_set_plugin (weechat_lua_plugin, - lua_current_script, - option); + rc = plugin_script_api_config_is_set_plugin (weechat_lua_plugin, + lua_current_script, + option); API_RETURN_INT(rc); } @@ -2057,10 +2060,10 @@ weechat_lua_api_config_set_plugin (lua_State *L) option = lua_tostring (lua_current_interpreter, -2); value = lua_tostring (lua_current_interpreter, -1); - rc = script_api_config_set_plugin (weechat_lua_plugin, - lua_current_script, - option, - value); + rc = plugin_script_api_config_set_plugin (weechat_lua_plugin, + lua_current_script, + option, + value); API_RETURN_INT(rc); } @@ -2081,10 +2084,10 @@ weechat_lua_api_config_set_desc_plugin (lua_State *L) option = lua_tostring (lua_current_interpreter, -2); description = lua_tostring (lua_current_interpreter, -1); - script_api_config_set_desc_plugin (weechat_lua_plugin, - lua_current_script, - option, - description); + plugin_script_api_config_set_desc_plugin (weechat_lua_plugin, + lua_current_script, + option, + description); API_RETURN_OK; } @@ -2105,9 +2108,9 @@ weechat_lua_api_config_unset_plugin (lua_State *L) option = lua_tostring (lua_current_interpreter, -1); - rc = script_api_config_unset_plugin (weechat_lua_plugin, - lua_current_script, - option); + rc = plugin_script_api_config_unset_plugin (weechat_lua_plugin, + lua_current_script, + option); API_RETURN_INT(rc); } @@ -2217,10 +2220,10 @@ weechat_lua_api_print (lua_State *L) buffer = lua_tostring (lua_current_interpreter, -2); message = lua_tostring (lua_current_interpreter, -1); - script_api_printf (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(buffer), - "%s", message); + plugin_script_api_printf (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(buffer), + "%s", message); API_RETURN_OK; } @@ -2245,12 +2248,12 @@ weechat_lua_api_print_date_tags (lua_State *L) tags = lua_tostring (lua_current_interpreter, -2); message = lua_tostring (lua_current_interpreter, -1); - script_api_printf_date_tags (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(buffer), - date, - tags, - "%s", message); + plugin_script_api_printf_date_tags (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(buffer), + date, + tags, + "%s", message); API_RETURN_OK; } @@ -2273,11 +2276,11 @@ weechat_lua_api_print_y (lua_State *L) y = lua_tonumber (lua_current_interpreter, -2); message = lua_tostring (lua_current_interpreter, -1); - script_api_printf_y (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(buffer), - y, - "%s", message); + plugin_script_api_printf_y (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(buffer), + y, + "%s", message); API_RETURN_OK; } @@ -2297,9 +2300,9 @@ weechat_lua_api_log_print (lua_State *L) message = lua_tostring (lua_current_interpreter, -1); - script_api_log_printf (weechat_lua_plugin, - lua_current_script, - "%s", message); + plugin_script_api_log_printf (weechat_lua_plugin, + lua_current_script, + "%s", message); API_RETURN_OK; } @@ -2325,7 +2328,7 @@ weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_lua_exec (script_callback->script, @@ -2372,16 +2375,16 @@ weechat_lua_api_hook_command (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_command (weechat_lua_plugin, - lua_current_script, - command, - description, - args, - args_description, - completion, - &weechat_lua_api_hook_command_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command (weechat_lua_plugin, + lua_current_script, + command, + description, + args, + args_description, + completion, + &weechat_lua_api_hook_command_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2404,7 +2407,7 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_lua_exec (script_callback->script, @@ -2446,12 +2449,12 @@ weechat_lua_api_hook_command_run (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_command_run (weechat_lua_plugin, - lua_current_script, - command, - &weechat_lua_api_hook_command_run_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command_run (weechat_lua_plugin, + lua_current_script, + command, + &weechat_lua_api_hook_command_run_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2518,14 +2521,14 @@ weechat_lua_api_hook_timer (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_timer (weechat_lua_plugin, - lua_current_script, - interval, - align_second, - max_calls, - &weechat_lua_api_hook_timer_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_timer (weechat_lua_plugin, + lua_current_script, + interval, + align_second, + max_calls, + &weechat_lua_api_hook_timer_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2592,15 +2595,15 @@ weechat_lua_api_hook_fd (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_fd (weechat_lua_plugin, - lua_current_script, - fd, - read, - write, - exception, - &weechat_lua_api_hook_fd_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_fd (weechat_lua_plugin, + lua_current_script, + fd, + read, + write, + exception, + &weechat_lua_api_hook_fd_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2668,13 +2671,13 @@ weechat_lua_api_hook_process (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_process (weechat_lua_plugin, - lua_current_script, - command, - timeout, - &weechat_lua_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process (weechat_lua_plugin, + lua_current_script, + command, + timeout, + &weechat_lua_api_hook_process_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2703,14 +2706,14 @@ weechat_lua_api_hook_process_hashtable (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_process_hashtable (weechat_lua_plugin, - lua_current_script, - command, - options, - timeout, - &weechat_lua_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_lua_plugin, + lua_current_script, + command, + options, + timeout, + &weechat_lua_api_hook_process_cb, + function, + data)); if (options) weechat_hashtable_free (options); @@ -2788,21 +2791,21 @@ weechat_lua_api_hook_connect (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_connect (weechat_lua_plugin, - lua_current_script, - proxy, - address, - port, - sock, - ipv6, - NULL, /* gnutls session */ - NULL, /* gnutls callback */ - 0, /* gnutls DH key size */ - NULL, /* gnutls priorities */ - local_hostname, - &weechat_lua_api_hook_connect_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_connect (weechat_lua_plugin, + lua_current_script, + proxy, + address, + port, + sock, + ipv6, + NULL, /* gnutls session */ + NULL, /* gnutls callback */ + 0, /* gnutls DH key size */ + NULL, /* gnutls priorities */ + local_hostname, + &weechat_lua_api_hook_connect_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2834,7 +2837,7 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2893,15 +2896,15 @@ weechat_lua_api_hook_print (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_print (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(buffer), - tags, - message, - strip_colors, - &weechat_lua_api_hook_print_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_print (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(buffer), + tags, + message, + strip_colors, + &weechat_lua_api_hook_print_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2939,7 +2942,7 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal, } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = script_ptr2str (signal_data); + func_argv[2] = API_PTR2STR(signal_data); free_needed = 1; } else @@ -2984,12 +2987,12 @@ weechat_lua_api_hook_signal (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_signal (weechat_lua_plugin, - lua_current_script, - signal, - &weechat_lua_api_hook_signal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_signal (weechat_lua_plugin, + lua_current_script, + signal, + &weechat_lua_api_hook_signal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3094,12 +3097,12 @@ weechat_lua_api_hook_hsignal (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_hsignal (weechat_lua_plugin, - lua_current_script, - signal, - &weechat_lua_api_hook_hsignal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_hsignal (weechat_lua_plugin, + lua_current_script, + signal, + &weechat_lua_api_hook_hsignal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3188,12 +3191,12 @@ weechat_lua_api_hook_config (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_config (weechat_lua_plugin, - lua_current_script, - option, - &weechat_lua_api_hook_config_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_config (weechat_lua_plugin, + lua_current_script, + option, + &weechat_lua_api_hook_config_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3218,8 +3221,8 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = script_ptr2str (buffer); - func_argv[3] = script_ptr2str (completion); + func_argv[2] = API_PTR2STR(buffer); + func_argv[3] = API_PTR2STR(completion); rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3263,13 +3266,13 @@ weechat_lua_api_hook_completion (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_completion (weechat_lua_plugin, - lua_current_script, - completion, - description, - &weechat_lua_api_hook_completion_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_completion (weechat_lua_plugin, + lua_current_script, + completion, + description, + &weechat_lua_api_hook_completion_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3350,12 +3353,12 @@ weechat_lua_api_hook_modifier (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_modifier (weechat_lua_plugin, - lua_current_script, - modifier, - &weechat_lua_api_hook_modifier_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_modifier (weechat_lua_plugin, + lua_current_script, + modifier, + &weechat_lua_api_hook_modifier_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3432,14 +3435,14 @@ weechat_lua_api_hook_info (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_info (weechat_lua_plugin, - lua_current_script, - info_name, - description, - args_description, - &weechat_lua_api_hook_info_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info (weechat_lua_plugin, + lua_current_script, + info_name, + description, + args_description, + &weechat_lua_api_hook_info_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3495,15 +3498,15 @@ weechat_lua_api_hook_info_hashtable (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_info_hashtable (weechat_lua_plugin, - lua_current_script, - info_name, - description, - args_description, - output_description, - &weechat_lua_api_hook_info_hashtable_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info_hashtable (weechat_lua_plugin, + lua_current_script, + info_name, + description, + args_description, + output_description, + &weechat_lua_api_hook_info_hashtable_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3527,7 +3530,7 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (info_name) ? (char *)info_name : empty_arg; - func_argv[2] = script_ptr2str (pointer); + func_argv[2] = API_PTR2STR(pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_lua_exec (script_callback->script, @@ -3566,15 +3569,15 @@ weechat_lua_api_hook_infolist (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_infolist (weechat_lua_plugin, - lua_current_script, - infolist_name, - description, - pointer_description, - args_description, - &weechat_lua_api_hook_infolist_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_infolist (weechat_lua_plugin, + lua_current_script, + infolist_name, + description, + pointer_description, + args_description, + &weechat_lua_api_hook_infolist_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3625,12 +3628,12 @@ weechat_lua_api_hook_focus (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_hook_focus (weechat_lua_plugin, - lua_current_script, - area, - &weechat_lua_api_hook_focus_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_focus (weechat_lua_plugin, + lua_current_script, + area, + &weechat_lua_api_hook_focus_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3650,9 +3653,9 @@ weechat_lua_api_unhook (lua_State *L) hook = lua_tostring (lua_current_interpreter, -1); - script_api_unhook (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(hook)); + plugin_script_api_unhook (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(hook)); API_RETURN_OK; } @@ -3666,7 +3669,7 @@ weechat_lua_api_unhook_all (lua_State *L) { API_FUNC(1, "unhook_all", API_RETURN_ERROR); - script_api_unhook_all (weechat_lua_plugin, lua_current_script); + plugin_script_api_unhook_all (weechat_lua_plugin, lua_current_script); API_RETURN_OK; } @@ -3689,7 +3692,7 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3730,7 +3733,7 @@ weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3774,15 +3777,15 @@ weechat_lua_api_buffer_new (lua_State *L) function_close = lua_tostring (lua_current_interpreter, -2); data_close = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_buffer_new (weechat_lua_plugin, - lua_current_script, - name, - &weechat_lua_api_buffer_input_data_cb, - function_input, - data_input, - &weechat_lua_api_buffer_close_cb, - function_close, - data_close)); + result = API_PTR2STR(plugin_script_api_buffer_new (weechat_lua_plugin, + lua_current_script, + name, + &weechat_lua_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_lua_api_buffer_close_cb, + function_close, + data_close)); API_RETURN_STRING_FREE(result); } @@ -3804,7 +3807,7 @@ weechat_lua_api_buffer_search (lua_State *L) plugin = lua_tostring (lua_current_interpreter, -2); name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_buffer_search (plugin, name)); + result = API_PTR2STR(weechat_buffer_search (plugin, name)); API_RETURN_STRING_FREE(result); } @@ -3820,7 +3823,7 @@ weechat_lua_api_buffer_search_main (lua_State *L) API_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search_main ()); + result = API_PTR2STR(weechat_buffer_search_main ()); API_RETURN_STRING_FREE(result); } @@ -3836,7 +3839,7 @@ weechat_lua_api_current_buffer (lua_State *L) API_FUNC(1, "current_buffer", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_buffer ()); + result = API_PTR2STR(weechat_current_buffer ()); API_RETURN_STRING_FREE(result); } @@ -3876,9 +3879,9 @@ weechat_lua_api_buffer_close (lua_State *L) buffer = lua_tostring (lua_current_interpreter, -1); - script_api_buffer_close (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(buffer)); + plugin_script_api_buffer_close (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(buffer)); API_RETURN_OK; } @@ -3990,8 +3993,8 @@ weechat_lua_api_buffer_get_pointer (lua_State *L) buffer = lua_tostring (lua_current_interpreter, -2); property = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_buffer_get_pointer (API_STR2PTR(buffer), - property)); + result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), + property)); API_RETURN_STRING_FREE(result); } @@ -4075,7 +4078,7 @@ weechat_lua_api_current_window (lua_State *L) API_FUNC(1, "current_window", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_window ()); + result = API_PTR2STR(weechat_current_window ()); API_RETURN_STRING_FREE(result); } @@ -4097,7 +4100,7 @@ weechat_lua_api_window_search_with_buffer (lua_State *L) buffer = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_window_search_with_buffer (API_STR2PTR(buffer))); + result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(buffer))); API_RETURN_STRING_FREE(result); } @@ -4164,8 +4167,8 @@ weechat_lua_api_window_get_pointer (lua_State *L) window = lua_tostring (lua_current_interpreter, -2); property = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_window_get_pointer (API_STR2PTR(window), - property)); + result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), + property)); API_RETURN_STRING_FREE(result); } @@ -4211,11 +4214,11 @@ weechat_lua_api_nicklist_add_group (lua_State *L) color = lua_tostring (lua_current_interpreter, -2); visible = lua_tonumber (lua_current_interpreter, -1); - result = script_ptr2str (weechat_nicklist_add_group (API_STR2PTR(buffer), - API_STR2PTR(parent_group), - name, - color, - visible)); + result = API_PTR2STR(weechat_nicklist_add_group (API_STR2PTR(buffer), + API_STR2PTR(parent_group), + name, + color, + visible)); API_RETURN_STRING_FREE(result); } @@ -4238,9 +4241,9 @@ weechat_lua_api_nicklist_search_group (lua_State *L) from_group = lua_tostring (lua_current_interpreter, -2); name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_nicklist_search_group (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_group (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4268,13 +4271,13 @@ weechat_lua_api_nicklist_add_nick (lua_State *L) prefix_color = lua_tostring (lua_current_interpreter, -2); visible = lua_tonumber (lua_current_interpreter, -1); - result = script_ptr2str (weechat_nicklist_add_nick (API_STR2PTR(buffer), - API_STR2PTR(group), - name, - color, - prefix, - prefix_color, - visible)); + result = API_PTR2STR(weechat_nicklist_add_nick (API_STR2PTR(buffer), + API_STR2PTR(group), + name, + color, + prefix, + prefix_color, + visible)); API_RETURN_STRING_FREE(result); } @@ -4297,9 +4300,9 @@ weechat_lua_api_nicklist_search_nick (lua_State *L) from_group = lua_tostring (lua_current_interpreter, -2); name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_nicklist_search_nick (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_nick (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4435,9 +4438,9 @@ weechat_lua_api_nicklist_group_get_pointer (lua_State *L) group = lua_tostring (lua_current_interpreter, -2); property = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(group), - property)); + result = API_PTR2STR(weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(group), + property)); API_RETURN_STRING_FREE(result); } @@ -4535,9 +4538,9 @@ weechat_lua_api_nicklist_nick_get_pointer (lua_State *L) nick = lua_tostring (lua_current_interpreter, -2); property = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(nick), - property)); + result = API_PTR2STR(weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(nick), + property)); API_RETURN_STRING_FREE(result); } @@ -4584,7 +4587,7 @@ weechat_lua_api_bar_item_search (lua_State *L) name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_bar_item_search (name)); + result = API_PTR2STR(weechat_bar_item_search (name)); API_RETURN_STRING_FREE(result); } @@ -4606,8 +4609,8 @@ weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (item); - func_argv[2] = script_ptr2str (window); + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); ret = (char *)weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4643,12 +4646,12 @@ weechat_lua_api_bar_item_new (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (script_api_bar_item_new (weechat_lua_plugin, - lua_current_script, - name, - &weechat_lua_api_bar_item_build_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_bar_item_new (weechat_lua_plugin, + lua_current_script, + name, + &weechat_lua_api_bar_item_build_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -4688,9 +4691,9 @@ weechat_lua_api_bar_item_remove (lua_State *L) item = lua_tostring (lua_current_interpreter, -1); - script_api_bar_item_remove (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(item)); + plugin_script_api_bar_item_remove (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(item)); API_RETURN_OK; } @@ -4711,7 +4714,7 @@ weechat_lua_api_bar_search (lua_State *L) name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_bar_search (name)); + result = API_PTR2STR(weechat_bar_search (name)); API_RETURN_STRING_FREE(result); } @@ -4748,21 +4751,21 @@ weechat_lua_api_bar_new (lua_State *L) separator = lua_tostring (lua_current_interpreter, -2); items = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_bar_new (name, - hidden, - priority, - type, - conditions, - position, - filling_top_bottom, - filling_left_right, - size, - size_max, - color_fg, - color_delim, - color_bg, - separator, - items)); + result = API_PTR2STR(weechat_bar_new (name, + hidden, + priority, + type, + conditions, + position, + filling_top_bottom, + filling_left_right, + size, + size_max, + color_fg, + color_delim, + color_bg, + separator, + items)); API_RETURN_STRING_FREE(result); } @@ -4847,10 +4850,10 @@ weechat_lua_api_command (lua_State *L) buffer = lua_tostring (lua_current_interpreter, -2); command = lua_tostring (lua_current_interpreter, -1); - script_api_command (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(buffer), - command); + plugin_script_api_command (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(buffer), + command); API_RETURN_OK; } @@ -4917,7 +4920,7 @@ weechat_lua_api_infolist_new (lua_State *L) API_FUNC(1, "infolist_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new ()); + result = API_PTR2STR(weechat_infolist_new ()); API_RETURN_STRING_FREE(result); } @@ -4938,7 +4941,7 @@ weechat_lua_api_infolist_new_item (lua_State *L) infolist = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_infolist_new_item (API_STR2PTR(infolist))); + result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(infolist))); API_RETURN_STRING_FREE(result); } @@ -4963,9 +4966,9 @@ weechat_lua_api_infolist_new_var_integer (lua_State *L) name = lua_tostring (lua_current_interpreter, -2); value = lua_tonumber (lua_current_interpreter, -1); - result = script_ptr2str (weechat_infolist_new_var_integer (API_STR2PTR(infolist), - name, - value)); + result = API_PTR2STR(weechat_infolist_new_var_integer (API_STR2PTR(infolist), + name, + value)); API_RETURN_STRING_FREE(result); } @@ -4989,9 +4992,9 @@ weechat_lua_api_infolist_new_var_string (lua_State *L) name = lua_tostring (lua_current_interpreter, -2); value = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_infolist_new_var_string (API_STR2PTR(infolist), - name, - value)); + result = API_PTR2STR(weechat_infolist_new_var_string (API_STR2PTR(infolist), + name, + value)); API_RETURN_STRING_FREE(result); } @@ -5015,9 +5018,9 @@ weechat_lua_api_infolist_new_var_pointer (lua_State *L) name = lua_tostring (lua_current_interpreter, -2); value = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_infolist_new_var_pointer (API_STR2PTR(infolist), - name, - API_STR2PTR(value))); + result = API_PTR2STR(weechat_infolist_new_var_pointer (API_STR2PTR(infolist), + name, + API_STR2PTR(value))); API_RETURN_STRING_FREE(result); } @@ -5041,9 +5044,9 @@ weechat_lua_api_infolist_new_var_time (lua_State *L) name = lua_tostring (lua_current_interpreter, -2); value = lua_tonumber (lua_current_interpreter, -1); - result = script_ptr2str (weechat_infolist_new_var_time (API_STR2PTR(infolist), - name, - value)); + result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(infolist), + name, + value)); API_RETURN_STRING_FREE(result); } @@ -5066,9 +5069,9 @@ weechat_lua_api_infolist_get (lua_State *L) pointer = lua_tostring (lua_current_interpreter, -2); arguments = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_infolist_get (name, - API_STR2PTR(pointer), - arguments)); + result = API_PTR2STR(weechat_infolist_get (name, + API_STR2PTR(pointer), + arguments)); API_RETURN_STRING_FREE(result); } @@ -5218,8 +5221,8 @@ weechat_lua_api_infolist_pointer (lua_State *L) infolist = lua_tostring (lua_current_interpreter, -2); variable = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_infolist_pointer (API_STR2PTR(infolist), - variable)); + result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), + variable)); API_RETURN_STRING_FREE(result); } @@ -5290,7 +5293,7 @@ weechat_lua_api_hdata_get (lua_State *L) name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_hdata_get (name)); + result = API_PTR2STR(weechat_hdata_get (name)); API_RETURN_STRING_FREE(result); } @@ -5428,8 +5431,8 @@ weechat_lua_api_hdata_get_list (lua_State *L) hdata = lua_tostring (lua_current_interpreter, -2); name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_hdata_get_list (API_STR2PTR(hdata), - name)); + result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), + name)); API_RETURN_STRING_FREE(result); } @@ -5478,9 +5481,9 @@ weechat_lua_api_hdata_move (lua_State *L) pointer = lua_tostring (lua_current_interpreter, -2); count = lua_tonumber (lua_current_interpreter, -1); - result = script_ptr2str (weechat_hdata_move (API_STR2PTR(hdata), - API_STR2PTR(pointer), - count)); + result = API_PTR2STR(weechat_hdata_move (API_STR2PTR(hdata), + API_STR2PTR(pointer), + count)); API_RETURN_STRING_FREE(result); } @@ -5607,9 +5610,9 @@ weechat_lua_api_hdata_pointer (lua_State *L) pointer = lua_tostring (lua_current_interpreter, -2); name = lua_tostring (lua_current_interpreter, -1); - result = script_ptr2str (weechat_hdata_pointer (API_STR2PTR(hdata), - API_STR2PTR(pointer), - name)); + result = API_PTR2STR(weechat_hdata_pointer (API_STR2PTR(hdata), + API_STR2PTR(pointer), + name)); API_RETURN_STRING_FREE(result); } @@ -5712,7 +5715,7 @@ weechat_lua_api_upgrade_new (lua_State *L) filename = lua_tostring (lua_current_interpreter, -2); write = lua_tonumber (lua_current_interpreter, -1); - result = script_ptr2str (weechat_upgrade_new (filename, write)); + result = API_PTR2STR(weechat_upgrade_new (filename, write)); API_RETURN_STRING_FREE(result); } @@ -5764,9 +5767,9 @@ weechat_lua_api_upgrade_read_cb (void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (upgrade_file); + func_argv[1] = API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = script_ptr2str (infolist); + func_argv[3] = API_PTR2STR(infolist); rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -5809,12 +5812,12 @@ weechat_lua_api_upgrade_read (lua_State *L) function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); - rc = script_api_upgrade_read (weechat_lua_plugin, - lua_current_script, - API_STR2PTR(upgrade_file), - &weechat_lua_api_upgrade_read_cb, - function, - data); + rc = plugin_script_api_upgrade_read (weechat_lua_plugin, + lua_current_script, + API_STR2PTR(upgrade_file), + &weechat_lua_api_upgrade_read_cb, + function, + data); API_RETURN_INT(rc); } diff --git a/src/plugins/scripts/lua/weechat-lua-api.h b/src/plugins/lua/weechat-lua-api.h index b37789215..b37789215 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.h +++ b/src/plugins/lua/weechat-lua-api.h diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c index 8957bbe88..654462d27 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/lua/weechat-lua.c @@ -30,8 +30,8 @@ #include <stdlib.h> #include <string.h> -#include "../../weechat-plugin.h" -#include "../script.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" #include "weechat-lua.h" #include "weechat-lua-api.h" @@ -351,8 +351,10 @@ weechat_lua_load (const char *filename) /* if script was registered, remove it from list */ if (lua_current_script) - script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script, - lua_current_script); + { + plugin_script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script, + lua_current_script); + } return 0; } @@ -375,11 +377,11 @@ weechat_lua_load (const char *filename) * set input/close callbacks for buffers created by this script * (to restore callbacks after upgrade) */ - script_set_buffer_callbacks (weechat_lua_plugin, - lua_scripts, - lua_current_script, - &weechat_lua_api_buffer_input_data_cb, - &weechat_lua_api_buffer_close_cb); + plugin_script_set_buffer_callbacks (weechat_lua_plugin, + lua_scripts, + lua_current_script, + &weechat_lua_api_buffer_input_data_cb, + &weechat_lua_api_buffer_close_cb); return 1; } @@ -430,7 +432,7 @@ weechat_lua_unload (struct t_plugin_script *script) lua_current_script = (lua_current_script->prev_script) ? lua_current_script->prev_script : lua_current_script->next_script; - script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script, script); + plugin_script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script, script); if (interpreter) lua_close (interpreter); @@ -445,7 +447,7 @@ weechat_lua_unload_name (const char *name) { struct t_plugin_script *ptr_script; - ptr_script = script_search (weechat_lua_plugin, lua_scripts, name); + ptr_script = plugin_script_search (weechat_lua_plugin, lua_scripts, name); if (ptr_script) { weechat_lua_unload (ptr_script); @@ -471,7 +473,7 @@ weechat_lua_reload_name (const char *name) struct t_plugin_script *ptr_script; char *filename; - ptr_script = script_search (weechat_lua_plugin, lua_scripts, name); + ptr_script = plugin_script_search (weechat_lua_plugin, lua_scripts, name); if (ptr_script) { filename = strdup (ptr_script->filename); @@ -522,29 +524,29 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer, if (argc == 1) { - script_display_list (weechat_lua_plugin, lua_scripts, - NULL, 0); + plugin_script_display_list (weechat_lua_plugin, lua_scripts, + NULL, 0); } else if (argc == 2) { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_lua_plugin, lua_scripts, - NULL, 0); + plugin_script_display_list (weechat_lua_plugin, lua_scripts, + NULL, 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_lua_plugin, lua_scripts, - NULL, 1); + plugin_script_display_list (weechat_lua_plugin, lua_scripts, + NULL, 1); } else if (weechat_strcasecmp (argv[1], "autoload") == 0) { - script_auto_load (weechat_lua_plugin, &weechat_lua_load_cb); + plugin_script_auto_load (weechat_lua_plugin, &weechat_lua_load_cb); } else if (weechat_strcasecmp (argv[1], "reload") == 0) { weechat_lua_unload_all (); - script_auto_load (weechat_lua_plugin, &weechat_lua_load_cb); + plugin_script_auto_load (weechat_lua_plugin, &weechat_lua_load_cb); } else if (weechat_strcasecmp (argv[1], "unload") == 0) { @@ -555,19 +557,19 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer, { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_lua_plugin, lua_scripts, - argv_eol[2], 0); + plugin_script_display_list (weechat_lua_plugin, lua_scripts, + argv_eol[2], 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_lua_plugin, lua_scripts, - argv_eol[2], 1); + plugin_script_display_list (weechat_lua_plugin, lua_scripts, + argv_eol[2], 1); } else if (weechat_strcasecmp (argv[1], "load") == 0) { /* load Lua script */ - path_script = script_search_path (weechat_lua_plugin, - argv_eol[2]); + path_script = plugin_script_search_path (weechat_lua_plugin, + argv_eol[2]); weechat_lua_load ((path_script) ? path_script : argv_eol[2]); if (path_script) free (path_script); @@ -608,7 +610,7 @@ weechat_lua_completion_cb (void *data, const char *completion_item, (void) completion_item; (void) buffer; - script_completion (weechat_lua_plugin, completion, lua_scripts); + plugin_script_completion (weechat_lua_plugin, completion, lua_scripts); return WEECHAT_RC_OK; } @@ -629,9 +631,9 @@ weechat_lua_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "lua_script") == 0) { - return script_infolist_list_scripts (weechat_lua_plugin, - lua_scripts, pointer, - arguments); + return plugin_script_infolist_list_scripts (weechat_lua_plugin, + lua_scripts, pointer, + arguments); } return NULL; @@ -653,7 +655,7 @@ weechat_lua_signal_debug_dump_cb (void *data, const char *signal, if (!signal_data || (weechat_strcasecmp ((char *)signal_data, LUA_PLUGIN_NAME) == 0)) { - script_print_log (weechat_lua_plugin, lua_scripts); + plugin_script_print_log (weechat_lua_plugin, lua_scripts); } return WEECHAT_RC_OK; @@ -673,7 +675,7 @@ weechat_lua_signal_buffer_closed_cb (void *data, const char *signal, (void) type_data; if (signal_data) - script_remove_buffer_callbacks (lua_scripts, signal_data); + plugin_script_remove_buffer_callbacks (lua_scripts, signal_data); return WEECHAT_RC_OK; } @@ -692,18 +694,18 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls) { if (data == &lua_action_install_list) { - script_action_install (weechat_lua_plugin, - lua_scripts, - &weechat_lua_unload, - &weechat_lua_load, - &lua_action_install_list); + plugin_script_action_install (weechat_lua_plugin, + lua_scripts, + &weechat_lua_unload, + &weechat_lua_load, + &lua_action_install_list); } else if (data == &lua_action_remove_list) { - script_action_remove (weechat_lua_plugin, - lua_scripts, - &weechat_lua_unload, - &lua_action_remove_list); + plugin_script_action_remove (weechat_lua_plugin, + lua_scripts, + &weechat_lua_unload, + &lua_action_remove_list); } } @@ -727,16 +729,16 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal, { if (strcmp (signal, "lua_script_install") == 0) { - script_action_add (&lua_action_install_list, - (const char *)signal_data); + plugin_script_action_add (&lua_action_install_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_lua_timer_action_cb, &lua_action_install_list); } else if (strcmp (signal, "lua_script_remove") == 0) { - script_action_add (&lua_action_remove_list, - (const char *)signal_data); + plugin_script_action_add (&lua_action_remove_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_lua_timer_action_cb, &lua_action_remove_list); @@ -766,11 +768,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) init.callback_load_file = &weechat_lua_load_cb; lua_quiet = 1; - script_init (weechat_lua_plugin, argc, argv, &init); + plugin_script_init (weechat_lua_plugin, argc, argv, &init); lua_quiet = 0; - script_display_short_list (weechat_lua_plugin, - lua_scripts); + plugin_script_display_short_list (weechat_lua_plugin, + lua_scripts); /* init ok */ return WEECHAT_RC_OK; @@ -785,7 +787,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) { /* unload all scripts */ lua_quiet = 1; - script_end (plugin, &lua_scripts, &weechat_lua_unload_all); + plugin_script_end (plugin, &lua_scripts, &weechat_lua_unload_all); lua_quiet = 0; return WEECHAT_RC_OK; diff --git a/src/plugins/scripts/lua/weechat-lua.h b/src/plugins/lua/weechat-lua.h index 0512d2272..0512d2272 100644 --- a/src/plugins/scripts/lua/weechat-lua.h +++ b/src/plugins/lua/weechat-lua.h diff --git a/src/plugins/scripts/perl/CMakeLists.txt b/src/plugins/perl/CMakeLists.txt index 276477f89..6bb7c2fc7 100644 --- a/src/plugins/scripts/perl/CMakeLists.txt +++ b/src/plugins/perl/CMakeLists.txt @@ -36,10 +36,10 @@ IF(PERL_FOUND) STRING(REPLACE "${PERL_DYNALOADER}" "" PERL_LFLAGS "${PERL_LFLAGS}") SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PERL_LFLAGS}") EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy ${PERL_DYNALOADER} ${CMAKE_CURRENT_BINARY_DIR}/libDynaLoader.a) - TARGET_LINK_LIBRARIES(perl ${PERL_LIBRARY} weechat_scripts ${CMAKE_CURRENT_BINARY_DIR}/libDynaLoader.a) + TARGET_LINK_LIBRARIES(perl ${PERL_LIBRARY} weechat_plugins_scripts ${CMAKE_CURRENT_BINARY_DIR}/libDynaLoader.a) ELSE(PERL_DYNALOADER) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PERL_LFLAGS}") - TARGET_LINK_LIBRARIES(perl ${PERL_LIBRARY} weechat_scripts) + TARGET_LINK_LIBRARIES(perl ${PERL_LIBRARY} weechat_plugins_scripts) ENDIF(PERL_DYNALOADER) ENDIF(PERL_FOUND) diff --git a/src/plugins/scripts/perl/Makefile.am b/src/plugins/perl/Makefile.am index ab7184f69..ab7184f69 100644 --- a/src/plugins/scripts/perl/Makefile.am +++ b/src/plugins/perl/Makefile.am diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 9434e3410..d03586822 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -29,10 +29,10 @@ #include <XSUB.h> #include <time.h> -#include "../../weechat-plugin.h" -#include "../script.h" -#include "../script-api.h" -#include "../script-callback.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" +#include "../plugin-script-api.h" +#include "../plugin-script-callback.h" #include "weechat-perl.h" @@ -52,9 +52,12 @@ perl_function_name); \ __ret; \ } +#define API_PTR2STR(__pointer) \ + plugin_script_ptr2str (__pointer) #define API_STR2PTR(__string) \ - script_str2ptr (weechat_perl_plugin, PERL_CURRENT_SCRIPT_NAME, \ - perl_function_name, __string) + plugin_script_str2ptr (weechat_perl_plugin, \ + PERL_CURRENT_SCRIPT_NAME, \ + perl_function_name, __string) #define API_RETURN_OK XSRETURN_YES #define API_RETURN_ERROR XSRETURN_NO #define API_RETURN_EMPTY XSRETURN_EMPTY @@ -131,7 +134,7 @@ XS (XS_weechat_api_register) shutdown_func = SvPV_nolen (ST (5)); charset = SvPV_nolen (ST (6)); - if (script_search (weechat_perl_plugin, perl_scripts, name)) + if (plugin_script_search (weechat_perl_plugin, perl_scripts, name)) { /* another script already exists with same name */ weechat_printf (NULL, @@ -143,12 +146,12 @@ XS (XS_weechat_api_register) } /* register script */ - perl_current_script = script_add (weechat_perl_plugin, - &perl_scripts, &last_perl_script, - (perl_current_script_filename) ? - perl_current_script_filename : "", - name, author, version, license, - description, shutdown_func, charset); + perl_current_script = plugin_script_add (weechat_perl_plugin, + &perl_scripts, &last_perl_script, + (perl_current_script_filename) ? + perl_current_script_filename : "", + name, author, version, license, + description, shutdown_func, charset); if (perl_current_script) { perl_registered_script = perl_current_script; @@ -198,8 +201,8 @@ XS (XS_weechat_api_charset_set) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_charset_set (perl_current_script, - SvPV_nolen (ST (0))); /* charset */ + plugin_script_api_charset_set (perl_current_script, + SvPV_nolen (ST (0))); /* charset */ API_RETURN_OK; } @@ -505,7 +508,7 @@ XS (XS_weechat_api_list_new) API_FUNC(1, "list_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_new ()); + result = API_PTR2STR(weechat_list_new ()); API_RETURN_STRING_FREE(result); } @@ -528,10 +531,10 @@ XS (XS_weechat_api_list_add) where = SvPV_nolen (ST (2)); user_data = SvPV_nolen (ST (3)); - result = script_ptr2str (weechat_list_add (API_STR2PTR(weelist), - data, - where, - API_STR2PTR(user_data))); + result = API_PTR2STR(weechat_list_add (API_STR2PTR(weelist), + data, + where, + API_STR2PTR(user_data))); API_RETURN_STRING_FREE(result); } @@ -552,8 +555,8 @@ XS (XS_weechat_api_list_search) weelist = SvPV_nolen (ST (0)); data = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_list_search (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -596,8 +599,8 @@ XS (XS_weechat_api_list_casesearch) weelist = SvPV_nolen (ST (0)); data = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_list_casesearch (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -638,8 +641,8 @@ XS (XS_weechat_api_list_get) if (items < 2) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_get (API_STR2PTR(SvPV_nolen (ST (0))), /* weelist */ - SvIV (ST (1)))); /* position */ + result = API_PTR2STR(weechat_list_get (API_STR2PTR(SvPV_nolen (ST (0))), /* weelist */ + SvIV (ST (1)))); /* position */ API_RETURN_STRING_FREE(result); } @@ -678,7 +681,7 @@ XS (XS_weechat_api_list_next) if (items < 1) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_next (API_STR2PTR(SvPV_nolen (ST (0))))); /* item */ + result = API_PTR2STR(weechat_list_next (API_STR2PTR(SvPV_nolen (ST (0))))); /* item */ API_RETURN_STRING_FREE(result); } @@ -696,7 +699,7 @@ XS (XS_weechat_api_list_prev) if (items < 1) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_prev (API_STR2PTR(SvPV_nolen (ST (0))))); /* item */ + result = API_PTR2STR(weechat_list_prev (API_STR2PTR(SvPV_nolen (ST (0))))); /* item */ API_RETURN_STRING_FREE(result); } @@ -811,7 +814,7 @@ weechat_perl_api_config_reload_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -851,12 +854,12 @@ XS (XS_weechat_api_config_new) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_config_new (weechat_perl_plugin, - perl_current_script, - name, - &weechat_perl_api_config_reload_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_config_new (weechat_perl_plugin, + perl_current_script, + name, + &weechat_perl_api_config_reload_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -882,8 +885,8 @@ weechat_perl_api_config_section_read_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -929,7 +932,7 @@ weechat_perl_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_perl_exec (script_callback->script, @@ -973,7 +976,7 @@ weechat_perl_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_perl_exec (script_callback->script, @@ -1018,8 +1021,8 @@ weechat_perl_api_config_section_create_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1066,9 +1069,9 @@ weechat_perl_api_config_section_delete_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); - func_argv[3] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); + func_argv[3] = API_PTR2STR(option); rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1125,27 +1128,27 @@ XS (XS_weechat_api_config_new_section) function_delete_option = SvPV_nolen (ST (12)); data_delete_option = SvPV_nolen (ST (13)); - result = script_ptr2str (script_api_config_new_section (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(cfg_file), - name, - SvIV (ST (2)), /* user_can_add_options */ - SvIV (ST (3)), /* user_can_delete_options */ - &weechat_perl_api_config_section_read_cb, - function_read, - data_read, - &weechat_perl_api_config_section_write_cb, - function_write, - data_write, - &weechat_perl_api_config_section_write_default_cb, - function_write_default, - data_write_default, - &weechat_perl_api_config_section_create_option_cb, - function_create_option, - data_create_option, - &weechat_perl_api_config_section_delete_option_cb, - function_delete_option, - data_delete_option)); + result = API_PTR2STR(plugin_script_api_config_new_section (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(cfg_file), + name, + SvIV (ST (2)), /* user_can_add_options */ + SvIV (ST (3)), /* user_can_delete_options */ + &weechat_perl_api_config_section_read_cb, + function_read, + data_read, + &weechat_perl_api_config_section_write_cb, + function_write, + data_write, + &weechat_perl_api_config_section_write_default_cb, + function_write_default, + data_write_default, + &weechat_perl_api_config_section_create_option_cb, + function_create_option, + data_create_option, + &weechat_perl_api_config_section_delete_option_cb, + function_delete_option, + data_delete_option)); API_RETURN_STRING_FREE(result); } @@ -1166,8 +1169,8 @@ XS (XS_weechat_api_config_search_section) config_file = SvPV_nolen (ST (0)); section_name = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_config_search_section (API_STR2PTR(config_file), - section_name)); + result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), + section_name)); API_RETURN_STRING_FREE(result); } @@ -1192,7 +1195,7 @@ weechat_perl_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_perl_exec (script_callback->script, @@ -1234,7 +1237,7 @@ weechat_perl_api_config_option_change_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1267,7 +1270,7 @@ weechat_perl_api_config_option_delete_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1313,28 +1316,28 @@ XS (XS_weechat_api_config_new_option) function_delete = SvPV_nolen (ST (15)); data_delete = SvPV_nolen (ST (16)); - result = script_ptr2str (script_api_config_new_option (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(config_file), - API_STR2PTR(section), - name, - type, - description, - string_values, - SvIV (ST (6)), /* min */ - SvIV (ST (7)), /* max */ - default_value, - value, - SvIV (ST (10)), /* null_value_allowed */ - &weechat_perl_api_config_option_check_value_cb, - function_check_value, - data_check_value, - &weechat_perl_api_config_option_change_cb, - function_change, - data_change, - &weechat_perl_api_config_option_delete_cb, - function_delete, - data_delete)); + result = API_PTR2STR(plugin_script_api_config_new_option (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(config_file), + API_STR2PTR(section), + name, + type, + description, + string_values, + SvIV (ST (6)), /* min */ + SvIV (ST (7)), /* max */ + default_value, + value, + SvIV (ST (10)), /* null_value_allowed */ + &weechat_perl_api_config_option_check_value_cb, + function_check_value, + data_check_value, + &weechat_perl_api_config_option_change_cb, + function_change, + data_change, + &weechat_perl_api_config_option_delete_cb, + function_delete, + data_delete)); API_RETURN_STRING_FREE(result); } @@ -1356,9 +1359,9 @@ XS (XS_weechat_api_config_search_option) section = SvPV_nolen (ST (1)); option_name = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_config_search_option (API_STR2PTR(config_file), - API_STR2PTR(section), - option_name)); + result = API_PTR2STR(weechat_config_search_option (API_STR2PTR(config_file), + API_STR2PTR(section), + option_name)); API_RETURN_STRING_FREE(result); } @@ -1784,9 +1787,9 @@ XS (XS_weechat_api_config_option_free) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_option_free (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(SvPV_nolen (ST (0)))); /* option */ + plugin_script_api_config_option_free (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(SvPV_nolen (ST (0)))); /* option */ API_RETURN_OK; } @@ -1804,9 +1807,9 @@ XS (XS_weechat_api_config_section_free_options) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free_options (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(SvPV_nolen (ST (0)))); /* section */ + plugin_script_api_config_section_free_options (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(SvPV_nolen (ST (0)))); /* section */ API_RETURN_OK; } @@ -1823,9 +1826,9 @@ XS (XS_weechat_api_config_section_free) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(SvPV_nolen (ST (0)))); /* section */ + plugin_script_api_config_section_free (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(SvPV_nolen (ST (0)))); /* section */ API_RETURN_OK; } @@ -1842,9 +1845,9 @@ XS (XS_weechat_api_config_free) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_free (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(SvPV_nolen (ST (0)))); /* config_file */ + plugin_script_api_config_free (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(SvPV_nolen (ST (0)))); /* config_file */ API_RETURN_OK; } @@ -1862,7 +1865,7 @@ XS (XS_weechat_api_config_get) if (items < 1) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_get (SvPV_nolen (ST (0)))); + result = API_PTR2STR(weechat_config_get (SvPV_nolen (ST (0)))); API_RETURN_STRING_FREE(result); } @@ -1880,9 +1883,9 @@ XS (XS_weechat_api_config_get_plugin) if (items < 1) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_api_config_get_plugin (weechat_perl_plugin, - perl_current_script, - SvPV_nolen (ST (0))); + result = plugin_script_api_config_get_plugin (weechat_perl_plugin, + perl_current_script, + SvPV_nolen (ST (0))); API_RETURN_STRING(result); } @@ -1903,9 +1906,9 @@ XS (XS_weechat_api_config_is_set_plugin) option = SvPV_nolen (ST (0)); - rc = script_api_config_is_set_plugin (weechat_perl_plugin, - perl_current_script, - option); + rc = plugin_script_api_config_is_set_plugin (weechat_perl_plugin, + perl_current_script, + option); API_RETURN_INT(rc); } @@ -1927,10 +1930,10 @@ XS (XS_weechat_api_config_set_plugin) option = SvPV_nolen (ST (0)); value = SvPV_nolen (ST (1)); - rc = script_api_config_set_plugin (weechat_perl_plugin, - perl_current_script, - option, - value); + rc = plugin_script_api_config_set_plugin (weechat_perl_plugin, + perl_current_script, + option, + value); API_RETURN_INT(rc); } @@ -1951,10 +1954,10 @@ XS (XS_weechat_api_config_set_desc_plugin) option = SvPV_nolen (ST (0)); description = SvPV_nolen (ST (1)); - script_api_config_set_desc_plugin (weechat_perl_plugin, - perl_current_script, - option, - description); + plugin_script_api_config_set_desc_plugin (weechat_perl_plugin, + perl_current_script, + option, + description); API_RETURN_OK; } @@ -1975,9 +1978,9 @@ XS (XS_weechat_api_config_unset_plugin) option = SvPV_nolen (ST (0)); - rc = script_api_config_unset_plugin (weechat_perl_plugin, - perl_current_script, - option); + rc = plugin_script_api_config_unset_plugin (weechat_perl_plugin, + perl_current_script, + option); API_RETURN_INT(rc); } @@ -2083,10 +2086,10 @@ XS (XS_weechat_api_print) buffer = SvPV_nolen (ST (0)); message = SvPV_nolen (ST (1)); - script_api_printf (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(buffer), - "%s", message); + plugin_script_api_printf (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(buffer), + "%s", message); API_RETURN_OK; } @@ -2109,12 +2112,12 @@ XS (XS_weechat_api_print_date_tags) tags = SvPV_nolen (ST (2)); message = SvPV_nolen (ST (3)); - script_api_printf_date_tags (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(buffer), - SvIV (ST (1)), - tags, - "%s", message); + plugin_script_api_printf_date_tags (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(buffer), + SvIV (ST (1)), + tags, + "%s", message); API_RETURN_OK; } @@ -2135,11 +2138,11 @@ XS (XS_weechat_api_print_y) buffer = SvPV_nolen (ST (0)); message = SvPV_nolen (ST (2)); - script_api_printf_y (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(buffer), - SvIV (ST (1)), - "%s", message); + plugin_script_api_printf_y (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(buffer), + SvIV (ST (1)), + "%s", message); API_RETURN_OK; } @@ -2157,9 +2160,9 @@ XS (XS_weechat_api_log_print) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_log_printf (weechat_perl_plugin, - perl_current_script, - "%s", SvPV_nolen (ST (0))); /* message */ + plugin_script_api_log_printf (weechat_perl_plugin, + perl_current_script, + "%s", SvPV_nolen (ST (0))); /* message */ API_RETURN_OK; } @@ -2185,7 +2188,7 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_perl_exec (script_callback->script, @@ -2231,16 +2234,16 @@ XS (XS_weechat_api_hook_command) function = SvPV_nolen (ST (5)); data = SvPV_nolen (ST (6)); - result = script_ptr2str (script_api_hook_command (weechat_perl_plugin, - perl_current_script, - command, - description, - args, - args_description, - completion, - &weechat_perl_api_hook_command_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command (weechat_perl_plugin, + perl_current_script, + command, + description, + args, + args_description, + completion, + &weechat_perl_api_hook_command_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2263,7 +2266,7 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_perl_exec (script_callback->script, @@ -2304,12 +2307,12 @@ XS (XS_weechat_api_hook_command_run) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_hook_command_run (weechat_perl_plugin, - perl_current_script, - command, - &weechat_perl_api_hook_command_run_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command_run (weechat_perl_plugin, + perl_current_script, + command, + &weechat_perl_api_hook_command_run_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2368,14 +2371,14 @@ XS (XS_weechat_api_hook_timer) if (items < 5) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_timer (weechat_perl_plugin, - perl_current_script, - SvIV (ST (0)), /* interval */ - SvIV (ST (1)), /* align_second */ - SvIV (ST (2)), /* max_calls */ - &weechat_perl_api_hook_timer_cb, - SvPV_nolen (ST (3)), /* perl function */ - SvPV_nolen (ST (4)))); /* data */ + result = API_PTR2STR(plugin_script_api_hook_timer (weechat_perl_plugin, + perl_current_script, + SvIV (ST (0)), /* interval */ + SvIV (ST (1)), /* align_second */ + SvIV (ST (2)), /* max_calls */ + &weechat_perl_api_hook_timer_cb, + SvPV_nolen (ST (3)), /* perl function */ + SvPV_nolen (ST (4)))); /* data */ API_RETURN_STRING_FREE(result); } @@ -2433,15 +2436,15 @@ XS (XS_weechat_api_hook_fd) if (items < 6) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_fd (weechat_perl_plugin, - perl_current_script, - SvIV (ST (0)), /* fd */ - SvIV (ST (1)), /* read */ - SvIV (ST (2)), /* write */ - SvIV (ST (3)), /* exception */ - &weechat_perl_api_hook_fd_cb, - SvPV_nolen (ST (4)), /* perl function */ - SvPV_nolen (ST (5)))); /* data */ + result = API_PTR2STR(plugin_script_api_hook_fd (weechat_perl_plugin, + perl_current_script, + SvIV (ST (0)), /* fd */ + SvIV (ST (1)), /* read */ + SvIV (ST (2)), /* write */ + SvIV (ST (3)), /* exception */ + &weechat_perl_api_hook_fd_cb, + SvPV_nolen (ST (4)), /* perl function */ + SvPV_nolen (ST (5)))); /* data */ API_RETURN_STRING_FREE(result); } @@ -2506,13 +2509,13 @@ XS (XS_weechat_api_hook_process) function = SvPV_nolen (ST (2)); data = SvPV_nolen (ST (3)); - result = script_ptr2str (script_api_hook_process (weechat_perl_plugin, - perl_current_script, - command, - SvIV (ST (1)), /* timeout */ - &weechat_perl_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process (weechat_perl_plugin, + perl_current_script, + command, + SvIV (ST (1)), /* timeout */ + &weechat_perl_api_hook_process_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2537,14 +2540,14 @@ XS (XS_weechat_api_hook_process_hashtable) function = SvPV_nolen (ST (3)); data = SvPV_nolen (ST (4)); - result = script_ptr2str (script_api_hook_process_hashtable (weechat_perl_plugin, - perl_current_script, - command, - options, - SvIV (ST (2)), /* timeout */ - &weechat_perl_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_perl_plugin, + perl_current_script, + command, + options, + SvIV (ST (2)), /* timeout */ + &weechat_perl_api_hook_process_cb, + function, + data)); if (options) weechat_hashtable_free (options); @@ -2617,21 +2620,21 @@ XS (XS_weechat_api_hook_connect) function = SvPV_nolen (ST (6)); data = SvPV_nolen (ST (7)); - result = script_ptr2str (script_api_hook_connect (weechat_perl_plugin, - perl_current_script, - proxy, - address, - SvIV (ST (2)), /* port */ - SvIV (ST (3)), /* sock */ - SvIV (ST (4)), /* ipv6 */ - NULL, /* gnutls session */ - NULL, /* gnutls callback */ - 0, /* gnutls DH key size */ - NULL, /* gnutls priorities */ - local_hostname, - &weechat_perl_api_hook_connect_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_connect (weechat_perl_plugin, + perl_current_script, + proxy, + address, + SvIV (ST (2)), /* port */ + SvIV (ST (3)), /* sock */ + SvIV (ST (4)), /* ipv6 */ + NULL, /* gnutls session */ + NULL, /* gnutls callback */ + 0, /* gnutls DH key size */ + NULL, /* gnutls priorities */ + local_hostname, + &weechat_perl_api_hook_connect_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2663,7 +2666,7 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2719,15 +2722,15 @@ XS (XS_weechat_api_hook_print) function = SvPV_nolen (ST (4)); data = SvPV_nolen (ST (5)); - result = script_ptr2str (script_api_hook_print (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(buffer), - tags, - message, - SvIV (ST (3)), /* strip_colors */ - &weechat_perl_api_hook_print_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_print (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(buffer), + tags, + message, + SvIV (ST (3)), /* strip_colors */ + &weechat_perl_api_hook_print_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2765,7 +2768,7 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = script_ptr2str (signal_data); + func_argv[2] = API_PTR2STR(signal_data); free_needed = 1; } else @@ -2809,12 +2812,12 @@ XS (XS_weechat_api_hook_signal) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_hook_signal (weechat_perl_plugin, - perl_current_script, - signal, - &weechat_perl_api_hook_signal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_signal (weechat_perl_plugin, + perl_current_script, + signal, + &weechat_perl_api_hook_signal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2918,12 +2921,12 @@ XS (XS_weechat_api_hook_hsignal) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_hook_hsignal (weechat_perl_plugin, - perl_current_script, - signal, - &weechat_perl_api_hook_hsignal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_hsignal (weechat_perl_plugin, + perl_current_script, + signal, + &weechat_perl_api_hook_hsignal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3010,12 +3013,12 @@ XS (XS_weechat_api_hook_config) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_hook_config (weechat_perl_plugin, - perl_current_script, - option, - &weechat_perl_api_hook_config_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_config (weechat_perl_plugin, + perl_current_script, + option, + &weechat_perl_api_hook_config_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3040,8 +3043,8 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = script_ptr2str (buffer); - func_argv[3] = script_ptr2str (completion); + func_argv[2] = API_PTR2STR(buffer); + func_argv[3] = API_PTR2STR(completion); rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3084,13 +3087,13 @@ XS (XS_weechat_api_hook_completion) function = SvPV_nolen (ST (2)); data = SvPV_nolen (ST (3)); - result = script_ptr2str (script_api_hook_completion (weechat_perl_plugin, - perl_current_script, - completion, - description, - &weechat_perl_api_hook_completion_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_completion (weechat_perl_plugin, + perl_current_script, + completion, + description, + &weechat_perl_api_hook_completion_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3167,12 +3170,12 @@ XS (XS_weechat_api_hook_modifier) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_hook_modifier (weechat_perl_plugin, - perl_current_script, - modifier, - &weechat_perl_api_hook_modifier_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_modifier (weechat_perl_plugin, + perl_current_script, + modifier, + &weechat_perl_api_hook_modifier_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3247,14 +3250,14 @@ XS (XS_weechat_api_hook_info) function = SvPV_nolen (ST (3)); data = SvPV_nolen (ST (4)); - result = script_ptr2str (script_api_hook_info (weechat_perl_plugin, - perl_current_script, - info_name, - description, - args_description, - &weechat_perl_api_hook_info_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info (weechat_perl_plugin, + perl_current_script, + info_name, + description, + args_description, + &weechat_perl_api_hook_info_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3309,15 +3312,15 @@ XS (XS_weechat_api_hook_info_hashtable) function = SvPV_nolen (ST (4)); data = SvPV_nolen (ST (5)); - result = script_ptr2str (script_api_hook_info_hashtable (weechat_perl_plugin, - perl_current_script, - info_name, - description, - args_description, - output_description, - &weechat_perl_api_hook_info_hashtable_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info_hashtable (weechat_perl_plugin, + perl_current_script, + info_name, + description, + args_description, + output_description, + &weechat_perl_api_hook_info_hashtable_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3341,7 +3344,7 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = script_ptr2str (pointer); + func_argv[2] = API_PTR2STR(pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_perl_exec (script_callback->script, @@ -3379,15 +3382,15 @@ XS (XS_weechat_api_hook_infolist) function = SvPV_nolen (ST (4)); data = SvPV_nolen (ST (5)); - result = script_ptr2str (script_api_hook_infolist (weechat_perl_plugin, - perl_current_script, - infolist_name, - description, - pointer_description, - args_description, - &weechat_perl_api_hook_infolist_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_infolist (weechat_perl_plugin, + perl_current_script, + infolist_name, + description, + pointer_description, + args_description, + &weechat_perl_api_hook_infolist_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3437,12 +3440,12 @@ XS (XS_weechat_api_hook_focus) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_hook_focus (weechat_perl_plugin, - perl_current_script, - area, - &weechat_perl_api_hook_focus_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_focus (weechat_perl_plugin, + perl_current_script, + area, + &weechat_perl_api_hook_focus_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3459,9 +3462,9 @@ XS (XS_weechat_api_unhook) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_unhook (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(SvPV_nolen (ST (0)))); /* hook */ + plugin_script_api_unhook (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(SvPV_nolen (ST (0)))); /* hook */ API_RETURN_OK; } @@ -3480,7 +3483,7 @@ XS (XS_weechat_api_unhook_all) API_FUNC(1, "unhook_all", API_RETURN_ERROR); - script_api_unhook_all (weechat_perl_plugin, perl_current_script); + plugin_script_api_unhook_all (weechat_perl_plugin, perl_current_script); API_RETURN_OK; } @@ -3503,7 +3506,7 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_perl_exec (script_callback->script, @@ -3543,7 +3546,7 @@ weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3585,15 +3588,15 @@ XS (XS_weechat_api_buffer_new) function_close = SvPV_nolen (ST (3)); data_close = SvPV_nolen (ST (4)); - result = script_ptr2str (script_api_buffer_new (weechat_perl_plugin, - perl_current_script, - name, - &weechat_perl_api_buffer_input_data_cb, - function_input, - data_input, - &weechat_perl_api_buffer_close_cb, - function_close, - data_close)); + result = API_PTR2STR(plugin_script_api_buffer_new (weechat_perl_plugin, + perl_current_script, + name, + &weechat_perl_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_perl_api_buffer_close_cb, + function_close, + data_close)); API_RETURN_STRING_FREE(result); } @@ -3614,7 +3617,7 @@ XS (XS_weechat_api_buffer_search) plugin = SvPV_nolen (ST (0)); name = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_buffer_search (plugin, name)); + result = API_PTR2STR(weechat_buffer_search (plugin, name)); API_RETURN_STRING_FREE(result); } @@ -3634,7 +3637,7 @@ XS (XS_weechat_api_buffer_search_main) API_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search_main ()); + result = API_PTR2STR(weechat_buffer_search_main ()); API_RETURN_STRING_FREE(result); } @@ -3654,7 +3657,7 @@ XS (XS_weechat_api_current_buffer) API_FUNC(1, "current_buffer", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_buffer ()); + result = API_PTR2STR(weechat_current_buffer ()); API_RETURN_STRING_FREE(result); } @@ -3688,9 +3691,9 @@ XS (XS_weechat_api_buffer_close) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_buffer_close (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(SvPV_nolen (ST (0)))); /* buffer */ + plugin_script_api_buffer_close (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(SvPV_nolen (ST (0)))); /* buffer */ API_RETURN_OK; } @@ -3791,8 +3794,8 @@ XS (XS_weechat_api_buffer_get_pointer) buffer = SvPV_nolen (ST (0)); property = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_buffer_get_pointer (API_STR2PTR(buffer), - property)); + result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), + property)); API_RETURN_STRING_FREE(result); } @@ -3878,7 +3881,7 @@ XS (XS_weechat_api_current_window) API_FUNC(1, "current_window", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_window ()); + result = API_PTR2STR(weechat_current_window ()); API_RETURN_STRING_FREE(result); } @@ -3896,7 +3899,7 @@ XS (XS_weechat_api_window_search_with_buffer) if (items < 1) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_window_search_with_buffer (API_STR2PTR(SvPV_nolen (ST (0))))); + result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(SvPV_nolen (ST (0))))); API_RETURN_STRING_FREE(result); } @@ -3962,8 +3965,8 @@ XS (XS_weechat_api_window_get_pointer) window = SvPV_nolen (ST (0)); property = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_window_get_pointer (API_STR2PTR(window), - property)); + result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), + property)); API_RETURN_STRING_FREE(result); } @@ -4003,11 +4006,11 @@ XS (XS_weechat_api_nicklist_add_group) name = SvPV_nolen (ST (2)); color = SvPV_nolen (ST (3)); - result = script_ptr2str (weechat_nicklist_add_group (API_STR2PTR(buffer), - API_STR2PTR(parent_group), - name, - color, - SvIV (ST (4)))); /* visible */ + result = API_PTR2STR(weechat_nicklist_add_group (API_STR2PTR(buffer), + API_STR2PTR(parent_group), + name, + color, + SvIV (ST (4)))); /* visible */ API_RETURN_STRING_FREE(result); } @@ -4029,9 +4032,9 @@ XS (XS_weechat_api_nicklist_search_group) from_group = SvPV_nolen (ST (1)); name = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_nicklist_search_group (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_group (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4056,13 +4059,13 @@ XS (XS_weechat_api_nicklist_add_nick) prefix = SvPV_nolen (ST (4)); prefix_color = SvPV_nolen (ST (5)); - result = script_ptr2str (weechat_nicklist_add_nick (API_STR2PTR(buffer), - API_STR2PTR(group), - name, - color, - prefix, - prefix_color, - SvIV (ST (6)))); /* visible */ + result = API_PTR2STR(weechat_nicklist_add_nick (API_STR2PTR(buffer), + API_STR2PTR(group), + name, + color, + prefix, + prefix_color, + SvIV (ST (6)))); /* visible */ API_RETURN_STRING_FREE(result); } @@ -4084,9 +4087,9 @@ XS (XS_weechat_api_nicklist_search_nick) from_group = SvPV_nolen (ST (1)); name = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_nicklist_search_nick (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_nick (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4219,9 +4222,9 @@ XS (XS_weechat_api_nicklist_group_get_pointer) group = SvPV_nolen (ST (1)); property = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(group), - property)); + result = API_PTR2STR(weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(group), + property)); API_RETURN_STRING_FREE(result); } @@ -4319,9 +4322,9 @@ XS (XS_weechat_api_nicklist_nick_get_pointer) nick = SvPV_nolen (ST (1)); property = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(nick), - property)); + result = API_PTR2STR(weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(nick), + property)); API_RETURN_STRING_FREE(result); } @@ -4365,7 +4368,7 @@ XS (XS_weechat_api_bar_item_search) if (items < 1) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_item_search (SvPV_nolen (ST (0)))); /* name */ + result = API_PTR2STR(weechat_bar_item_search (SvPV_nolen (ST (0)))); /* name */ API_RETURN_STRING_FREE(result); } @@ -4387,8 +4390,8 @@ weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (item); - func_argv[2] = script_ptr2str (window); + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); ret = (char *)weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4423,12 +4426,12 @@ XS (XS_weechat_api_bar_item_new) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - result = script_ptr2str (script_api_bar_item_new (weechat_perl_plugin, - perl_current_script, - name, - &weechat_perl_api_bar_item_build_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_bar_item_new (weechat_perl_plugin, + perl_current_script, + name, + &weechat_perl_api_bar_item_build_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -4462,9 +4465,9 @@ XS (XS_weechat_api_bar_item_remove) if (items < 1) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_bar_item_remove (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(SvPV_nolen (ST (0)))); /* item */ + plugin_script_api_bar_item_remove (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(SvPV_nolen (ST (0)))); /* item */ API_RETURN_OK; } @@ -4482,7 +4485,7 @@ XS (XS_weechat_api_bar_search) if (items < 1) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_search (SvPV_nolen (ST (0)))); /* name */ + result = API_PTR2STR(weechat_bar_search (SvPV_nolen (ST (0)))); /* name */ API_RETURN_STRING_FREE(result); } @@ -4518,21 +4521,21 @@ XS (XS_weechat_api_bar_new) separator = SvPV_nolen (ST (13)); bar_items = SvPV_nolen (ST (14)); - result = script_ptr2str (weechat_bar_new (name, - hidden, - priority, - type, - conditions, - position, - filling_top_bottom, - filling_left_right, - size, - size_max, - color_fg, - color_delim, - color_bg, - separator, - bar_items)); + result = API_PTR2STR(weechat_bar_new (name, + hidden, + priority, + type, + conditions, + position, + filling_top_bottom, + filling_left_right, + size, + size_max, + color_fg, + color_delim, + color_bg, + separator, + bar_items)); API_RETURN_STRING_FREE(result); } @@ -4609,10 +4612,10 @@ XS (XS_weechat_api_command) buffer = SvPV_nolen (ST (0)); command = SvPV_nolen (ST (1)); - script_api_command (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(buffer), - command); + plugin_script_api_command (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(buffer), + command); API_RETURN_OK; } @@ -4684,7 +4687,7 @@ XS (XS_weechat_api_infolist_new) API_FUNC(1, "infolist_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new ()); + result = API_PTR2STR(weechat_infolist_new ()); API_RETURN_STRING_FREE(result); } @@ -4704,7 +4707,7 @@ XS (XS_weechat_api_infolist_new_item) infolist = SvPV_nolen (ST (0)); - result = script_ptr2str (weechat_infolist_new_item (API_STR2PTR(infolist))); + result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(infolist))); API_RETURN_STRING_FREE(result); } @@ -4725,9 +4728,9 @@ XS (XS_weechat_api_infolist_new_var_integer) infolist = SvPV_nolen (ST (0)); name = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_infolist_new_var_integer (API_STR2PTR(infolist), - name, - SvIV (ST (2)))); /* value */ + result = API_PTR2STR(weechat_infolist_new_var_integer (API_STR2PTR(infolist), + name, + SvIV (ST (2)))); /* value */ API_RETURN_STRING_FREE(result); } @@ -4749,9 +4752,9 @@ XS (XS_weechat_api_infolist_new_var_string) name = SvPV_nolen (ST (1)); value = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_infolist_new_var_string (API_STR2PTR(infolist), - name, - value)); + result = API_PTR2STR(weechat_infolist_new_var_string (API_STR2PTR(infolist), + name, + value)); API_RETURN_STRING_FREE(result); } @@ -4773,9 +4776,9 @@ XS (XS_weechat_api_infolist_new_var_pointer) name = SvPV_nolen (ST (1)); value = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_infolist_new_var_pointer (API_STR2PTR(infolist), - name, - API_STR2PTR(value))); + result = API_PTR2STR(weechat_infolist_new_var_pointer (API_STR2PTR(infolist), + name, + API_STR2PTR(value))); API_RETURN_STRING_FREE(result); } @@ -4796,9 +4799,9 @@ XS (XS_weechat_api_infolist_new_var_time) infolist = SvPV_nolen (ST (0)); name = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_infolist_new_var_time (API_STR2PTR(infolist), - name, - SvIV (ST (2)))); /* value */ + result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(infolist), + name, + SvIV (ST (2)))); /* value */ API_RETURN_STRING_FREE(result); } @@ -4820,9 +4823,9 @@ XS (XS_weechat_api_infolist_get) pointer = SvPV_nolen (ST (1)); arguments = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_infolist_get (name, - API_STR2PTR(pointer), - arguments)); + result = API_PTR2STR(weechat_infolist_get (name, + API_STR2PTR(pointer), + arguments)); API_RETURN_STRING_FREE(result); } @@ -4960,7 +4963,7 @@ XS (XS_weechat_api_infolist_pointer) infolist = SvPV_nolen (ST (0)); variable = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_infolist_pointer (API_STR2PTR(infolist), variable)); + result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), variable)); API_RETURN_STRING_FREE(result); } @@ -5025,7 +5028,7 @@ XS (XS_weechat_api_hdata_get) name = SvPV_nolen (ST (0)); - result = script_ptr2str (weechat_hdata_get (name)); + result = API_PTR2STR(weechat_hdata_get (name)); API_RETURN_STRING_FREE(result); } @@ -5164,8 +5167,8 @@ XS (XS_weechat_api_hdata_get_list) hdata = SvPV_nolen (ST (0)); name = SvPV_nolen (ST (1)); - result = script_ptr2str (weechat_hdata_get_list (API_STR2PTR(hdata), - name)); + result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), + name)); API_RETURN_STRING_FREE(result); } @@ -5213,9 +5216,9 @@ XS (XS_weechat_api_hdata_move) pointer = SvPV_nolen (ST (1)); count = SvIV(ST (2)); - result = script_ptr2str (weechat_hdata_move (API_STR2PTR(hdata), - API_STR2PTR(pointer), - count)); + result = API_PTR2STR(weechat_hdata_move (API_STR2PTR(hdata), + API_STR2PTR(pointer), + count)); API_RETURN_STRING_FREE(result); } @@ -5341,9 +5344,9 @@ XS (XS_weechat_api_hdata_pointer) pointer = SvPV_nolen (ST (1)); name = SvPV_nolen (ST (2)); - result = script_ptr2str (weechat_hdata_pointer (API_STR2PTR(hdata), - API_STR2PTR(pointer), - name)); + result = API_PTR2STR(weechat_hdata_pointer (API_STR2PTR(hdata), + API_STR2PTR(pointer), + name)); API_RETURN_STRING_FREE(result); } @@ -5443,8 +5446,8 @@ XS (XS_weechat_api_upgrade_new) filename = SvPV_nolen (ST (0)); - result = script_ptr2str (weechat_upgrade_new (filename, - SvIV (ST (1)))); /* write */ + result = API_PTR2STR(weechat_upgrade_new (filename, + SvIV (ST (1)))); /* write */ API_RETURN_STRING_FREE(result); } @@ -5495,9 +5498,9 @@ weechat_perl_api_upgrade_read_cb (void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (upgrade_file); + func_argv[1] = API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = script_ptr2str (infolist); + func_argv[3] = API_PTR2STR(infolist); rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -5540,12 +5543,12 @@ XS (XS_weechat_api_upgrade_read) function = SvPV_nolen (ST (1)); data = SvPV_nolen (ST (2)); - rc = script_api_upgrade_read (weechat_perl_plugin, - perl_current_script, - API_STR2PTR(upgrade_file), - &weechat_perl_api_upgrade_read_cb, - function, - data); + rc = plugin_script_api_upgrade_read (weechat_perl_plugin, + perl_current_script, + API_STR2PTR(upgrade_file), + &weechat_perl_api_upgrade_read_cb, + function, + data); API_RETURN_INT(rc); } diff --git a/src/plugins/scripts/perl/weechat-perl-api.h b/src/plugins/perl/weechat-perl-api.h index 662dd002a..662dd002a 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.h +++ b/src/plugins/perl/weechat-perl-api.h diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c index 0acf76651..42e3606c5 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/perl/weechat-perl.c @@ -28,8 +28,8 @@ #include <perl.h> #include <XSUB.h> -#include "../../weechat-plugin.h" -#include "../script.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" #include "weechat-perl.h" #include "weechat-perl-api.h" @@ -490,9 +490,9 @@ weechat_perl_load (const char *filename) #endif if (perl_current_script && (perl_current_script != &temp_script)) { - script_remove (weechat_perl_plugin, - &perl_scripts, &last_perl_script, - perl_current_script); + plugin_script_remove (weechat_perl_plugin, + &perl_scripts, &last_perl_script, + perl_current_script); } free (eval); @@ -525,11 +525,11 @@ weechat_perl_load (const char *filename) * set input/close callbacks for buffers created by this script * (to restore callbacks after upgrade) */ - script_set_buffer_callbacks (weechat_perl_plugin, - perl_scripts, - perl_current_script, - &weechat_perl_api_buffer_input_data_cb, - &weechat_perl_api_buffer_close_cb); + plugin_script_set_buffer_callbacks (weechat_perl_plugin, + perl_scripts, + perl_current_script, + &weechat_perl_api_buffer_input_data_cb, + &weechat_perl_api_buffer_close_cb); return 1; } @@ -586,8 +586,8 @@ weechat_perl_unload (struct t_plugin_script *script) perl_current_script = (perl_current_script->prev_script) ? perl_current_script->prev_script : perl_current_script->next_script; - script_remove (weechat_perl_plugin, &perl_scripts, &last_perl_script, - script); + plugin_script_remove (weechat_perl_plugin, &perl_scripts, &last_perl_script, + script); #ifdef MULTIPLICITY if (interpreter) @@ -610,7 +610,7 @@ weechat_perl_unload_name (const char *name) { struct t_plugin_script *ptr_script; - ptr_script = script_search (weechat_perl_plugin, perl_scripts, name); + ptr_script = plugin_script_search (weechat_perl_plugin, perl_scripts, name); if (ptr_script) { weechat_perl_unload (ptr_script); @@ -649,7 +649,7 @@ weechat_perl_reload_name (const char *name) struct t_plugin_script *ptr_script; char *filename; - ptr_script = script_search (weechat_perl_plugin, perl_scripts, name); + ptr_script = plugin_script_search (weechat_perl_plugin, perl_scripts, name); if (ptr_script) { filename = strdup (ptr_script->filename); @@ -687,29 +687,29 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer, if (argc == 1) { - script_display_list (weechat_perl_plugin, perl_scripts, - NULL, 0); + plugin_script_display_list (weechat_perl_plugin, perl_scripts, + NULL, 0); } else if (argc == 2) { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_perl_plugin, perl_scripts, - NULL, 0); + plugin_script_display_list (weechat_perl_plugin, perl_scripts, + NULL, 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_perl_plugin, perl_scripts, - NULL, 1); + plugin_script_display_list (weechat_perl_plugin, perl_scripts, + NULL, 1); } else if (weechat_strcasecmp (argv[1], "autoload") == 0) { - script_auto_load (weechat_perl_plugin, &weechat_perl_load_cb); + plugin_script_auto_load (weechat_perl_plugin, &weechat_perl_load_cb); } else if (weechat_strcasecmp (argv[1], "reload") == 0) { weechat_perl_unload_all (); - script_auto_load (weechat_perl_plugin, &weechat_perl_load_cb); + plugin_script_auto_load (weechat_perl_plugin, &weechat_perl_load_cb); } else if (weechat_strcasecmp (argv[1], "unload") == 0) { @@ -720,19 +720,19 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer, { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_perl_plugin, perl_scripts, - argv_eol[2], 0); + plugin_script_display_list (weechat_perl_plugin, perl_scripts, + argv_eol[2], 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_perl_plugin, perl_scripts, - argv_eol[2], 1); + plugin_script_display_list (weechat_perl_plugin, perl_scripts, + argv_eol[2], 1); } else if (weechat_strcasecmp (argv[1], "load") == 0) { /* load Perl script */ - path_script = script_search_path (weechat_perl_plugin, - argv_eol[2]); + path_script = plugin_script_search_path (weechat_perl_plugin, + argv_eol[2]); weechat_perl_load ((path_script) ? path_script : argv_eol[2]); if (path_script) free (path_script); @@ -773,7 +773,7 @@ weechat_perl_completion_cb (void *data, const char *completion_item, (void) completion_item; (void) buffer; - script_completion (weechat_perl_plugin, completion, perl_scripts); + plugin_script_completion (weechat_perl_plugin, completion, perl_scripts); return WEECHAT_RC_OK; } @@ -794,9 +794,9 @@ weechat_perl_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "perl_script") == 0) { - return script_infolist_list_scripts (weechat_perl_plugin, - perl_scripts, pointer, - arguments); + return plugin_script_infolist_list_scripts (weechat_perl_plugin, + perl_scripts, pointer, + arguments); } return NULL; @@ -818,7 +818,7 @@ weechat_perl_signal_debug_dump_cb (void *data, const char *signal, if (!signal_data || (weechat_strcasecmp ((char *)signal_data, PERL_PLUGIN_NAME) == 0)) { - script_print_log (weechat_perl_plugin, perl_scripts); + plugin_script_print_log (weechat_perl_plugin, perl_scripts); } return WEECHAT_RC_OK; @@ -838,7 +838,7 @@ weechat_perl_signal_buffer_closed_cb (void *data, const char *signal, (void) type_data; if (signal_data) - script_remove_buffer_callbacks (perl_scripts, signal_data); + plugin_script_remove_buffer_callbacks (perl_scripts, signal_data); return WEECHAT_RC_OK; } @@ -857,18 +857,18 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls) { if (data == &perl_action_install_list) { - script_action_install (weechat_perl_plugin, - perl_scripts, - &weechat_perl_unload, - &weechat_perl_load, - &perl_action_install_list); + plugin_script_action_install (weechat_perl_plugin, + perl_scripts, + &weechat_perl_unload, + &weechat_perl_load, + &perl_action_install_list); } else if (data == &perl_action_remove_list) { - script_action_remove (weechat_perl_plugin, - perl_scripts, - &weechat_perl_unload, - &perl_action_remove_list); + plugin_script_action_remove (weechat_perl_plugin, + perl_scripts, + &weechat_perl_unload, + &perl_action_remove_list); } } @@ -892,16 +892,16 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal, { if (strcmp (signal, "perl_script_install") == 0) { - script_action_add (&perl_action_install_list, - (const char *)signal_data); + plugin_script_action_add (&perl_action_install_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_perl_timer_action_cb, &perl_action_install_list); } else if (strcmp (signal, "perl_script_remove") == 0) { - script_action_add (&perl_action_remove_list, - (const char *)signal_data); + plugin_script_action_add (&perl_action_remove_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_perl_timer_action_cb, &perl_action_remove_list); @@ -981,11 +981,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) init.callback_load_file = &weechat_perl_load_cb; perl_quiet = 1; - script_init (weechat_perl_plugin, argc, argv, &init); + plugin_script_init (weechat_perl_plugin, argc, argv, &init); perl_quiet = 0; - script_display_short_list (weechat_perl_plugin, - perl_scripts); + plugin_script_display_short_list (weechat_perl_plugin, + perl_scripts); weechat_hook_signal ("quit", &weechat_perl_signal_quit_upgrade_cb, NULL); weechat_hook_signal ("upgrade", &weechat_perl_signal_quit_upgrade_cb, NULL); @@ -1003,7 +1003,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) { /* unload all scripts */ perl_quiet = 1; - script_end (plugin, &perl_scripts, &weechat_perl_unload_all); + plugin_script_end (plugin, &perl_scripts, &weechat_perl_unload_all); perl_quiet = 0; #ifndef MULTIPLICITY diff --git a/src/plugins/scripts/perl/weechat-perl.h b/src/plugins/perl/weechat-perl.h index 87a601aac..87a601aac 100644 --- a/src/plugins/scripts/perl/weechat-perl.h +++ b/src/plugins/perl/weechat-perl.h diff --git a/src/plugins/plugin-script-api.c b/src/plugins/plugin-script-api.c new file mode 100644 index 000000000..0f7794857 --- /dev/null +++ b/src/plugins/plugin-script-api.c @@ -0,0 +1,1482 @@ +/* + * Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * script-api.c: script API functions, used by script plugins (perl/python/..) + */ + +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <stdio.h> + +#include "weechat-plugin.h" +#include "plugin-script.h" +#include "plugin-script-api.h" +#include "plugin-script-callback.h" + + +/* + * plugin_script_api_charset_set: set charset for script + */ + +void +plugin_script_api_charset_set (struct t_plugin_script *script, + const char *charset) +{ + if (script->charset) + free (script->charset); + + script->charset = (charset) ? strdup (charset) : NULL; +} + +/* + * plugin_script_api_config_new: create a new configuration file + * return new configuration file, NULL if error + */ + +struct t_config_file * +plugin_script_api_config_new (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + int (*callback_reload)(void *data, + struct t_config_file *config_file), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_config_file *new_config_file; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_config_file = weechat_config_new (name, callback_reload, + (function && function[0]) ? script_cb : NULL); + if (new_config_file) + script_cb->config_file = new_config_file; + else + plugin_script_callback_remove (script, script_cb); + + return new_config_file; +} + +/* + * plugin_script_api_config_new_section: create a new section in configuration + * file + * return new section, NULL if error + */ + +struct t_config_section * +plugin_script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_file *config_file, + const char *name, + int user_can_add_options, + int user_can_delete_options, + int (*callback_read)(void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value), + const char *function_read, + const char *data_read, + int (*callback_write)(void *data, + struct t_config_file *config_file, + const char *section_name), + const char *function_write, + const char *data_write, + int (*callback_write_default)(void *data, + struct t_config_file *config_file, + const char *section_name), + const char *function_write_default, + const char *data_write_default, + int (*callback_create_option)(void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value), + const char *function_create_option, + const char *data_create_option, + int (*callback_delete_option)(void *data, + struct t_config_file *config_file, + struct t_config_section *section, + struct t_config_option *option), + const char *function_delete_option, + const char *data_delete_option) +{ + struct t_script_callback *script_cb_read, *script_cb_write; + struct t_script_callback *script_cb_write_default, *script_cb_create_option; + struct t_script_callback *script_cb_delete_option; + struct t_config_section *new_section; + + script_cb_read = plugin_script_callback_add (script, function_read, data_read); + script_cb_write = plugin_script_callback_add (script, function_write, data_write); + script_cb_write_default = plugin_script_callback_add (script, function_write_default, data_write_default); + script_cb_create_option = plugin_script_callback_add (script, function_create_option, data_create_option); + script_cb_delete_option = plugin_script_callback_add (script, function_delete_option, data_delete_option); + if (!script_cb_read || !script_cb_write || !script_cb_write_default + || !script_cb_create_option || !script_cb_delete_option) + { + if (script_cb_read) + plugin_script_callback_remove (script, script_cb_read); + if (script_cb_write) + plugin_script_callback_remove (script, script_cb_write); + if (script_cb_write_default) + plugin_script_callback_remove (script, script_cb_write_default); + if (script_cb_create_option) + plugin_script_callback_remove (script, script_cb_create_option); + if (script_cb_delete_option) + plugin_script_callback_remove (script, script_cb_delete_option); + return NULL; + } + + new_section = weechat_config_new_section (config_file, + name, + user_can_add_options, + user_can_delete_options, + (function_read && function_read[0]) ? callback_read : NULL, + (function_read && function_read[0]) ? script_cb_read : NULL, + (function_write && function_write[0]) ? callback_write : NULL, + (function_write && function_write[0]) ? script_cb_write : NULL, + (function_write_default && function_write_default[0]) ? callback_write_default : NULL, + (function_write_default && function_write_default[0]) ? script_cb_write_default : NULL, + (function_create_option && function_create_option[0]) ? callback_create_option : NULL, + (function_create_option && function_create_option[0]) ? script_cb_create_option : NULL, + (function_delete_option && function_delete_option[0]) ? callback_delete_option : NULL, + (function_delete_option && function_delete_option[0]) ? script_cb_delete_option : NULL); + if (new_section) + { + script_cb_read->config_file = config_file; + script_cb_read->config_section = new_section; + script_cb_write->config_file = config_file; + script_cb_write->config_section = new_section; + script_cb_write_default->config_file = config_file; + script_cb_write_default->config_section = new_section; + script_cb_create_option->config_file = config_file; + script_cb_create_option->config_section = new_section; + script_cb_delete_option->config_file = config_file; + script_cb_delete_option->config_section = new_section; + } + else + { + plugin_script_callback_remove (script, script_cb_read); + plugin_script_callback_remove (script, script_cb_write); + plugin_script_callback_remove (script, script_cb_write_default); + plugin_script_callback_remove (script, script_cb_create_option); + plugin_script_callback_remove (script, script_cb_delete_option); + } + + return new_section; +} + +/* + * plugin_script_api_config_new_option: create a new option in section + * return new option, NULL if error + */ + +struct t_config_option * +plugin_script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_file *config_file, + struct t_config_section *section, + const char *name, const char *type, + const char *description, const char *string_values, + int min, int max, + const char *default_value, + const char *value, + int null_value_allowed, + int (*callback_check_value)(void *data, + struct t_config_option *option, + const char *value), + const char *function_check_value, + const char *data_check_value, + void (*callback_change)(void *data, + struct t_config_option *option), + const char *function_change, + const char *data_change, + void (*callback_delete)(void *data, + struct t_config_option *option), + const char *function_delete, + const char *data_delete) +{ + struct t_script_callback *script_cb_check_value, *script_cb_change; + struct t_script_callback *script_cb_delete; + struct t_config_option *new_option; + + script_cb_check_value = plugin_script_callback_add (script, function_check_value, data_check_value); + script_cb_change = plugin_script_callback_add (script, function_change, data_change); + script_cb_delete = plugin_script_callback_add (script, function_delete, data_delete); + if (!script_cb_check_value || !script_cb_change || !script_cb_delete) + { + if (script_cb_check_value) + plugin_script_callback_remove (script, script_cb_check_value); + if (script_cb_change) + plugin_script_callback_remove (script, script_cb_change); + if (script_cb_delete) + plugin_script_callback_remove (script, script_cb_delete); + return NULL; + } + + new_option = weechat_config_new_option (config_file, section, name, type, + description, string_values, min, + max, default_value, value, + null_value_allowed, + (function_check_value && function_check_value[0]) ? callback_check_value : NULL, + (function_check_value && function_check_value[0]) ? script_cb_check_value : NULL, + (function_change && function_change[0]) ? callback_change : NULL, + (function_change && function_change[0]) ? script_cb_change : NULL, + (function_delete && function_delete[0]) ? callback_delete : NULL, + (function_delete && function_delete[0]) ? script_cb_delete : NULL); + if (new_option) + { + script_cb_check_value->config_file = config_file; + script_cb_check_value->config_section = section; + script_cb_check_value->config_option = new_option; + script_cb_change->config_file = config_file; + script_cb_change->config_section = section; + script_cb_change->config_option = new_option; + script_cb_delete->config_file = config_file; + script_cb_delete->config_section = section; + script_cb_delete->config_option = new_option; + } + else + { + plugin_script_callback_remove (script, script_cb_check_value); + plugin_script_callback_remove (script, script_cb_change); + plugin_script_callback_remove (script, script_cb_delete); + } + + return new_option; +} + +/* + * plugin_script_api_config_option_free: free an option in configuration file + */ + +void +plugin_script_api_config_option_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_option *option) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + if (!weechat_plugin || !script || !option) + return; + + weechat_config_option_free (option); + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if (ptr_script_cb->config_option == option) + plugin_script_callback_remove (script, ptr_script_cb); + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_config_section_free_options: free all options of a section in + * configuration file + */ + +void +plugin_script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + if (!weechat_plugin || !script || !section) + return; + + weechat_config_section_free_options (section); + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if ((ptr_script_cb->config_section == section) + && ptr_script_cb->config_option) + plugin_script_callback_remove (script, ptr_script_cb); + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_config_section_free: free a section in configuration file + */ + +void +plugin_script_api_config_section_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + if (!weechat_plugin || !script || !section) + return; + + weechat_config_section_free (section); + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if (ptr_script_cb->config_section == section) + plugin_script_callback_remove (script, ptr_script_cb); + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_config_free: free configuration file + */ + +void +plugin_script_api_config_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_file *config_file) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + if (!weechat_plugin || !script || !config_file) + return; + + weechat_config_free (config_file); + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if (ptr_script_cb->config_file == config_file) + plugin_script_callback_remove (script, ptr_script_cb); + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_printf: print a message + */ + +void +plugin_script_api_printf (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, const char *format, ...) +{ + char *buf2; + + weechat_va_format (format); + if (!vbuffer) + return; + + buf2 = (script && script->charset && script->charset[0]) ? + weechat_iconv_to_internal (script->charset, vbuffer) : NULL; + weechat_printf (buffer, "%s", (buf2) ? buf2 : vbuffer); + if (buf2) + free (buf2); + + free (vbuffer); +} + +/* + * plugin_script_api_printf_date_tags: print a message with optional date and + * tags + */ + +void +plugin_script_api_printf_date_tags (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, + time_t date, const char *tags, + const char *format, ...) +{ + char *buf2; + + weechat_va_format (format); + if (!vbuffer) + return; + + buf2 = (script->charset && script->charset[0]) ? + weechat_iconv_to_internal (script->charset, vbuffer) : NULL; + weechat_printf_date_tags (buffer, date, tags, + "%s", (buf2) ? buf2 : vbuffer); + if (buf2) + free (buf2); + + free (vbuffer); +} + +/* + * plugin_script_api_printf_y: print a message on a buffer with free content + */ + +void +plugin_script_api_printf_y (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, int y, + const char *format, ...) +{ + char *buf2; + + weechat_va_format (format); + if (!vbuffer) + return; + + buf2 = (script->charset && script->charset[0]) ? + weechat_iconv_to_internal (script->charset, vbuffer) : NULL; + weechat_printf_y (buffer, y, "%s", (buf2) ? buf2 : vbuffer); + if (buf2) + free (buf2); + + free (vbuffer); +} + +/* + * plugin_script_api_log_printf: add a message in WeeChat log file + */ + +void +plugin_script_api_log_printf (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *format, ...) +{ + char *buf2; + + weechat_va_format (format); + if (!vbuffer) + return; + + buf2 = (script->charset && script->charset[0]) ? + weechat_iconv_to_internal (script->charset, vbuffer) : NULL; + weechat_log_printf ("%s", (buf2) ? buf2 : vbuffer); + if (buf2) + free (buf2); + + free (vbuffer); +} + +/* + * plugin_script_api_hook_command: hook a command + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_command (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, const char *description, + const char *args, const char *args_description, + const char *completion, + int (*callback)(void *data, + struct t_gui_buffer *buffer, + int argc, char **argv, + char **argv_eol), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_command (command, description, args, + args_description, completion, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_command_run: hook a command_run + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, + int (*callback)(void *data, + struct t_gui_buffer *buffer, + const char *command), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_command_run (command, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_timer: hook a timer + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + int interval, int align_second, int max_calls, + int (*callback)(void *data, + int remaining_calls), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_timer (interval, align_second, max_calls, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_fd: hook a fd + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_fd (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + int fd, int flag_read, int flag_write, + int flag_exception, + int (*callback)(void *data, int fd), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_fd (fd, flag_read, flag_write, flag_exception, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_process_hashtable: hook a process + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, + struct t_hashtable *options, + int timeout, + int (*callback)(void *data, + const char *command, + int return_code, + const char *out, + const char *err), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_process_hashtable (command, options, timeout, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_process: hook a process + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_process (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, + int timeout, + int (*callback)(void *data, + const char *command, + int return_code, + const char *out, + const char *err), + const char *function, + const char *data) +{ + return plugin_script_api_hook_process_hashtable (weechat_plugin, script, + command, NULL, timeout, + callback, function, data); +} + +/* + * plugin_script_api_hook_connect: hook a connection + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *proxy, const char *address, int port, + int sock, int ipv6, void *gnutls_sess, + void *gnutls_cb, int gnutls_dhkey_size, + const char *gnutls_priorities, + const char *local_hostname, + int (*callback)(void *data, int status, + int gnutls_rc, + const char *error, + const char *ip_address), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_connect (proxy, address, port, sock, ipv6, + gnutls_sess, gnutls_cb, gnutls_dhkey_size, + gnutls_priorities, local_hostname, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_print: hook a print + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_print (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, + const char *tags, const char *message, + int strip_colors, + int (*callback)(void *data, + struct t_gui_buffer *buffer, + time_t date, + int tags_count, const char **tags, + int displayed, int highlight, + const char *prefix, + const char *message), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_print (buffer, tags, message, strip_colors, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_signal: hook a signal + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_signal (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *signal, + int (*callback)(void *data, const char *signal, + const char *type_data, + void *signal_data), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_signal (signal, callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_hsignal: hook a hsignal + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_hsignal (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *signal, + int (*callback)(void *data, const char *signal, + struct t_hashtable *hashtable), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_hsignal (signal, callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_config: hook a config option + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_config (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option, + int (*callback)(void *data, const char *option, + const char *value), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_config (option, callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_completion: hook a completion + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *completion, + const char *description, + int (*callback)(void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_completion (completion, description, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_modifier: hook a modifier + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *modifier, + char *(*callback)(void *data, const char *modifier, + const char *modifier_data, + const char *string), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_modifier (modifier, callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_info: hook an info + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_info (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *info_name, + const char *description, + const char *args_description, + const char *(*callback)(void *data, + const char *info_name, + const char *arguments), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_info (info_name, description, args_description, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_info_hashtable: hook an info_hashtable + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *info_name, + const char *description, + const char *args_description, + const char *output_description, + struct t_hashtable *(*callback)(void *data, + const char *info_name, + struct t_hashtable *hashtable), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_info_hashtable (info_name, description, + args_description, + output_description, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_infolist: hook an infolist + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *infolist_name, + const char *description, + const char *pointer_description, + const char *args_description, + struct t_infolist *(*callback)(void *data, + const char *infolist_name, + void *pointer, + const char *arguments), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_infolist (infolist_name, description, + pointer_description, args_description, + callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_hook_focus: hook a focus + * return new hook, NULL if error + */ + +struct t_hook * +plugin_script_api_hook_focus (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *area, + struct t_hashtable *(*callback)(void *data, + struct t_hashtable *info), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_hook *new_hook; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_hook = weechat_hook_focus (area, callback, script_cb); + if (new_hook) + { + weechat_hook_set (new_hook, "subplugin", script->name); + script_cb->hook = new_hook; + } + else + plugin_script_callback_remove (script, script_cb); + + return new_hook; +} + +/* + * plugin_script_api_unhook: unhook something + */ + +void +plugin_script_api_unhook (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_hook *hook) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + if (!weechat_plugin || !script || !hook) + return; + + weechat_unhook (hook); + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if (ptr_script_cb->hook == hook) + plugin_script_callback_remove (script, ptr_script_cb); + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_unhook_all: remove all hooks from a script + */ + +void +plugin_script_api_unhook_all (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if (ptr_script_cb->hook) + { + weechat_unhook (ptr_script_cb->hook); + plugin_script_callback_remove (script, ptr_script_cb); + } + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_buffer_new: create a new buffer + */ + +struct t_gui_buffer * +plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + int (*input_callback)(void *data, + struct t_gui_buffer *buffer, + const char *input_data), + const char *function_input, + const char *data_input, + int (*close_callback)(void *data, + struct t_gui_buffer *buffer), + const char *function_close, + const char *data_close) +{ + struct t_script_callback *script_cb_input; + struct t_script_callback *script_cb_close; + struct t_gui_buffer *new_buffer; + + script_cb_input = plugin_script_callback_add (script, function_input, data_input); + script_cb_close = plugin_script_callback_add (script, function_close, data_close); + if (!script_cb_input || !script_cb_close) + { + if (script_cb_input) + plugin_script_callback_remove (script, script_cb_input); + if (script_cb_close) + plugin_script_callback_remove (script, script_cb_close); + return NULL; + } + + new_buffer = weechat_buffer_new (name, + (function_input && function_input[0]) ? input_callback : NULL, + (function_input && function_input[0]) ? script_cb_input : NULL, + (function_close && function_close[0]) ? close_callback : NULL, + (function_close && function_close[0]) ? script_cb_close : NULL); + if (new_buffer) + { + script_cb_input->buffer = new_buffer; + script_cb_close->buffer = new_buffer; + + /* used when upgrading weechat, to set callbacks */ + weechat_buffer_set (new_buffer, "localvar_set_script_name", script->name); + weechat_buffer_set (new_buffer, "localvar_set_script_input_cb", function_input); + weechat_buffer_set (new_buffer, "localvar_set_script_input_cb_data", data_input); + weechat_buffer_set (new_buffer, "localvar_set_script_close_cb", function_close); + weechat_buffer_set (new_buffer, "localvar_set_script_close_cb_data", data_close); + } + else + { + plugin_script_callback_remove (script, script_cb_input); + plugin_script_callback_remove (script, script_cb_close); + } + + return new_buffer; +} + +/* + * plugin_script_api_buffer_close: close a buffer + */ + +void +plugin_script_api_buffer_close (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + if (!weechat_plugin || !script || !buffer) + return; + + weechat_buffer_close (buffer); + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if (ptr_script_cb->buffer == buffer) + plugin_script_callback_remove (script, ptr_script_cb); + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_bar_item_new: add a new bar item + */ + +struct t_gui_bar_item * +plugin_script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + char *(*build_callback)(void *data, + struct t_gui_bar_item *item, + struct t_gui_window *window), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + struct t_gui_bar_item *new_item; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return NULL; + + new_item = weechat_bar_item_new (name, + (function && function[0]) ? build_callback : NULL, + (function && function[0]) ? script_cb : NULL); + if (new_item) + script_cb->bar_item = new_item; + else + plugin_script_callback_remove (script, script_cb); + + return new_item; +} + +/* + * plugin_script_api_bar_item_remove: remove a bar item + */ + +void +plugin_script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_bar_item *item) +{ + struct t_script_callback *ptr_script_cb, *next_callback; + + if (!weechat_plugin || !script || !item) + return; + + weechat_bar_item_remove (item); + + ptr_script_cb = script->callbacks; + while (ptr_script_cb) + { + next_callback = ptr_script_cb->next_callback; + + if (ptr_script_cb->bar_item == item) + plugin_script_callback_remove (script, ptr_script_cb); + + ptr_script_cb = next_callback; + } +} + +/* + * plugin_script_api_command: execute a command (simulate user entry) + */ + +void +plugin_script_api_command (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, const char *command) +{ + char *command2; + + command2 = (script->charset && script->charset[0]) ? + weechat_iconv_to_internal (script->charset, command) : NULL; + + weechat_command (buffer, (command2) ? command2 : command); + + if (command2) + free (command2); +} + +/* + * plugin_script_api_config_get_plugin: get a value of a script option + * format in file is "plugin.script.option" + */ + +const char * +plugin_script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option) +{ + char *option_fullname; + const char *return_value; + + option_fullname = malloc ((strlen (script->name) + + strlen (option) + 2)); + if (!option_fullname) + return NULL; + + strcpy (option_fullname, script->name); + strcat (option_fullname, "."); + strcat (option_fullname, option); + + return_value = weechat_config_get_plugin (option_fullname); + free (option_fullname); + + return return_value; +} + +/* + * plugin_script_api_config_is_set_plugin: check if a script option is set + */ + +int +plugin_script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option) +{ + char *option_fullname; + int return_code; + + option_fullname = malloc ((strlen (script->name) + + strlen (option) + 2)); + if (!option_fullname) + return 0; + + strcpy (option_fullname, script->name); + strcat (option_fullname, "."); + strcat (option_fullname, option); + + return_code = weechat_config_is_set_plugin (option_fullname); + free (option_fullname); + + return return_code; +} + +/* + * plugin_script_api_config_set_plugin: set value of a script config option + * format in file is "plugin.script.option" + */ + +int +plugin_script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option, const char *value) +{ + char *option_fullname; + int return_code; + + option_fullname = malloc ((strlen (script->name) + + strlen (option) + 2)); + if (!option_fullname) + return 0; + + strcpy (option_fullname, script->name); + strcat (option_fullname, "."); + strcat (option_fullname, option); + + return_code = weechat_config_set_plugin (option_fullname, value); + free (option_fullname); + + return return_code; +} + +/* + * plugin_script_api_config_set_plugin: set value of a script config option + * format in file is "plugin.script.option" + */ + +void +plugin_script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option, const char *description) +{ + char *option_fullname; + + option_fullname = malloc ((strlen (script->name) + + strlen (option) + 2)); + if (!option_fullname) + return; + + strcpy (option_fullname, script->name); + strcat (option_fullname, "."); + strcat (option_fullname, option); + + weechat_config_set_desc_plugin (option_fullname, description); + free (option_fullname); +} + +/* + * plugin_script_api_config_unset_plugin: unset script config option + * format in file is "plugin.script.option" + */ + +int +plugin_script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option) +{ + char *option_fullname; + int return_code; + + option_fullname = malloc ((strlen (script->name) + + strlen (option) + 2)); + if (!option_fullname) + return 0; + + strcpy (option_fullname, script->name); + strcat (option_fullname, "."); + strcat (option_fullname, option); + + return_code = weechat_config_unset_plugin (option_fullname); + free (option_fullname); + + return return_code; +} + +/* + * plugin_script_api_upgrade_read: read upgrade file + * return 1 if ok, 0 if error + */ + +int +plugin_script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_upgrade_file *upgrade_file, + int (*callback_read)(void *data, + struct t_upgrade_file *upgrade_file, + int object_id, + struct t_infolist *infolist), + const char *function, + const char *data) +{ + struct t_script_callback *script_cb; + int rc; + + if (!function || !function[0]) + return 0; + + script_cb = plugin_script_callback_add (script, function, data); + if (!script_cb) + return 0; + script_cb->upgrade_file = upgrade_file; + + rc = weechat_upgrade_read (upgrade_file, + callback_read, + script_cb); + + plugin_script_callback_remove (script, script_cb); + + return rc; +} diff --git a/src/plugins/plugin-script-api.h b/src/plugins/plugin-script-api.h new file mode 100644 index 000000000..af5bd3e85 --- /dev/null +++ b/src/plugins/plugin-script-api.h @@ -0,0 +1,359 @@ +/* + * Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __WEECHAT_PLUGIN_SCRIPT_API_H +#define __WEECHAT_PLUGIN_SCRIPT_API_H 1 + +extern void plugin_script_api_charset_set (struct t_plugin_script *script, + const char *charset); +extern struct t_config_file *plugin_script_api_config_new (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + int (*callback_reload)(void *data, + struct t_config_file *config_file), + const char *function, + const char *data); +extern struct t_config_section *plugin_script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_file *config_file, + const char *name, + int user_can_add_options, + int user_can_delete_options, + int (*callback_read)(void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value), + const char *function_read, + const char *data_read, + int (*callback_write)(void *data, + struct t_config_file *config_file, + const char *section_name), + const char *function_write, + const char *data_write, + int (*callback_write_default)(void *data, + struct t_config_file *config_file, + const char *section_name), + const char *function_write_default, + const char *data_write_default, + int (*callback_create_option)(void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value), + const char *function_create_option, + const char *data_create_option, + int (*callback_delete_option)(void *data, + struct t_config_file *config_file, + struct t_config_section *section, + struct t_config_option *option), + const char *function_delete_option, + const char *data_delete_option); +extern struct t_config_option *plugin_script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_file *config_file, + struct t_config_section *section, + const char *name, + const char *type, + const char *description, + const char *string_values, + int min, int max, + const char *default_value, + const char *value, + int null_value_allowed, + int (*callback_check_value)(void *data, + struct t_config_option *option, + const char *value), + const char *function_check_value, + const char *data_check_value, + void (*callback_change)(void *data, + struct t_config_option *option), + const char *function_change, + const char *data_change, + void (*callback_delete)(void *data, + struct t_config_option *option), + const char *function_delete, + const char *data_delete); +extern void plugin_script_api_config_option_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_option *option); +extern void plugin_script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section); +extern void plugin_script_api_config_section_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section); +extern void plugin_script_api_config_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_file *config_file); +extern void plugin_script_api_printf (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, + const char *format, ...); +extern void plugin_script_api_printf_date_tags (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, + time_t date, const char *tags, + const char *format, ...); +extern void plugin_script_api_printf_y (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, + int y, const char *format, ...); +extern void plugin_script_api_log_printf (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *format, ...); +extern struct t_hook *plugin_script_api_hook_command (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, const char *description, + const char *args, const char *args_description, + const char *completion, + int (*callback)(void *data, + struct t_gui_buffer *buffer, + int argc, char **argv, + char **argv_eol), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, + int (*callback)(void *data, + struct t_gui_buffer *buffer, + const char *command), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + int interval, int align_second, + int max_calls, + int (*callback)(void *data, + int remaining_calls), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_fd (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + int fd, int flag_read, + int flag_write, int flag_exception, + int (*callback)(void *data, int fd), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, + struct t_hashtable *options, + int timeout, + int (*callback)(void *data, + const char *command, + int return_code, + const char *out, + const char *err), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_process (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *command, + int timeout, + int (*callback)(void *data, + const char *command, + int return_code, + const char *out, + const char *err), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *proxy, + const char *address, + int port, + int sock, + int ipv6, + void *gnutls_sess, + void *gnutls_cb, + int gnutls_dhkey_size, + const char *gnutls_priorities, + const char *local_hostname, + int (*callback)(void *data, + int status, + int gnutls_rc, + const char *error, + const char *ip_address), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_print (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, + const char *tags, + const char *message, + int strip_colors, + int (*callback)(void *data, + struct t_gui_buffer *buffer, + time_t date, + int tags_count, + const char **tags, + int displayed, + int highlight, + const char *prefix, + const char *message), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_signal (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *signal, + int (*callback)(void *data, + const char *signal, + const char *type_data, + void *signal_data), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_hsignal (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *signal, + int (*callback)(void *data, + const char *signal, + struct t_hashtable *hashtable), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_config (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option, + int (*callback)(void *data, + const char *option, + const char *value), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *completion, + const char *description, + int (*callback)(void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *modifier, + char *(*callback)(void *data, + const char *modifier, + const char *modifier_data, + const char *string), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_info (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *info_name, + const char *description, + const char *args_description, + const char *(*callback)(void *data, + const char *info_name, + const char *arguments), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *info_name, + const char *description, + const char *args_description, + const char *output_description, + struct t_hashtable *(*callback)(void *data, + const char *info_name, + struct t_hashtable *hashtable), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *infolist_name, + const char *description, + const char *pointer_description, + const char *args_description, + struct t_infolist *(*callback)(void *data, + const char *infolist_name, + void *pointer, + const char *arguments), + const char *function, + const char *data); +extern struct t_hook *plugin_script_api_hook_focus (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *area, + struct t_hashtable *(*callback)(void *data, + struct t_hashtable *info), + const char *function, + const char *data); +extern void plugin_script_api_unhook (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_hook *hook); +extern void plugin_script_api_unhook_all (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script); +extern struct t_gui_buffer *plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + int (*input_callback)(void *data, + struct t_gui_buffer *buffer, + const char *input_data), + const char *function_input, + const char *data_input, + int (*close_callback)(void *data, + struct t_gui_buffer *buffer), + const char *function_close, + const char *data_close); +extern void plugin_script_api_buffer_close (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer); +extern struct t_gui_bar_item *plugin_script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + char *(*build_callback)(void *data, + struct t_gui_bar_item *item, + struct t_gui_window *window), + const char *function, + const char *data); +extern void plugin_script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_bar_item *item); +extern void plugin_script_api_command (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_gui_buffer *buffer, + const char *command); +extern const char *plugin_script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option); +extern int plugin_script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option); +extern int plugin_script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option, const char *value); +extern void plugin_script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option, + const char *description); +extern int plugin_script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *option); +extern int plugin_script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_upgrade_file *upgrade_file, + int (*callback_read)(void *data, + struct t_upgrade_file *upgrade_file, + int object_id, + struct t_infolist *infolist), + const char *function, + const char *data); + +#endif /* __WEECHAT_PLUGIN_SCRIPT_API_H */ diff --git a/src/plugins/scripts/script-callback.c b/src/plugins/plugin-script-callback.c index 4c1fa7414..673114174 100644 --- a/src/plugins/scripts/script-callback.c +++ b/src/plugins/plugin-script-callback.c @@ -25,17 +25,17 @@ #include <unistd.h> #include <string.h> -#include "../weechat-plugin.h" -#include "script.h" -#include "script-callback.h" +#include "weechat-plugin.h" +#include "plugin-script.h" +#include "plugin-script-callback.h" /* - * script_callback_alloc: allocate a new callback and initializes it + * plugin_script_callback_alloc: allocate a new callback and initializes it */ struct t_script_callback * -script_callback_alloc () +plugin_script_callback_alloc () { struct t_script_callback *new_script_callback; @@ -59,21 +59,21 @@ script_callback_alloc () } /* - * script_callback_add: allocate a new callback, initialize it - * (script/function/data) and add it to list - * return pointer to new callback or NULL if error + * plugin_script_callback_add: allocate a new callback, initialize it + * (script/function/data) and add it to list + * return pointer to new callback or NULL if error */ struct t_script_callback * -script_callback_add (struct t_plugin_script *script, - const char *function, - const char *data) +plugin_script_callback_add (struct t_plugin_script *script, + const char *function, + const char *data) { struct t_script_callback *script_cb; if (!script) return NULL; - script_cb = script_callback_alloc (); + script_cb = plugin_script_callback_alloc (); if (!script_cb) return NULL; @@ -93,11 +93,11 @@ script_callback_add (struct t_plugin_script *script, } /* - * script_callback_free_data: free data of a script callback + * plugin_script_callback_free_data: free data of a script callback */ void -script_callback_free_data (struct t_script_callback *script_callback) +plugin_script_callback_free_data (struct t_script_callback *script_callback) { if (script_callback->function) free (script_callback->function); @@ -106,12 +106,12 @@ script_callback_free_data (struct t_script_callback *script_callback) } /* - * script_callback_remove: remove a callback from a script + * plugin_script_callback_remove: remove a callback from a script */ void -script_callback_remove (struct t_plugin_script *script, - struct t_script_callback *script_callback) +plugin_script_callback_remove (struct t_plugin_script *script, + struct t_script_callback *script_callback) { /* remove callback from list */ if (script_callback->prev_callback) @@ -123,31 +123,31 @@ script_callback_remove (struct t_plugin_script *script, if (script->callbacks == script_callback) script->callbacks = script_callback->next_callback; - script_callback_free_data (script_callback); + plugin_script_callback_free_data (script_callback); free (script_callback); } /* - * script_callback_remove_all: remove all callbacks from a script + * plugin_script_callback_remove_all: remove all callbacks from a script */ void -script_callback_remove_all (struct t_plugin_script *script) +plugin_script_callback_remove_all (struct t_plugin_script *script) { while (script->callbacks) { - script_callback_remove (script, script->callbacks); + plugin_script_callback_remove (script, script->callbacks); } } /* - * script_callback_print_log: print callback infos in log (usually for crash dump) + * plugin_script_callback_print_log: print callback infos in log (usually for crash dump) */ void -script_callback_print_log (struct t_weechat_plugin *weechat_plugin, - struct t_script_callback *script_callback) +plugin_script_callback_print_log (struct t_weechat_plugin *weechat_plugin, + struct t_script_callback *script_callback) { weechat_log_printf (""); weechat_log_printf (" [callback (addr:0x%lx)]", script_callback); diff --git a/src/plugins/scripts/script-callback.h b/src/plugins/plugin-script-callback.h index f48fdb13c..5ffdea846 100644 --- a/src/plugins/scripts/script-callback.h +++ b/src/plugins/plugin-script-callback.h @@ -17,8 +17,8 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __WEECHAT_SCRIPT_CALLBACK_H -#define __WEECHAT_SCRIPT_CALLBACK_H 1 +#ifndef __WEECHAT_PLUGIN_SCRIPT_CALLBACK_H +#define __WEECHAT_PLUGIN_SCRIPT_CALLBACK_H 1 struct t_script_callback { @@ -36,13 +36,13 @@ struct t_script_callback struct t_script_callback *next_callback; /* link to previous callback */ }; -extern struct t_script_callback *script_callback_add (struct t_plugin_script *script, - const char *function, - const char *data); -extern void script_callback_remove (struct t_plugin_script *script, - struct t_script_callback *script_callback); -extern void script_callback_remove_all (struct t_plugin_script *script); -extern void script_callback_print_log (struct t_weechat_plugin *weechat_plugin, - struct t_script_callback *script_callback); +extern struct t_script_callback *plugin_script_callback_add (struct t_plugin_script *script, + const char *function, + const char *data); +extern void plugin_script_callback_remove (struct t_plugin_script *script, + struct t_script_callback *script_callback); +extern void plugin_script_callback_remove_all (struct t_plugin_script *script); +extern void plugin_script_callback_print_log (struct t_weechat_plugin *weechat_plugin, + struct t_script_callback *script_callback); -#endif /* __WEECHAT_SCRIPT_CALLBACK_H */ +#endif /* __WEECHAT_PLUGIN_SCRIPT_CALLBACK_H */ diff --git a/src/plugins/scripts/script.c b/src/plugins/plugin-script.c index 7f5ec2d2e..be35c605e 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/plugin-script.c @@ -18,7 +18,7 @@ */ /* - * script.c: common functions used by script plugins (perl/python/..) + * plugin-script.c: common functions used by script plugins (perl/python/..) */ #include <stdlib.h> @@ -32,9 +32,9 @@ #include <sys/stat.h> #include <dirent.h> -#include "../weechat-plugin.h" -#include "script.h" -#include "script-callback.h" +#include "weechat-plugin.h" +#include "plugin-script.h" +#include "plugin-script-callback.h" #define SCRIPT_OPTION_CHECK_LICENSE "check_license" @@ -43,11 +43,11 @@ int script_option_check_license = 0; /* - * script_config_read: read script configuration + * plugin_script_config_read: read script configuration */ void -script_config_read (struct t_weechat_plugin *weechat_plugin) +plugin_script_config_read (struct t_weechat_plugin *weechat_plugin) { const char *string; @@ -64,35 +64,36 @@ script_config_read (struct t_weechat_plugin *weechat_plugin) } /* - * script_config_cb: callback called when config option is changed + * plugin_script_config_cb: callback called when config option is changed */ int -script_config_cb (void *data, const char *option, const char *value) +plugin_script_config_cb (void *data, const char *option, const char *value) { /* make C compiler happy */ (void) option; (void) value; - script_config_read (data); + plugin_script_config_read (data); return WEECHAT_RC_OK; } /* - * script_init: initialize script plugin + * plugin_script_init: initialize script plugin */ void -script_init (struct t_weechat_plugin *weechat_plugin, int argc, char *argv[], - struct t_plugin_script_init *init) +plugin_script_init (struct t_weechat_plugin *weechat_plugin, + int argc, char *argv[], + struct t_plugin_script_init *init) { char *string, *completion; char signal_name[128]; int length, i, auto_load_scripts; /* read script configuration */ - script_config_read (weechat_plugin); + plugin_script_config_read (weechat_plugin); /* add hook for config option */ length = strlen (weechat_plugin->name) + 64; @@ -101,7 +102,7 @@ script_init (struct t_weechat_plugin *weechat_plugin, int argc, char *argv[], { snprintf (string, length, "plugins.var.%s.%s", weechat_plugin->name, SCRIPT_OPTION_CHECK_LICENSE); - weechat_hook_config (string, &script_config_cb, weechat_plugin); + weechat_hook_config (string, &plugin_script_config_cb, weechat_plugin); free (string); } @@ -207,19 +208,19 @@ script_init (struct t_weechat_plugin *weechat_plugin, int argc, char *argv[], /* autoload scripts */ if (auto_load_scripts) { - script_auto_load (weechat_plugin, init->callback_load_file); + plugin_script_auto_load (weechat_plugin, init->callback_load_file); } } /* - * script_valid: check if a script pointer exists - * return 1 if script exists - * 0 if script is not found + * plugin_script_valid: check if a script pointer exists + * return 1 if script exists + * 0 if script is not found */ int -script_valid (struct t_plugin_script *scripts, - struct t_plugin_script *script) +plugin_script_valid (struct t_plugin_script *scripts, + struct t_plugin_script *script) { struct t_plugin_script *ptr_script; @@ -238,13 +239,13 @@ script_valid (struct t_plugin_script *scripts, } /* - * script_ptr2str: convert pointer to string for usage in a script - * (any language) - * WARNING: result has to be free() after use + * plugin_script_ptr2str: convert pointer to string for usage in a script + * (any language) + * WARNING: result has to be free() after use */ char * -script_ptr2str (void *pointer) +plugin_script_ptr2str (void *pointer) { char pointer_str[128]; @@ -258,13 +259,13 @@ script_ptr2str (void *pointer) } /* - * script_str2ptr: convert string to pointer for usage outside script + * plugin_script_str2ptr: convert string to pointer for usage outside script */ void * -script_str2ptr (struct t_weechat_plugin *weechat_plugin, - const char *script_name, const char *function_name, - const char *str_pointer) +plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin, + const char *script_name, const char *function_name, + const char *str_pointer) { long unsigned int value; int rc; @@ -299,12 +300,12 @@ invalid: } /* - * script_auto_load: auto-load all scripts in a directory + * plugin_script_auto_load: auto-load all scripts in a directory */ void -script_auto_load (struct t_weechat_plugin *weechat_plugin, - void (*callback)(void *data, const char *filename)) +plugin_script_auto_load (struct t_weechat_plugin *weechat_plugin, + void (*callback)(void *data, const char *filename)) { const char *dir_home; char *dir_name; @@ -327,12 +328,12 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin, } /* - * script_search: search a script in list (by registered name) + * plugin_script_search: search a script in list (by registered name) */ struct t_plugin_script * -script_search (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, const char *name) +plugin_script_search (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, const char *name) { struct t_plugin_script *ptr_script; @@ -348,13 +349,13 @@ script_search (struct t_weechat_plugin *weechat_plugin, } /* - * script_search_by_full_name: search a script in list (by full name, for - * example "weeget.py") + * plugin_script_search_by_full_name: search a script in list (by full name, + * for example "weeget.py") */ struct t_plugin_script * -script_search_by_full_name (struct t_plugin_script *scripts, - const char *full_name) +plugin_script_search_by_full_name (struct t_plugin_script *scripts, + const char *full_name) { char *base_name; struct t_plugin_script *ptr_script; @@ -372,12 +373,12 @@ script_search_by_full_name (struct t_plugin_script *scripts, } /* - * script_search_path: search path name of a script + * plugin_script_search_path: search path name of a script */ char * -script_search_path (struct t_weechat_plugin *weechat_plugin, - const char *filename) +plugin_script_search_path (struct t_weechat_plugin *weechat_plugin, + const char *filename) { char *final_name; const char *dir_home, *dir_system; @@ -451,13 +452,13 @@ script_search_path (struct t_weechat_plugin *weechat_plugin, } /* - * script_find_pos: find position for a script (for sorting scripts list) + * plugin_script_find_pos: find position for a script (for sorting scripts list) */ struct t_plugin_script * -script_find_pos (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - struct t_plugin_script *script) +plugin_script_find_pos (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + struct t_plugin_script *script) { struct t_plugin_script *ptr_script; @@ -470,20 +471,20 @@ script_find_pos (struct t_weechat_plugin *weechat_plugin, } /* - * script_insert_sorted: insert a script in list, keeping sort on name + * plugin_script_insert_sorted: insert a script in list, keeping sort on name */ void -script_insert_sorted (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script **scripts, - struct t_plugin_script **last_script, - struct t_plugin_script *script) +plugin_script_insert_sorted (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script **scripts, + struct t_plugin_script **last_script, + struct t_plugin_script *script) { struct t_plugin_script *pos_script; if (*scripts) { - pos_script = script_find_pos (weechat_plugin, *scripts, script); + pos_script = plugin_script_find_pos (weechat_plugin, *scripts, script); if (pos_script) { @@ -516,16 +517,17 @@ script_insert_sorted (struct t_weechat_plugin *weechat_plugin, } /* - * script_add: add a script to list of scripts + * plugin_script_add: add a script to list of scripts */ struct t_plugin_script * -script_add (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script **scripts, - struct t_plugin_script **last_script, - const char *filename, const char *name, const char *author, const char *version, - const char *license, const char *description, const char *shutdown_func, - const char *charset) +plugin_script_add (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script **scripts, + struct t_plugin_script **last_script, + const char *filename, const char *name, const char *author, + const char *version, const char *license, + const char *description, const char *shutdown_func, + const char *charset) { struct t_plugin_script *new_script; @@ -565,7 +567,8 @@ script_add (struct t_weechat_plugin *weechat_plugin, new_script->callbacks = NULL; new_script->unloading = 0; - script_insert_sorted (weechat_plugin, scripts, last_script, new_script); + plugin_script_insert_sorted (weechat_plugin, scripts, last_script, + new_script); return new_script; } @@ -578,20 +581,20 @@ script_add (struct t_weechat_plugin *weechat_plugin, } /* - * script_set_buffer_callbacks: restore buffers callbacks (input and - * close) for buffers created by script - * plugin + * plugin_script_set_buffer_callbacks: restore buffers callbacks (input and + * close) for buffers created by script + * plugin */ void -script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - struct t_plugin_script *script, - int (*callback_buffer_input) (void *data, - struct t_gui_buffer *buffer, - const char *input_data), - int (*callback_buffer_close) (void *data, - struct t_gui_buffer *buffer)) +plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + struct t_plugin_script *script, + int (*callback_buffer_input) (void *data, + struct t_gui_buffer *buffer, + const char *input_data), + int (*callback_buffer_close) (void *data, + struct t_gui_buffer *buffer)) { struct t_infolist *infolist; struct t_gui_buffer *ptr_buffer; @@ -612,8 +615,8 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, script_name = weechat_buffer_get_string (ptr_buffer, "localvar_script_name"); if (script_name && script_name[0]) { - ptr_script = script_search (weechat_plugin, scripts, - script_name); + ptr_script = plugin_script_search (weechat_plugin, scripts, + script_name); if (ptr_script && (ptr_script == script)) { str_script_input_cb = weechat_buffer_get_string (ptr_buffer, @@ -627,9 +630,9 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, if (str_script_input_cb && str_script_input_cb[0]) { - script_cb_input = script_callback_add (ptr_script, - str_script_input_cb, - str_script_input_cb_data); + script_cb_input = plugin_script_callback_add (ptr_script, + str_script_input_cb, + str_script_input_cb_data); if (script_cb_input) { script_cb_input->buffer = ptr_buffer; @@ -643,9 +646,9 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, } if (str_script_close_cb && str_script_close_cb[0]) { - script_cb_close = script_callback_add (ptr_script, - str_script_close_cb, - str_script_close_cb_data); + script_cb_close = plugin_script_callback_add (ptr_script, + str_script_close_cb, + str_script_close_cb_data); if (script_cb_close) { script_cb_close->buffer = ptr_buffer; @@ -666,13 +669,13 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, } /* - * script_remove_buffer_callbacks: remove callbacks for a buffer (called when a - * buffer is closed by user) + * plugin_script_remove_buffer_callbacks: remove callbacks for a buffer (called + * when a buffer is closed by user) */ void -script_remove_buffer_callbacks (struct t_plugin_script *scripts, - struct t_gui_buffer *buffer) +plugin_script_remove_buffer_callbacks (struct t_plugin_script *scripts, + struct t_gui_buffer *buffer) { struct t_plugin_script *ptr_script; struct t_script_callback *ptr_script_cb, *next_script_cb; @@ -692,7 +695,7 @@ script_remove_buffer_callbacks (struct t_plugin_script *scripts, next_script_cb = ptr_script_cb->next_callback; if (ptr_script_cb->buffer == buffer) - script_callback_remove (ptr_script, ptr_script_cb); + plugin_script_callback_remove (ptr_script, ptr_script_cb); ptr_script_cb = next_script_cb; } @@ -701,14 +704,14 @@ script_remove_buffer_callbacks (struct t_plugin_script *scripts, } /* - * script_remove: remove a script from list of scripts + * plugin_script_remove: remove a script from list of scripts */ void -script_remove (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script **scripts, - struct t_plugin_script **last_script, - struct t_plugin_script *script) +plugin_script_remove (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script **scripts, + struct t_plugin_script **last_script, + struct t_plugin_script *script) { struct t_script_callback *ptr_script_cb, *ptr_script_cb2; @@ -762,7 +765,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin, } /* remove all callbacks created by this script */ - script_callback_remove_all (script); + plugin_script_callback_remove_all (script); /* free data */ if (script->filename) @@ -797,13 +800,13 @@ script_remove (struct t_weechat_plugin *weechat_plugin, } /* - * script_completion: complete with list of scripts + * plugin_script_completion: complete with list of scripts */ void -script_completion (struct t_weechat_plugin *weechat_plugin, - struct t_gui_completion *completion, - struct t_plugin_script *scripts) +plugin_script_completion (struct t_weechat_plugin *weechat_plugin, + struct t_gui_completion *completion, + struct t_plugin_script *scripts) { struct t_plugin_script *ptr_script; @@ -816,11 +819,11 @@ script_completion (struct t_weechat_plugin *weechat_plugin, } /* - * script_action_add: add script name for a plugin action + * plugin_script_action_add: add script name for a plugin action */ void -script_action_add (char **action_list, const char *name) +plugin_script_action_add (char **action_list, const char *name) { int length; char *action_list2; @@ -850,12 +853,13 @@ script_action_add (char **action_list, const char *name) } /* - * script_remove_file: remove script file(s) from disk + * plugin_script_remove_file: remove script file(s) from disk */ void -script_remove_file (struct t_weechat_plugin *weechat_plugin, const char *name, - int display_error_if_no_script_removed) +plugin_script_remove_file (struct t_weechat_plugin *weechat_plugin, + const char *name, + int display_error_if_no_script_removed) { int num_found, i; char *path_script; @@ -864,7 +868,7 @@ script_remove_file (struct t_weechat_plugin *weechat_plugin, const char *name, i = 0; while (i < 2) { - path_script = script_search_path (weechat_plugin, name); + path_script = plugin_script_search_path (weechat_plugin, name); /* script not found? */ if (!path_script || (strcmp (path_script, name) == 0)) break; @@ -900,21 +904,23 @@ script_remove_file (struct t_weechat_plugin *weechat_plugin, const char *name, } /* - * script_action_install: install some scripts (using comma separated list) - * this function does following tasks: - * 1. unload script (if script is loaded) - * 2. remove script file(s) - * 3. move script file from "install" dir to language dir - * 4. make link in autoload dir - * 5. load script + * plugin_script_action_install: install some scripts (using comma separated + * list) + * this function does following tasks: + * 1. unload script (if script is loaded) + * 2. remove script file(s) + * 3. move script file from "install" dir to + * language dir + * 4. make link in autoload dir + * 5. load script */ void -script_action_install (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - void (*script_unload)(struct t_plugin_script *script), - int (*script_load)(const char *filename), - char **list) +plugin_script_action_install (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + void (*script_unload)(struct t_plugin_script *script), + int (*script_load)(const char *filename), + char **list) { char **argv, *name, *ptr_base_name, *base_name, *new_path, *autoload_path; char *symlink_path; @@ -937,12 +943,13 @@ script_action_install (struct t_weechat_plugin *weechat_plugin, if (base_name) { /* unload script, if script is loaded */ - ptr_script = script_search_by_full_name (scripts, base_name); + ptr_script = plugin_script_search_by_full_name (scripts, + base_name); if (ptr_script) (*script_unload) (ptr_script); /* remove script file(s) */ - script_remove_file (weechat_plugin, base_name, 0); + plugin_script_remove_file (weechat_plugin, base_name, 0); /* move file from install dir to language dir */ dir_home = weechat_info_get ("weechat_dir", ""); @@ -1010,17 +1017,17 @@ script_action_install (struct t_weechat_plugin *weechat_plugin, } /* - * script_action_remove: remove some scripts (using comma separated list) - * this function does following tasks: - * 1. unload script (if script is loaded) - * 2. remove script file(s) + * plugin_script_action_remove: remove some scripts (using comma separated list) + * this function does following tasks: + * 1. unload script (if script is loaded) + * 2. remove script file(s) */ void -script_action_remove (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - void (*script_unload)(struct t_plugin_script *script), - char **list) +plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + void (*script_unload)(struct t_plugin_script *script), + char **list) { char **argv; int argc, i; @@ -1034,12 +1041,12 @@ script_action_remove (struct t_weechat_plugin *weechat_plugin, for (i = 0; i < argc; i++) { /* unload script, if script is loaded */ - ptr_script = script_search_by_full_name (scripts, argv[i]); + ptr_script = plugin_script_search_by_full_name (scripts, argv[i]); if (ptr_script) (*script_unload) (ptr_script); /* remove script file(s) */ - script_remove_file (weechat_plugin, argv[i], 1); + plugin_script_remove_file (weechat_plugin, argv[i], 1); } weechat_string_free_split (argv); } @@ -1049,13 +1056,13 @@ script_action_remove (struct t_weechat_plugin *weechat_plugin, } /* - * script_display_list: print list of scripts + * plugin_script_display_list: print list of scripts */ void -script_display_list (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - const char *name, int full) +plugin_script_display_list (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + const char *name, int full) { struct t_plugin_script *ptr_script; @@ -1096,12 +1103,12 @@ script_display_list (struct t_weechat_plugin *weechat_plugin, } /* - * script_display_short_list: print list of scripts on one line + * plugin_script_display_short_list: print list of scripts on one line */ void -script_display_short_list (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts) +plugin_script_display_short_list (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts) { const char *scripts_loaded; char *buf; @@ -1141,14 +1148,14 @@ script_display_short_list (struct t_weechat_plugin *weechat_plugin, } /* - * script_add_to_infolist: add a script in an infolist - * return 1 if ok, 0 if error + * plugin_script_add_to_infolist: add a script in an infolist + * return 1 if ok, 0 if error */ int -script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, - struct t_infolist *infolist, - struct t_plugin_script *script) +plugin_script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, + struct t_infolist *infolist, + struct t_plugin_script *script) { struct t_infolist_item *ptr_item; @@ -1186,19 +1193,19 @@ script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, } /* - * script_infolist_list_scripts: build infolist with list of scripts + * plugin_script_infolist_list_scripts: build infolist with list of scripts */ struct t_infolist * -script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - void *pointer, - const char *arguments) +plugin_script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + void *pointer, + const char *arguments) { struct t_infolist *ptr_infolist; struct t_plugin_script *ptr_script; - if (pointer && !script_valid (scripts, pointer)) + if (pointer && !plugin_script_valid (scripts, pointer)) return NULL; ptr_infolist = weechat_infolist_new (); @@ -1207,8 +1214,8 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, if (pointer) { /* build list with only one script */ - if (!script_add_to_infolist (weechat_plugin, - ptr_infolist, pointer)) + if (!plugin_script_add_to_infolist (weechat_plugin, + ptr_infolist, pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -1224,8 +1231,8 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, if (!arguments || !arguments[0] || weechat_string_match (ptr_script->name, arguments, 0)) { - if (!script_add_to_infolist (weechat_plugin, - ptr_infolist, ptr_script)) + if (!plugin_script_add_to_infolist (weechat_plugin, + ptr_infolist, ptr_script)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -1240,13 +1247,13 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, } /* - * script_end: end script plugin + * plugin_script_end: end script plugin */ void -script_end (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script **scripts, - void (*callback_unload_all)()) +plugin_script_end (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script **scripts, + void (*callback_unload_all)()) { int scripts_loaded; @@ -1262,12 +1269,12 @@ script_end (struct t_weechat_plugin *weechat_plugin, } /* - * script_print_log: print script infos in log (usually for crash dump) + * plugin_script_print_log: print script infos in log (usually for crash dump) */ void -script_print_log (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts) +plugin_script_print_log (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts) { struct t_plugin_script *ptr_script; struct t_script_callback *ptr_script_cb; @@ -1298,7 +1305,7 @@ script_print_log (struct t_weechat_plugin *weechat_plugin, for (ptr_script_cb = ptr_script->callbacks; ptr_script_cb; ptr_script_cb = ptr_script_cb->next_callback) { - script_callback_print_log (weechat_plugin, ptr_script_cb); + plugin_script_callback_print_log (weechat_plugin, ptr_script_cb); } } diff --git a/src/plugins/scripts/script.h b/src/plugins/plugin-script.h index f8373613e..f031af422 100644 --- a/src/plugins/scripts/script.h +++ b/src/plugins/plugin-script.h @@ -17,8 +17,8 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __WEECHAT_SCRIPT_H -#define __WEECHAT_SCRIPT_H 1 +#ifndef __WEECHAT_PLUGIN_SCRIPT_H +#define __WEECHAT_PLUGIN_SCRIPT_H 1 /* constants which defines return types for weechat_<lang>_exec functions */ @@ -90,72 +90,73 @@ struct t_plugin_script_init void (*callback_load_file)(void *data, const char *filename); }; -extern void script_init (struct t_weechat_plugin *weechat_plugin, - int argc, char *argv[], - struct t_plugin_script_init *init); -extern int script_valid (struct t_plugin_script *scripts, - struct t_plugin_script *script); -extern char *script_ptr2str (void *pointer); -extern void *script_str2ptr (struct t_weechat_plugin *weechat_plugin, - const char *script_name, const char *function_name, - const char *pointer_str); -extern void script_auto_load (struct t_weechat_plugin *weechat_plugin, - void (*callback)(void *data, const char *filename)); -extern struct t_plugin_script *script_search (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - const char *name); -extern char *script_search_path (struct t_weechat_plugin *weechat_plugin, - const char *filename); -extern struct t_plugin_script *script_add (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script **scripts, - struct t_plugin_script **last_script, - const char *filename, const char *name, - const char *author, const char *version, - const char *license, const char *description, - const char *shutdown_func, const char *charset); -extern void script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, +extern void plugin_script_init (struct t_weechat_plugin *weechat_plugin, + int argc, char *argv[], + struct t_plugin_script_init *init); +extern int plugin_script_valid (struct t_plugin_script *scripts, + struct t_plugin_script *script); +extern char *plugin_script_ptr2str (void *pointer); +extern void *plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin, + const char *script_name, + const char *function_name, + const char *pointer_str); +extern void plugin_script_auto_load (struct t_weechat_plugin *weechat_plugin, + void (*callback)(void *data, const char *filename)); +extern struct t_plugin_script *plugin_script_search (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + const char *name); +extern char *plugin_script_search_path (struct t_weechat_plugin *weechat_plugin, + const char *filename); +extern struct t_plugin_script *plugin_script_add (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script **scripts, + struct t_plugin_script **last_script, + const char *filename, const char *name, + const char *author, const char *version, + const char *license, const char *description, + const char *shutdown_func, const char *charset); +extern void plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + struct t_plugin_script *script, + int (*callback_buffer_input) (void *data, + struct t_gui_buffer *buffer, + const char *input_data), + int (*callback_buffer_close) (void *data, + struct t_gui_buffer *buffer)); +extern void plugin_script_remove_buffer_callbacks (struct t_plugin_script *scripts, + struct t_gui_buffer *buffer); +extern void plugin_script_remove (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script **scripts, + struct t_plugin_script **last_script, + struct t_plugin_script *script); +extern void plugin_script_completion (struct t_weechat_plugin *weechat_plugin, + struct t_gui_completion *completion, + struct t_plugin_script *scripts); +extern void plugin_script_action_add (char **action_list, const char *name); +extern void plugin_script_action_install (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + void (*script_unload)(struct t_plugin_script *script), + int (*script_load)(const char *filename), + char **list); +extern void plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *scripts, - struct t_plugin_script *script, - int (*callback_buffer_input) (void *data, - struct t_gui_buffer *buffer, - const char *input_data), - int (*callback_buffer_close) (void *data, - struct t_gui_buffer *buffer)); -extern void script_remove_buffer_callbacks (struct t_plugin_script *scripts, - struct t_gui_buffer *buffer); -extern void script_remove (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script **scripts, - struct t_plugin_script **last_script, - struct t_plugin_script *script); -extern void script_completion (struct t_weechat_plugin *weechat_plugin, - struct t_gui_completion *completion, - struct t_plugin_script *scripts); -extern void script_action_add (char **action_list, const char *name); -extern void script_action_install (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - void (*script_unload)(struct t_plugin_script *script), - int (*script_load)(const char *filename), - char **list); -extern void script_action_remove (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - void (*script_unload)(struct t_plugin_script *script), - char **list); -extern void script_display_list (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - const char *name, int full); -extern void script_display_short_list (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts); -extern int script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, - struct t_infolist *infolist, - struct t_plugin_script *script); -extern struct t_infolist *script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts, - void *pointer, - const char *arguments); -extern void script_end (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script **scripts, - void (*callback_unload_all)()); -extern void script_print_log (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *scripts); + void (*script_unload)(struct t_plugin_script *script), + char **list); +extern void plugin_script_display_list (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + const char *name, int full); +extern void plugin_script_display_short_list (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts); +extern int plugin_script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, + struct t_infolist *infolist, + struct t_plugin_script *script); +extern struct t_infolist *plugin_script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts, + void *pointer, + const char *arguments); +extern void plugin_script_end (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script **scripts, + void (*callback_unload_all)()); +extern void plugin_script_print_log (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *scripts); -#endif /* __WEECHAT_SCRIPT_H */ +#endif /* __WEECHAT_PLUGIN_SCRIPT_H */ diff --git a/src/plugins/scripts/python/CMakeLists.txt b/src/plugins/python/CMakeLists.txt index b39a5f394..669bb34f9 100644 --- a/src/plugins/scripts/python/CMakeLists.txt +++ b/src/plugins/python/CMakeLists.txt @@ -25,7 +25,7 @@ SET_TARGET_PROPERTIES(python PROPERTIES PREFIX "") IF(PYTHON_FOUND) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PYTHON_LFLAGS}") - TARGET_LINK_LIBRARIES(python ${PYTHON_LIBRARY} weechat_scripts) + TARGET_LINK_LIBRARIES(python ${PYTHON_LIBRARY} weechat_plugins_scripts) ENDIF(PYTHON_FOUND) INSTALL(TARGETS python LIBRARY DESTINATION ${LIBDIR}/plugins) diff --git a/src/plugins/scripts/python/Makefile.am b/src/plugins/python/Makefile.am index db37e7095..db37e7095 100644 --- a/src/plugins/scripts/python/Makefile.am +++ b/src/plugins/python/Makefile.am diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 0dac4b641..a90749d97 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -27,10 +27,10 @@ #include <Python.h> #include <time.h> -#include "../../weechat-plugin.h" -#include "../script.h" -#include "../script-api.h" -#include "../script-callback.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" +#include "../plugin-script-api.h" +#include "../plugin-script-callback.h" #include "weechat-python.h" @@ -50,9 +50,12 @@ python_function_name); \ __ret; \ } +#define API_PTR2STR(__pointer) \ + plugin_script_ptr2str (__pointer) #define API_STR2PTR(__string) \ - script_str2ptr (weechat_python_plugin, PYTHON_CURRENT_SCRIPT_NAME, \ - python_function_name, __string) + plugin_script_str2ptr (weechat_python_plugin, \ + PYTHON_CURRENT_SCRIPT_NAME, \ + python_function_name, __string) #define API_RETURN_OK return PyLong_FromLong((long)1); #define API_RETURN_ERROR return PyLong_FromLong ((long)0); #define API_RETURN_EMPTY \ @@ -113,7 +116,7 @@ weechat_python_api_register (PyObject *self, PyObject *args) &license, &description, &shutdown_func, &charset)) API_WRONG_ARGS(API_RETURN_ERROR); - if (script_search (weechat_python_plugin, python_scripts, name)) + if (plugin_script_search (weechat_python_plugin, python_scripts, name)) { /* another script already exists with same name */ weechat_printf (NULL, @@ -125,12 +128,12 @@ weechat_python_api_register (PyObject *self, PyObject *args) } /* register script */ - python_current_script = script_add (weechat_python_plugin, - &python_scripts, &last_python_script, - (python_current_script_filename) ? - python_current_script_filename : "", - name, author, version, license, - description, shutdown_func, charset); + python_current_script = plugin_script_add (weechat_python_plugin, + &python_scripts, &last_python_script, + (python_current_script_filename) ? + python_current_script_filename : "", + name, author, version, license, + description, shutdown_func, charset); if (python_current_script) { python_registered_script = python_current_script; @@ -185,8 +188,8 @@ weechat_python_api_charset_set (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &charset)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_charset_set (python_current_script, - charset); + plugin_script_api_charset_set (python_current_script, + charset); API_RETURN_OK; } @@ -521,7 +524,7 @@ weechat_python_api_list_new (PyObject *self, PyObject *args) API_FUNC(1, "list_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_new ()); + result = API_PTR2STR(weechat_list_new ()); API_RETURN_STRING_FREE(result); } @@ -544,10 +547,10 @@ weechat_python_api_list_add (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssss", &weelist, &data, &where, &user_data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_add (API_STR2PTR(weelist), - data, - where, - API_STR2PTR(user_data))); + result = API_PTR2STR(weechat_list_add (API_STR2PTR(weelist), + data, + where, + API_STR2PTR(user_data))); API_RETURN_STRING_FREE(result); } @@ -568,8 +571,8 @@ weechat_python_api_list_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_search (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -611,8 +614,8 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_casesearch (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -656,8 +659,8 @@ weechat_python_api_list_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &weelist, &position)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_get (API_STR2PTR(weelist), - position)); + result = API_PTR2STR(weechat_list_get (API_STR2PTR(weelist), + position)); API_RETURN_STRING_FREE(result); } @@ -697,7 +700,7 @@ weechat_python_api_list_next (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &item)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_next (API_STR2PTR(item))); + result = API_PTR2STR(weechat_list_next (API_STR2PTR(item))); API_RETURN_STRING_FREE(result); } @@ -717,7 +720,7 @@ weechat_python_api_list_prev (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &item)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_prev (API_STR2PTR(item))); + result = API_PTR2STR(weechat_list_prev (API_STR2PTR(item))); API_RETURN_STRING_FREE(result); } @@ -839,7 +842,7 @@ weechat_python_api_config_reload_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -879,12 +882,12 @@ weechat_python_api_config_new (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &name, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_config_new (weechat_python_plugin, - python_current_script, - name, - &weechat_python_api_config_reload_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_config_new (weechat_python_plugin, + python_current_script, + name, + &weechat_python_api_config_reload_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -909,8 +912,8 @@ weechat_python_api_config_read_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -956,7 +959,7 @@ weechat_python_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_python_exec (script_callback->script, @@ -1000,7 +1003,7 @@ weechat_python_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_python_exec (script_callback->script, @@ -1045,8 +1048,8 @@ weechat_python_api_config_section_create_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1093,9 +1096,9 @@ weechat_python_api_config_section_delete_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); - func_argv[3] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); + func_argv[3] = API_PTR2STR(option); rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1160,27 +1163,27 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args) &data_delete_option)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_config_new_section (weechat_python_plugin, - python_current_script, - API_STR2PTR(config_file), - name, - user_can_add_options, - user_can_delete_options, - &weechat_python_api_config_read_cb, - function_read, - data_read, - &weechat_python_api_config_section_write_cb, - function_write, - data_write, - &weechat_python_api_config_section_write_default_cb, - function_write_default, - data_write_default, - &weechat_python_api_config_section_create_option_cb, - function_create_option, - data_create_option, - &weechat_python_api_config_section_delete_option_cb, - function_delete_option, - data_delete_option)); + result = API_PTR2STR(plugin_script_api_config_new_section (weechat_python_plugin, + python_current_script, + API_STR2PTR(config_file), + name, + user_can_add_options, + user_can_delete_options, + &weechat_python_api_config_read_cb, + function_read, + data_read, + &weechat_python_api_config_section_write_cb, + function_write, + data_write, + &weechat_python_api_config_section_write_default_cb, + function_write_default, + data_write_default, + &weechat_python_api_config_section_create_option_cb, + function_create_option, + data_create_option, + &weechat_python_api_config_section_delete_option_cb, + function_delete_option, + data_delete_option)); API_RETURN_STRING_FREE(result); } @@ -1201,8 +1204,8 @@ weechat_python_api_config_search_section (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &config_file, §ion_name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_search_section (API_STR2PTR(config_file), - section_name)); + result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), + section_name)); API_RETURN_STRING_FREE(result); } @@ -1227,7 +1230,7 @@ weechat_python_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_python_exec (script_callback->script, @@ -1269,7 +1272,7 @@ weechat_python_api_config_option_change_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1302,7 +1305,7 @@ weechat_python_api_config_option_delete_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1354,28 +1357,28 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args) &data_delete)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_config_new_option (weechat_python_plugin, - python_current_script, - API_STR2PTR(config_file), - API_STR2PTR(section), - name, - type, - description, - string_values, - min, - max, - default_value, - value, - null_value_allowed, - &weechat_python_api_config_option_check_value_cb, - function_check_value, - data_check_value, - &weechat_python_api_config_option_change_cb, - function_change, - data_change, - &weechat_python_api_config_option_delete_cb, - function_delete, - data_delete)); + result = API_PTR2STR(plugin_script_api_config_new_option (weechat_python_plugin, + python_current_script, + API_STR2PTR(config_file), + API_STR2PTR(section), + name, + type, + description, + string_values, + min, + max, + default_value, + value, + null_value_allowed, + &weechat_python_api_config_option_check_value_cb, + function_check_value, + data_check_value, + &weechat_python_api_config_option_change_cb, + function_change, + data_change, + &weechat_python_api_config_option_delete_cb, + function_delete, + data_delete)); API_RETURN_STRING_FREE(result); } @@ -1397,9 +1400,9 @@ weechat_python_api_config_search_option (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &config_file, §ion, &option_name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_search_option (API_STR2PTR(config_file), - API_STR2PTR(section), - option_name)); + result = API_PTR2STR(weechat_config_search_option (API_STR2PTR(config_file), + API_STR2PTR(section), + option_name)); API_RETURN_STRING_FREE(result); } @@ -1854,9 +1857,9 @@ weechat_python_api_config_option_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_option_free (weechat_python_plugin, - python_current_script, - API_STR2PTR(option)); + plugin_script_api_config_option_free (weechat_python_plugin, + python_current_script, + API_STR2PTR(option)); API_RETURN_OK; } @@ -1876,9 +1879,9 @@ weechat_python_api_config_section_free_options (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", §ion)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free_options (weechat_python_plugin, - python_current_script, - API_STR2PTR(section)); + plugin_script_api_config_section_free_options (weechat_python_plugin, + python_current_script, + API_STR2PTR(section)); API_RETURN_OK; } @@ -1897,9 +1900,9 @@ weechat_python_api_config_section_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", §ion)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free (weechat_python_plugin, - python_current_script, - API_STR2PTR(section)); + plugin_script_api_config_section_free (weechat_python_plugin, + python_current_script, + API_STR2PTR(section)); API_RETURN_OK; } @@ -1918,9 +1921,9 @@ weechat_python_api_config_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &config_file)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_free (weechat_python_plugin, - python_current_script, - API_STR2PTR(config_file)); + plugin_script_api_config_free (weechat_python_plugin, + python_current_script, + API_STR2PTR(config_file)); API_RETURN_OK; } @@ -1940,7 +1943,7 @@ weechat_python_api_config_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_get (option)); + result = API_PTR2STR(weechat_config_get (option)); API_RETURN_STRING_FREE(result); } @@ -1960,9 +1963,9 @@ weechat_python_api_config_get_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_api_config_get_plugin (weechat_python_plugin, - python_current_script, - option); + result = plugin_script_api_config_get_plugin (weechat_python_plugin, + python_current_script, + option); API_RETURN_STRING(result); } @@ -1982,9 +1985,9 @@ weechat_python_api_config_is_set_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR)); - rc = script_api_config_is_set_plugin (weechat_python_plugin, - python_current_script, - option); + rc = plugin_script_api_config_is_set_plugin (weechat_python_plugin, + python_current_script, + option); API_RETURN_INT(rc); } @@ -2005,10 +2008,10 @@ weechat_python_api_config_set_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &option, &value)) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR)); - rc = script_api_config_set_plugin (weechat_python_plugin, - python_current_script, - option, - value); + rc = plugin_script_api_config_set_plugin (weechat_python_plugin, + python_current_script, + option, + value); API_RETURN_INT(rc); } @@ -2028,10 +2031,10 @@ weechat_python_api_config_set_desc_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &option, &description)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_set_desc_plugin (weechat_python_plugin, - python_current_script, - option, - description); + plugin_script_api_config_set_desc_plugin (weechat_python_plugin, + python_current_script, + option, + description); API_RETURN_OK; } @@ -2051,9 +2054,9 @@ weechat_python_api_config_unset_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR)); - rc = script_api_config_unset_plugin (weechat_python_plugin, - python_current_script, - option); + rc = plugin_script_api_config_unset_plugin (weechat_python_plugin, + python_current_script, + option); API_RETURN_INT(rc); } @@ -2162,10 +2165,10 @@ weechat_python_api_prnt (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_printf (weechat_python_plugin, - python_current_script, - API_STR2PTR(buffer), - "%s", message); + plugin_script_api_printf (weechat_python_plugin, + python_current_script, + API_STR2PTR(buffer), + "%s", message); API_RETURN_OK; } @@ -2189,12 +2192,12 @@ weechat_python_api_prnt_date_tags (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "siss", &buffer, &date, &tags, &message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_printf_date_tags (weechat_python_plugin, - python_current_script, - API_STR2PTR(buffer), - date, - tags, - "%s", message); + plugin_script_api_printf_date_tags (weechat_python_plugin, + python_current_script, + API_STR2PTR(buffer), + date, + tags, + "%s", message); API_RETURN_OK; } @@ -2216,11 +2219,11 @@ weechat_python_api_prnt_y (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sis", &buffer, &y, &message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_printf_y (weechat_python_plugin, - python_current_script, - API_STR2PTR(buffer), - y, - "%s", message); + plugin_script_api_printf_y (weechat_python_plugin, + python_current_script, + API_STR2PTR(buffer), + y, + "%s", message); API_RETURN_OK; } @@ -2239,9 +2242,9 @@ weechat_python_api_log_print (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &message)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_log_printf (weechat_python_plugin, - python_current_script, - "%s", message); + plugin_script_api_log_printf (weechat_python_plugin, + python_current_script, + "%s", message); API_RETURN_OK; } @@ -2267,7 +2270,7 @@ weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_python_exec (script_callback->script, @@ -2314,16 +2317,16 @@ weechat_python_api_hook_command (PyObject *self, PyObject *args) &args_description, &completion, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_command (weechat_python_plugin, - python_current_script, - command, - description, - arguments, - args_description, - completion, - &weechat_python_api_hook_command_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command (weechat_python_plugin, + python_current_script, + command, + description, + arguments, + args_description, + completion, + &weechat_python_api_hook_command_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2346,7 +2349,7 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_python_exec (script_callback->script, @@ -2387,12 +2390,12 @@ weechat_python_api_hook_command_run (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &command, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_command_run (weechat_python_plugin, - python_current_script, - command, - &weechat_python_api_hook_command_run_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command_run (weechat_python_plugin, + python_current_script, + command, + &weechat_python_api_hook_command_run_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2459,14 +2462,14 @@ weechat_python_api_hook_timer (PyObject *self, PyObject *args) &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_timer (weechat_python_plugin, - python_current_script, - interval, - align_second, - max_calls, - &weechat_python_api_hook_timer_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_timer (weechat_python_plugin, + python_current_script, + interval, + align_second, + max_calls, + &weechat_python_api_hook_timer_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2533,15 +2536,15 @@ weechat_python_api_hook_fd (PyObject *self, PyObject *args) &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_fd (weechat_python_plugin, - python_current_script, - fd, - read, - write, - exception, - &weechat_python_api_hook_fd_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_fd (weechat_python_plugin, + python_current_script, + fd, + read, + write, + exception, + &weechat_python_api_hook_fd_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2612,13 +2615,13 @@ weechat_python_api_hook_process (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "siss", &command, &timeout, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_process (weechat_python_plugin, - python_current_script, - command, - timeout, - &weechat_python_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process (weechat_python_plugin, + python_current_script, + command, + timeout, + &weechat_python_api_hook_process_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2648,14 +2651,14 @@ weechat_python_api_hook_process_hashtable (PyObject *self, PyObject *args) options = weechat_python_dict_to_hashtable (dict, WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE); - result = script_ptr2str (script_api_hook_process_hashtable (weechat_python_plugin, - python_current_script, - command, - options, - timeout, - &weechat_python_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_python_plugin, + python_current_script, + command, + options, + timeout, + &weechat_python_api_hook_process_cb, + function, + data)); if (options) weechat_hashtable_free (options); @@ -2732,21 +2735,21 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args) &ipv6, &local_hostname, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_connect (weechat_python_plugin, - python_current_script, - proxy, - address, - port, - sock, - ipv6, - NULL, /* gnutls session */ - NULL, /* gnutls callback */ - 0, /* gnutls DH key size */ - NULL, /* gnutls priorities */ - local_hostname, - &weechat_python_api_hook_connect_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_connect (weechat_python_plugin, + python_current_script, + proxy, + address, + port, + sock, + ipv6, + NULL, /* gnutls session */ + NULL, /* gnutls callback */ + 0, /* gnutls DH key size */ + NULL, /* gnutls priorities */ + local_hostname, + &weechat_python_api_hook_connect_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2778,7 +2781,7 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -2837,15 +2840,15 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args) &strip_colors, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_print (weechat_python_plugin, - python_current_script, - API_STR2PTR(buffer), - tags, - message, - strip_colors, - &weechat_python_api_hook_print_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_print (weechat_python_plugin, + python_current_script, + API_STR2PTR(buffer), + tags, + message, + strip_colors, + &weechat_python_api_hook_print_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2883,7 +2886,7 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = script_ptr2str (signal_data); + func_argv[2] = API_PTR2STR(signal_data); free_needed = 1; } else @@ -2927,12 +2930,12 @@ weechat_python_api_hook_signal (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &signal, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_signal (weechat_python_plugin, - python_current_script, - signal, - &weechat_python_api_hook_signal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_signal (weechat_python_plugin, + python_current_script, + signal, + &weechat_python_api_hook_signal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3040,12 +3043,12 @@ weechat_python_api_hook_hsignal (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &signal, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_hsignal (weechat_python_plugin, - python_current_script, - signal, - &weechat_python_api_hook_hsignal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_hsignal (weechat_python_plugin, + python_current_script, + signal, + &weechat_python_api_hook_hsignal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3133,12 +3136,12 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &option, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_config (weechat_python_plugin, - python_current_script, - option, - &weechat_python_api_hook_config_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_config (weechat_python_plugin, + python_current_script, + option, + &weechat_python_api_hook_config_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3163,8 +3166,8 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = script_ptr2str (buffer); - func_argv[3] = script_ptr2str (completion); + func_argv[2] = API_PTR2STR(buffer); + func_argv[3] = API_PTR2STR(completion); rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3208,13 +3211,13 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args) &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_completion (weechat_python_plugin, - python_current_script, - completion, - description, - &weechat_python_api_hook_completion_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_completion (weechat_python_plugin, + python_current_script, + completion, + description, + &weechat_python_api_hook_completion_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3293,12 +3296,12 @@ weechat_python_api_hook_modifier (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &modifier, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_modifier (weechat_python_plugin, - python_current_script, - modifier, - &weechat_python_api_hook_modifier_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_modifier (weechat_python_plugin, + python_current_script, + modifier, + &weechat_python_api_hook_modifier_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3374,14 +3377,14 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args) &args_description, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_info (weechat_python_plugin, - python_current_script, - info_name, - description, - args_description, - &weechat_python_api_hook_info_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info (weechat_python_plugin, + python_current_script, + info_name, + description, + args_description, + &weechat_python_api_hook_info_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3446,15 +3449,15 @@ weechat_python_api_hook_info_hashtable (PyObject *self, PyObject *args) &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_info_hashtable (weechat_python_plugin, - python_current_script, - info_name, - description, - args_description, - output_description, - &weechat_python_api_hook_info_hashtable_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info_hashtable (weechat_python_plugin, + python_current_script, + info_name, + description, + args_description, + output_description, + &weechat_python_api_hook_info_hashtable_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3478,7 +3481,7 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = script_ptr2str (pointer); + func_argv[2] = API_PTR2STR(pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_python_exec (script_callback->script, @@ -3518,15 +3521,15 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args) &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_infolist (weechat_python_plugin, - python_current_script, - infolist_name, - description, - pointer_description, - args_description, - &weechat_python_api_hook_infolist_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_infolist (weechat_python_plugin, + python_current_script, + infolist_name, + description, + pointer_description, + args_description, + &weechat_python_api_hook_infolist_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3583,12 +3586,12 @@ weechat_python_api_hook_focus (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &area, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_focus (weechat_python_plugin, - python_current_script, - area, - &weechat_python_api_hook_focus_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_focus (weechat_python_plugin, + python_current_script, + area, + &weechat_python_api_hook_focus_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3607,9 +3610,9 @@ weechat_python_api_unhook (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &hook)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_unhook (weechat_python_plugin, - python_current_script, - API_STR2PTR(hook)); + plugin_script_api_unhook (weechat_python_plugin, + python_current_script, + API_STR2PTR(hook)); API_RETURN_OK; } @@ -3626,7 +3629,7 @@ weechat_python_api_unhook_all (PyObject *self, PyObject *args) API_FUNC(1, "unhook_all", API_RETURN_ERROR); - script_api_unhook_all (weechat_python_plugin, python_current_script); + plugin_script_api_unhook_all (weechat_python_plugin, python_current_script); API_RETURN_OK; } @@ -3649,7 +3652,7 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_python_exec (script_callback->script, @@ -3689,7 +3692,7 @@ weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3732,15 +3735,15 @@ weechat_python_api_buffer_new (PyObject *self, PyObject *args) &function_close, &data_close)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_buffer_new (weechat_python_plugin, - python_current_script, - name, - &weechat_python_api_buffer_input_data_cb, - function_input, - data_input, - &weechat_python_api_buffer_close_cb, - function_close, - data_close)); + result = API_PTR2STR(plugin_script_api_buffer_new (weechat_python_plugin, + python_current_script, + name, + &weechat_python_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_python_api_buffer_close_cb, + function_close, + data_close)); API_RETURN_STRING_FREE(result); } @@ -3762,7 +3765,7 @@ weechat_python_api_buffer_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &plugin, &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search (plugin, name)); + result = API_PTR2STR(weechat_buffer_search (plugin, name)); API_RETURN_STRING_FREE(result); } @@ -3782,7 +3785,7 @@ weechat_python_api_buffer_search_main (PyObject *self, PyObject *args) API_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search_main ()); + result = API_PTR2STR(weechat_buffer_search_main ()); API_RETURN_STRING_FREE(result); } @@ -3802,7 +3805,7 @@ weechat_python_api_current_buffer (PyObject *self, PyObject *args) API_FUNC(1, "current_buffer", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_buffer ()); + result = API_PTR2STR(weechat_current_buffer ()); API_RETURN_STRING_FREE(result); } @@ -3840,9 +3843,9 @@ weechat_python_api_buffer_close (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &buffer)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_buffer_close (weechat_python_plugin, - python_current_script, - API_STR2PTR(buffer)); + plugin_script_api_buffer_close (weechat_python_plugin, + python_current_script, + API_STR2PTR(buffer)); API_RETURN_OK; } @@ -3948,8 +3951,8 @@ weechat_python_api_buffer_get_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_get_pointer (API_STR2PTR(buffer), - property)); + result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), + property)); API_RETURN_STRING_FREE(result); } @@ -4036,7 +4039,7 @@ weechat_python_api_current_window (PyObject *self, PyObject *args) API_FUNC(1, "current_window", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_window ()); + result = API_PTR2STR(weechat_current_window ()); API_RETURN_STRING_FREE(result); } @@ -4057,7 +4060,7 @@ weechat_python_api_window_search_with_buffer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &buffer)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_window_search_with_buffer (API_STR2PTR(buffer))); + result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(buffer))); API_RETURN_STRING_FREE(result); } @@ -4120,8 +4123,8 @@ weechat_python_api_window_get_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &window, &property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_window_get_pointer (API_STR2PTR(window), - property)); + result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), + property)); API_RETURN_STRING_FREE(result); } @@ -4166,11 +4169,11 @@ weechat_python_api_nicklist_add_group (PyObject *self, PyObject *args) &color, &visible)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_add_group (API_STR2PTR(buffer), - API_STR2PTR(parent_group), - name, - color, - visible)); + result = API_PTR2STR(weechat_nicklist_add_group (API_STR2PTR(buffer), + API_STR2PTR(parent_group), + name, + color, + visible)); API_RETURN_STRING_FREE(result); } @@ -4192,9 +4195,9 @@ weechat_python_api_nicklist_search_group (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &buffer, &from_group, &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_search_group (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_group (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4222,13 +4225,13 @@ weechat_python_api_nicklist_add_nick (PyObject *self, PyObject *args) &prefix, &prefix_color, &visible)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_add_nick (API_STR2PTR(buffer), - API_STR2PTR(group), - name, - color, - prefix, - prefix_color, - visible)); + result = API_PTR2STR(weechat_nicklist_add_nick (API_STR2PTR(buffer), + API_STR2PTR(group), + name, + color, + prefix, + prefix_color, + visible)); API_RETURN_STRING_FREE(result); } @@ -4250,9 +4253,9 @@ weechat_python_api_nicklist_search_nick (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &buffer, &from_group, &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_search_nick (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_nick (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4383,9 +4386,9 @@ weechat_python_api_nicklist_group_get_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &buffer, &group, &property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(group), - property)); + result = API_PTR2STR(weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(group), + property)); API_RETURN_STRING_FREE(result); } @@ -4480,9 +4483,9 @@ weechat_python_api_nicklist_nick_get_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &buffer, &nick, &property)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(nick), - property)); + result = API_PTR2STR(weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(nick), + property)); API_RETURN_STRING_FREE(result); } @@ -4527,7 +4530,7 @@ weechat_python_api_bar_item_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_item_search (name)); + result = API_PTR2STR(weechat_bar_item_search (name)); API_RETURN_STRING_FREE(result); } @@ -4549,8 +4552,8 @@ weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (item); - func_argv[2] = script_ptr2str (window); + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); ret = (char *)weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4585,12 +4588,12 @@ weechat_python_api_bar_item_new (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &name, &function, &data)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_bar_item_new (weechat_python_plugin, - python_current_script, - name, - &weechat_python_api_bar_item_build_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_bar_item_new (weechat_python_plugin, + python_current_script, + name, + &weechat_python_api_bar_item_build_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -4628,9 +4631,9 @@ weechat_python_api_bar_item_remove (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &item)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_bar_item_remove (weechat_python_plugin, - python_current_script, - API_STR2PTR(item)); + plugin_script_api_bar_item_remove (weechat_python_plugin, + python_current_script, + API_STR2PTR(item)); API_RETURN_OK; } @@ -4650,7 +4653,7 @@ weechat_python_api_bar_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_search (name)); + result = API_PTR2STR(weechat_bar_search (name)); API_RETURN_STRING_FREE(result); } @@ -4689,21 +4692,21 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args) &color_delim, &color_bg, &separator, &items)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_new (name, - hidden, - priority, - type, - conditions, - position, - filling_top_bottom, - filling_left_right, - size, - size_max, - color_fg, - color_delim, - color_bg, - separator, - items)); + result = API_PTR2STR(weechat_bar_new (name, + hidden, + priority, + type, + conditions, + position, + filling_top_bottom, + filling_left_right, + size, + size_max, + color_fg, + color_delim, + color_bg, + separator, + items)); API_RETURN_STRING_FREE(result); } @@ -4784,10 +4787,10 @@ weechat_python_api_command (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &command)) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_command (weechat_python_plugin, - python_current_script, - API_STR2PTR(buffer), - command); + plugin_script_api_command (weechat_python_plugin, + python_current_script, + API_STR2PTR(buffer), + command); API_RETURN_OK; } @@ -4856,7 +4859,7 @@ weechat_python_api_infolist_new (PyObject *self, PyObject *args) (void) args; API_FUNC(1, "infolist_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new ()); + result = API_PTR2STR(weechat_infolist_new ()); API_RETURN_STRING_FREE(result); } @@ -4876,7 +4879,7 @@ weechat_python_api_infolist_new_item (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &infolist)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_item (API_STR2PTR(infolist))); + result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(infolist))); API_RETURN_STRING_FREE(result); } @@ -4900,9 +4903,9 @@ weechat_python_api_infolist_new_var_integer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_integer (API_STR2PTR(infolist), - name, - value)); + result = API_PTR2STR(weechat_infolist_new_var_integer (API_STR2PTR(infolist), + name, + value)); API_RETURN_STRING_FREE(result); } @@ -4925,9 +4928,9 @@ weechat_python_api_infolist_new_var_string (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_string (API_STR2PTR(infolist), - name, - value)); + result = API_PTR2STR(weechat_infolist_new_var_string (API_STR2PTR(infolist), + name, + value)); API_RETURN_STRING_FREE(result); } @@ -4950,9 +4953,9 @@ weechat_python_api_infolist_new_var_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_pointer (API_STR2PTR(infolist), - name, - API_STR2PTR(value))); + result = API_PTR2STR(weechat_infolist_new_var_pointer (API_STR2PTR(infolist), + name, + API_STR2PTR(value))); API_RETURN_STRING_FREE(result); } @@ -4976,9 +4979,9 @@ weechat_python_api_infolist_new_var_time (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_time (API_STR2PTR(infolist), - name, - value)); + result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(infolist), + name, + value)); API_RETURN_STRING_FREE(result); } @@ -5000,9 +5003,9 @@ weechat_python_api_infolist_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &name, &pointer, &arguments)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_get (name, - API_STR2PTR(pointer), - arguments)); + result = API_PTR2STR(weechat_infolist_get (name, + API_STR2PTR(pointer), + arguments)); API_RETURN_STRING_FREE(result); } @@ -5147,8 +5150,8 @@ weechat_python_api_infolist_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &infolist, &variable)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_pointer (API_STR2PTR(infolist), - variable)); + result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), + variable)); API_RETURN_STRING_FREE(result); } @@ -5216,7 +5219,7 @@ weechat_python_api_hdata_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_get (name)); + result = API_PTR2STR(weechat_hdata_get (name)); API_RETURN_STRING_FREE(result); } @@ -5352,8 +5355,8 @@ weechat_python_api_hdata_get_list (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &hdata, &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_get_list (API_STR2PTR(hdata), - name)); + result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), + name)); API_RETURN_STRING_FREE(result); } @@ -5400,9 +5403,9 @@ weechat_python_api_hdata_move (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssi", &hdata, &pointer, &count)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_move (API_STR2PTR(hdata), - API_STR2PTR(pointer), - count)); + result = API_PTR2STR(weechat_hdata_move (API_STR2PTR(hdata), + API_STR2PTR(pointer), + count)); API_RETURN_STRING_FREE(result); } @@ -5525,9 +5528,9 @@ weechat_python_api_hdata_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_pointer (API_STR2PTR(hdata), - API_STR2PTR(pointer), - name)); + result = API_PTR2STR(weechat_hdata_pointer (API_STR2PTR(hdata), + API_STR2PTR(pointer), + name)); API_RETURN_STRING_FREE(result); } @@ -5628,7 +5631,7 @@ weechat_python_api_upgrade_new (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &filename, &write)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_upgrade_new (filename, write)); + result = API_PTR2STR(weechat_upgrade_new (filename, write)); API_RETURN_STRING_FREE(result); } @@ -5679,9 +5682,9 @@ weechat_python_api_upgrade_read_cb (void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (upgrade_file); + func_argv[1] = API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = script_ptr2str (infolist); + func_argv[3] = API_PTR2STR(infolist); rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -5723,12 +5726,12 @@ weechat_python_api_upgrade_read (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &upgrade_file, &function, &data)) API_WRONG_ARGS(API_RETURN_INT(0)); - rc = script_api_upgrade_read (weechat_python_plugin, - python_current_script, - API_STR2PTR(upgrade_file), - &weechat_python_api_upgrade_read_cb, - function, - data); + rc = plugin_script_api_upgrade_read (weechat_python_plugin, + python_current_script, + API_STR2PTR(upgrade_file), + &weechat_python_api_upgrade_read_cb, + function, + data); API_RETURN_INT(rc); } diff --git a/src/plugins/scripts/python/weechat-python-api.h b/src/plugins/python/weechat-python-api.h index 4c12f2916..4c12f2916 100644 --- a/src/plugins/scripts/python/weechat-python-api.h +++ b/src/plugins/python/weechat-python-api.h diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/python/weechat-python.c index 993a089b5..d56eebfd1 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/python/weechat-python.c @@ -29,8 +29,8 @@ #include <sys/stat.h> #include <unistd.h> -#include "../../weechat-plugin.h" -#include "../script.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" #include "weechat-python.h" #include "weechat-python-api.h" @@ -695,9 +695,9 @@ weechat_python_load (const char *filename) /* if script was registered, remove it from list */ if (python_current_script != NULL) { - script_remove (weechat_python_plugin, - &python_scripts, &last_python_script, - python_current_script); + plugin_script_remove (weechat_python_plugin, + &python_scripts, &last_python_script, + python_current_script); } Py_EndInterpreter (python_current_interpreter); @@ -734,11 +734,11 @@ weechat_python_load (const char *filename) * set input/close callbacks for buffers created by this script * (to restore callbacks after upgrade) */ - script_set_buffer_callbacks (weechat_python_plugin, - python_scripts, - python_current_script, - &weechat_python_api_buffer_input_data_cb, - &weechat_python_api_buffer_close_cb); + plugin_script_set_buffer_callbacks (weechat_python_plugin, + python_scripts, + python_current_script, + &weechat_python_api_buffer_input_data_cb, + &weechat_python_api_buffer_close_cb); return 1; } @@ -789,8 +789,8 @@ weechat_python_unload (struct t_plugin_script *script) python_current_script = (python_current_script->prev_script) ? python_current_script->prev_script : python_current_script->next_script; - script_remove (weechat_python_plugin, &python_scripts, &last_python_script, - script); + plugin_script_remove (weechat_python_plugin, &python_scripts, &last_python_script, + script); if (interpreter) { @@ -811,7 +811,7 @@ weechat_python_unload_name (const char *name) { struct t_plugin_script *ptr_script; - ptr_script = script_search (weechat_python_plugin, python_scripts, name); + ptr_script = plugin_script_search (weechat_python_plugin, python_scripts, name); if (ptr_script) { weechat_python_unload (ptr_script); @@ -850,7 +850,7 @@ weechat_python_reload_name (const char *name) struct t_plugin_script *ptr_script; char *filename; - ptr_script = script_search (weechat_python_plugin, python_scripts, name); + ptr_script = plugin_script_search (weechat_python_plugin, python_scripts, name); if (ptr_script) { filename = strdup (ptr_script->filename); @@ -888,29 +888,29 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer, if (argc == 1) { - script_display_list (weechat_python_plugin, python_scripts, - NULL, 0); + plugin_script_display_list (weechat_python_plugin, python_scripts, + NULL, 0); } else if (argc == 2) { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_python_plugin, python_scripts, - NULL, 0); + plugin_script_display_list (weechat_python_plugin, python_scripts, + NULL, 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_python_plugin, python_scripts, - NULL, 1); + plugin_script_display_list (weechat_python_plugin, python_scripts, + NULL, 1); } else if (weechat_strcasecmp (argv[1], "autoload") == 0) { - script_auto_load (weechat_python_plugin, &weechat_python_load_cb); + plugin_script_auto_load (weechat_python_plugin, &weechat_python_load_cb); } else if (weechat_strcasecmp (argv[1], "reload") == 0) { weechat_python_unload_all (); - script_auto_load (weechat_python_plugin, &weechat_python_load_cb); + plugin_script_auto_load (weechat_python_plugin, &weechat_python_load_cb); } else if (weechat_strcasecmp (argv[1], "unload") == 0) { @@ -921,19 +921,19 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer, { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_python_plugin, python_scripts, - argv_eol[2], 0); + plugin_script_display_list (weechat_python_plugin, python_scripts, + argv_eol[2], 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_python_plugin, python_scripts, - argv_eol[2], 1); + plugin_script_display_list (weechat_python_plugin, python_scripts, + argv_eol[2], 1); } else if (weechat_strcasecmp (argv[1], "load") == 0) { /* load Python script */ - path_script = script_search_path (weechat_python_plugin, - argv_eol[2]); + path_script = plugin_script_search_path (weechat_python_plugin, + argv_eol[2]); weechat_python_load ((path_script) ? path_script : argv_eol[2]); if (path_script) free (path_script); @@ -975,7 +975,7 @@ weechat_python_completion_cb (void *data, const char *completion_item, (void) completion_item; (void) buffer; - script_completion (weechat_python_plugin, completion, python_scripts); + plugin_script_completion (weechat_python_plugin, completion, python_scripts); return WEECHAT_RC_OK; } @@ -1028,9 +1028,9 @@ weechat_python_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "python_script") == 0) { - return script_infolist_list_scripts (weechat_python_plugin, - python_scripts, pointer, - arguments); + return plugin_script_infolist_list_scripts (weechat_python_plugin, + python_scripts, pointer, + arguments); } return NULL; @@ -1053,7 +1053,7 @@ weechat_python_signal_debug_dump_cb (void *data, const char *signal, if (!signal_data || (weechat_strcasecmp ((char *)signal_data, PYTHON_PLUGIN_NAME) == 0)) { - script_print_log (weechat_python_plugin, python_scripts); + plugin_script_print_log (weechat_python_plugin, python_scripts); } return WEECHAT_RC_OK; @@ -1075,7 +1075,7 @@ weechat_python_signal_buffer_closed_cb (void *data, const char *signal, (void) type_data; if (signal_data) - script_remove_buffer_callbacks (python_scripts, signal_data); + plugin_script_remove_buffer_callbacks (python_scripts, signal_data); return WEECHAT_RC_OK; } @@ -1094,18 +1094,18 @@ weechat_python_timer_action_cb (void *data, int remaining_calls) { if (data == &python_action_install_list) { - script_action_install (weechat_python_plugin, - python_scripts, - &weechat_python_unload, - &weechat_python_load, - &python_action_install_list); + plugin_script_action_install (weechat_python_plugin, + python_scripts, + &weechat_python_unload, + &weechat_python_load, + &python_action_install_list); } else if (data == &python_action_remove_list) { - script_action_remove (weechat_python_plugin, - python_scripts, - &weechat_python_unload, - &python_action_remove_list); + plugin_script_action_remove (weechat_python_plugin, + python_scripts, + &weechat_python_unload, + &python_action_remove_list); } } @@ -1129,16 +1129,16 @@ weechat_python_signal_script_action_cb (void *data, const char *signal, { if (strcmp (signal, "python_script_install") == 0) { - script_action_add (&python_action_install_list, - (const char *)signal_data); + plugin_script_action_add (&python_action_install_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_python_timer_action_cb, &python_action_install_list); } else if (strcmp (signal, "python_script_remove") == 0) { - script_action_add (&python_action_remove_list, - (const char *)signal_data); + plugin_script_action_add (&python_action_remove_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_python_timer_action_cb, &python_action_remove_list); @@ -1208,11 +1208,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) init.callback_load_file = &weechat_python_load_cb; python_quiet = 1; - script_init (weechat_python_plugin, argc, argv, &init); + plugin_script_init (weechat_python_plugin, argc, argv, &init); python_quiet = 0; - script_display_short_list (weechat_python_plugin, - python_scripts); + plugin_script_display_short_list (weechat_python_plugin, + python_scripts); /* init ok */ return WEECHAT_RC_OK; @@ -1227,7 +1227,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) { /* unload all scripts */ python_quiet = 1; - script_end (plugin, &python_scripts, &weechat_python_unload_all); + plugin_script_end (plugin, &python_scripts, &weechat_python_unload_all); python_quiet = 0; /* free Python interpreter */ diff --git a/src/plugins/scripts/python/weechat-python.h b/src/plugins/python/weechat-python.h index 1a522603a..1a522603a 100644 --- a/src/plugins/scripts/python/weechat-python.h +++ b/src/plugins/python/weechat-python.h diff --git a/src/plugins/scripts/ruby/CMakeLists.txt b/src/plugins/ruby/CMakeLists.txt index ee69844d5..5f2aa86ee 100644 --- a/src/plugins/scripts/ruby/CMakeLists.txt +++ b/src/plugins/ruby/CMakeLists.txt @@ -24,7 +24,7 @@ SET_TARGET_PROPERTIES(ruby PROPERTIES PREFIX "") IF(RUBY_FOUND) INCLUDE_DIRECTORIES(${RUBY_INCLUDE_PATH} ${RUBY_ARCH}) - TARGET_LINK_LIBRARIES(ruby ${RUBY_LIBRARY} weechat_scripts) + TARGET_LINK_LIBRARIES(ruby ${RUBY_LIBRARY} weechat_plugins_scripts) ENDIF(RUBY_FOUND) INSTALL(TARGETS ruby LIBRARY DESTINATION ${LIBDIR}/plugins) diff --git a/src/plugins/scripts/ruby/Makefile.am b/src/plugins/ruby/Makefile.am index dedb40944..dedb40944 100644 --- a/src/plugins/scripts/ruby/Makefile.am +++ b/src/plugins/ruby/Makefile.am diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 6c5aadaa6..f2ea2bba8 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -27,10 +27,10 @@ #include <ruby.h> #include <time.h> -#include "../../weechat-plugin.h" -#include "../script.h" -#include "../script-api.h" -#include "../script-callback.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" +#include "../plugin-script-api.h" +#include "../plugin-script-callback.h" #include "weechat-ruby.h" @@ -50,9 +50,12 @@ ruby_function_name); \ __ret; \ } +#define API_PTR2STR(__pointer) \ + plugin_script_ptr2str (__pointer) #define API_STR2PTR(__string) \ - script_str2ptr (weechat_ruby_plugin, RUBY_CURRENT_SCRIPT_NAME, \ - ruby_function_name, __string) + plugin_script_str2ptr (weechat_ruby_plugin, \ + RUBY_CURRENT_SCRIPT_NAME, \ + ruby_function_name, __string) #define API_RETURN_OK return INT2FIX (1); #define API_RETURN_ERROR return INT2FIX (0); #define API_RETURN_EMPTY return Qnil; @@ -124,7 +127,7 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author, c_shutdown_func = StringValuePtr (shutdown_func); c_charset = StringValuePtr (charset); - if (script_search (weechat_ruby_plugin, ruby_scripts, c_name)) + if (plugin_script_search (weechat_ruby_plugin, ruby_scripts, c_name)) { /* another script already exists with same name */ weechat_printf (NULL, @@ -136,13 +139,13 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author, } /* register script */ - ruby_current_script = script_add (weechat_ruby_plugin, - &ruby_scripts, &last_ruby_script, - (ruby_current_script_filename) ? - ruby_current_script_filename : "", - c_name, c_author, c_version, c_license, - c_description, c_shutdown_func, - c_charset); + ruby_current_script = plugin_script_add (weechat_ruby_plugin, + &ruby_scripts, &last_ruby_script, + (ruby_current_script_filename) ? + ruby_current_script_filename : "", + c_name, c_author, c_version, c_license, + c_description, c_shutdown_func, + c_charset); if (ruby_current_script) { @@ -204,7 +207,7 @@ weechat_ruby_api_charset_set (VALUE class, VALUE charset) c_charset = StringValuePtr (charset); - script_api_charset_set (ruby_current_script, c_charset); + plugin_script_api_charset_set (ruby_current_script, c_charset); API_RETURN_OK; } @@ -593,7 +596,7 @@ weechat_ruby_api_list_new (VALUE class) API_FUNC(1, "list_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_new ()); + result = API_PTR2STR(weechat_list_new ()); API_RETURN_STRING(result); } @@ -622,10 +625,10 @@ weechat_ruby_api_list_add (VALUE class, VALUE weelist, VALUE data, VALUE where, c_where = StringValuePtr (where); c_user_data = StringValuePtr (user_data); - result = script_ptr2str (weechat_list_add (API_STR2PTR(c_weelist), - c_data, - c_where, - API_STR2PTR(c_user_data))); + result = API_PTR2STR(weechat_list_add (API_STR2PTR(c_weelist), + c_data, + c_where, + API_STR2PTR(c_user_data))); API_RETURN_STRING(result); } @@ -649,8 +652,8 @@ weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data) c_weelist = StringValuePtr (weelist); c_data = StringValuePtr (data); - result = script_ptr2str (weechat_list_search (API_STR2PTR(c_weelist), - c_data)); + result = API_PTR2STR(weechat_list_search (API_STR2PTR(c_weelist), + c_data)); API_RETURN_STRING(result); } @@ -699,8 +702,8 @@ weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data) c_weelist = StringValuePtr (weelist); c_data = StringValuePtr (data); - result = script_ptr2str (weechat_list_casesearch (API_STR2PTR(c_weelist), - c_data)); + result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(c_weelist), + c_data)); API_RETURN_STRING(result); } @@ -751,8 +754,8 @@ weechat_ruby_api_list_get (VALUE class, VALUE weelist, VALUE position) c_weelist = StringValuePtr (weelist); c_position = FIX2INT (position); - result = script_ptr2str (weechat_list_get (API_STR2PTR(c_weelist), - c_position)); + result = API_PTR2STR(weechat_list_get (API_STR2PTR(c_weelist), + c_position)); API_RETURN_STRING(result); } @@ -799,7 +802,7 @@ weechat_ruby_api_list_next (VALUE class, VALUE item) c_item = StringValuePtr (item); - result = script_ptr2str (weechat_list_next (API_STR2PTR(c_item))); + result = API_PTR2STR(weechat_list_next (API_STR2PTR(c_item))); API_RETURN_STRING(result); } @@ -821,7 +824,7 @@ weechat_ruby_api_list_prev (VALUE class, VALUE item) c_item = StringValuePtr (item); - result = script_ptr2str (weechat_list_prev (API_STR2PTR(c_item))); + result = API_PTR2STR(weechat_list_prev (API_STR2PTR(c_item))); API_RETURN_STRING(result); } @@ -959,7 +962,7 @@ weechat_ruby_api_config_reload_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1005,12 +1008,12 @@ weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_config_new (weechat_ruby_plugin, - ruby_current_script, - c_name, - &weechat_ruby_api_config_reload_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_config_new (weechat_ruby_plugin, + ruby_current_script, + c_name, + &weechat_ruby_api_config_reload_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -1035,8 +1038,8 @@ weechat_ruby_api_config_read_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1082,7 +1085,7 @@ weechat_ruby_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -1126,7 +1129,7 @@ weechat_ruby_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -1171,8 +1174,8 @@ weechat_ruby_api_config_section_create_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1219,9 +1222,9 @@ weechat_ruby_api_config_section_delete_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); - func_argv[3] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); + func_argv[3] = API_PTR2STR(option); rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1314,27 +1317,27 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, c_function_delete_option = StringValuePtr (function_delete_option); c_data_delete_option = StringValuePtr (data_delete_option); - result = script_ptr2str (script_api_config_new_section (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_config_file), - c_name, - c_user_can_add_options, - c_user_can_delete_options, - &weechat_ruby_api_config_read_cb, - c_function_read, - c_data_read, - &weechat_ruby_api_config_section_write_cb, - c_function_write, - c_data_write, - &weechat_ruby_api_config_section_write_default_cb, - c_function_write_default, - c_data_write_default, - &weechat_ruby_api_config_section_create_option_cb, - c_function_create_option, - c_data_create_option, - &weechat_ruby_api_config_section_delete_option_cb, - c_function_delete_option, - c_data_delete_option)); + result = API_PTR2STR(plugin_script_api_config_new_section (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_config_file), + c_name, + c_user_can_add_options, + c_user_can_delete_options, + &weechat_ruby_api_config_read_cb, + c_function_read, + c_data_read, + &weechat_ruby_api_config_section_write_cb, + c_function_write, + c_data_write, + &weechat_ruby_api_config_section_write_default_cb, + c_function_write_default, + c_data_write_default, + &weechat_ruby_api_config_section_create_option_cb, + c_function_create_option, + c_data_create_option, + &weechat_ruby_api_config_section_delete_option_cb, + c_function_delete_option, + c_data_delete_option)); API_RETURN_STRING_FREE(result); } @@ -1360,8 +1363,8 @@ weechat_ruby_api_config_search_section (VALUE class, VALUE config_file, c_config_file = StringValuePtr (config_file); c_section_name = StringValuePtr (section_name); - result = script_ptr2str (weechat_config_search_section (API_STR2PTR(c_config_file), - c_section_name)); + result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(c_config_file), + c_section_name)); API_RETURN_STRING_FREE(result); } @@ -1386,7 +1389,7 @@ weechat_ruby_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -1428,7 +1431,7 @@ weechat_ruby_api_config_option_change_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1461,7 +1464,7 @@ weechat_ruby_api_config_option_delete_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1546,28 +1549,28 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, c_function_delete = StringValuePtr (function_delete); c_data_delete = StringValuePtr (data_delete); - result = script_ptr2str (script_api_config_new_option (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_config_file), - API_STR2PTR(c_section), - c_name, - c_type, - c_description, - c_string_values, - c_min, - c_max, - c_default_value, - c_value, - c_null_value_allowed, - &weechat_ruby_api_config_option_check_value_cb, - c_function_check_value, - c_data_check_value, - &weechat_ruby_api_config_option_change_cb, - c_function_change, - c_data_change, - &weechat_ruby_api_config_option_delete_cb, - c_function_delete, - c_data_delete)); + result = API_PTR2STR(plugin_script_api_config_new_option (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_config_file), + API_STR2PTR(c_section), + c_name, + c_type, + c_description, + c_string_values, + c_min, + c_max, + c_default_value, + c_value, + c_null_value_allowed, + &weechat_ruby_api_config_option_check_value_cb, + c_function_check_value, + c_data_check_value, + &weechat_ruby_api_config_option_change_cb, + c_function_change, + c_data_change, + &weechat_ruby_api_config_option_delete_cb, + c_function_delete, + c_data_delete)); API_RETURN_STRING_FREE(result); } @@ -1595,9 +1598,9 @@ weechat_ruby_api_config_search_option (VALUE class, VALUE config_file, c_section = StringValuePtr (section); c_option_name = StringValuePtr (option_name); - result = script_ptr2str (weechat_config_search_option (API_STR2PTR(c_config_file), - API_STR2PTR(c_section), - c_option_name)); + result = API_PTR2STR(weechat_config_search_option (API_STR2PTR(c_config_file), + API_STR2PTR(c_section), + c_option_name)); API_RETURN_STRING_FREE(result); } @@ -2131,9 +2134,9 @@ weechat_ruby_api_config_option_free (VALUE class, VALUE option) c_option = StringValuePtr (option); - script_api_config_option_free (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_option)); + plugin_script_api_config_option_free (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_option)); API_RETURN_OK; } @@ -2156,9 +2159,9 @@ weechat_ruby_api_config_section_free_options (VALUE class, VALUE section) c_section = StringValuePtr (section); - script_api_config_section_free_options (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_section)); + plugin_script_api_config_section_free_options (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_section)); API_RETURN_OK; } @@ -2180,9 +2183,9 @@ weechat_ruby_api_config_section_free (VALUE class, VALUE section) c_section = StringValuePtr (section); - script_api_config_section_free (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_section)); + plugin_script_api_config_section_free (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_section)); API_RETURN_OK; } @@ -2204,9 +2207,9 @@ weechat_ruby_api_config_free (VALUE class, VALUE config_file) c_config_file = StringValuePtr (config_file); - script_api_config_free (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_config_file)); + plugin_script_api_config_free (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_config_file)); API_RETURN_OK; } @@ -2229,7 +2232,7 @@ weechat_ruby_api_config_get (VALUE class, VALUE option) c_option = StringValuePtr (option); - result = script_ptr2str (weechat_config_get (c_option)); + result = API_PTR2STR(weechat_config_get (c_option)); API_RETURN_STRING_FREE(result); } @@ -2252,9 +2255,9 @@ weechat_ruby_api_config_get_plugin (VALUE class, VALUE option) c_option = StringValuePtr (option); - result = script_api_config_get_plugin (weechat_ruby_plugin, - ruby_current_script, - c_option); + result = plugin_script_api_config_get_plugin (weechat_ruby_plugin, + ruby_current_script, + c_option); API_RETURN_STRING(result); } @@ -2277,9 +2280,9 @@ weechat_ruby_api_config_is_set_plugin (VALUE class, VALUE option) c_option = StringValuePtr (option); - rc = script_api_config_is_set_plugin (weechat_ruby_plugin, - ruby_current_script, - c_option); + rc = plugin_script_api_config_is_set_plugin (weechat_ruby_plugin, + ruby_current_script, + c_option); API_RETURN_INT(rc); } @@ -2304,10 +2307,10 @@ weechat_ruby_api_config_set_plugin (VALUE class, VALUE option, VALUE value) c_option = StringValuePtr (option); c_value = StringValuePtr (value); - rc = script_api_config_set_plugin (weechat_ruby_plugin, - ruby_current_script, - c_option, - c_value); + rc = plugin_script_api_config_set_plugin (weechat_ruby_plugin, + ruby_current_script, + c_option, + c_value); API_RETURN_INT(rc); } @@ -2332,10 +2335,10 @@ weechat_ruby_api_config_set_desc_plugin (VALUE class, VALUE option, c_option = StringValuePtr (option); c_description = StringValuePtr (description); - script_api_config_set_desc_plugin (weechat_ruby_plugin, - ruby_current_script, - c_option, - c_description); + plugin_script_api_config_set_desc_plugin (weechat_ruby_plugin, + ruby_current_script, + c_option, + c_description); API_RETURN_OK; } @@ -2358,9 +2361,9 @@ weechat_ruby_api_config_unset_plugin (VALUE class, VALUE option) c_option = StringValuePtr (option); - rc = script_api_config_unset_plugin (weechat_ruby_plugin, - ruby_current_script, - c_option); + rc = plugin_script_api_config_unset_plugin (weechat_ruby_plugin, + ruby_current_script, + c_option); API_RETURN_INT(rc); } @@ -2485,10 +2488,10 @@ weechat_ruby_api_print (VALUE class, VALUE buffer, VALUE message) c_buffer = StringValuePtr (buffer); c_message = StringValuePtr (message); - script_api_printf (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_buffer), - "%s", c_message); + plugin_script_api_printf (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_buffer), + "%s", c_message); API_RETURN_OK; } @@ -2519,12 +2522,12 @@ weechat_ruby_api_print_date_tags (VALUE class, VALUE buffer, VALUE date, c_tags = StringValuePtr (tags); c_message = StringValuePtr (message); - script_api_printf_date_tags (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_buffer), - c_date, - c_tags, - "%s", c_message); + plugin_script_api_printf_date_tags (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_buffer), + c_date, + c_tags, + "%s", c_message); API_RETURN_OK; } @@ -2551,11 +2554,11 @@ weechat_ruby_api_print_y (VALUE class, VALUE buffer, VALUE y, VALUE message) c_y = FIX2INT (y); c_message = StringValuePtr (message); - script_api_printf_y (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_buffer), - c_y, - "%s", c_message); + plugin_script_api_printf_y (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_buffer), + c_y, + "%s", c_message); API_RETURN_OK; } @@ -2577,9 +2580,9 @@ weechat_ruby_api_log_print (VALUE class, VALUE message) c_message = StringValuePtr (message); - script_api_log_printf (weechat_ruby_plugin, - ruby_current_script, - "%s", c_message); + plugin_script_api_log_printf (weechat_ruby_plugin, + ruby_current_script, + "%s", c_message); API_RETURN_OK; } @@ -2605,7 +2608,7 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -2664,16 +2667,16 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_command (weechat_ruby_plugin, - ruby_current_script, - c_command, - c_description, - c_args, - c_args_description, - c_completion, - &weechat_ruby_api_hook_command_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_command (weechat_ruby_plugin, + ruby_current_script, + c_command, + c_description, + c_args, + c_args_description, + c_completion, + &weechat_ruby_api_hook_command_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -2696,7 +2699,7 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -2743,12 +2746,12 @@ weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_command_run (weechat_ruby_plugin, - ruby_current_script, - c_command, - &weechat_ruby_api_hook_command_run_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_command_run (weechat_ruby_plugin, + ruby_current_script, + c_command, + &weechat_ruby_api_hook_command_run_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -2823,14 +2826,14 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_timer (weechat_ruby_plugin, - ruby_current_script, - c_interval, - c_align_second, - c_max_calls, - &weechat_ruby_api_hook_timer_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_timer (weechat_ruby_plugin, + ruby_current_script, + c_interval, + c_align_second, + c_max_calls, + &weechat_ruby_api_hook_timer_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -2906,15 +2909,15 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_fd (weechat_ruby_plugin, - ruby_current_script, - c_fd, - c_read, - c_write, - c_exception, - &weechat_ruby_api_hook_fd_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_fd (weechat_ruby_plugin, + ruby_current_script, + c_fd, + c_read, + c_write, + c_exception, + &weechat_ruby_api_hook_fd_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -2988,13 +2991,13 @@ weechat_ruby_api_hook_process (VALUE class, VALUE command, VALUE timeout, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_process (weechat_ruby_plugin, - ruby_current_script, - c_command, - c_timeout, - &weechat_ruby_api_hook_process_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_process (weechat_ruby_plugin, + ruby_current_script, + c_command, + c_timeout, + &weechat_ruby_api_hook_process_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3032,14 +3035,14 @@ weechat_ruby_api_hook_process_hashtable (VALUE class, VALUE command, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_process_hashtable (weechat_ruby_plugin, - ruby_current_script, - c_command, - c_options, - c_timeout, - &weechat_ruby_api_hook_process_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_ruby_plugin, + ruby_current_script, + c_command, + c_options, + c_timeout, + &weechat_ruby_api_hook_process_cb, + c_function, + c_data)); if (c_options) weechat_hashtable_free (c_options); @@ -3131,21 +3134,21 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_connect (weechat_ruby_plugin, - ruby_current_script, - c_proxy, - c_address, - c_port, - c_sock, - c_ipv6, - NULL, /* gnutls session */ - NULL, /* gnutls callback */ - 0, /* gnutls DH key size */ - NULL, /* gnutls priorities */ - c_local_hostname, - &weechat_ruby_api_hook_connect_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_connect (weechat_ruby_plugin, + ruby_current_script, + c_proxy, + c_address, + c_port, + c_sock, + c_ipv6, + NULL, /* gnutls session */ + NULL, /* gnutls callback */ + 0, /* gnutls DH key size */ + NULL, /* gnutls priorities */ + c_local_hostname, + &weechat_ruby_api_hook_connect_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3177,7 +3180,7 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -3246,15 +3249,15 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_print (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_buffer), - c_tags, - c_message, - c_strip_colors, - &weechat_ruby_api_hook_print_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_print (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_buffer), + c_tags, + c_message, + c_strip_colors, + &weechat_ruby_api_hook_print_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3292,7 +3295,7 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = script_ptr2str (signal_data); + func_argv[2] = API_PTR2STR(signal_data); free_needed = 1; } else @@ -3342,12 +3345,12 @@ weechat_ruby_api_hook_signal (VALUE class, VALUE signal, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_signal (weechat_ruby_plugin, - ruby_current_script, - c_signal, - &weechat_ruby_api_hook_signal_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_signal (weechat_ruby_plugin, + ruby_current_script, + c_signal, + &weechat_ruby_api_hook_signal_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3462,12 +3465,12 @@ weechat_ruby_api_hook_hsignal (VALUE class, VALUE signal, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_hsignal (weechat_ruby_plugin, - ruby_current_script, - c_signal, - &weechat_ruby_api_hook_hsignal_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_hsignal (weechat_ruby_plugin, + ruby_current_script, + c_signal, + &weechat_ruby_api_hook_hsignal_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3563,12 +3566,12 @@ weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_config (weechat_ruby_plugin, - ruby_current_script, - c_option, - &weechat_ruby_api_hook_config_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_config (weechat_ruby_plugin, + ruby_current_script, + c_option, + &weechat_ruby_api_hook_config_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3593,8 +3596,8 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = script_ptr2str (buffer); - func_argv[3] = script_ptr2str (completion); + func_argv[2] = API_PTR2STR(buffer); + func_argv[3] = API_PTR2STR(completion); rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3646,13 +3649,13 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_completion (weechat_ruby_plugin, - ruby_current_script, - c_completion, - c_description, - &weechat_ruby_api_hook_completion_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_completion (weechat_ruby_plugin, + ruby_current_script, + c_completion, + c_description, + &weechat_ruby_api_hook_completion_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3745,12 +3748,12 @@ weechat_ruby_api_hook_modifier (VALUE class, VALUE modifier, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_modifier (weechat_ruby_plugin, - ruby_current_script, - c_modifier, - &weechat_ruby_api_hook_modifier_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_modifier (weechat_ruby_plugin, + ruby_current_script, + c_modifier, + &weechat_ruby_api_hook_modifier_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3841,14 +3844,14 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_info (weechat_ruby_plugin, - ruby_current_script, - c_info_name, - c_description, - c_args_description, - &weechat_ruby_api_hook_info_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_info (weechat_ruby_plugin, + ruby_current_script, + c_info_name, + c_description, + c_args_description, + &weechat_ruby_api_hook_info_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3917,15 +3920,15 @@ weechat_ruby_api_hook_info_hashtable (VALUE class, VALUE info_name, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_info_hashtable (weechat_ruby_plugin, - ruby_current_script, - c_info_name, - c_description, - c_args_description, - c_output_description, - &weechat_ruby_api_hook_info_hashtable_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_info_hashtable (weechat_ruby_plugin, + ruby_current_script, + c_info_name, + c_description, + c_args_description, + c_output_description, + &weechat_ruby_api_hook_info_hashtable_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -3949,7 +3952,7 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = script_ptr2str (pointer); + func_argv[2] = API_PTR2STR(pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_ruby_exec (script_callback->script, @@ -4000,15 +4003,15 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_infolist (weechat_ruby_plugin, - ruby_current_script, - c_infolist_name, - c_description, - c_pointer_description, - c_args_description, - &weechat_ruby_api_hook_infolist_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_infolist (weechat_ruby_plugin, + ruby_current_script, + c_infolist_name, + c_description, + c_pointer_description, + c_args_description, + &weechat_ruby_api_hook_infolist_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -4063,12 +4066,12 @@ weechat_ruby_api_hook_focus (VALUE class, VALUE area, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_hook_focus (weechat_ruby_plugin, - ruby_current_script, - c_area, - &weechat_ruby_api_hook_focus_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_hook_focus (weechat_ruby_plugin, + ruby_current_script, + c_area, + &weechat_ruby_api_hook_focus_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -4090,9 +4093,9 @@ weechat_ruby_api_unhook (VALUE class, VALUE hook) c_hook = StringValuePtr (hook); - script_api_unhook (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_hook)); + plugin_script_api_unhook (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_hook)); API_RETURN_OK; } @@ -4106,7 +4109,7 @@ weechat_ruby_api_unhook_all (VALUE class) { API_FUNC(1, "unhook_all", API_RETURN_ERROR); - script_api_unhook_all (weechat_ruby_plugin, ruby_current_script); + plugin_script_api_unhook_all (weechat_ruby_plugin, ruby_current_script); API_RETURN_OK; } @@ -4129,7 +4132,7 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -4170,7 +4173,7 @@ weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4223,15 +4226,15 @@ weechat_ruby_api_buffer_new (VALUE class, VALUE name, VALUE function_input, c_function_close = StringValuePtr (function_close); c_data_close = StringValuePtr (data_close); - result = script_ptr2str (script_api_buffer_new (weechat_ruby_plugin, - ruby_current_script, - c_name, - &weechat_ruby_api_buffer_input_data_cb, - c_function_input, - c_data_input, - &weechat_ruby_api_buffer_close_cb, - c_function_close, - c_data_close)); + result = API_PTR2STR(plugin_script_api_buffer_new (weechat_ruby_plugin, + ruby_current_script, + c_name, + &weechat_ruby_api_buffer_input_data_cb, + c_function_input, + c_data_input, + &weechat_ruby_api_buffer_close_cb, + c_function_close, + c_data_close)); API_RETURN_STRING_FREE(result); } @@ -4256,7 +4259,7 @@ weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) c_plugin = StringValuePtr (plugin); c_name = StringValuePtr (name); - result = script_ptr2str (weechat_buffer_search (c_plugin, c_name)); + result = API_PTR2STR(weechat_buffer_search (c_plugin, c_name)); API_RETURN_STRING_FREE(result); } @@ -4273,7 +4276,7 @@ weechat_ruby_api_buffer_search_main (VALUE class) API_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search_main ()); + result = API_PTR2STR(weechat_buffer_search_main ()); API_RETURN_STRING_FREE(result); } @@ -4290,7 +4293,7 @@ weechat_ruby_api_current_buffer (VALUE class) API_FUNC(1, "current_buffer", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_buffer ()); + result = API_PTR2STR(weechat_current_buffer ()); API_RETURN_STRING_FREE(result); } @@ -4334,9 +4337,9 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer) c_buffer = StringValuePtr (buffer); - script_api_buffer_close (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_buffer)); + plugin_script_api_buffer_close (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_buffer)); API_RETURN_OK; } @@ -4464,8 +4467,8 @@ weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property) c_buffer = StringValuePtr (buffer); c_property = StringValuePtr (property); - result = script_ptr2str (weechat_buffer_get_pointer (API_STR2PTR(c_buffer), - c_property)); + result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(c_buffer), + c_property)); API_RETURN_STRING_FREE(result); } @@ -4563,7 +4566,7 @@ weechat_ruby_api_current_window (VALUE class) API_FUNC(1, "current_window", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_window ()); + result = API_PTR2STR(weechat_current_window ()); API_RETURN_STRING_FREE(result); } @@ -4587,7 +4590,7 @@ weechat_ruby_api_window_search_with_buffer (VALUE class, VALUE buffer) c_buffer = StringValuePtr (buffer); - result = script_ptr2str (weechat_window_search_with_buffer (API_STR2PTR(c_buffer))); + result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(c_buffer))); API_RETURN_STRING_FREE(result); } @@ -4664,8 +4667,8 @@ weechat_ruby_api_window_get_pointer (VALUE class, VALUE window, VALUE property) c_window = StringValuePtr (window); c_property = StringValuePtr (property); - result = script_ptr2str (weechat_window_get_pointer (API_STR2PTR(c_window), - c_property)); + result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(c_window), + c_property)); API_RETURN_STRING_FREE(result); } @@ -4722,11 +4725,11 @@ weechat_ruby_api_nicklist_add_group (VALUE class, VALUE buffer, c_color = StringValuePtr (color); c_visible = FIX2INT (visible); - result = script_ptr2str (weechat_nicklist_add_group (API_STR2PTR(c_buffer), - API_STR2PTR(c_parent_group), - c_name, - c_color, - c_visible)); + result = API_PTR2STR(weechat_nicklist_add_group (API_STR2PTR(c_buffer), + API_STR2PTR(c_parent_group), + c_name, + c_color, + c_visible)); API_RETURN_STRING_FREE(result); } @@ -4754,9 +4757,9 @@ weechat_ruby_api_nicklist_search_group (VALUE class, VALUE buffer, c_from_group = StringValuePtr (from_group); c_name = StringValuePtr (name); - result = script_ptr2str (weechat_nicklist_search_group (API_STR2PTR(c_buffer), - API_STR2PTR(c_from_group), - c_name)); + result = API_PTR2STR(weechat_nicklist_search_group (API_STR2PTR(c_buffer), + API_STR2PTR(c_from_group), + c_name)); API_RETURN_STRING_FREE(result); } @@ -4796,13 +4799,13 @@ weechat_ruby_api_nicklist_add_nick (VALUE class, VALUE buffer, VALUE group, c_prefix_color = StringValuePtr (prefix_color); c_visible = FIX2INT (visible); - result = script_ptr2str (weechat_nicklist_add_nick (API_STR2PTR(c_buffer), - API_STR2PTR(c_group), - c_name, - c_color, - c_prefix, - c_prefix_color, - c_visible)); + result = API_PTR2STR(weechat_nicklist_add_nick (API_STR2PTR(c_buffer), + API_STR2PTR(c_group), + c_name, + c_color, + c_prefix, + c_prefix_color, + c_visible)); API_RETURN_STRING_FREE(result); } @@ -4830,9 +4833,9 @@ weechat_ruby_api_nicklist_search_nick (VALUE class, VALUE buffer, c_from_group = StringValuePtr (from_group); c_name = StringValuePtr (name); - result = script_ptr2str (weechat_nicklist_search_nick (API_STR2PTR(c_buffer), - API_STR2PTR(c_from_group), - c_name)); + result = API_PTR2STR(weechat_nicklist_search_nick (API_STR2PTR(c_buffer), + API_STR2PTR(c_from_group), + c_name)); API_RETURN_STRING_FREE(result); } @@ -4992,9 +4995,9 @@ weechat_ruby_api_nicklist_group_get_pointer (VALUE class, VALUE buffer, c_group = StringValuePtr (group); c_property = StringValuePtr (property); - result = script_ptr2str (weechat_nicklist_group_get_pointer (API_STR2PTR(c_buffer), - API_STR2PTR(c_group), - c_property)); + result = API_PTR2STR(weechat_nicklist_group_get_pointer (API_STR2PTR(c_buffer), + API_STR2PTR(c_group), + c_property)); API_RETURN_STRING_FREE(result); } @@ -5114,9 +5117,9 @@ weechat_ruby_api_nicklist_nick_get_pointer (VALUE class, VALUE buffer, c_nick = StringValuePtr (nick); c_property = StringValuePtr (property); - result = script_ptr2str (weechat_nicklist_nick_get_pointer (API_STR2PTR(c_buffer), - API_STR2PTR(c_nick), - c_property)); + result = API_PTR2STR(weechat_nicklist_nick_get_pointer (API_STR2PTR(c_buffer), + API_STR2PTR(c_nick), + c_property)); API_RETURN_STRING_FREE(result); } @@ -5171,7 +5174,7 @@ weechat_ruby_api_bar_item_search (VALUE class, VALUE name) c_name = StringValuePtr (name); - result = script_ptr2str (weechat_bar_item_search (c_name)); + result = API_PTR2STR(weechat_bar_item_search (c_name)); API_RETURN_STRING_FREE(result); } @@ -5193,8 +5196,8 @@ weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (item); - func_argv[2] = script_ptr2str (window); + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); ret = (char *)weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -5235,12 +5238,12 @@ weechat_ruby_api_bar_item_new (VALUE class, VALUE name, VALUE function, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - result = script_ptr2str (script_api_bar_item_new (weechat_ruby_plugin, - ruby_current_script, - c_name, - &weechat_ruby_api_bar_item_build_cb, - c_function, - c_data)); + result = API_PTR2STR(plugin_script_api_bar_item_new (weechat_ruby_plugin, + ruby_current_script, + c_name, + &weechat_ruby_api_bar_item_build_cb, + c_function, + c_data)); API_RETURN_STRING_FREE(result); } @@ -5284,9 +5287,9 @@ weechat_ruby_api_bar_item_remove (VALUE class, VALUE item) c_item = StringValuePtr (item); - script_api_bar_item_remove (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_item)); + plugin_script_api_bar_item_remove (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_item)); API_RETURN_OK; } @@ -5309,7 +5312,7 @@ weechat_ruby_api_bar_search (VALUE class, VALUE name) c_name = StringValuePtr (name); - result = script_ptr2str (weechat_bar_search (c_name)); + result = API_PTR2STR(weechat_bar_search (c_name)); API_RETURN_STRING_FREE(result); } @@ -5372,21 +5375,21 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE hidden, c_separator = StringValuePtr (separator); c_items = StringValuePtr (items); - result = script_ptr2str (weechat_bar_new (c_name, - c_hidden, - c_priority, - c_type, - c_conditions, - c_position, - c_filling_top_bottom, - c_filling_left_right, - c_size, - c_size_max, - c_color_fg, - c_color_delim, - c_color_bg, - c_separator, - c_items)); + result = API_PTR2STR(weechat_bar_new (c_name, + c_hidden, + c_priority, + c_type, + c_conditions, + c_position, + c_filling_top_bottom, + c_filling_left_right, + c_size, + c_size_max, + c_color_fg, + c_color_delim, + c_color_bg, + c_separator, + c_items)); API_RETURN_STRING_FREE(result); } @@ -5482,10 +5485,10 @@ weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command) c_buffer = StringValuePtr (buffer); c_command = StringValuePtr (command); - script_api_command (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_buffer), - c_command); + plugin_script_api_command (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_buffer), + c_command); API_RETURN_OK; } @@ -5561,7 +5564,7 @@ weechat_ruby_api_infolist_new (VALUE class) API_FUNC(1, "infolist_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new ()); + result = API_PTR2STR(weechat_infolist_new ()); API_RETURN_STRING_FREE(result); } @@ -5584,7 +5587,7 @@ weechat_ruby_api_infolist_new_item (VALUE class, VALUE infolist) c_infolist = StringValuePtr (infolist); - result = script_ptr2str (weechat_infolist_new_item (API_STR2PTR(c_infolist))); + result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(c_infolist))); API_RETURN_STRING_FREE(result); } @@ -5614,9 +5617,9 @@ weechat_ruby_api_infolist_new_var_integer (VALUE class, VALUE infolist, c_name = StringValuePtr (name); c_value = FIX2INT (value); - result = script_ptr2str (weechat_infolist_new_var_integer (API_STR2PTR(c_infolist), - c_name, - c_value)); + result = API_PTR2STR(weechat_infolist_new_var_integer (API_STR2PTR(c_infolist), + c_name, + c_value)); API_RETURN_STRING_FREE(result); } @@ -5645,9 +5648,9 @@ weechat_ruby_api_infolist_new_var_string (VALUE class, VALUE infolist, c_name = StringValuePtr (name); c_value = StringValuePtr (value); - result = script_ptr2str (weechat_infolist_new_var_string (API_STR2PTR(c_infolist), - c_name, - c_value)); + result = API_PTR2STR(weechat_infolist_new_var_string (API_STR2PTR(c_infolist), + c_name, + c_value)); API_RETURN_STRING_FREE(result); } @@ -5676,9 +5679,9 @@ weechat_ruby_api_infolist_new_var_pointer (VALUE class, VALUE infolist, c_name = StringValuePtr (name); c_value = StringValuePtr (value); - result = script_ptr2str (weechat_infolist_new_var_pointer (API_STR2PTR(c_infolist), - c_name, - API_STR2PTR(c_value))); + result = API_PTR2STR(weechat_infolist_new_var_pointer (API_STR2PTR(c_infolist), + c_name, + API_STR2PTR(c_value))); API_RETURN_STRING_FREE(result); } @@ -5707,9 +5710,9 @@ weechat_ruby_api_infolist_new_var_time (VALUE class, VALUE infolist, c_name = StringValuePtr (name); c_value = FIX2INT (value); - result = script_ptr2str (weechat_infolist_new_var_time (API_STR2PTR(c_infolist), - c_name, - c_value)); + result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(c_infolist), + c_name, + c_value)); API_RETURN_STRING_FREE(result); } @@ -5737,9 +5740,9 @@ weechat_ruby_api_infolist_get (VALUE class, VALUE name, VALUE pointer, c_pointer = StringValuePtr (pointer); c_arguments = StringValuePtr (arguments); - result = script_ptr2str (weechat_infolist_get (c_name, - API_STR2PTR(c_pointer), - c_arguments)); + result = API_PTR2STR(weechat_infolist_get (c_name, + API_STR2PTR(c_pointer), + c_arguments)); API_RETURN_STRING_FREE(result); } @@ -5906,7 +5909,7 @@ weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable) c_infolist = StringValuePtr (infolist); c_variable = StringValuePtr (variable); - result = script_ptr2str (weechat_infolist_pointer (API_STR2PTR(c_infolist), c_variable)); + result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(c_infolist), c_variable)); API_RETURN_STRING_FREE(result); } @@ -5983,7 +5986,7 @@ weechat_ruby_api_hdata_get (VALUE class, VALUE name) c_name = StringValuePtr (name); - result = script_ptr2str (weechat_hdata_get (c_name)); + result = API_PTR2STR(weechat_hdata_get (c_name)); API_RETURN_STRING_FREE(result); } @@ -6146,8 +6149,8 @@ weechat_ruby_api_hdata_get_list (VALUE class, VALUE hdata, VALUE name) c_hdata = StringValuePtr (hdata); c_name = StringValuePtr (name); - result = script_ptr2str (weechat_hdata_get_list (API_STR2PTR(c_hdata), - c_name)); + result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(c_hdata), + c_name)); API_RETURN_STRING_FREE(result); } @@ -6361,9 +6364,9 @@ weechat_ruby_api_hdata_pointer (VALUE class, VALUE hdata, VALUE pointer, c_pointer = StringValuePtr (pointer); c_name = StringValuePtr (name); - result = script_ptr2str (weechat_hdata_pointer (API_STR2PTR(c_hdata), - API_STR2PTR(c_pointer), - c_name)); + result = API_PTR2STR(weechat_hdata_pointer (API_STR2PTR(c_hdata), + API_STR2PTR(c_pointer), + c_name)); API_RETURN_STRING_FREE(result); } @@ -6485,8 +6488,8 @@ weechat_ruby_api_upgrade_new (VALUE class, VALUE filename, VALUE write) c_filename = StringValuePtr (filename); c_write = FIX2INT (write); - result = script_ptr2str (weechat_upgrade_new (c_filename, - c_write)); + result = API_PTR2STR(weechat_upgrade_new (c_filename, + c_write)); API_RETURN_STRING_FREE(result); } @@ -6543,9 +6546,9 @@ weechat_ruby_api_upgrade_read_cb (void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (upgrade_file); + func_argv[1] = API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = script_ptr2str (infolist); + func_argv[3] = API_PTR2STR(infolist); rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -6593,12 +6596,12 @@ weechat_ruby_api_upgrade_read (VALUE class, VALUE upgrade_file, c_function = StringValuePtr (function); c_data = StringValuePtr (data); - rc = script_api_upgrade_read (weechat_ruby_plugin, - ruby_current_script, - API_STR2PTR(c_upgrade_file), - &weechat_ruby_api_upgrade_read_cb, - c_function, - c_data); + rc = plugin_script_api_upgrade_read (weechat_ruby_plugin, + ruby_current_script, + API_STR2PTR(c_upgrade_file), + &weechat_ruby_api_upgrade_read_cb, + c_function, + c_data); API_RETURN_INT(rc); } diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.h b/src/plugins/ruby/weechat-ruby-api.h index 708bf518f..708bf518f 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.h +++ b/src/plugins/ruby/weechat-ruby-api.h diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c index 01709ac74..37074646a 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/ruby/weechat-ruby.c @@ -33,8 +33,8 @@ #include <sys/types.h> #include <sys/stat.h> -#include "../../weechat-plugin.h" -#include "../script.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" #include "weechat-ruby.h" #include "weechat-ruby-api.h" @@ -564,9 +564,9 @@ weechat_ruby_load (const char *filename) if (ruby_current_script != NULL) { - script_remove (weechat_ruby_plugin, - &ruby_scripts, &last_ruby_script, - ruby_current_script); + plugin_script_remove (weechat_ruby_plugin, + &ruby_scripts, &last_ruby_script, + ruby_current_script); } return 0; @@ -589,11 +589,11 @@ weechat_ruby_load (const char *filename) * set input/close callbacks for buffers created by this script * (to restore callbacks after upgrade) */ - script_set_buffer_callbacks (weechat_ruby_plugin, - ruby_scripts, - ruby_current_script, - &weechat_ruby_api_buffer_input_data_cb, - &weechat_ruby_api_buffer_close_cb); + plugin_script_set_buffer_callbacks (weechat_ruby_plugin, + ruby_scripts, + ruby_current_script, + &weechat_ruby_api_buffer_input_data_cb, + &weechat_ruby_api_buffer_close_cb); return 1; } @@ -644,8 +644,8 @@ weechat_ruby_unload (struct t_plugin_script *script) ruby_current_script = (ruby_current_script->prev_script) ? ruby_current_script->prev_script : ruby_current_script->next_script; - script_remove (weechat_ruby_plugin, &ruby_scripts, &last_ruby_script, - script); + plugin_script_remove (weechat_ruby_plugin, &ruby_scripts, &last_ruby_script, + script); if (interpreter) rb_gc_unregister_address (interpreter); @@ -660,7 +660,7 @@ weechat_ruby_unload_name (const char *name) { struct t_plugin_script *ptr_script; - ptr_script = script_search (weechat_ruby_plugin, ruby_scripts, name); + ptr_script = plugin_script_search (weechat_ruby_plugin, ruby_scripts, name); if (ptr_script) { weechat_ruby_unload (ptr_script); @@ -686,7 +686,7 @@ weechat_ruby_reload_name (const char *name) struct t_plugin_script *ptr_script; char *filename; - ptr_script = script_search (weechat_ruby_plugin, ruby_scripts, name); + ptr_script = plugin_script_search (weechat_ruby_plugin, ruby_scripts, name); if (ptr_script) { filename = strdup (ptr_script->filename); @@ -737,29 +737,29 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer, if (argc == 1) { - script_display_list (weechat_ruby_plugin, ruby_scripts, - NULL, 0); + plugin_script_display_list (weechat_ruby_plugin, ruby_scripts, + NULL, 0); } else if (argc == 2) { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_ruby_plugin, ruby_scripts, - NULL, 0); + plugin_script_display_list (weechat_ruby_plugin, ruby_scripts, + NULL, 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_ruby_plugin, ruby_scripts, - NULL, 1); + plugin_script_display_list (weechat_ruby_plugin, ruby_scripts, + NULL, 1); } else if (weechat_strcasecmp (argv[1], "autoload") == 0) { - script_auto_load (weechat_ruby_plugin, &weechat_ruby_load_cb); + plugin_script_auto_load (weechat_ruby_plugin, &weechat_ruby_load_cb); } else if (weechat_strcasecmp (argv[1], "reload") == 0) { weechat_ruby_unload_all (); - script_auto_load (weechat_ruby_plugin, &weechat_ruby_load_cb); + plugin_script_auto_load (weechat_ruby_plugin, &weechat_ruby_load_cb); } else if (weechat_strcasecmp (argv[1], "unload") == 0) { @@ -770,19 +770,19 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer, { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_ruby_plugin, ruby_scripts, - argv_eol[2], 0); + plugin_script_display_list (weechat_ruby_plugin, ruby_scripts, + argv_eol[2], 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_ruby_plugin, ruby_scripts, - argv_eol[2], 1); + plugin_script_display_list (weechat_ruby_plugin, ruby_scripts, + argv_eol[2], 1); } else if (weechat_strcasecmp (argv[1], "load") == 0) { /* load Ruby script */ - path_script = script_search_path (weechat_ruby_plugin, - argv_eol[2]); + path_script = plugin_script_search_path (weechat_ruby_plugin, + argv_eol[2]); weechat_ruby_load ((path_script) ? path_script : argv_eol[2]); if (path_script) free (path_script); @@ -823,7 +823,7 @@ weechat_ruby_completion_cb (void *data, const char *completion_item, (void) completion_item; (void) buffer; - script_completion (weechat_ruby_plugin, completion, ruby_scripts); + plugin_script_completion (weechat_ruby_plugin, completion, ruby_scripts); return WEECHAT_RC_OK; } @@ -844,9 +844,9 @@ weechat_ruby_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "ruby_script") == 0) { - return script_infolist_list_scripts (weechat_ruby_plugin, - ruby_scripts, pointer, - arguments); + return plugin_script_infolist_list_scripts (weechat_ruby_plugin, + ruby_scripts, pointer, + arguments); } return NULL; @@ -868,7 +868,7 @@ weechat_ruby_signal_debug_dump_cb (void *data, const char *signal, if (!signal_data || (weechat_strcasecmp ((char *)signal_data, RUBY_PLUGIN_NAME) == 0)) { - script_print_log (weechat_ruby_plugin, ruby_scripts); + plugin_script_print_log (weechat_ruby_plugin, ruby_scripts); } return WEECHAT_RC_OK; @@ -888,7 +888,7 @@ weechat_ruby_signal_buffer_closed_cb (void *data, const char *signal, (void) type_data; if (signal_data) - script_remove_buffer_callbacks (ruby_scripts, signal_data); + plugin_script_remove_buffer_callbacks (ruby_scripts, signal_data); return WEECHAT_RC_OK; } @@ -907,18 +907,18 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls) { if (data == &ruby_action_install_list) { - script_action_install (weechat_ruby_plugin, - ruby_scripts, - &weechat_ruby_unload, - &weechat_ruby_load, - &ruby_action_install_list); + plugin_script_action_install (weechat_ruby_plugin, + ruby_scripts, + &weechat_ruby_unload, + &weechat_ruby_load, + &ruby_action_install_list); } else if (data == &ruby_action_remove_list) { - script_action_remove (weechat_ruby_plugin, - ruby_scripts, - &weechat_ruby_unload, - &ruby_action_remove_list); + plugin_script_action_remove (weechat_ruby_plugin, + ruby_scripts, + &weechat_ruby_unload, + &ruby_action_remove_list); } } @@ -942,16 +942,16 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal, { if (strcmp (signal, "ruby_script_install") == 0) { - script_action_add (&ruby_action_install_list, - (const char *)signal_data); + plugin_script_action_add (&ruby_action_install_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_ruby_timer_action_cb, &ruby_action_install_list); } else if (strcmp (signal, "ruby_script_remove") == 0) { - script_action_add (&ruby_action_remove_list, - (const char *)signal_data); + plugin_script_action_add (&ruby_action_remove_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_ruby_timer_action_cb, &ruby_action_remove_list); @@ -1079,11 +1079,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) init.callback_load_file = &weechat_ruby_load_cb; ruby_quiet = 1; - script_init (weechat_ruby_plugin, argc, argv, &init); + plugin_script_init (weechat_ruby_plugin, argc, argv, &init); ruby_quiet = 0; - script_display_short_list (weechat_ruby_plugin, - ruby_scripts); + plugin_script_display_short_list (weechat_ruby_plugin, + ruby_scripts); /* init ok */ return WEECHAT_RC_OK; @@ -1098,7 +1098,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) { /* unload all scripts */ ruby_quiet = 1; - script_end (plugin, &ruby_scripts, &weechat_ruby_unload_all); + plugin_script_end (plugin, &ruby_scripts, &weechat_ruby_unload_all); ruby_quiet = 0; /* diff --git a/src/plugins/scripts/ruby/weechat-ruby.h b/src/plugins/ruby/weechat-ruby.h index cf3e7a1b2..cf3e7a1b2 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.h +++ b/src/plugins/ruby/weechat-ruby.h diff --git a/src/plugins/scripts/CMakeLists.txt b/src/plugins/scripts/CMakeLists.txt deleted file mode 100644 index cd97d6bb1..000000000 --- a/src/plugins/scripts/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org> -# -# This file is part of WeeChat, the extensible chat client. -# -# WeeChat is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# WeeChat is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with WeeChat. If not, see <http://www.gnu.org/licenses/>. -# - -SET(LIB_SCRIPTS_SRC script.c script.h script-callback.c script-callback.h -script-api.c script-api.h) - -ADD_DEFINITIONS(${CMAKE_SHARED_LIBRARY_C_FLAGS}) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) -ADD_LIBRARY(weechat_scripts STATIC ${LIB_SCRIPTS_SRC}) - -IF(ENABLE_PERL) - FIND_PACKAGE(Perl) - IF(PERL_FOUND) - ADD_SUBDIRECTORY( perl ) - ENDIF(PERL_FOUND) -ENDIF(ENABLE_PERL) - -IF(ENABLE_PYTHON) - FIND_PACKAGE(Python) - IF(PYTHON_FOUND) - ADD_SUBDIRECTORY( python ) - ENDIF(PYTHON_FOUND) -ENDIF(ENABLE_PYTHON) - -IF(ENABLE_RUBY) - FIND_PACKAGE(Ruby) - IF(RUBY_FOUND) - ADD_SUBDIRECTORY( ruby ) - ENDIF(RUBY_FOUND) -ENDIF(ENABLE_RUBY) - -IF(ENABLE_LUA) - FIND_PACKAGE(Lua) - IF(LUA_FOUND) - ADD_SUBDIRECTORY( lua ) - ENDIF(LUA_FOUND) -ENDIF(ENABLE_LUA) - -IF(ENABLE_TCL) - FIND_PACKAGE(TCL) - IF(TCL_FOUND) - ADD_SUBDIRECTORY( tcl ) - ENDIF(TCL_FOUND) -ENDIF(ENABLE_TCL) - -IF(ENABLE_GUILE) - FIND_PACKAGE(Guile) - IF(GUILE_FOUND) - ADD_SUBDIRECTORY( guile ) - ENDIF(GUILE_FOUND) -ENDIF(ENABLE_GUILE) diff --git a/src/plugins/scripts/Makefile.am b/src/plugins/scripts/Makefile.am deleted file mode 100644 index a30bbf8ce..000000000 --- a/src/plugins/scripts/Makefile.am +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org> -# -# This file is part of WeeChat, the extensible chat client. -# -# WeeChat is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# WeeChat is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with WeeChat. If not, see <http://www.gnu.org/licenses/>. -# - -INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" - -noinst_LTLIBRARIES = lib_weechat_plugins_scripts.la - -lib_weechat_plugins_scripts_la_SOURCES = script.c \ - script.h \ - script-callback.c \ - script-callback.h \ - script-api.c \ - script-api.h - -if PLUGIN_PERL -perl_dir = perl -endif - -if PLUGIN_PYTHON -python_dir = python -endif - -if PLUGIN_RUBY -ruby_dir = ruby -endif - -if PLUGIN_LUA -lua_dir = lua -endif - -if PLUGIN_TCL -tcl_dir = tcl -endif - -if PLUGIN_GUILE -guile_dir = guile -endif - -SUBDIRS = . $(perl_dir) $(python_dir) $(ruby_dir) $(lua_dir) $(tcl_dir) $(guile_dir) - -EXTRA_DIST = CMakeLists.txt diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c deleted file mode 100644 index 4431dd086..000000000 --- a/src/plugins/scripts/script-api.c +++ /dev/null @@ -1,1479 +0,0 @@ -/* - * Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * WeeChat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * script-api.c: script API functions, used by script plugins (perl/python/..) - */ - -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <stdio.h> - -#include "../weechat-plugin.h" -#include "script.h" -#include "script-api.h" -#include "script-callback.h" - - -/* - * script_api_charset_set: set charset for script - */ - -void -script_api_charset_set (struct t_plugin_script *script, - const char *charset) -{ - if (script->charset) - free (script->charset); - - script->charset = (charset) ? strdup (charset) : NULL; -} - -/* - * script_api_config_new: create a new configuration file - * return new configuration file, NULL if error - */ - -struct t_config_file * -script_api_config_new (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *name, - int (*callback_reload)(void *data, - struct t_config_file *config_file), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_config_file *new_config_file; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_config_file = weechat_config_new (name, callback_reload, - (function && function[0]) ? script_cb : NULL); - if (new_config_file) - script_cb->config_file = new_config_file; - else - script_callback_remove (script, script_cb); - - return new_config_file; -} - -/* - * script_api_config_new_section: create a new section in configuration file - * return new section, NULL if error - */ - -struct t_config_section * -script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_file *config_file, - const char *name, - int user_can_add_options, - int user_can_delete_options, - int (*callback_read)(void *data, - struct t_config_file *config_file, - struct t_config_section *section, - const char *option_name, - const char *value), - const char *function_read, - const char *data_read, - int (*callback_write)(void *data, - struct t_config_file *config_file, - const char *section_name), - const char *function_write, - const char *data_write, - int (*callback_write_default)(void *data, - struct t_config_file *config_file, - const char *section_name), - const char *function_write_default, - const char *data_write_default, - int (*callback_create_option)(void *data, - struct t_config_file *config_file, - struct t_config_section *section, - const char *option_name, - const char *value), - const char *function_create_option, - const char *data_create_option, - int (*callback_delete_option)(void *data, - struct t_config_file *config_file, - struct t_config_section *section, - struct t_config_option *option), - const char *function_delete_option, - const char *data_delete_option) -{ - struct t_script_callback *script_cb_read, *script_cb_write; - struct t_script_callback *script_cb_write_default, *script_cb_create_option; - struct t_script_callback *script_cb_delete_option; - struct t_config_section *new_section; - - script_cb_read = script_callback_add (script, function_read, data_read); - script_cb_write = script_callback_add (script, function_write, data_write); - script_cb_write_default = script_callback_add (script, function_write_default, data_write_default); - script_cb_create_option = script_callback_add (script, function_create_option, data_create_option); - script_cb_delete_option = script_callback_add (script, function_delete_option, data_delete_option); - if (!script_cb_read || !script_cb_write || !script_cb_write_default - || !script_cb_create_option || !script_cb_delete_option) - { - if (script_cb_read) - script_callback_remove (script, script_cb_read); - if (script_cb_write) - script_callback_remove (script, script_cb_write); - if (script_cb_write_default) - script_callback_remove (script, script_cb_write_default); - if (script_cb_create_option) - script_callback_remove (script, script_cb_create_option); - if (script_cb_delete_option) - script_callback_remove (script, script_cb_delete_option); - return NULL; - } - - new_section = weechat_config_new_section (config_file, - name, - user_can_add_options, - user_can_delete_options, - (function_read && function_read[0]) ? callback_read : NULL, - (function_read && function_read[0]) ? script_cb_read : NULL, - (function_write && function_write[0]) ? callback_write : NULL, - (function_write && function_write[0]) ? script_cb_write : NULL, - (function_write_default && function_write_default[0]) ? callback_write_default : NULL, - (function_write_default && function_write_default[0]) ? script_cb_write_default : NULL, - (function_create_option && function_create_option[0]) ? callback_create_option : NULL, - (function_create_option && function_create_option[0]) ? script_cb_create_option : NULL, - (function_delete_option && function_delete_option[0]) ? callback_delete_option : NULL, - (function_delete_option && function_delete_option[0]) ? script_cb_delete_option : NULL); - if (new_section) - { - script_cb_read->config_file = config_file; - script_cb_read->config_section = new_section; - script_cb_write->config_file = config_file; - script_cb_write->config_section = new_section; - script_cb_write_default->config_file = config_file; - script_cb_write_default->config_section = new_section; - script_cb_create_option->config_file = config_file; - script_cb_create_option->config_section = new_section; - script_cb_delete_option->config_file = config_file; - script_cb_delete_option->config_section = new_section; - } - else - { - script_callback_remove (script, script_cb_read); - script_callback_remove (script, script_cb_write); - script_callback_remove (script, script_cb_write_default); - script_callback_remove (script, script_cb_create_option); - script_callback_remove (script, script_cb_delete_option); - } - - return new_section; -} - -/* - * script_api_config_new_option: create a new option in section - * return new option, NULL if error - */ - -struct t_config_option * -script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_file *config_file, - struct t_config_section *section, - const char *name, const char *type, - const char *description, const char *string_values, - int min, int max, - const char *default_value, - const char *value, - int null_value_allowed, - int (*callback_check_value)(void *data, - struct t_config_option *option, - const char *value), - const char *function_check_value, - const char *data_check_value, - void (*callback_change)(void *data, - struct t_config_option *option), - const char *function_change, - const char *data_change, - void (*callback_delete)(void *data, - struct t_config_option *option), - const char *function_delete, - const char *data_delete) -{ - struct t_script_callback *script_cb_check_value, *script_cb_change; - struct t_script_callback *script_cb_delete; - struct t_config_option *new_option; - - script_cb_check_value = script_callback_add (script, function_check_value, data_check_value); - script_cb_change = script_callback_add (script, function_change, data_change); - script_cb_delete = script_callback_add (script, function_delete, data_delete); - if (!script_cb_check_value || !script_cb_change || !script_cb_delete) - { - if (script_cb_check_value) - script_callback_remove (script, script_cb_check_value); - if (script_cb_change) - script_callback_remove (script, script_cb_change); - if (script_cb_delete) - script_callback_remove (script, script_cb_delete); - return NULL; - } - - new_option = weechat_config_new_option (config_file, section, name, type, - description, string_values, min, - max, default_value, value, - null_value_allowed, - (function_check_value && function_check_value[0]) ? callback_check_value : NULL, - (function_check_value && function_check_value[0]) ? script_cb_check_value : NULL, - (function_change && function_change[0]) ? callback_change : NULL, - (function_change && function_change[0]) ? script_cb_change : NULL, - (function_delete && function_delete[0]) ? callback_delete : NULL, - (function_delete && function_delete[0]) ? script_cb_delete : NULL); - if (new_option) - { - script_cb_check_value->config_file = config_file; - script_cb_check_value->config_section = section; - script_cb_check_value->config_option = new_option; - script_cb_change->config_file = config_file; - script_cb_change->config_section = section; - script_cb_change->config_option = new_option; - script_cb_delete->config_file = config_file; - script_cb_delete->config_section = section; - script_cb_delete->config_option = new_option; - } - else - { - script_callback_remove (script, script_cb_check_value); - script_callback_remove (script, script_cb_change); - script_callback_remove (script, script_cb_delete); - } - - return new_option; -} - -/* - * script_api_config_option_free: free an option in configuration file - */ - -void -script_api_config_option_free (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_option *option) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - if (!weechat_plugin || !script || !option) - return; - - weechat_config_option_free (option); - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if (ptr_script_cb->config_option == option) - script_callback_remove (script, ptr_script_cb); - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_config_section_free_options: free all options of a section in - * configuration file - */ - -void -script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_section *section) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - if (!weechat_plugin || !script || !section) - return; - - weechat_config_section_free_options (section); - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if ((ptr_script_cb->config_section == section) - && ptr_script_cb->config_option) - script_callback_remove (script, ptr_script_cb); - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_config_section_free: free a section in configuration file - */ - -void -script_api_config_section_free (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_section *section) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - if (!weechat_plugin || !script || !section) - return; - - weechat_config_section_free (section); - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if (ptr_script_cb->config_section == section) - script_callback_remove (script, ptr_script_cb); - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_config_free: free configuration file - */ - -void -script_api_config_free (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_file *config_file) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - if (!weechat_plugin || !script || !config_file) - return; - - weechat_config_free (config_file); - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if (ptr_script_cb->config_file == config_file) - script_callback_remove (script, ptr_script_cb); - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_printf: print a message - */ - -void -script_api_printf (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, const char *format, ...) -{ - char *buf2; - - weechat_va_format (format); - if (!vbuffer) - return; - - buf2 = (script && script->charset && script->charset[0]) ? - weechat_iconv_to_internal (script->charset, vbuffer) : NULL; - weechat_printf (buffer, "%s", (buf2) ? buf2 : vbuffer); - if (buf2) - free (buf2); - - free (vbuffer); -} - -/* - * script_api_printf_date_tags: print a message with optional date and tags - */ - -void -script_api_printf_date_tags (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, - time_t date, const char *tags, - const char *format, ...) -{ - char *buf2; - - weechat_va_format (format); - if (!vbuffer) - return; - - buf2 = (script->charset && script->charset[0]) ? - weechat_iconv_to_internal (script->charset, vbuffer) : NULL; - weechat_printf_date_tags (buffer, date, tags, - "%s", (buf2) ? buf2 : vbuffer); - if (buf2) - free (buf2); - - free (vbuffer); -} - -/* - * script_api_printf_y: print a message on a buffer with free content - */ - -void -script_api_printf_y (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, int y, - const char *format, ...) -{ - char *buf2; - - weechat_va_format (format); - if (!vbuffer) - return; - - buf2 = (script->charset && script->charset[0]) ? - weechat_iconv_to_internal (script->charset, vbuffer) : NULL; - weechat_printf_y (buffer, y, "%s", (buf2) ? buf2 : vbuffer); - if (buf2) - free (buf2); - - free (vbuffer); -} - -/* - * script_api_log_printf: add a message in WeeChat log file - */ - -void -script_api_log_printf (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *format, ...) -{ - char *buf2; - - weechat_va_format (format); - if (!vbuffer) - return; - - buf2 = (script->charset && script->charset[0]) ? - weechat_iconv_to_internal (script->charset, vbuffer) : NULL; - weechat_log_printf ("%s", (buf2) ? buf2 : vbuffer); - if (buf2) - free (buf2); - - free (vbuffer); -} - -/* - * script_api_hook_command: hook a command - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_command (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, const char *description, - const char *args, const char *args_description, - const char *completion, - int (*callback)(void *data, - struct t_gui_buffer *buffer, - int argc, char **argv, - char **argv_eol), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_command (command, description, args, - args_description, completion, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_command_run: hook a command_run - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, - int (*callback)(void *data, - struct t_gui_buffer *buffer, - const char *command), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_command_run (command, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_timer: hook a timer - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - int interval, int align_second, int max_calls, - int (*callback)(void *data, - int remaining_calls), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_timer (interval, align_second, max_calls, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_fd: hook a fd - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_fd (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - int fd, int flag_read, int flag_write, - int flag_exception, - int (*callback)(void *data, int fd), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_fd (fd, flag_read, flag_write, flag_exception, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_process_hashtable: hook a process - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, - struct t_hashtable *options, - int timeout, - int (*callback)(void *data, - const char *command, - int return_code, - const char *out, - const char *err), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_process_hashtable (command, options, timeout, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_process: hook a process - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_process (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, - int timeout, - int (*callback)(void *data, - const char *command, - int return_code, - const char *out, - const char *err), - const char *function, - const char *data) -{ - return script_api_hook_process_hashtable (weechat_plugin, script, command, - NULL, timeout, - callback, function, data); -} - -/* - * script_api_hook_connect: hook a connection - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *proxy, const char *address, int port, - int sock, int ipv6, void *gnutls_sess, - void *gnutls_cb, int gnutls_dhkey_size, - const char *gnutls_priorities, - const char *local_hostname, - int (*callback)(void *data, int status, - int gnutls_rc, - const char *error, - const char *ip_address), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_connect (proxy, address, port, sock, ipv6, - gnutls_sess, gnutls_cb, gnutls_dhkey_size, - gnutls_priorities, local_hostname, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_print: hook a print - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_print (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, - const char *tags, const char *message, int strip_colors, - int (*callback)(void *data, - struct t_gui_buffer *buffer, - time_t date, - int tags_count, const char **tags, - int displayed, int highlight, - const char *prefix, - const char *message), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_print (buffer, tags, message, strip_colors, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_signal: hook a signal - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_signal (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *signal, - int (*callback)(void *data, const char *signal, - const char *type_data, - void *signal_data), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_signal (signal, callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_hsignal: hook a hsignal - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_hsignal (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *signal, - int (*callback)(void *data, const char *signal, - struct t_hashtable *hashtable), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_hsignal (signal, callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_config: hook a config option - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_config (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option, - int (*callback)(void *data, const char *option, - const char *value), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_config (option, callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_completion: hook a completion - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *completion, - const char *description, - int (*callback)(void *data, - const char *completion_item, - struct t_gui_buffer *buffer, - struct t_gui_completion *completion), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_completion (completion, description, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_modifier: hook a modifier - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *modifier, - char *(*callback)(void *data, const char *modifier, - const char *modifier_data, - const char *string), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_modifier (modifier, callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_info: hook an info - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_info (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *info_name, - const char *description, - const char *args_description, - const char *(*callback)(void *data, - const char *info_name, - const char *arguments), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_info (info_name, description, args_description, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_info_hashtable: hook an info_hashtable - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *info_name, - const char *description, - const char *args_description, - const char *output_description, - struct t_hashtable *(*callback)(void *data, - const char *info_name, - struct t_hashtable *hashtable), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_info_hashtable (info_name, description, - args_description, - output_description, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_infolist: hook an infolist - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *infolist_name, - const char *description, - const char *pointer_description, - const char *args_description, - struct t_infolist *(*callback)(void *data, - const char *infolist_name, - void *pointer, - const char *arguments), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_infolist (infolist_name, description, - pointer_description, args_description, - callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_hook_focus: hook a focus - * return new hook, NULL if error - */ - -struct t_hook * -script_api_hook_focus (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *area, - struct t_hashtable *(*callback)(void *data, - struct t_hashtable *info), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_hook *new_hook; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_hook = weechat_hook_focus (area, callback, script_cb); - if (new_hook) - { - weechat_hook_set (new_hook, "subplugin", script->name); - script_cb->hook = new_hook; - } - else - script_callback_remove (script, script_cb); - - return new_hook; -} - -/* - * script_api_unhook: unhook something - */ - -void -script_api_unhook (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_hook *hook) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - if (!weechat_plugin || !script || !hook) - return; - - weechat_unhook (hook); - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if (ptr_script_cb->hook == hook) - script_callback_remove (script, ptr_script_cb); - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_unhook_all: remove all hooks from a script - */ - -void -script_api_unhook_all (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if (ptr_script_cb->hook) - { - weechat_unhook (ptr_script_cb->hook); - script_callback_remove (script, ptr_script_cb); - } - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_buffer_new: create a new buffer - */ - -struct t_gui_buffer * -script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *name, - int (*input_callback)(void *data, - struct t_gui_buffer *buffer, - const char *input_data), - const char *function_input, - const char *data_input, - int (*close_callback)(void *data, - struct t_gui_buffer *buffer), - const char *function_close, - const char *data_close) -{ - struct t_script_callback *script_cb_input; - struct t_script_callback *script_cb_close; - struct t_gui_buffer *new_buffer; - - script_cb_input = script_callback_add (script, function_input, data_input); - script_cb_close = script_callback_add (script, function_close, data_close); - if (!script_cb_input || !script_cb_close) - { - if (script_cb_input) - script_callback_remove (script, script_cb_input); - if (script_cb_close) - script_callback_remove (script, script_cb_close); - return NULL; - } - - new_buffer = weechat_buffer_new (name, - (function_input && function_input[0]) ? input_callback : NULL, - (function_input && function_input[0]) ? script_cb_input : NULL, - (function_close && function_close[0]) ? close_callback : NULL, - (function_close && function_close[0]) ? script_cb_close : NULL); - if (new_buffer) - { - script_cb_input->buffer = new_buffer; - script_cb_close->buffer = new_buffer; - - /* used when upgrading weechat, to set callbacks */ - weechat_buffer_set (new_buffer, "localvar_set_script_name", script->name); - weechat_buffer_set (new_buffer, "localvar_set_script_input_cb", function_input); - weechat_buffer_set (new_buffer, "localvar_set_script_input_cb_data", data_input); - weechat_buffer_set (new_buffer, "localvar_set_script_close_cb", function_close); - weechat_buffer_set (new_buffer, "localvar_set_script_close_cb_data", data_close); - } - else - { - script_callback_remove (script, script_cb_input); - script_callback_remove (script, script_cb_close); - } - - return new_buffer; -} - -/* - * script_api_buffer_close: close a buffer - */ - -void -script_api_buffer_close (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - if (!weechat_plugin || !script || !buffer) - return; - - weechat_buffer_close (buffer); - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if (ptr_script_cb->buffer == buffer) - script_callback_remove (script, ptr_script_cb); - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_bar_item_new: add a new bar item - */ - -struct t_gui_bar_item * -script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *name, - char *(*build_callback)(void *data, - struct t_gui_bar_item *item, - struct t_gui_window *window), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - struct t_gui_bar_item *new_item; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return NULL; - - new_item = weechat_bar_item_new (name, - (function && function[0]) ? build_callback : NULL, - (function && function[0]) ? script_cb : NULL); - if (new_item) - script_cb->bar_item = new_item; - else - script_callback_remove (script, script_cb); - - return new_item; -} - -/* - * script_api_bar_item_remove: remove a bar item - */ - -void -script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_bar_item *item) -{ - struct t_script_callback *ptr_script_cb, *next_callback; - - if (!weechat_plugin || !script || !item) - return; - - weechat_bar_item_remove (item); - - ptr_script_cb = script->callbacks; - while (ptr_script_cb) - { - next_callback = ptr_script_cb->next_callback; - - if (ptr_script_cb->bar_item == item) - script_callback_remove (script, ptr_script_cb); - - ptr_script_cb = next_callback; - } -} - -/* - * script_api_command: execute a command (simulate user entry) - */ - -void -script_api_command (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, const char *command) -{ - char *command2; - - command2 = (script->charset && script->charset[0]) ? - weechat_iconv_to_internal (script->charset, command) : NULL; - - weechat_command (buffer, (command2) ? command2 : command); - - if (command2) - free (command2); -} - -/* - * script_api_config_get_plugin: get a value of a script option - * format in file is "plugin.script.option" - */ - -const char * -script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option) -{ - char *option_fullname; - const char *return_value; - - option_fullname = malloc ((strlen (script->name) + - strlen (option) + 2)); - if (!option_fullname) - return NULL; - - strcpy (option_fullname, script->name); - strcat (option_fullname, "."); - strcat (option_fullname, option); - - return_value = weechat_config_get_plugin (option_fullname); - free (option_fullname); - - return return_value; -} - -/* - * script_api_config_is_set_plugin: check if a script option is set - */ - -int -script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option) -{ - char *option_fullname; - int return_code; - - option_fullname = malloc ((strlen (script->name) + - strlen (option) + 2)); - if (!option_fullname) - return 0; - - strcpy (option_fullname, script->name); - strcat (option_fullname, "."); - strcat (option_fullname, option); - - return_code = weechat_config_is_set_plugin (option_fullname); - free (option_fullname); - - return return_code; -} - -/* - * script_api_config_set_plugin: set value of a script config option - * format in file is "plugin.script.option" - */ - -int -script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option, const char *value) -{ - char *option_fullname; - int return_code; - - option_fullname = malloc ((strlen (script->name) + - strlen (option) + 2)); - if (!option_fullname) - return 0; - - strcpy (option_fullname, script->name); - strcat (option_fullname, "."); - strcat (option_fullname, option); - - return_code = weechat_config_set_plugin (option_fullname, value); - free (option_fullname); - - return return_code; -} - -/* - * script_api_config_set_plugin: set value of a script config option - * format in file is "plugin.script.option" - */ - -void -script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option, const char *description) -{ - char *option_fullname; - - option_fullname = malloc ((strlen (script->name) + - strlen (option) + 2)); - if (!option_fullname) - return; - - strcpy (option_fullname, script->name); - strcat (option_fullname, "."); - strcat (option_fullname, option); - - weechat_config_set_desc_plugin (option_fullname, description); - free (option_fullname); -} - -/* - * script_api_config_unset_plugin: unset script config option - * format in file is "plugin.script.option" - */ - -int -script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option) -{ - char *option_fullname; - int return_code; - - option_fullname = malloc ((strlen (script->name) + - strlen (option) + 2)); - if (!option_fullname) - return 0; - - strcpy (option_fullname, script->name); - strcat (option_fullname, "."); - strcat (option_fullname, option); - - return_code = weechat_config_unset_plugin (option_fullname); - free (option_fullname); - - return return_code; -} - -/* - * script_api_upgrade_read: read upgrade file - * return 1 if ok, 0 if error - */ - -int -script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_upgrade_file *upgrade_file, - int (*callback_read)(void *data, - struct t_upgrade_file *upgrade_file, - int object_id, - struct t_infolist *infolist), - const char *function, - const char *data) -{ - struct t_script_callback *script_cb; - int rc; - - if (!function || !function[0]) - return 0; - - script_cb = script_callback_add (script, function, data); - if (!script_cb) - return 0; - script_cb->upgrade_file = upgrade_file; - - rc = weechat_upgrade_read (upgrade_file, - callback_read, - script_cb); - - script_callback_remove (script, script_cb); - - return rc; -} diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h deleted file mode 100644 index c60f10a70..000000000 --- a/src/plugins/scripts/script-api.h +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * WeeChat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __WEECHAT_SCRIPT_API_H -#define __WEECHAT_SCRIPT_API_H 1 - -extern void script_api_charset_set (struct t_plugin_script *script, - const char *charset); -extern struct t_config_file *script_api_config_new (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *name, - int (*callback_reload)(void *data, - struct t_config_file *config_file), - const char *function, - const char *data); -extern struct t_config_section *script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_file *config_file, - const char *name, - int user_can_add_options, - int user_can_delete_options, - int (*callback_read)(void *data, - struct t_config_file *config_file, - struct t_config_section *section, - const char *option_name, - const char *value), - const char *function_read, - const char *data_read, - int (*callback_write)(void *data, - struct t_config_file *config_file, - const char *section_name), - const char *function_write, - const char *data_write, - int (*callback_write_default)(void *data, - struct t_config_file *config_file, - const char *section_name), - const char *function_write_default, - const char *data_write_default, - int (*callback_create_option)(void *data, - struct t_config_file *config_file, - struct t_config_section *section, - const char *option_name, - const char *value), - const char *function_create_option, - const char *data_create_option, - int (*callback_delete_option)(void *data, - struct t_config_file *config_file, - struct t_config_section *section, - struct t_config_option *option), - const char *function_delete_option, - const char *data_delete_option); -extern struct t_config_option *script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_file *config_file, - struct t_config_section *section, - const char *name, - const char *type, - const char *description, - const char *string_values, - int min, int max, - const char *default_value, - const char *value, - int null_value_allowed, - int (*callback_check_value)(void *data, - struct t_config_option *option, - const char *value), - const char *function_check_value, - const char *data_check_value, - void (*callback_change)(void *data, - struct t_config_option *option), - const char *function_change, - const char *data_change, - void (*callback_delete)(void *data, - struct t_config_option *option), - const char *function_delete, - const char *data_delete); -extern void script_api_config_option_free (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_option *option); -extern void script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_section *section); -extern void script_api_config_section_free (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_section *section); -extern void script_api_config_free (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_config_file *config_file); -extern void script_api_printf (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, - const char *format, ...); -extern void script_api_printf_date_tags (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, - time_t date, const char *tags, - const char *format, ...); -extern void script_api_printf_y (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, - int y, const char *format, ...); -extern void script_api_log_printf (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *format, ...); -extern struct t_hook *script_api_hook_command (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, const char *description, - const char *args, const char *args_description, - const char *completion, - int (*callback)(void *data, - struct t_gui_buffer *buffer, - int argc, char **argv, - char **argv_eol), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, - int (*callback)(void *data, - struct t_gui_buffer *buffer, - const char *command), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - int interval, int align_second, - int max_calls, - int (*callback)(void *data, - int remaining_calls), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_fd (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - int fd, int flag_read, - int flag_write, int flag_exception, - int (*callback)(void *data, int fd), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_process_hashtable (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, - struct t_hashtable *options, - int timeout, - int (*callback)(void *data, - const char *command, - int return_code, - const char *out, - const char *err), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_process (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *command, - int timeout, - int (*callback)(void *data, - const char *command, - int return_code, - const char *out, - const char *err), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *proxy, - const char *address, - int port, - int sock, - int ipv6, - void *gnutls_sess, - void *gnutls_cb, - int gnutls_dhkey_size, - const char *gnutls_priorities, - const char *local_hostname, - int (*callback)(void *data, - int status, - int gnutls_rc, - const char *error, - const char *ip_address), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, - const char *tags, - const char *message, - int strip_colors, - int (*callback)(void *data, - struct t_gui_buffer *buffer, - time_t date, - int tags_count, - const char **tags, - int displayed, - int highlight, - const char *prefix, - const char *message), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_signal (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *signal, - int (*callback)(void *data, - const char *signal, - const char *type_data, - void *signal_data), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_hsignal (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *signal, - int (*callback)(void *data, - const char *signal, - struct t_hashtable *hashtable), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_config (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option, - int (*callback)(void *data, - const char *option, - const char *value), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *completion, - const char *description, - int (*callback)(void *data, - const char *completion_item, - struct t_gui_buffer *buffer, - struct t_gui_completion *completion), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *modifier, - char *(*callback)(void *data, - const char *modifier, - const char *modifier_data, - const char *string), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *info_name, - const char *description, - const char *args_description, - const char *(*callback)(void *data, - const char *info_name, - const char *arguments), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *info_name, - const char *description, - const char *args_description, - const char *output_description, - struct t_hashtable *(*callback)(void *data, - const char *info_name, - struct t_hashtable *hashtable), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *infolist_name, - const char *description, - const char *pointer_description, - const char *args_description, - struct t_infolist *(*callback)(void *data, - const char *infolist_name, - void *pointer, - const char *arguments), - const char *function, - const char *data); -extern struct t_hook *script_api_hook_focus (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *area, - struct t_hashtable *(*callback)(void *data, - struct t_hashtable *info), - const char *function, - const char *data); -extern void script_api_unhook (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_hook *hook); -extern void script_api_unhook_all (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script); -extern struct t_gui_buffer *script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *name, - int (*input_callback)(void *data, - struct t_gui_buffer *buffer, - const char *input_data), - const char *function_input, - const char *data_input, - int (*close_callback)(void *data, - struct t_gui_buffer *buffer), - const char *function_close, - const char *data_close); -extern void script_api_buffer_close (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer); -extern struct t_gui_bar_item *script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *name, - char *(*build_callback)(void *data, - struct t_gui_bar_item *item, - struct t_gui_window *window), - const char *function, - const char *data); -extern void script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_bar_item *item); -extern void script_api_command (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_gui_buffer *buffer, - const char *command); -extern const char *script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option); -extern int script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option); -extern int script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option, const char *value); -extern void script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option, - const char *description); -extern int script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *option); -extern int script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - struct t_upgrade_file *upgrade_file, - int (*callback_read)(void *data, - struct t_upgrade_file *upgrade_file, - int object_id, - struct t_infolist *infolist), - const char *function, - const char *data); - -#endif /* __WEECHAT_SCRIPT_API_H */ diff --git a/src/plugins/scripts/tcl/CMakeLists.txt b/src/plugins/tcl/CMakeLists.txt index 9bd6d2b93..a33487c7c 100644 --- a/src/plugins/scripts/tcl/CMakeLists.txt +++ b/src/plugins/tcl/CMakeLists.txt @@ -30,7 +30,7 @@ IF(TCL_FOUND) INCLUDE_DIRECTORIES(${TCL_INCLUDE_PATH}) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${TCL_LFLAGS}") - TARGET_LINK_LIBRARIES(tcl ${TCL_LIBRARY} weechat_scripts) + TARGET_LINK_LIBRARIES(tcl ${TCL_LIBRARY} weechat_plugins_scripts) ENDIF(TCL_FOUND) diff --git a/src/plugins/scripts/tcl/Makefile.am b/src/plugins/tcl/Makefile.am index 65d43b917..65d43b917 100644 --- a/src/plugins/scripts/tcl/Makefile.am +++ b/src/plugins/tcl/Makefile.am diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 3af454fa6..2fee99c14 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -30,10 +30,10 @@ #include <string.h> #include <time.h> -#include "../../weechat-plugin.h" -#include "../script.h" -#include "../script-api.h" -#include "../script-callback.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" +#include "../plugin-script-api.h" +#include "../plugin-script-callback.h" #include "weechat-tcl.h" @@ -53,9 +53,12 @@ tcl_function_name); \ __ret; \ } +#define API_PTR2STR(__pointer) \ + plugin_script_ptr2str (__pointer) #define API_STR2PTR(__string) \ - script_str2ptr (weechat_tcl_plugin, TCL_CURRENT_SCRIPT_NAME, \ - tcl_function_name, __string) + plugin_script_str2ptr (weechat_tcl_plugin, \ + TCL_CURRENT_SCRIPT_NAME, \ + tcl_function_name, __string) #define API_RETURN_OK \ { \ objp = Tcl_GetObjResult (interp); \ @@ -242,7 +245,7 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc, shutdown_func = Tcl_GetStringFromObj (objv[6], &i); charset = Tcl_GetStringFromObj (objv[7], &i); - if (script_search (weechat_tcl_plugin, tcl_scripts, name)) + if (plugin_script_search (weechat_tcl_plugin, tcl_scripts, name)) { /* another script already exists with same name */ weechat_printf (NULL, @@ -254,12 +257,12 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc, } /* register script */ - tcl_current_script = script_add (weechat_tcl_plugin, - &tcl_scripts, &last_tcl_script, - (tcl_current_script_filename) ? - tcl_current_script_filename : "", - name, author, version, license, - description, shutdown_func, charset); + tcl_current_script = plugin_script_add (weechat_tcl_plugin, + &tcl_scripts, &last_tcl_script, + (tcl_current_script_filename) ? + tcl_current_script_filename : "", + name, author, version, license, + description, shutdown_func, charset); if (tcl_current_script) { tcl_registered_script = tcl_current_script; @@ -320,8 +323,8 @@ weechat_tcl_api_charset_set (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_charset_set (tcl_current_script, - Tcl_GetStringFromObj (objv[1], &i)); /* charset */ + plugin_script_api_charset_set (tcl_current_script, + Tcl_GetStringFromObj (objv[1], &i)); /* charset */ API_RETURN_OK; } @@ -701,7 +704,7 @@ weechat_tcl_api_list_new (ClientData clientData, Tcl_Interp *interp, API_FUNC(1, "list_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_new ()); + result = API_PTR2STR(weechat_list_new ()); API_RETURN_STRING_FREE(result); } @@ -728,10 +731,10 @@ weechat_tcl_api_list_add (ClientData clientData, Tcl_Interp *interp, where = Tcl_GetStringFromObj (objv[3], &i); user_data = Tcl_GetStringFromObj (objv[4], &i); - result = script_ptr2str (weechat_list_add (API_STR2PTR(weelist), - data, - where, - API_STR2PTR(user_data))); + result = API_PTR2STR(weechat_list_add (API_STR2PTR(weelist), + data, + where, + API_STR2PTR(user_data))); API_RETURN_STRING_FREE(result); } @@ -755,8 +758,8 @@ weechat_tcl_api_list_search (ClientData clientData, Tcl_Interp *interp, weelist = Tcl_GetStringFromObj (objv[1], &i); data = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_list_search (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_search (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -804,8 +807,8 @@ weechat_tcl_api_list_casesearch (ClientData clientData, Tcl_Interp *interp, weelist = Tcl_GetStringFromObj (objv[1], &i); data = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_list_casesearch (API_STR2PTR(weelist), - data)); + result = API_PTR2STR(weechat_list_casesearch (API_STR2PTR(weelist), + data)); API_RETURN_STRING_FREE(result); } @@ -854,8 +857,8 @@ weechat_tcl_api_list_get (ClientData clientData, Tcl_Interp *interp, if (Tcl_GetIntFromObj (interp, objv[2], &position) != TCL_OK) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_get (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* weelist */ - position)); + result = API_PTR2STR(weechat_list_get (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* weelist */ + position)); API_RETURN_STRING_FREE(result); } @@ -900,7 +903,7 @@ weechat_tcl_api_list_next (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_next (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* item */ + result = API_PTR2STR(weechat_list_next (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* item */ API_RETURN_STRING_FREE(result); } @@ -921,7 +924,7 @@ weechat_tcl_api_list_prev (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_list_prev (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* item */ + result = API_PTR2STR(weechat_list_prev (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* item */ API_RETURN_STRING_FREE(result); } @@ -1054,7 +1057,7 @@ weechat_tcl_api_config_reload_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1097,12 +1100,12 @@ weechat_tcl_api_config_new (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_config_new (weechat_tcl_plugin, - tcl_current_script, - name, - &weechat_tcl_api_config_reload_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_config_new (weechat_tcl_plugin, + tcl_current_script, + name, + &weechat_tcl_api_config_reload_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -1128,8 +1131,8 @@ weechat_tcl_api_config_section_read_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1175,7 +1178,7 @@ weechat_tcl_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -1219,7 +1222,7 @@ weechat_tcl_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); + func_argv[1] = API_PTR2STR(config_file); func_argv[2] = (section_name) ? (char *)section_name : empty_arg; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -1265,8 +1268,8 @@ weechat_tcl_api_config_section_create_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); func_argv[3] = (option_name) ? (char *)option_name : empty_arg; func_argv[4] = (value) ? (char *)value : empty_arg; @@ -1314,9 +1317,9 @@ weechat_tcl_api_config_section_delete_option_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (config_file); - func_argv[2] = script_ptr2str (section); - func_argv[3] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(config_file); + func_argv[2] = API_PTR2STR(section); + func_argv[3] = API_PTR2STR(option); rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1383,27 +1386,27 @@ weechat_tcl_api_config_new_section (ClientData clientData, Tcl_Interp *interp, function_delete_option = Tcl_GetStringFromObj (objv[13], &i); data_delete_option = Tcl_GetStringFromObj (objv[14], &i); - result = script_ptr2str (script_api_config_new_section (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(cfg_file), - name, - can_add, /* user_can_add_options */ - can_delete, /* user_can_delete_options */ - &weechat_tcl_api_config_section_read_cb, - function_read, - data_read, - &weechat_tcl_api_config_section_write_cb, - function_write, - data_write, - &weechat_tcl_api_config_section_write_default_cb, - function_write_default, - data_write_default, - &weechat_tcl_api_config_section_create_option_cb, - function_create_option, - data_create_option, - &weechat_tcl_api_config_section_delete_option_cb, - function_delete_option, - data_delete_option)); + result = API_PTR2STR(plugin_script_api_config_new_section (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(cfg_file), + name, + can_add, /* user_can_add_options */ + can_delete, /* user_can_delete_options */ + &weechat_tcl_api_config_section_read_cb, + function_read, + data_read, + &weechat_tcl_api_config_section_write_cb, + function_write, + data_write, + &weechat_tcl_api_config_section_write_default_cb, + function_write_default, + data_write_default, + &weechat_tcl_api_config_section_create_option_cb, + function_create_option, + data_create_option, + &weechat_tcl_api_config_section_delete_option_cb, + function_delete_option, + data_delete_option)); API_RETURN_STRING_FREE(result); } @@ -1427,8 +1430,8 @@ weechat_tcl_api_config_search_section (ClientData clientData, Tcl_Interp *interp config_file = Tcl_GetStringFromObj (objv[1], &i); section_name = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_config_search_section (API_STR2PTR(config_file), - section_name)); + result = API_PTR2STR(weechat_config_search_section (API_STR2PTR(config_file), + section_name)); API_RETURN_STRING_FREE(result); } @@ -1454,7 +1457,7 @@ weechat_tcl_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); func_argv[2] = (value) ? (char *)value : empty_arg; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -1496,7 +1499,7 @@ weechat_tcl_api_config_option_change_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1529,7 +1532,7 @@ weechat_tcl_api_config_option_delete_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (option); + func_argv[1] = API_PTR2STR(option); rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1583,28 +1586,28 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp, function_delete = Tcl_GetStringFromObj (objv[16], &i); data_delete = Tcl_GetStringFromObj (objv[17], &i); - result = script_ptr2str (script_api_config_new_option (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(config_file), - API_STR2PTR(section), - name, - type, - description, - string_values, - min, - max, - default_value, - value, - null_value_allowed, - &weechat_tcl_api_config_option_check_value_cb, - function_check_value, - data_check_value, - &weechat_tcl_api_config_option_change_cb, - function_change, - data_change, - &weechat_tcl_api_config_option_delete_cb, - function_delete, - data_delete)); + result = API_PTR2STR(plugin_script_api_config_new_option (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(config_file), + API_STR2PTR(section), + name, + type, + description, + string_values, + min, + max, + default_value, + value, + null_value_allowed, + &weechat_tcl_api_config_option_check_value_cb, + function_check_value, + data_check_value, + &weechat_tcl_api_config_option_change_cb, + function_change, + data_change, + &weechat_tcl_api_config_option_delete_cb, + function_delete, + data_delete)); API_RETURN_STRING_FREE(result); } @@ -1630,9 +1633,9 @@ weechat_tcl_api_config_search_option (ClientData clientData, Tcl_Interp *interp, section = Tcl_GetStringFromObj (objv[2], &i); option_name = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (weechat_config_search_option (API_STR2PTR(config_file), - API_STR2PTR(section), - option_name)); + result = API_PTR2STR(weechat_config_search_option (API_STR2PTR(config_file), + API_STR2PTR(section), + option_name)); API_RETURN_STRING_FREE(result); } @@ -2127,9 +2130,9 @@ weechat_tcl_api_config_option_free (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_option_free (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* option */ + plugin_script_api_config_option_free (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* option */ API_RETURN_OK; } @@ -2150,9 +2153,9 @@ weechat_tcl_api_config_section_free_options (ClientData clientData, Tcl_Interp * if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free_options (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */ + plugin_script_api_config_section_free_options (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */ API_RETURN_OK; } @@ -2172,9 +2175,9 @@ weechat_tcl_api_config_section_free (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_section_free (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */ + plugin_script_api_config_section_free (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* section */ API_RETURN_OK; } @@ -2194,9 +2197,9 @@ weechat_tcl_api_config_free (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_config_free (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* config_file */ + plugin_script_api_config_free (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* config_file */ API_RETURN_OK; } @@ -2217,7 +2220,7 @@ weechat_tcl_api_config_get (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_config_get (Tcl_GetStringFromObj (objv[1], &i))); + result = API_PTR2STR(weechat_config_get (Tcl_GetStringFromObj (objv[1], &i))); API_RETURN_STRING_FREE(result); } @@ -2238,9 +2241,9 @@ weechat_tcl_api_config_get_plugin (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_api_config_get_plugin (weechat_tcl_plugin, - tcl_current_script, - Tcl_GetStringFromObj (objv[1], &i)); + result = plugin_script_api_config_get_plugin (weechat_tcl_plugin, + tcl_current_script, + Tcl_GetStringFromObj (objv[1], &i)); API_RETURN_STRING(result); } @@ -2263,9 +2266,9 @@ weechat_tcl_api_config_is_set_plugin (ClientData clientData, Tcl_Interp *interp, option = Tcl_GetStringFromObj (objv[1], &i); - rc = script_api_config_is_set_plugin (weechat_tcl_plugin, - tcl_current_script, - option); + rc = plugin_script_api_config_is_set_plugin (weechat_tcl_plugin, + tcl_current_script, + option); API_RETURN_INT(rc); } @@ -2289,10 +2292,10 @@ weechat_tcl_api_config_set_plugin (ClientData clientData, Tcl_Interp *interp, option = Tcl_GetStringFromObj (objv[1], &i); value = Tcl_GetStringFromObj (objv[2], &i); - rc = script_api_config_set_plugin (weechat_tcl_plugin, - tcl_current_script, - option, - value); + rc = plugin_script_api_config_set_plugin (weechat_tcl_plugin, + tcl_current_script, + option, + value); API_RETURN_INT(rc); } @@ -2316,10 +2319,10 @@ weechat_tcl_api_config_set_desc_plugin (ClientData clientData, Tcl_Interp *inter option = Tcl_GetStringFromObj (objv[1], &i); description = Tcl_GetStringFromObj (objv[2], &i); - script_api_config_set_desc_plugin (weechat_tcl_plugin, - tcl_current_script, - option, - description); + plugin_script_api_config_set_desc_plugin (weechat_tcl_plugin, + tcl_current_script, + option, + description); API_RETURN_OK; } @@ -2342,9 +2345,9 @@ weechat_tcl_api_config_unset_plugin (ClientData clientData, Tcl_Interp *interp, option = Tcl_GetStringFromObj (objv[1], &i); - rc = script_api_config_unset_plugin (weechat_tcl_plugin, - tcl_current_script, - option); + rc = plugin_script_api_config_unset_plugin (weechat_tcl_plugin, + tcl_current_script, + option); API_RETURN_INT(rc); } @@ -2463,10 +2466,10 @@ weechat_tcl_api_print (ClientData clientData, Tcl_Interp *interp, buffer = Tcl_GetStringFromObj (objv[1], &i); message = Tcl_GetStringFromObj (objv[2], &i); - script_api_printf (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(buffer), - "%s", message); + plugin_script_api_printf (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(buffer), + "%s", message); API_RETURN_OK; } @@ -2495,12 +2498,12 @@ weechat_tcl_api_print_date_tags (ClientData clientData, Tcl_Interp *interp, tags = Tcl_GetStringFromObj (objv[3], &i); message = Tcl_GetStringFromObj (objv[4], &i); - script_api_printf_date_tags (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(buffer), - tdate, - tags, - "%s", message); + plugin_script_api_printf_date_tags (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(buffer), + tdate, + tags, + "%s", message); API_RETURN_OK; } @@ -2527,11 +2530,11 @@ weechat_tcl_api_print_y (ClientData clientData, Tcl_Interp *interp, buffer = Tcl_GetStringFromObj (objv[1], &i); message = Tcl_GetStringFromObj (objv[3], &i); - script_api_printf_y (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(buffer), - y, - "%s", message); + plugin_script_api_printf_y (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(buffer), + y, + "%s", message); API_RETURN_OK; } @@ -2555,9 +2558,9 @@ weechat_tcl_api_log_print (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_log_printf (weechat_tcl_plugin, - tcl_current_script, - "%s", Tcl_GetStringFromObj (objv[1], &i)); /* message */ + plugin_script_api_log_printf (weechat_tcl_plugin, + tcl_current_script, + "%s", Tcl_GetStringFromObj (objv[1], &i)); /* message */ API_RETURN_OK; } @@ -2583,7 +2586,7 @@ weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -2632,16 +2635,16 @@ weechat_tcl_api_hook_command (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[6], &i); data = Tcl_GetStringFromObj (objv[7], &i); - result = script_ptr2str (script_api_hook_command (weechat_tcl_plugin, - tcl_current_script, - command, - description, - args, - args_description, - completion, - &weechat_tcl_api_hook_command_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command (weechat_tcl_plugin, + tcl_current_script, + command, + description, + args, + args_description, + completion, + &weechat_tcl_api_hook_command_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2664,7 +2667,7 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (command) ? (char *)command : empty_arg; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -2708,12 +2711,12 @@ weechat_tcl_api_hook_command_run (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_hook_command_run (weechat_tcl_plugin, - tcl_current_script, - command, - &weechat_tcl_api_hook_command_run_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_command_run (weechat_tcl_plugin, + tcl_current_script, + command, + &weechat_tcl_api_hook_command_run_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2781,14 +2784,14 @@ weechat_tcl_api_hook_timer (ClientData clientData, Tcl_Interp *interp, API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_timer (weechat_tcl_plugin, - tcl_current_script, - interval, /* interval */ - align_second, /* align_second */ - max_calls, /* max_calls */ - &weechat_tcl_api_hook_timer_cb, - Tcl_GetStringFromObj (objv[4], &i), /* tcl function */ - Tcl_GetStringFromObj (objv[5], &i))); /* data */ + result = API_PTR2STR(plugin_script_api_hook_timer (weechat_tcl_plugin, + tcl_current_script, + interval, /* interval */ + align_second, /* align_second */ + max_calls, /* max_calls */ + &weechat_tcl_api_hook_timer_cb, + Tcl_GetStringFromObj (objv[4], &i), /* tcl function */ + Tcl_GetStringFromObj (objv[5], &i))); /* data */ API_RETURN_STRING_FREE(result); } @@ -2855,15 +2858,15 @@ weechat_tcl_api_hook_fd (ClientData clientData, Tcl_Interp *interp, || (Tcl_GetIntFromObj (interp, objv[4], &exception) != TCL_OK)) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (script_api_hook_fd (weechat_tcl_plugin, - tcl_current_script, - fd, /* fd */ - read, /* read */ - write, /* write */ - exception, /* exception */ - &weechat_tcl_api_hook_fd_cb, - Tcl_GetStringFromObj (objv[5], &i), /* tcl function */ - Tcl_GetStringFromObj (objv[6], &i))); /* data */ + result = API_PTR2STR(plugin_script_api_hook_fd (weechat_tcl_plugin, + tcl_current_script, + fd, /* fd */ + read, /* read */ + write, /* write */ + exception, /* exception */ + &weechat_tcl_api_hook_fd_cb, + Tcl_GetStringFromObj (objv[5], &i), /* tcl function */ + Tcl_GetStringFromObj (objv[6], &i))); /* data */ API_RETURN_STRING_FREE(result); } @@ -2934,13 +2937,13 @@ weechat_tcl_api_hook_process (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[3], &i); data = Tcl_GetStringFromObj (objv[4], &i); - result = script_ptr2str (script_api_hook_process (weechat_tcl_plugin, - tcl_current_script, - command, - timeout, - &weechat_tcl_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process (weechat_tcl_plugin, + tcl_current_script, + command, + timeout, + &weechat_tcl_api_hook_process_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -2973,14 +2976,14 @@ weechat_tcl_api_hook_process_hashtable (ClientData clientData, function = Tcl_GetStringFromObj (objv[4], &i); data = Tcl_GetStringFromObj (objv[5], &i); - result = script_ptr2str (script_api_hook_process_hashtable (weechat_tcl_plugin, - tcl_current_script, - command, - options, - timeout, - &weechat_tcl_api_hook_process_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_tcl_plugin, + tcl_current_script, + command, + options, + timeout, + &weechat_tcl_api_hook_process_cb, + function, + data)); if (options) weechat_hashtable_free (options); @@ -3061,21 +3064,21 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[7], &i); data = Tcl_GetStringFromObj (objv[8], &i); - result = script_ptr2str (script_api_hook_connect (weechat_tcl_plugin, - tcl_current_script, - proxy, - address, - port, - sock, - ipv6, - NULL, /* gnutls session */ - NULL, /* gnutls callback */ - 0, /* gnutls DH key size */ - NULL, /* gnutls priorities */ - local_hostname, - &weechat_tcl_api_hook_connect_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_connect (weechat_tcl_plugin, + tcl_current_script, + proxy, + address, + port, + sock, + ipv6, + NULL, /* gnutls session */ + NULL, /* gnutls callback */ + 0, /* gnutls DH key size */ + NULL, /* gnutls priorities */ + local_hostname, + &weechat_tcl_api_hook_connect_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3107,7 +3110,7 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = timebuffer; func_argv[3] = weechat_string_build_with_split_string (tags, ","); if (!func_argv[3]) @@ -3169,15 +3172,15 @@ weechat_tcl_api_hook_print (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[5], &i); data = Tcl_GetStringFromObj (objv[6], &i); - result = script_ptr2str (script_api_hook_print (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(buffer), - tags, - message, - strip_colors, /* strip_colors */ - &weechat_tcl_api_hook_print_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_print (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(buffer), + tags, + message, + strip_colors, /* strip_colors */ + &weechat_tcl_api_hook_print_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3215,7 +3218,7 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - func_argv[2] = script_ptr2str (signal_data); + func_argv[2] = API_PTR2STR(signal_data); free_needed = 1; } else @@ -3262,12 +3265,12 @@ weechat_tcl_api_hook_signal (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_hook_signal (weechat_tcl_plugin, - tcl_current_script, - signal, - &weechat_tcl_api_hook_signal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_signal (weechat_tcl_plugin, + tcl_current_script, + signal, + &weechat_tcl_api_hook_signal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3380,12 +3383,12 @@ weechat_tcl_api_hook_hsignal (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_hook_hsignal (weechat_tcl_plugin, - tcl_current_script, - signal, - &weechat_tcl_api_hook_hsignal_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_hsignal (weechat_tcl_plugin, + tcl_current_script, + signal, + &weechat_tcl_api_hook_hsignal_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3478,12 +3481,12 @@ weechat_tcl_api_hook_config (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_hook_config (weechat_tcl_plugin, - tcl_current_script, - option, - &weechat_tcl_api_hook_config_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_config (weechat_tcl_plugin, + tcl_current_script, + option, + &weechat_tcl_api_hook_config_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3508,8 +3511,8 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; - func_argv[2] = script_ptr2str (buffer); - func_argv[3] = script_ptr2str (completion); + func_argv[2] = API_PTR2STR(buffer); + func_argv[3] = API_PTR2STR(completion); rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3555,13 +3558,13 @@ weechat_tcl_api_hook_completion (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[3], &i); data = Tcl_GetStringFromObj (objv[4], &i); - result = script_ptr2str (script_api_hook_completion (weechat_tcl_plugin, - tcl_current_script, - completion, - description, - &weechat_tcl_api_hook_completion_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_completion (weechat_tcl_plugin, + tcl_current_script, + completion, + description, + &weechat_tcl_api_hook_completion_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3647,12 +3650,12 @@ weechat_tcl_api_hook_modifier (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_hook_modifier (weechat_tcl_plugin, - tcl_current_script, - modifier, - &weechat_tcl_api_hook_modifier_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_modifier (weechat_tcl_plugin, + tcl_current_script, + modifier, + &weechat_tcl_api_hook_modifier_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3733,14 +3736,14 @@ weechat_tcl_api_hook_info (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[4], &i); data = Tcl_GetStringFromObj (objv[5], &i); - result = script_ptr2str (script_api_hook_info (weechat_tcl_plugin, - tcl_current_script, - info_name, - description, - args_description, - &weechat_tcl_api_hook_info_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info (weechat_tcl_plugin, + tcl_current_script, + info_name, + description, + args_description, + &weechat_tcl_api_hook_info_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3798,15 +3801,15 @@ weechat_tcl_api_hook_info_hashtable (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[5], &i); data = Tcl_GetStringFromObj (objv[6], &i); - result = script_ptr2str (script_api_hook_info_hashtable (weechat_tcl_plugin, - tcl_current_script, - info_name, - description, - args_description, - output_description, - &weechat_tcl_api_hook_info_hashtable_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_info_hashtable (weechat_tcl_plugin, + tcl_current_script, + info_name, + description, + args_description, + output_description, + &weechat_tcl_api_hook_info_hashtable_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3830,7 +3833,7 @@ weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name, { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; func_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; - func_argv[2] = script_ptr2str (pointer); + func_argv[2] = API_PTR2STR(pointer); func_argv[3] = (arguments) ? (char *)arguments : empty_arg; result = (struct t_infolist *)weechat_tcl_exec (script_callback->script, @@ -3871,15 +3874,15 @@ weechat_tcl_api_hook_infolist (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[5], &i); data = Tcl_GetStringFromObj (objv[6], &i); - result = script_ptr2str (script_api_hook_infolist (weechat_tcl_plugin, - tcl_current_script, - infolist_name, - description, - pointer_description, - args_description, - &weechat_tcl_api_hook_infolist_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_infolist (weechat_tcl_plugin, + tcl_current_script, + infolist_name, + description, + pointer_description, + args_description, + &weechat_tcl_api_hook_infolist_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3932,12 +3935,12 @@ weechat_tcl_api_hook_focus (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_hook_focus (weechat_tcl_plugin, - tcl_current_script, - area, - &weechat_tcl_api_hook_focus_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_hook_focus (weechat_tcl_plugin, + tcl_current_script, + area, + &weechat_tcl_api_hook_focus_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -3957,9 +3960,9 @@ weechat_tcl_api_unhook (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_unhook (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* hook */ + plugin_script_api_unhook (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* hook */ API_RETURN_OK; } @@ -3981,7 +3984,7 @@ weechat_tcl_api_unhook_all (ClientData clientData, Tcl_Interp *interp, API_FUNC(1, "unhook_all", API_RETURN_ERROR); - script_api_unhook_all (weechat_tcl_plugin, tcl_current_script); + plugin_script_api_unhook_all (weechat_tcl_plugin, tcl_current_script); API_RETURN_OK; } @@ -4004,7 +4007,7 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); func_argv[2] = (input_data) ? (char *)input_data : empty_arg; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -4044,7 +4047,7 @@ weechat_tcl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (buffer); + func_argv[1] = API_PTR2STR(buffer); rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4089,15 +4092,15 @@ weechat_tcl_api_buffer_new (ClientData clientData, Tcl_Interp *interp, function_close = Tcl_GetStringFromObj (objv[4], &i); data_close = Tcl_GetStringFromObj (objv[5], &i); - result = script_ptr2str (script_api_buffer_new (weechat_tcl_plugin, - tcl_current_script, - name, - &weechat_tcl_api_buffer_input_data_cb, - function_input, - data_input, - &weechat_tcl_api_buffer_close_cb, - function_close, - data_close)); + result = API_PTR2STR(plugin_script_api_buffer_new (weechat_tcl_plugin, + tcl_current_script, + name, + &weechat_tcl_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_tcl_api_buffer_close_cb, + function_close, + data_close)); API_RETURN_STRING_FREE(result); } @@ -4121,7 +4124,7 @@ weechat_tcl_api_buffer_search (ClientData clientData, Tcl_Interp *interp, plugin = Tcl_GetStringFromObj (objv[1], &i); name = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_buffer_search (plugin, name)); + result = API_PTR2STR(weechat_buffer_search (plugin, name)); API_RETURN_STRING_FREE(result); } @@ -4144,7 +4147,7 @@ weechat_tcl_api_buffer_search_main (ClientData clientData, Tcl_Interp *interp, API_FUNC(1, "buffer_search_main", API_RETURN_EMPTY); - result = script_ptr2str (weechat_buffer_search_main ()); + result = API_PTR2STR(weechat_buffer_search_main ()); API_RETURN_STRING_FREE(result); } @@ -4167,7 +4170,7 @@ weechat_tcl_api_current_buffer (ClientData clientData, Tcl_Interp *interp, API_FUNC(1, "current_buffer", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_buffer ()); + result = API_PTR2STR(weechat_current_buffer ()); API_RETURN_STRING_FREE(result); } @@ -4207,9 +4210,9 @@ weechat_tcl_api_buffer_close (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_buffer_close (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* buffer */ + plugin_script_api_buffer_close (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* buffer */ API_RETURN_OK; } @@ -4329,8 +4332,8 @@ weechat_tcl_api_buffer_get_pointer (ClientData clientData, Tcl_Interp *interp, buffer = Tcl_GetStringFromObj (objv[1], &i); property = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_buffer_get_pointer (API_STR2PTR(buffer), - property)); + result = API_PTR2STR(weechat_buffer_get_pointer (API_STR2PTR(buffer), + property)); API_RETURN_STRING_FREE(result); } @@ -4428,7 +4431,7 @@ weechat_tcl_api_current_window (ClientData clientData, Tcl_Interp *interp, API_FUNC(1, "current_window", API_RETURN_EMPTY); - result = script_ptr2str (weechat_current_window ()); + result = API_PTR2STR(weechat_current_window ()); API_RETURN_STRING_FREE(result); } @@ -4452,7 +4455,7 @@ weechat_tcl_api_window_search_with_buffer (ClientData clientData, Tcl_Interp *in buffer = Tcl_GetStringFromObj (objv[1], &i); - result = script_ptr2str (weechat_window_search_with_buffer (API_STR2PTR(buffer))); + result = API_PTR2STR(weechat_window_search_with_buffer (API_STR2PTR(buffer))); API_RETURN_STRING_FREE(result); } @@ -4526,8 +4529,8 @@ weechat_tcl_api_window_get_pointer (ClientData clientData, Tcl_Interp *interp, window = Tcl_GetStringFromObj (objv[1], &i); property = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_window_get_pointer (API_STR2PTR(window), - property)); + result = API_PTR2STR(weechat_window_get_pointer (API_STR2PTR(window), + property)); API_RETURN_STRING_FREE(result); } @@ -4579,11 +4582,11 @@ weechat_tcl_api_nicklist_add_group (ClientData clientData, Tcl_Interp *interp, name = Tcl_GetStringFromObj (objv[3], &i); color = Tcl_GetStringFromObj (objv[4], &i); - result = script_ptr2str (weechat_nicklist_add_group (API_STR2PTR(buffer), - API_STR2PTR(parent_group), - name, - color, - visible)); /* visible */ + result = API_PTR2STR(weechat_nicklist_add_group (API_STR2PTR(buffer), + API_STR2PTR(parent_group), + name, + color, + visible)); /* visible */ API_RETURN_STRING_FREE(result); } @@ -4608,9 +4611,9 @@ weechat_tcl_api_nicklist_search_group (ClientData clientData, Tcl_Interp *interp from_group = Tcl_GetStringFromObj (objv[2], &i); name = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (weechat_nicklist_search_group (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_group (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4641,13 +4644,13 @@ weechat_tcl_api_nicklist_add_nick (ClientData clientData, Tcl_Interp *interp, prefix = Tcl_GetStringFromObj (objv[5], &i); prefix_color = Tcl_GetStringFromObj (objv[6], &i); - result = script_ptr2str (weechat_nicklist_add_nick (API_STR2PTR(buffer), - API_STR2PTR(group), - name, - color, - prefix, - prefix_color, - visible)); /* visible */ + result = API_PTR2STR(weechat_nicklist_add_nick (API_STR2PTR(buffer), + API_STR2PTR(group), + name, + color, + prefix, + prefix_color, + visible)); /* visible */ API_RETURN_STRING_FREE(result); } @@ -4672,9 +4675,9 @@ weechat_tcl_api_nicklist_search_nick (ClientData clientData, Tcl_Interp *interp, from_group = Tcl_GetStringFromObj (objv[2], &i); name = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (weechat_nicklist_search_nick (API_STR2PTR(buffer), - API_STR2PTR(from_group), - name)); + result = API_PTR2STR(weechat_nicklist_search_nick (API_STR2PTR(buffer), + API_STR2PTR(from_group), + name)); API_RETURN_STRING_FREE(result); } @@ -4828,9 +4831,9 @@ weechat_tcl_api_nicklist_group_get_pointer (ClientData clientData, group = Tcl_GetStringFromObj (objv[2], &i); property = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(group), - property)); + result = API_PTR2STR(weechat_nicklist_group_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(group), + property)); API_RETURN_STRING_FREE(result); } @@ -4943,9 +4946,9 @@ weechat_tcl_api_nicklist_nick_get_pointer (ClientData clientData, nick = Tcl_GetStringFromObj (objv[2], &i); property = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), - API_STR2PTR(nick), - property)); + result = API_PTR2STR(weechat_nicklist_nick_get_pointer (API_STR2PTR(buffer), + API_STR2PTR(nick), + property)); API_RETURN_STRING_FREE(result); } @@ -4995,7 +4998,7 @@ weechat_tcl_api_bar_item_search (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_item_search (Tcl_GetStringFromObj (objv[1], &i))); /* name */ + result = API_PTR2STR(weechat_bar_item_search (Tcl_GetStringFromObj (objv[1], &i))); /* name */ API_RETURN_STRING_FREE(result); } @@ -5017,8 +5020,8 @@ weechat_tcl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, if (script_callback && script_callback->function && script_callback->function[0]) { func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (item); - func_argv[2] = script_ptr2str (window); + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); ret = (char *)weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -5056,12 +5059,12 @@ weechat_tcl_api_bar_item_new (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (script_api_bar_item_new (weechat_tcl_plugin, - tcl_current_script, - name, - &weechat_tcl_api_bar_item_build_cb, - function, - data)); + result = API_PTR2STR(plugin_script_api_bar_item_new (weechat_tcl_plugin, + tcl_current_script, + name, + &weechat_tcl_api_bar_item_build_cb, + function, + data)); API_RETURN_STRING_FREE(result); } @@ -5101,9 +5104,9 @@ weechat_tcl_api_bar_item_remove (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_ERROR); - script_api_bar_item_remove (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* item */ + plugin_script_api_bar_item_remove (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i))); /* item */ API_RETURN_OK; } @@ -5124,7 +5127,7 @@ weechat_tcl_api_bar_search (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_bar_search (Tcl_GetStringFromObj (objv[1], &i))); /* name */ + result = API_PTR2STR(weechat_bar_search (Tcl_GetStringFromObj (objv[1], &i))); /* name */ API_RETURN_STRING_FREE(result); } @@ -5163,21 +5166,21 @@ weechat_tcl_api_bar_new (ClientData clientData, Tcl_Interp *interp, separator = Tcl_GetStringFromObj (objv[14], &i); bar_items = Tcl_GetStringFromObj (objv[15], &i); - result = script_ptr2str (weechat_bar_new (name, - hidden, - priority, - type, - conditions, - position, - filling_top_bottom, - filling_left_right, - size, - size_max, - color_fg, - color_delim, - color_bg, - separator, - bar_items)); + result = API_PTR2STR(weechat_bar_new (name, + hidden, + priority, + type, + conditions, + position, + filling_top_bottom, + filling_left_right, + size, + size_max, + color_fg, + color_delim, + color_bg, + separator, + bar_items)); API_RETURN_STRING_FREE(result); } @@ -5266,10 +5269,10 @@ weechat_tcl_api_command (ClientData clientData, Tcl_Interp *interp, buffer = Tcl_GetStringFromObj (objv[1], &i); command = Tcl_GetStringFromObj (objv[2], &i); - script_api_command (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(buffer), - command); + plugin_script_api_command (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(buffer), + command); API_RETURN_OK; } @@ -5345,7 +5348,7 @@ weechat_tcl_api_infolist_new (ClientData clientData, Tcl_Interp *interp, API_FUNC(1, "infolist_new", API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new ()); + result = API_PTR2STR(weechat_infolist_new ()); API_RETURN_STRING_FREE(result); } @@ -5366,7 +5369,7 @@ weechat_tcl_api_infolist_new_item (ClientData clientData, Tcl_Interp *interp, if (objc < 2) API_WRONG_ARGS(API_RETURN_INT(0)); - result = script_ptr2str (weechat_infolist_new_item (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* infolist */ + result = API_PTR2STR(weechat_infolist_new_item (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)))); /* infolist */ API_RETURN_STRING_FREE(result); } @@ -5391,9 +5394,9 @@ weechat_tcl_api_infolist_new_var_integer (ClientData clientData, Tcl_Interp *int if (Tcl_GetIntFromObj (interp, objv[3], &value) != TCL_OK) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_integer (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ - Tcl_GetStringFromObj (objv[2], &i), /* name */ - value)); + result = API_PTR2STR(weechat_infolist_new_var_integer (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ + Tcl_GetStringFromObj (objv[2], &i), /* name */ + value)); API_RETURN_STRING_FREE(result); } @@ -5415,9 +5418,9 @@ weechat_tcl_api_infolist_new_var_string (ClientData clientData, Tcl_Interp *inte if (objc < 4) API_WRONG_ARGS(API_RETURN_INT(0)); - result = script_ptr2str (weechat_infolist_new_var_string (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ - Tcl_GetStringFromObj (objv[2], &i), /* name */ - Tcl_GetStringFromObj (objv[3], &i))); /* value */ + result = API_PTR2STR(weechat_infolist_new_var_string (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ + Tcl_GetStringFromObj (objv[2], &i), /* name */ + Tcl_GetStringFromObj (objv[3], &i))); /* value */ API_RETURN_STRING_FREE(result); } @@ -5438,9 +5441,9 @@ weechat_tcl_api_infolist_new_var_pointer (ClientData clientData, Tcl_Interp *int if (objc < 4) API_WRONG_ARGS(API_RETURN_INT(0)); - result = script_ptr2str (weechat_infolist_new_var_pointer (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ - Tcl_GetStringFromObj (objv[2], &i), /* name */ - API_STR2PTR(Tcl_GetStringFromObj (objv[3], &i)))); /* value */ + result = API_PTR2STR(weechat_infolist_new_var_pointer (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ + Tcl_GetStringFromObj (objv[2], &i), /* name */ + API_STR2PTR(Tcl_GetStringFromObj (objv[3], &i)))); /* value */ API_RETURN_STRING_FREE(result); } @@ -5464,9 +5467,9 @@ weechat_tcl_api_infolist_new_var_time (ClientData clientData, Tcl_Interp *interp if (Tcl_GetIntFromObj (interp, objv[3], &value) != TCL_OK) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_infolist_new_var_time (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ - Tcl_GetStringFromObj (objv[2], &i), /* name */ - value)); + result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* infolist */ + Tcl_GetStringFromObj (objv[2], &i), /* name */ + value)); API_RETURN_STRING_FREE(result); } @@ -5491,9 +5494,9 @@ weechat_tcl_api_infolist_get (ClientData clientData, Tcl_Interp *interp, pointer = Tcl_GetStringFromObj (objv[2], &i); arguments = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (weechat_infolist_get (name, - API_STR2PTR(pointer), - arguments)); + result = API_PTR2STR(weechat_infolist_get (name, + API_STR2PTR(pointer), + arguments)); API_RETURN_STRING_FREE(result); } @@ -5653,7 +5656,7 @@ weechat_tcl_api_infolist_pointer (ClientData clientData, Tcl_Interp *interp, infolist = Tcl_GetStringFromObj (objv[1], &i); variable = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_infolist_pointer (API_STR2PTR(infolist), variable)); + result = API_PTR2STR(weechat_infolist_pointer (API_STR2PTR(infolist), variable)); API_RETURN_STRING_FREE(result); } @@ -5727,7 +5730,7 @@ weechat_tcl_api_hdata_get (ClientData clientData, Tcl_Interp *interp, name = Tcl_GetStringFromObj (objv[1], &i); - result = script_ptr2str (weechat_hdata_get (name)); + result = API_PTR2STR(weechat_hdata_get (name)); API_RETURN_STRING_FREE(result); } @@ -5886,8 +5889,8 @@ weechat_tcl_api_hdata_get_list (ClientData clientData, Tcl_Interp *interp, hdata = Tcl_GetStringFromObj (objv[1], &i); name = Tcl_GetStringFromObj (objv[2], &i); - result = script_ptr2str (weechat_hdata_get_list (API_STR2PTR(hdata), - name)); + result = API_PTR2STR(weechat_hdata_get_list (API_STR2PTR(hdata), + name)); API_RETURN_STRING_FREE(result); } @@ -5941,9 +5944,9 @@ weechat_tcl_api_hdata_move (ClientData clientData, Tcl_Interp *interp, if (Tcl_GetIntFromObj (interp, objv[3], &count) != TCL_OK) API_WRONG_ARGS(API_RETURN_EMPTY); - result = script_ptr2str (weechat_hdata_move (API_STR2PTR(hdata), - API_STR2PTR(pointer), - count)); + result = API_PTR2STR(weechat_hdata_move (API_STR2PTR(hdata), + API_STR2PTR(pointer), + count)); API_RETURN_STRING_FREE(result); } @@ -6082,9 +6085,9 @@ weechat_tcl_api_hdata_pointer (ClientData clientData, Tcl_Interp *interp, pointer = Tcl_GetStringFromObj (objv[2], &i); name = Tcl_GetStringFromObj (objv[3], &i); - result = script_ptr2str (weechat_hdata_pointer (API_STR2PTR(hdata), - API_STR2PTR(pointer), - name)); + result = API_PTR2STR(weechat_hdata_pointer (API_STR2PTR(hdata), + API_STR2PTR(pointer), + name)); API_RETURN_STRING_FREE(result); } @@ -6200,7 +6203,7 @@ weechat_tcl_api_upgrade_new (ClientData clientData, Tcl_Interp *interp, filename = Tcl_GetStringFromObj (objv[1], &i); - result = script_ptr2str (weechat_upgrade_new (filename, write)); + result = API_PTR2STR(weechat_upgrade_new (filename, write)); API_RETURN_STRING_FREE(result); } @@ -6256,9 +6259,9 @@ weechat_tcl_api_upgrade_read_cb (void *data, snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = script_ptr2str (upgrade_file); + func_argv[1] = API_PTR2STR(upgrade_file); func_argv[2] = str_object_id; - func_argv[3] = script_ptr2str (infolist); + func_argv[3] = API_PTR2STR(infolist); rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -6303,12 +6306,12 @@ weechat_tcl_api_upgrade_read (ClientData clientData, Tcl_Interp *interp, function = Tcl_GetStringFromObj (objv[2], &i); data = Tcl_GetStringFromObj (objv[3], &i); - rc = script_api_upgrade_read (weechat_tcl_plugin, - tcl_current_script, - API_STR2PTR(upgrade_file), - &weechat_tcl_api_upgrade_read_cb, - function, - data); + rc = plugin_script_api_upgrade_read (weechat_tcl_plugin, + tcl_current_script, + API_STR2PTR(upgrade_file), + &weechat_tcl_api_upgrade_read_cb, + function, + data); API_RETURN_INT(rc); } diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.h b/src/plugins/tcl/weechat-tcl-api.h index 8c1f60392..8c1f60392 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.h +++ b/src/plugins/tcl/weechat-tcl-api.h diff --git a/src/plugins/scripts/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c index a93fc551b..84fbcbdcb 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.c +++ b/src/plugins/tcl/weechat-tcl.c @@ -31,8 +31,8 @@ #include <stdlib.h> #include <string.h> -#include "../../weechat-plugin.h" -#include "../script.h" +#include "../weechat-plugin.h" +#include "../plugin-script.h" #include "weechat-tcl.h" #include "weechat-tcl-api.h" @@ -337,11 +337,11 @@ weechat_tcl_load (const char *filename) * set input/close callbacks for buffers created by this script * (to restore callbacks after upgrade) */ - script_set_buffer_callbacks (weechat_tcl_plugin, - tcl_scripts, - tcl_current_script, - &weechat_tcl_api_buffer_input_data_cb, - &weechat_tcl_api_buffer_close_cb); + plugin_script_set_buffer_callbacks (weechat_tcl_plugin, + tcl_scripts, + tcl_current_script, + &weechat_tcl_api_buffer_input_data_cb, + &weechat_tcl_api_buffer_close_cb); return 1; } @@ -392,7 +392,7 @@ weechat_tcl_unload (struct t_plugin_script *script) tcl_current_script = (tcl_current_script->prev_script) ? tcl_current_script->prev_script : tcl_current_script->next_script; - script_remove (weechat_tcl_plugin, &tcl_scripts, &last_tcl_script, script); + plugin_script_remove (weechat_tcl_plugin, &tcl_scripts, &last_tcl_script, script); Tcl_DeleteInterp(interp); } @@ -406,7 +406,7 @@ weechat_tcl_unload_name (const char *name) { struct t_plugin_script *ptr_script; - ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name); + ptr_script = plugin_script_search (weechat_tcl_plugin, tcl_scripts, name); if (ptr_script) { weechat_tcl_unload (ptr_script); @@ -445,7 +445,7 @@ weechat_tcl_reload_name (const char *name) struct t_plugin_script *ptr_script; char *filename; - ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name); + ptr_script = plugin_script_search (weechat_tcl_plugin, tcl_scripts, name); if (ptr_script) { filename = strdup (ptr_script->filename); @@ -483,29 +483,29 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer, if (argc == 1) { - script_display_list (weechat_tcl_plugin, tcl_scripts, - NULL, 0); + plugin_script_display_list (weechat_tcl_plugin, tcl_scripts, + NULL, 0); } else if (argc == 2) { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_tcl_plugin, tcl_scripts, - NULL, 0); + plugin_script_display_list (weechat_tcl_plugin, tcl_scripts, + NULL, 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_tcl_plugin, tcl_scripts, - NULL, 1); + plugin_script_display_list (weechat_tcl_plugin, tcl_scripts, + NULL, 1); } else if (weechat_strcasecmp (argv[1], "autoload") == 0) { - script_auto_load (weechat_tcl_plugin, &weechat_tcl_load_cb); + plugin_script_auto_load (weechat_tcl_plugin, &weechat_tcl_load_cb); } else if (weechat_strcasecmp (argv[1], "reload") == 0) { weechat_tcl_unload_all (); - script_auto_load (weechat_tcl_plugin, &weechat_tcl_load_cb); + plugin_script_auto_load (weechat_tcl_plugin, &weechat_tcl_load_cb); } else if (weechat_strcasecmp (argv[1], "unload") == 0) { @@ -516,19 +516,19 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer, { if (weechat_strcasecmp (argv[1], "list") == 0) { - script_display_list (weechat_tcl_plugin, tcl_scripts, - argv_eol[2], 0); + plugin_script_display_list (weechat_tcl_plugin, tcl_scripts, + argv_eol[2], 0); } else if (weechat_strcasecmp (argv[1], "listfull") == 0) { - script_display_list (weechat_tcl_plugin, tcl_scripts, - argv_eol[2], 1); + plugin_script_display_list (weechat_tcl_plugin, tcl_scripts, + argv_eol[2], 1); } else if (weechat_strcasecmp (argv[1], "load") == 0) { /* load Tcl script */ - path_script = script_search_path (weechat_tcl_plugin, - argv_eol[2]); + path_script = plugin_script_search_path (weechat_tcl_plugin, + argv_eol[2]); weechat_tcl_load ((path_script) ? path_script : argv_eol[2]); if (path_script) free (path_script); @@ -569,7 +569,7 @@ weechat_tcl_completion_cb (void *data, const char *completion_item, (void) completion_item; (void) buffer; - script_completion (weechat_tcl_plugin, completion, tcl_scripts); + plugin_script_completion (weechat_tcl_plugin, completion, tcl_scripts); return WEECHAT_RC_OK; } @@ -590,9 +590,9 @@ weechat_tcl_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "tcl_script") == 0) { - return script_infolist_list_scripts (weechat_tcl_plugin, - tcl_scripts, pointer, - arguments); + return plugin_script_infolist_list_scripts (weechat_tcl_plugin, + tcl_scripts, pointer, + arguments); } return NULL; @@ -614,7 +614,7 @@ weechat_tcl_signal_debug_dump_cb (void *data, const char *signal, if (!signal_data || (weechat_strcasecmp ((char *)signal_data, TCL_PLUGIN_NAME) == 0)) { - script_print_log (weechat_tcl_plugin, tcl_scripts); + plugin_script_print_log (weechat_tcl_plugin, tcl_scripts); } return WEECHAT_RC_OK; @@ -634,7 +634,7 @@ weechat_tcl_signal_buffer_closed_cb (void *data, const char *signal, (void) type_data; if (signal_data) - script_remove_buffer_callbacks (tcl_scripts, signal_data); + plugin_script_remove_buffer_callbacks (tcl_scripts, signal_data); return WEECHAT_RC_OK; } @@ -653,18 +653,18 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls) { if (data == &tcl_action_install_list) { - script_action_install (weechat_tcl_plugin, - tcl_scripts, - &weechat_tcl_unload, - &weechat_tcl_load, - &tcl_action_install_list); + plugin_script_action_install (weechat_tcl_plugin, + tcl_scripts, + &weechat_tcl_unload, + &weechat_tcl_load, + &tcl_action_install_list); } else if (data == &tcl_action_remove_list) { - script_action_remove (weechat_tcl_plugin, - tcl_scripts, - &weechat_tcl_unload, - &tcl_action_remove_list); + plugin_script_action_remove (weechat_tcl_plugin, + tcl_scripts, + &weechat_tcl_unload, + &tcl_action_remove_list); } } @@ -688,16 +688,16 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal, { if (strcmp (signal, "tcl_script_install") == 0) { - script_action_add (&tcl_action_install_list, - (const char *)signal_data); + plugin_script_action_add (&tcl_action_install_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_tcl_timer_action_cb, &tcl_action_install_list); } else if (strcmp (signal, "tcl_script_remove") == 0) { - script_action_add (&tcl_action_remove_list, - (const char *)signal_data); + plugin_script_action_add (&tcl_action_remove_list, + (const char *)signal_data); weechat_hook_timer (1, 0, 1, &weechat_tcl_timer_action_cb, &tcl_action_remove_list); @@ -727,11 +727,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) init.callback_load_file = &weechat_tcl_load_cb; tcl_quiet = 1; - script_init (weechat_tcl_plugin, argc, argv, &init); + plugin_script_init (weechat_tcl_plugin, argc, argv, &init); tcl_quiet = 0; - script_display_short_list (weechat_tcl_plugin, - tcl_scripts); + plugin_script_display_short_list (weechat_tcl_plugin, + tcl_scripts); /* init ok */ return WEECHAT_RC_OK; @@ -746,7 +746,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) { /* unload all scripts */ tcl_quiet = 1; - script_end (plugin, &tcl_scripts, &weechat_tcl_unload_all); + plugin_script_end (plugin, &tcl_scripts, &weechat_tcl_unload_all); tcl_quiet = 0; return WEECHAT_RC_OK; diff --git a/src/plugins/scripts/tcl/weechat-tcl.h b/src/plugins/tcl/weechat-tcl.h index 62a258885..62a258885 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.h +++ b/src/plugins/tcl/weechat-tcl.h |