summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt47
-rw-r--r--ChangeLog3
-rw-r--r--Makefile.am1
-rw-r--r--cmake/FindGuile.cmake51
-rw-r--r--configure.in42
-rw-r--r--doc/de/autogen/plugin_api/completions.txt12
-rw-r--r--doc/de/autogen/plugin_api/infolists.txt12
-rw-r--r--doc/de/autogen/user/guile_commands.txt20
-rw-r--r--doc/de/weechat_scripting.de.txt94
-rw-r--r--doc/de/weechat_user.de.txt65
-rw-r--r--doc/docgen.py17
-rw-r--r--doc/en/autogen/plugin_api/completions.txt2
-rw-r--r--doc/en/autogen/plugin_api/infolists.txt2
-rw-r--r--doc/en/autogen/user/guile_commands.txt20
-rw-r--r--doc/en/weechat_scripting.en.txt91
-rw-r--r--doc/en/weechat_user.en.txt65
-rw-r--r--doc/fr/autogen/plugin_api/completions.txt2
-rw-r--r--doc/fr/autogen/plugin_api/infolists.txt2
-rw-r--r--doc/fr/autogen/user/guile_commands.txt20
-rw-r--r--doc/fr/weechat_scripting.fr.txt89
-rw-r--r--doc/fr/weechat_user.fr.txt63
-rw-r--r--doc/it/autogen/plugin_api/completions.txt2
-rw-r--r--doc/it/autogen/plugin_api/infolists.txt2
-rw-r--r--doc/it/autogen/user/guile_commands.txt20
-rw-r--r--doc/it/weechat_scripting.it.txt94
-rw-r--r--doc/it/weechat_user.it.txt65
-rw-r--r--doc/pl/weechat_scripting.pl.txt93
-rw-r--r--po/POTFILES.in4
-rw-r--r--po/srcfiles.cmake4
-rw-r--r--src/plugins/CMakeLists.txt4
-rw-r--r--src/plugins/Makefile.am4
-rw-r--r--src/plugins/scripts/CMakeLists.txt7
-rw-r--r--src/plugins/scripts/Makefile.am6
-rw-r--r--src/plugins/scripts/guile/CMakeLists.txt31
-rw-r--r--src/plugins/scripts/guile/Makefile.am33
-rw-r--r--src/plugins/scripts/guile/weechat-guile-api.c5502
-rw-r--r--src/plugins/scripts/guile/weechat-guile-api.h30
-rw-r--r--src/plugins/scripts/guile/weechat-guile.c891
-rw-r--r--src/plugins/scripts/guile/weechat-guile.h47
39 files changed, 7281 insertions, 278 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d0538003..c8eb2eb63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,29 +59,30 @@ ELSE(DEFINED INCLUDEDIR)
SET(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
ENDIF(DEFINED INCLUDEDIR)
-OPTION(ENABLE_NCURSES "Enable Ncurses interface" ON)
-OPTION(ENABLE_GTK "Enable GTK interface" OFF)
-OPTION(ENABLE_NLS "Enable Native Language Support" ON)
-OPTION(ENABLE_GCRYPT "Enable libgcrypt support" ON)
-OPTION(ENABLE_GNUTLS "Enable SSLv3/TLS support" ON)
-OPTION(ENABLE_LARGEFILE "Enable Large File Support" ON)
-OPTION(ENABLE_ALIAS "Enable Alias plugin" ON)
-OPTION(ENABLE_ASPELL "Enable Aspell plugin" ON)
-OPTION(ENABLE_CHARSET "Enable Charset plugin" ON)
-OPTION(ENABLE_DEMO "Enable Demo plugin" OFF)
-OPTION(ENABLE_FIFO "Enable FIFO plugin" ON)
-OPTION(ENABLE_IRC "Enable IRC plugin" ON)
-OPTION(ENABLE_LOGGER "Enable Logger plugin" ON)
-OPTION(ENABLE_RELAY "Enable Relay plugin" ON)
-OPTION(ENABLE_RMODIFIER "Enable Rmodifier plugin" ON)
-OPTION(ENABLE_SCRIPTS "Enable script plugins" ON)
-OPTION(ENABLE_PERL "Enable Perl scripting language" ON)
-OPTION(ENABLE_PYTHON "Enable Python scripting language" ON)
-OPTION(ENABLE_RUBY "Enable Ruby scripting language" ON)
-OPTION(ENABLE_LUA "Enable Lua scripting language" ON)
-OPTION(ENABLE_TCL "Enable Tcl scripting language" ON)
-OPTION(ENABLE_XFER "Enable Xfer plugin" ON)
-OPTION(ENABLE_DOC "Enable Documentation" ON)
+OPTION(ENABLE_NCURSES "Enable Ncurses interface" ON)
+OPTION(ENABLE_GTK "Enable GTK interface" OFF)
+OPTION(ENABLE_NLS "Enable Native Language Support" ON)
+OPTION(ENABLE_GCRYPT "Enable libgcrypt support" ON)
+OPTION(ENABLE_GNUTLS "Enable SSLv3/TLS support" ON)
+OPTION(ENABLE_LARGEFILE "Enable Large File Support" ON)
+OPTION(ENABLE_ALIAS "Enable Alias plugin" ON)
+OPTION(ENABLE_ASPELL "Enable Aspell plugin" ON)
+OPTION(ENABLE_CHARSET "Enable Charset plugin" ON)
+OPTION(ENABLE_DEMO "Enable Demo plugin" OFF)
+OPTION(ENABLE_FIFO "Enable FIFO plugin" ON)
+OPTION(ENABLE_IRC "Enable IRC plugin" ON)
+OPTION(ENABLE_LOGGER "Enable Logger plugin" ON)
+OPTION(ENABLE_RELAY "Enable Relay plugin" ON)
+OPTION(ENABLE_RMODIFIER "Enable Rmodifier plugin" ON)
+OPTION(ENABLE_SCRIPTS "Enable script plugins" ON)
+OPTION(ENABLE_PERL "Enable Perl scripting language" ON)
+OPTION(ENABLE_PYTHON "Enable Python scripting language" ON)
+OPTION(ENABLE_RUBY "Enable Ruby scripting language" ON)
+OPTION(ENABLE_LUA "Enable Lua scripting language" ON)
+OPTION(ENABLE_TCL "Enable Tcl scripting language" ON)
+OPTION(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON)
+OPTION(ENABLE_XFER "Enable Xfer plugin" ON)
+OPTION(ENABLE_DOC "Enable Documentation" ON)
IF(ENABLE_NLS)
ADD_SUBDIRECTORY( po )
diff --git a/ChangeLog b/ChangeLog
index 82bfc2e1e..5d104c4e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.3.7-dev, 2011-10-25
+v0.3.7-dev, 2011-10-26
Version 0.3.7 (under dev!)
@@ -10,6 +10,7 @@ Version 0.3.7 (under dev!)
* core: fix compilation error with "pid_t" on Mac OS X (bug #34639)
* core: enable background process under Cygwin to connect to servers, fix
reconnection problem (bug #34626)
+* guile: new script plugin for scheme (task #7289)
Version 0.3.6 (2011-10-22)
--------------------------
diff --git a/Makefile.am b/Makefile.am
index fdda264e0..30c3395b5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,7 @@ EXTRA_DIST = CMakeLists.txt \
cmake/FindRuby.cmake \
cmake/FindSourcehighlight.cmake \
cmake/FindTCL.cmake \
+ cmake/FindGuile.cmake \
cmake/makedist.sh.in \
po/CMakeLists.txt \
po/srcfiles.cmake \
diff --git a/cmake/FindGuile.cmake b/cmake/FindGuile.cmake
new file mode 100644
index 000000000..9786e3682
--- /dev/null
+++ b/cmake/FindGuile.cmake
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2011 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/>.
+#
+
+# - Find Guile
+# This module finds if Guile is installed and determines where the include files
+# and libraries are. It also determines what the name of the library is. This
+# code sets the following variables:
+#
+# GUILE_FOUND = Guile is installed
+# GUILE_INCLUDE_DIRS = Guile include directory
+# GUILE_LIBRARIES = Link options to compile Guile
+
+IF(GUILE_FOUND)
+ # Already in cache, be silent
+ SET(GUILE_FIND_QUIETLY TRUE)
+ENDIF(GUILE_FOUND)
+
+FIND_PATH(GUILE_INCLUDE_DIR libguile.h /usr/include /usr/local/include /usr/include/libguile /usr/local/include/libguile)
+
+FIND_LIBRARY(GUILE_LIBRARY NAMES guile PATH /usr/lib /usr/local/lib)
+
+IF(GUILE_INCLUDE_DIR AND GUILE_LIBRARY)
+ SET(GUILE_FOUND TRUE)
+ SET(GUILE_INCLUDE_DIRS ${GUILE_INCLUDE_DIR})
+ SET(GUILE_LIBRARIES ${GUILE_LIBRARY})
+ELSE(GUILE_INCLUDE_DIR AND GUILE_LIBRARY)
+ SET(GUILE_FOUND FALSE)
+ SET(GUILE_INCLUDE_DIRS)
+ SET(GUILE_LIBRARIES)
+ENDIF(GUILE_INCLUDE_DIR AND GUILE_LIBRARY)
+
+MARK_AS_ADVANCED(
+ GUILE_INCLUDE_DIR
+ GUILE_LIBRARY
+ )
diff --git a/configure.in b/configure.in
index 5b713f133..887f31373 100644
--- a/configure.in
+++ b/configure.in
@@ -121,6 +121,7 @@ AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON])
AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY])
AH_VERBATIM([PLUGIN_LUA], [#undef PLUGIN_LUA])
AH_VERBATIM([PLUGIN_TCL], [#undef PLUGIN_TCL])
+AH_VERBATIM([PLUGIN_GUILE], [#undef PLUGIN_GUILE])
AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER])
AH_VERBATIM([DOC], [#undef DOC])
@@ -148,6 +149,7 @@ AC_ARG_ENABLE(python, [ --disable-python turn off Python script pl
AC_ARG_ENABLE(ruby, [ --disable-ruby turn off Ruby script plugin (default=compiled if found)],enable_ruby=$enableval,enable_ruby=yes)
AC_ARG_ENABLE(lua, [ --disable-lua turn off Lua script plugin (default=compiled if found)],enable_lua=$enableval,enable_lua=yes)
AC_ARG_ENABLE(tcl, [ --disable-tcl turn off Tcl script plugin (default=compiled if found)],enable_tcl=$enableval,enable_tcl=yes)
+AC_ARG_ENABLE(guile, [ --disable-guile turn off Guile (scheme) script plugin (default=compiled if found)],enable_guile=$enableval,enable_guile=yes)
AC_ARG_ENABLE(xfer, [ --disable-xfer turn off Xfer (file transfer) plugin (default=compiled if found)],enable_xfer=$enableval,enable_xfer=yes)
AC_ARG_WITH(lua-inc, [ --with-lua-inc=DIR, lua include files are in DIR (default=autodetect)],lua_inc=$withval,lua_inc='')
AC_ARG_WITH(lua-lib, [ --with-lua-lib=DIR, lua library files are in DIR (default=autodetect)],lua_lib=$withval,lua_lib='')
@@ -297,6 +299,7 @@ if test "x$enable_scripts" = "xno" ; then
enable_ruby="no"
enable_lua="no"
enable_tcl="no"
+ enable_guile="no"
fi
# ---------------------------------- alias -------------------------------------
@@ -746,6 +749,40 @@ if test "x$enable_tcl" = "xyes" ; then
AC_DEFINE(PLUGIN_TCL)
fi
+# --------------------------------- guile -------------------------------------
+
+GUILE_VERSION=
+
+if test "x$enable_guile" = "xyes" ; then
+ enable_plugins="yes"
+
+ guile_found="no"
+ GUILECONFIG=""
+ AC_CHECK_PROGS(GUILECONFIG, guile-config)
+ if test "x$GUILECONFIG" != "x" ; then
+ AC_MSG_CHECKING(for Guile headers and librairies with guile-config)
+ echo
+ GUILE_CFLAGS=`$GUILECONFIG compile`
+ GUILE_LFLAGS=`$GUILECONFIG link`
+ GUILE_VERSION=`$GUILECONFIG info guileversion`
+ tcl_found="yes"
+ fi
+
+ if test "x$tcl_found" = "xno" ; then
+ AC_MSG_WARN([
+*** Script guile-config couldn't be found on your system.
+*** WeeChat will be built without Guile (scheme) support.])
+ enable_guile="no"
+ not_found="$not_found guile"
+ fi
+fi
+
+if test "x$enable_guile" = "xyes" ; then
+ AC_SUBST(GUILE_CFLAGS)
+ AC_SUBST(GUILE_LFLAGS)
+ AC_DEFINE(PLUGIN_GUILE)
+fi
+
# ---------------------------------- xfer --------------------------------------
if test "x$enable_xfer" = "xyes" ; then
@@ -1023,6 +1060,7 @@ AM_CONDITIONAL(PLUGIN_PYTHON, test "$enable_python" = "yes")
AM_CONDITIONAL(PLUGIN_RUBY, test "$enable_ruby" = "yes")
AM_CONDITIONAL(PLUGIN_LUA, test "$enable_lua" = "yes")
AM_CONDITIONAL(PLUGIN_TCL, test "$enable_tcl" = "yes")
+AM_CONDITIONAL(PLUGIN_GUILE, test "$enable_guile" = "yes")
AM_CONDITIONAL(PLUGIN_XFER, test "$enable_xfer" = "yes")
AM_CONDITIONAL(DOC, test "$enable_doc" = "yes")
@@ -1053,6 +1091,7 @@ AC_OUTPUT([Makefile
src/plugins/scripts/ruby/Makefile
src/plugins/scripts/lua/Makefile
src/plugins/scripts/tcl/Makefile
+ src/plugins/scripts/guile/Makefile
src/plugins/xfer/Makefile
src/gui/Makefile
src/gui/curses/Makefile
@@ -1129,6 +1168,9 @@ fi
if test "x$enable_tcl" = "xyes"; then
listplugins="$listplugins tcl($TCL_VERSION)"
fi
+if test "x$enable_guile" = "xyes"; then
+ listplugins="$listplugins guile($GUILE_VERSION)"
+fi
if test "x$enable_xfer" = "xyes"; then
listplugins="$listplugins xfer"
fi
diff --git a/doc/de/autogen/plugin_api/completions.txt b/doc/de/autogen/plugin_api/completions.txt
index c5b38401e..2402c11a7 100644
--- a/doc/de/autogen/plugin_api/completions.txt
+++ b/doc/de/autogen/plugin_api/completions.txt
@@ -8,6 +8,8 @@
| aspell | aspell_langs | Liste der Unterstützten Übersetzungen (lang) für Aspell
+| guile | guile_script | Liste der Skripten
+
| irc | irc_channel | Aktueller IRC-Channel
| irc | irc_channel_nicks_hosts | Liste der Nicks und Hostnamen des aktuellen Channels
@@ -38,11 +40,11 @@
| irc | nick | Liste der Nicks im aktuellen Channel
-| lua | lua_script | Liste der Skripten:
+| lua | lua_script | Liste der Skripten
-| perl | perl_script | Liste der Skripten:
+| perl | perl_script | Liste der Skripten
-| python | python_script | Liste der Skripten:
+| python | python_script | Liste der Skripten
| relay | relay_free_port | Erster freier Port für Relay-Erweiterung
@@ -52,9 +54,9 @@
| rmodifier | rmodifier | Liste der rmodifier
-| ruby | ruby_script | Liste der Skripten:
+| ruby | ruby_script | Liste der Skripten
-| tcl | tcl_script | Liste der Skripten:
+| tcl | tcl_script | Liste der Skripten
| weechat | bars_names | Namen der Infobars
diff --git a/doc/de/autogen/plugin_api/infolists.txt b/doc/de/autogen/plugin_api/infolists.txt
index a212a5729..55519cd4f 100644
--- a/doc/de/autogen/plugin_api/infolists.txt
+++ b/doc/de/autogen/plugin_api/infolists.txt
@@ -4,6 +4,8 @@
| alias | alias | Liste der Alias | Alias Pointer (optional) | Alias Name (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
+| guile | guile_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
+
| irc | irc_channel | Liste der Channels eines IRC-Servers | Channel Pointer (optional) | Server,Channel (Channel ist optional)
| irc | irc_ignore | Liste von ignorierten IRCs | Ignore Pointer (optional) | -
@@ -16,19 +18,19 @@
| logger | logger_buffer | Liste der protokollierten Buffer | Logger Pointer (optional) | -
-| lua | lua_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
+| lua | lua_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
-| perl | perl_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
+| perl | perl_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
-| python | python_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
+| python | python_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
| relay | relay | Liste der Relay-Clients | Relay Pointer (optional) | -
| rmodifier | rmodifier | Liste der rmodifier | rmodifier Pointer (optional) | rmodifier Name (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
-| ruby | ruby_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
+| ruby | ruby_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
-| tcl | tcl_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
+| tcl | tcl_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
| weechat | bar | Auflistung der Bars | Bar Pointer (optional) | Bar Name (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
diff --git a/doc/de/autogen/user/guile_commands.txt b/doc/de/autogen/user/guile_commands.txt
new file mode 100644
index 000000000..922d1e194
--- /dev/null
+++ b/doc/de/autogen/user/guile_commands.txt
@@ -0,0 +1,20 @@
+[[command_guile_guile]]
+[command]*`guile`* auflisten/installieren/deinstallieren von Skripten::
+........................................
+/guile list|listfull [<name>]
+ load <filename>
+ autoload
+ reload|unload [<name>]
+
+ list: installierte Erweiterungen werden aufgelistet
+listfull: detaillierte Auflistung aller installierten Erweiterungen
+ load: installiert eine Erweiterung
+autoload: installiert automatisch alle Erweiterungen aus System- oder Benutzerverzeichnis
+ reload: eine Erweiterung wird erneut installiert (falls kein Name angegeben wird dann werden alle Erweiterungen entfernt und erneut installiert)
+ unload: deinstalliert eine oder alle Erweiterungen
+filename: Skript (Datei) das geladen werden soll
+ name: Name eines Skripts (Name welcher mit der "register" Funktion genutzt wird)
+
+Ohne Angabe eines Argumentes listet /plugin alle geladenen Erweiterungen auf.
+........................................
+
diff --git a/doc/de/weechat_scripting.de.txt b/doc/de/weechat_scripting.de.txt
index efb53739d..ee1e4d579 100644
--- a/doc/de/weechat_scripting.de.txt
+++ b/doc/de/weechat_scripting.de.txt
@@ -16,9 +16,16 @@ Einleitung
WeeChat (Wee Enhanced Environment for Chat) ist ein freier, schneller und
schlanker Chat-Client der für viele Betriebssysteme entwickelt wird.
-Diese Anleitung beschreibt die Vorgehensweise um Skripten für WeeChat zu
-erstellen. Dabei werden fünf Skriptsprachen unterstützt: perl, python,
-ruby, lua und tcl.
+// TRANSLATION MISSING
+This manual documents way to write scripts for WeeChat, using one of supported
+script languages:
+
+* python
+* perl
+* ruby
+* lua
+* tcl
+* guile (scheme)
[NOTE]
Beinahe alle Beispiele in dieser Dokumentation beziehen sich auf Python.
@@ -32,20 +39,46 @@ Skripten in WeeChat
Besonderheiten der einzelnen Skriptsprachen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Es existieren einige Besonderheiten für jede Skriptsprache:
+Python
+^^^^^^
-* perl:
-** Funktionen werden im Format `weechat::xxx(arg1, arg2, ...);` ausgeführt
-* python:
-** WeeChat muss als Modul eingebunden werden: `import weechat`
-** Um die WeeChat Funktion `print*` nutzen zu können muss `prnt*` genutzt
- werden ('print' ist ein reservierter Befehl von Python!)
-** Funktionen werden im Format `weechat.xxx(arg1, arg2, ...)` ausgeführt
-* ruby:
-** Es muss 'weechat_init' definiert und darin die Funktion 'register' ausgeführt werden
-** Funktionen werden im Format `Weechat.xxx(arg1, arg2, ...)` ausgeführt
-* tcl:
-** Funktionen werden im Format `weechat::xxx arg1 arg2 ...` ausgeführt
+* WeeChat muss als Modul eingebunden werden: `import weechat`
+* Um die WeeChat Funktion `print*` nutzen zu können muss `prnt*` genutzt
+ werden ('print' ist ein reservierter Befehl von Python!)
+* Funktionen werden im Format `weechat.xxx(arg1, arg2, ...)` ausgeführt
+
+Perl
+^^^^
+
+* Funktionen werden im Format `weechat::xxx(arg1, arg2, ...);` ausgeführt
+
+Ruby
+^^^^
+
+* Es muss 'weechat_init' definiert und darin die Funktion 'register' ausgeführt werden
+* Funktionen werden im Format `Weechat.xxx(arg1, arg2, ...)` ausgeführt
+
+Lua
+^^^
+
+* Funktionen werden im Format `weechat.xxx(arg1, arg2, ...)` ausgeführt
+
+Tcl
+^^^
+
+* Funktionen werden im Format `weechat::xxx arg1 arg2 ...` ausgeführt
+
+Guile (scheme)
+^^^^^^^^^^^^^^
+
+// TRANSLATION MISSING
+* Functions are called with `(weechat:xxx arg1 arg2 ...)`
+* Following functions take one list of arguments (instead of many arguments
+ for other functions), because number of arguments exceed number of allowed
+ arguments in Guile:
+** config_new_section
+** config_new_option
+** bar_new
[[register_function]]
Die "Register" Funktion
@@ -74,14 +107,6 @@ Argumente:
Beispielskripten, für jede Sprache:
-* perl:
-
-[source,perl]
-----------------------------------------
-weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test Skript", "", "");
-weechat::print("", "Hallo, von einem perl Skript!");
-----------------------------------------
-
* python:
[source,python]
@@ -92,6 +117,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Test Skript", "", "
weechat.prnt("", "Hallo, von einem python Skript!")
----------------------------------------
+* perl:
+
+[source,perl]
+----------------------------------------
+weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test Skript", "", "");
+weechat::print("", "Hallo, von einem perl Skript!");
+----------------------------------------
+
* ruby:
[source,ruby]
@@ -113,12 +146,20 @@ weechat.print("", "Hallo, von einem lua Skript!")
* tcl:
-// [source,tcl]
+[source,tcl]
----------------------------------------
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Test Skript" "" ""
weechat::print "" "Hallo, von einem tcl Skript!"
----------------------------------------
+* guile (scheme):
+
+[source,lisp]
+----------------------------------------
+(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
+(weechat:print "" "Hello, from scheme script!")
+----------------------------------------
+
[[load_script]]
Laden von Skripten
~~~~~~~~~~~~~~~~~~
@@ -127,11 +168,12 @@ Der Befehl zum Laden von Skripten ist davon abhängig welche Skriptsprache
genutzt werden soll:
----------------------------------------
-/perl load perl/skript.pl
/python load python/skript.py
+/perl load perl/skript.pl
/ruby load ruby/skript.rb
/lua load lua/skript.lua
/tcl load tcl/skript.tcl
+/guile load guile/skript.scm
----------------------------------------
Um Skripten automatisch beim Start von WeeChat zu laden kann man einen Link
diff --git a/doc/de/weechat_user.de.txt b/doc/de/weechat_user.de.txt
index 6a3b0222c..0d53b9c6a 100644
--- a/doc/de/weechat_user.de.txt
+++ b/doc/de/weechat_user.de.txt
@@ -86,23 +86,24 @@ Abhängigkeiten
folgende Tabelle beschreibt welche Pakete zwingend notwendig sind um WeeChat zu kompilieren und
welche Pakete optional genutzt werden können.
-[width="80%",cols="4,^2,13",options="header"]
+[width="100%",cols="5,^3,^3,13",options="header"]
|========================================
-| Paket ^(1)^ | benötigt | Funktion
-| cmake | *ja* | zum kompilieren (autotools ist möglich. cmake wird aber empfohlen)
-| libncursesw5-dev ^(2)^ | *ja* | ncurses Oberfläche
-| gettext | nein | Internationalisierung (Übersetzung der Mitteilungen; Hauptsprache ist englisch)
-| libgcrypt11-dev | nein | SASL Authentifikation am IRC Server mittels DH-BLOWFISH Methode
-| libgnutls-dev (≥ 2.2.0) | nein | SSL Verbindung zu einem IRC Server
-| ca-certificates | nein | Zertifikate für SSL Verbindungen
-| libaspell-dev | nein | aspell Erweiterung
-| libperl-dev | nein | perl Erweiterung
-| python-dev | nein | python Erweiterung
-| ruby1.8-dev | nein | ruby Erweiterung
-| liblua5.1-0-dev | nein | lua Erweiterung
-| tcl-dev (≥ 8.5) | nein | tcl Erweiterung
-| asciidoc (≥ 8.5.0) | nein | erstellt Dokumentation (HTML Dateien)
-| source-highlight | nein | Syntax highlight für Quelltext in HTML Dokumentation
+| Paket ^(1)^ | Version | benötigt | Funktion
+| cmake | | *ja* | zum kompilieren (autotools ist möglich. cmake wird aber empfohlen)
+| libncursesw5-dev ^(2)^ | | *ja* | ncurses Oberfläche
+| gettext | | | Internationalisierung (Übersetzung der Mitteilungen; Hauptsprache ist englisch)
+| libgcrypt11-dev | | | SASL Authentifikation am IRC Server mittels DH-BLOWFISH Methode
+| libgnutls-dev | ≥ 2.2.0 | | SSL Verbindung zu einem IRC Server
+| ca-certificates | | | Zertifikate für SSL Verbindungen
+| libaspell-dev | | | aspell Erweiterung
+| python-dev | 2.5 → 2.7 | | python Erweiterung
+| libperl-dev | | | perl Erweiterung
+| ruby1.8-dev | | | ruby Erweiterung
+| liblua5.1-0-dev | | | lua Erweiterung
+| tcl-dev | ≥ 8.5 | | tcl Erweiterung
+| guile-1.8-dev | | | guile (scheme) Erweiterung
+| asciidoc | ≥ 8.5.0 | | erstellt Dokumentation (HTML Dateien)
+| source-highlight | | | Syntax highlight für Quelltext in HTML Dokumentation
|========================================
[NOTE]
@@ -1005,8 +1006,8 @@ nachträglich zu laden oder zu entfernen.
Es ist wichtig zwischen 'Erweiterung' und 'Skript' zu unterscheiden. Eine Erweiterung
ist eine Binärdatei die kompiliert wurde und mit dem Befehl `/plugin` geladen wird.
-Dem gegenüber ist ein 'Skript' eine Textdatei die durch eine Erweiterung z.B. 'perl'
-mittels dem Befehl `/perl` geladen wird.
+Dem gegenüber ist ein 'Skript' eine Textdatei die durch eine Erweiterung z.B. 'python'
+mittels dem Befehl `/python` geladen wird.
Mit dem Befehl `/plugin` kann eine Erweiterung geladen bzw. entfernt werden. Auch können
mit dem Befehl alle installierten Erweiterungen aufgelistet werden. Wird eine Erweiterung
@@ -1035,11 +1036,12 @@ Standarderweiterungen:
| logger | erstellt Protokolldateien von Buffern
| relay | Daten via Netzwerk übermitteln (IRC Proxy)
| rmodifier | wandelt Schlüsselwörter mit regulären Ausdrücken
-| perl | Perl-Skript API
| python | Python-Skript API
+| perl | Perl-Skript API
| ruby | Ruby-Skript API
| lua | Lua-Skript API
| tcl | Tcl-Skript API
+| guile | Guile(scheme)-Skript API
| xfer | Datentransfer und Direktchat
|========================================
@@ -1237,11 +1239,11 @@ $ echo 'irc.freenode.#weechat *Hallo!' >~/.weechat/weechat_fifo_12345
$ echo '*hello!' >~/.weechat/weechat_fifo_12345
----------------------------------------
-* sendet zwei Befehle um alle Perl-Skripten zu entfernen und dann neu zu laden (die beiden Befehle müssen
+* sendet zwei Befehle um alle Python-Skripten zu entfernen und dann neu zu laden (die beiden Befehle müssen
mit "\n" getrennt werden):
----------------------------------------
-$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
+$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
----------------------------------------
Das nachfolgende Skript sendet einen Befehl an alle laufenden WeeChat Instanzen:
@@ -1943,7 +1945,8 @@ Lautet die Befehlszeile `/oper nick password` wird diese in der Befehlszeile als
Skripten Erweiterungen
~~~~~~~~~~~~~~~~~~~~~~
-WeeChat unterstützt fünf Skript-Erweiterungen: Perl, Python, Ruby, Lua und Tcl.
+WeeChat unterstützt sechs Skript-Erweiterungen: Python, Perl, Ruby, Lua, Tcl und Guile
+(scheme).
Diese Erweiterungen können für die jeweilige Sprache die Skripten laden, ausführen und
entfernen.
@@ -1952,18 +1955,18 @@ bitte die 'WeeChat Scripting Guide'.
Skripten für WeeChat finden Sie auf: http://www.weechat.org/scripts
-[[perl_commands]]
-Perl Befehle
-^^^^^^^^^^^^
-
-include::autogen/user/perl_commands.txt[]
-
[[python_commands]]
Python Befehle
^^^^^^^^^^^^^^
include::autogen/user/python_commands.txt[]
+[[perl_commands]]
+Perl Befehle
+^^^^^^^^^^^^
+
+include::autogen/user/perl_commands.txt[]
+
[[ruby_commands]]
Ruby Befehle
^^^^^^^^^^^^
@@ -1982,6 +1985,12 @@ Tcl Befehle
include::autogen/user/tcl_commands.txt[]
+[[guile_commands]]
+Guile Befehle
+^^^^^^^^^^^^^
+
+include::autogen/user/guile_commands.txt[]
+
[[xfer_plugin]]
Xfer Erweiterung
~~~~~~~~~~~~~~~~
diff --git a/doc/docgen.py b/doc/docgen.py
index a64d4db05..2e7711a81 100644
--- a/doc/docgen.py
+++ b/doc/docgen.py
@@ -93,6 +93,7 @@ plugin_list = { 'weechat' : 'co',
'ruby' : '',
'lua' : '',
'tcl' : '',
+ 'guile' : '',
'xfer' : 'co' }
# options to ignore
@@ -251,16 +252,24 @@ def get_completions():
def update_file(oldfile, newfile, num_files, num_files_updated, obj):
"""Update a doc file."""
- shaold = hashlib.sha224(open(oldfile, 'r').read()).hexdigest()
- shanew = hashlib.sha224(open(newfile, 'r').read()).hexdigest()
+ try:
+ shaold = hashlib.sha224(open(oldfile, 'r').read()).hexdigest()
+ except:
+ shaold = ''
+ try:
+ shanew = hashlib.sha224(open(newfile, 'r').read()).hexdigest()
+ except:
+ shanew = ''
if shaold != shanew:
- os.unlink(oldfile)
+ if os.path.exists(oldfile):
+ os.unlink(oldfile)
os.rename(newfile, oldfile)
num_files_updated['total1'] += 1
num_files_updated['total2'] += 1
num_files_updated[obj] += 1
else:
- os.unlink(newfile)
+ if os.path.exists(oldfile):
+ os.unlink(newfile)
num_files['total1'] += 1
num_files['total2'] += 1
num_files[obj] += 1
diff --git a/doc/en/autogen/plugin_api/completions.txt b/doc/en/autogen/plugin_api/completions.txt
index 45626fdcc..bec6757fb 100644
--- a/doc/en/autogen/plugin_api/completions.txt
+++ b/doc/en/autogen/plugin_api/completions.txt
@@ -8,6 +8,8 @@
| aspell | aspell_langs | list of supported langs for aspell
+| guile | guile_script | list of scripts
+
| irc | irc_channel | current IRC channel
| irc | irc_channel_nicks_hosts | nicks and hostnames of current IRC channel
diff --git a/doc/en/autogen/plugin_api/infolists.txt b/doc/en/autogen/plugin_api/infolists.txt
index 88534c235..7397122ff 100644
--- a/doc/en/autogen/plugin_api/infolists.txt
+++ b/doc/en/autogen/plugin_api/infolists.txt
@@ -4,6 +4,8 @@
| alias | alias | list of aliases | alias pointer (optional) | alias name (can start or end with "*" as wildcard) (optional)
+| guile | guile_script | list of scripts | script pointer (optional) | script name (can start or end with "*" as wildcard) (optional)
+
| irc | irc_channel | list of channels for an IRC server | channel pointer (optional) | server,channel (channel is optional)
| irc | irc_ignore | list of IRC ignores | ignore pointer (optional) | -
diff --git a/doc/en/autogen/user/guile_commands.txt b/doc/en/autogen/user/guile_commands.txt
new file mode 100644
index 000000000..be0c993ae
--- /dev/null
+++ b/doc/en/autogen/user/guile_commands.txt
@@ -0,0 +1,20 @@
+[[command_guile_guile]]
+[command]*`guile`* list/load/unload scripts::
+........................................
+/guile list|listfull [<name>]
+ load <filename>
+ autoload
+ reload|unload [<name>]
+
+ list: list loaded scripts
+listfull: list loaded scripts (verbose)
+ load: load a script
+autoload: load all scripts in "autoload" directory
+ reload: reload a script (if no name given, unload all scripts, then load all scripts in "autoload" directory)
+ unload: unload a script (if no name given, unload all scripts)
+filename: script (file) to load
+ name: a script name (name used in call to "register" function)
+
+Without argument, this command lists all loaded scripts.
+........................................
+
diff --git a/doc/en/weechat_scripting.en.txt b/doc/en/weechat_scripting.en.txt
index e827c3f58..3afbdf0df 100644
--- a/doc/en/weechat_scripting.en.txt
+++ b/doc/en/weechat_scripting.en.txt
@@ -16,8 +16,15 @@ Introduction
WeeChat (Wee Enhanced Environment for Chat) is a free chat client, fast and
light, designed for many operating systems.
-This manual documents way to write scripts for WeeChat, using one of five
-supported script languages: perl, python, ruby, lua or tcl.
+This manual documents way to write scripts for WeeChat, using one of supported
+script languages:
+
+* python
+* perl
+* ruby
+* lua
+* tcl
+* guile (scheme)
[NOTE]
Almost all examples in this doc are written in Python, but API is the same for
@@ -31,20 +38,45 @@ Scripts in WeeChat
Languages specificities
~~~~~~~~~~~~~~~~~~~~~~~
-Some things are specific to languages:
+Python
+^^^^^^
-* perl:
-** functions are called with `weechat::xxx(arg1, arg2, ...);`
-* python:
-** you have to `import weechat`
-** functions `print*` are called `prnt*` in python (because 'print' is reserved
- keyword)
-** functions are called with `weechat.xxx(arg1, arg2, ...)`
-* ruby:
-** you have to define 'weechat_init' and call 'register' inside
-** functions are called with `Weechat.xxx(arg1, arg2, ...)`
-* tcl:
-** functions are called with `weechat::xxx arg1 arg2 ...`
+* You have to `import weechat`
+* Functions `print*` are called `prnt*` in python (because 'print' is reserved
+ keyword)
+* Functions are called with `weechat.xxx(arg1, arg2, ...)`
+
+Perl
+^^^^
+
+* Functions are called with `weechat::xxx(arg1, arg2, ...);`
+
+Ruby
+^^^^
+
+* You have to define 'weechat_init' and call 'register' inside
+* Functions are called with `Weechat.xxx(arg1, arg2, ...)`
+
+Lua
+^^^
+
+* Functions are called with `weechat.xxx(arg1, arg2, ...)`
+
+Tcl
+^^^
+
+* Functions are called with `weechat::xxx arg1 arg2 ...`
+
+Guile (scheme)
+^^^^^^^^^^^^^^
+
+* Functions are called with `(weechat:xxx arg1 arg2 ...)`
+* Following functions take one list of arguments (instead of many arguments
+ for other functions), because number of arguments exceed number of allowed
+ arguments in Guile:
+** config_new_section
+** config_new_option
+** bar_new
[[register_function]]
Register function
@@ -73,14 +105,6 @@ Arguments:
Example of script, for each language:
-* perl:
-
-[source,perl]
-----------------------------------------
-weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
-weechat::print("", "Hello, from perl script!");
-----------------------------------------
-
* python:
[source,python]
@@ -91,6 +115,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Test script", "", "
weechat.prnt("", "Hello, from python script!")
----------------------------------------
+* perl:
+
+[source,perl]
+----------------------------------------
+weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
+weechat::print("", "Hello, from perl script!");
+----------------------------------------
+
* ruby:
[source,ruby]
@@ -112,12 +144,20 @@ weechat.print("", "Hello, from lua script!")
* tcl:
-// [source,tcl]
+[source,tcl]
----------------------------------------
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Test script" "" ""
weechat::print "" "Hello, from tcl script!"
----------------------------------------
+* guile (scheme):
+
+[source,lisp]
+----------------------------------------
+(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
+(weechat:print "" "Hello, from scheme script!")
+----------------------------------------
+
[[load_script]]
Load script
~~~~~~~~~~~
@@ -125,11 +165,12 @@ Load script
You have to use command, depending on language:
----------------------------------------
-/perl load perl/script.pl
/python load python/script.py
+/perl load perl/script.pl
/ruby load ruby/script.rb
/lua load lua/script.lua
/tcl load tcl/script.tcl
+/guile load guile/script.scm
----------------------------------------
You can make link in directory 'language/autoload' to autoload script when
diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt
index 35b0a5665..04e9e4357 100644
--- a/doc/en/weechat_user.en.txt
+++ b/doc/en/weechat_user.en.txt
@@ -86,23 +86,24 @@ Dependencies
Following table shows list of packages that are required or optional to
compile WeeChat.
-[width="80%",cols="4,^2,13",options="header"]
+[width="100%",cols="5,^3,^3,13",options="header"]
|========================================
-| Package ^(1)^ | Required | Feature
-| cmake | *yes* | build (autotools still possible, but cmake is recommended)
-| libncursesw5-dev ^(2)^ | *yes* | ncurses interface
-| gettext | no | internationalization (translation of messages; base language is english)
-| libgcrypt11-dev | no | SASL authentication with IRC server using DH-BLOWFISH mechanism
-| libgnutls-dev (≥ 2.2.0) | no | SSL connection to IRC server
-| ca-certificates | no | certificates for SSL connections
-| libaspell-dev | no | aspell plugin
-| libperl-dev | no | perl plugin
-| python-dev | no | python plugin
-| ruby1.8-dev | no | ruby plugin
-| liblua5.1-0-dev | no | lua plugin
-| tcl-dev (≥ 8.5) | no | tcl plugin
-| asciidoc (≥ 8.5.0) | no | build documentation (HTML files)
-| source-highlight | no | syntax highlight for sources in HTML documentation
+| Package ^(1)^ | Version | Required | Feature
+| cmake | | *yes* | build (autotools still possible, but cmake is recommended)
+| libncursesw5-dev ^(2)^ | | *yes* | ncurses interface
+| gettext | | | internationalization (translation of messages; base language is english)
+| libgcrypt11-dev | | | SASL authentication with IRC server using DH-BLOWFISH mechanism
+| libgnutls-dev | ≥ 2.2.0 | | SSL connection to IRC server
+| ca-certificates | | | certificates for SSL connections
+| libaspell-dev | | | aspell plugin
+| python-dev | 2.5 → 2.7 | | python plugin
+| libperl-dev | | | perl plugin
+| ruby1.8-dev | | | ruby plugin
+| liblua5.1-0-dev | | | lua plugin
+| tcl-dev | ≥ 8.5 | | tcl plugin
+| guile-1.8-dev | | | guile (scheme) plugin
+| asciidoc | ≥ 8.5.0 | | build documentation (HTML files)
+| source-highlight | | | syntax highlight for sources in HTML documentation
|========================================
[NOTE]
@@ -992,8 +993,8 @@ possible to load or unload plugins while WeeChat is running.
It's important to make difference between a 'plugin' and a 'script': a
'plugin' is a binary file compiled and loaded with command `/plugin`, whereas
-a 'script' is a text file loaded with a plugin like 'perl' with command
-`/perl`.
+a 'script' is a text file loaded with a plugin like 'python' with command
+`/python`.
You can use command `/plugin` to load/unload a plugin, or list all loaded
plugins.
@@ -1022,11 +1023,12 @@ Default plugins are:
| logger | Log buffers to files
| relay | Relay data via network (IRC proxy)
| rmodifier | Alter modifier strings with regular expressions
-| perl | Perl scripting API
| python | Python scripting API
+| perl | Perl scripting API
| ruby | Ruby scripting API
| lua | Lua scripting API
| tcl | Tcl scripting API
+| guile | Guile (scheme) scripting API
| xfer | File transfer and direct chat
|========================================
@@ -1220,11 +1222,11 @@ $ echo 'irc.freenode.#weechat *hello!' >~/.weechat/weechat_fifo_12345
$ echo '*hello!' >~/.weechat/weechat_fifo_12345
----------------------------------------
-* send two commands to unload/reload Perl scripts (you have to separate them
+* send two commands to unload/reload Python scripts (you have to separate them
with "\n"):
----------------------------------------
-$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
+$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
----------------------------------------
You can write a script to send command to all running WeeChat at same time,
@@ -1913,7 +1915,8 @@ If command line contains: `/oper nick password` then display becomes:
Scripts plugins
~~~~~~~~~~~~~~~
-WeeChat provides 5 scripting plugins: Perl, Python, Ruby, Lua and Tcl.
+WeeChat provides 6 scripting plugins: Python, Perl, Ruby, Lua, Tcl and Guile
+(scheme).
These plugins can load, execute and unload scripts for these languages.
For more information about how to write scripts, or WeeChat API for
@@ -1921,18 +1924,18 @@ scripts, please read 'WeeChat Scripting Guide'.
You can find some scripts for WeeChat here: http://www.weechat.org/scripts
-[[perl_commands]]
-Perl commands
-^^^^^^^^^^^^^
-
-include::autogen/user/perl_commands.txt[]
-
[[python_commands]]
Python commands
^^^^^^^^^^^^^^^
include::autogen/user/python_commands.txt[]
+[[perl_commands]]
+Perl commands
+^^^^^^^^^^^^^
+
+include::autogen/user/perl_commands.txt[]
+
[[ruby_commands]]
Ruby commands
^^^^^^^^^^^^^
@@ -1951,6 +1954,12 @@ Tcl commands
include::autogen/user/tcl_commands.txt[]
+[[guile_commands]]
+Guile commands
+^^^^^^^^^^^^^^
+
+include::autogen/user/guile_commands.txt[]
+
[[xfer_plugin]]
Xfer plugin
~~~~~~~~~~~
diff --git a/doc/fr/autogen/plugin_api/completions.txt b/doc/fr/autogen/plugin_api/completions.txt
index eb090fc45..370e0b52d 100644
--- a/doc/fr/autogen/plugin_api/completions.txt
+++ b/doc/fr/autogen/plugin_api/completions.txt
@@ -8,6 +8,8 @@
| aspell | aspell_langs | liste des langues supportées pour aspell
+| guile | guile_script | liste des scripts
+
| irc | irc_channel | canal IRC courant
| irc | irc_channel_nicks_hosts | pseudos et noms d'hôtes du canal IRC courant
diff --git a/doc/fr/autogen/plugin_api/infolists.txt b/doc/fr/autogen/plugin_api/infolists.txt
index fca6e7ea1..fc05a383e 100644
--- a/doc/fr/autogen/plugin_api/infolists.txt
+++ b/doc/fr/autogen/plugin_api/infolists.txt
@@ -4,6 +4,8 @@
| alias | alias | liste des alias | pointeur vers l'alias (optionnel) | nom d'alias (peut démarrer ou se terminer par "*" comme joker) (optionnel)
+| guile | guile_script | liste des scripts | pointeur vers le script (optionnel) | nom de script (peut démarrer ou se terminer par "*" comme joker) (optionnel)
+
| irc | irc_channel | liste des canaux pour un serveur IRC | pointeur vers le canal (optionnel) | serveur,canal (le canal est optionnel)
| irc | irc_ignore | liste des ignores IRC | pointeur vers l'ignore (optionnel) | -
diff --git a/doc/fr/autogen/user/guile_commands.txt b/doc/fr/autogen/user/guile_commands.txt
new file mode 100644
index 000000000..7e4a99e62
--- /dev/null
+++ b/doc/fr/autogen/user/guile_commands.txt
@@ -0,0 +1,20 @@
+[[command_guile_guile]]
+[command]*`guile`* lister/charger/décharger des scripts::
+........................................
+/guile list|listfull [<nom>]
+ load <fichier>
+ autoload
+ reload|unload [<nom>]
+
+ list: lister les scripts chargés
+listfull: lister les scripts chargés (verbeux)
+ load: charger un script
+autoload: charger tous les scripts dans le répertoire "autoload"
+ reload: recharger un script (si pas de nom donné, décharger tous les scripts puis charger tous les scripts dans le répertoire "autoload")
+ unload: décharger un script (si pas de nom donné, décharger tous les scripts)
+ fichier: script (fichier) à charger
+ nom: nom de script (nom utilisé dans l'appel à la fonction "register")
+
+Sans paramètre, cette commande liste les scripts chargés.
+........................................
+
diff --git a/doc/fr/weechat_scripting.fr.txt b/doc/fr/weechat_scripting.fr.txt
index e3672f7b2..32173cfd9 100644
--- a/doc/fr/weechat_scripting.fr.txt
+++ b/doc/fr/weechat_scripting.fr.txt
@@ -18,7 +18,14 @@ WeeChat (Wee Enhanced Environment for Chat) est un client de discussion libre,
rapide et léger, conçu pour différents systèmes d'exploitation.
Ce manuel documente la façon d'écrire des scripts pour WeeChat, en utilisant
-l'un des cinq langages de script supportés : perl, python, ruby, lua ou tcl.
+l'un des langages de script supportés :
+
+* python
+* perl
+* ruby
+* lua
+* tcl
+* guile (scheme)
[NOTE]
La majorité des exemples de cette documentation sont écrits en Python, mais
@@ -32,20 +39,45 @@ Scripts dans WeeChat
Spécificités des langages
~~~~~~~~~~~~~~~~~~~~~~~~~
-Quelques choses sont spécifiques aux langages :
+Python
+^^^^^^
-* perl :
-** les fonctions sont appelées par `weechat::xxx(arg1, arg2, ...);`
-* python :
-** vous devez utiliser `import weechat`
-** les fonctions `print*` se nomment `prnt*` en python (car 'print' est un mot
- clé réservé)
-** les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...)`
-* ruby :
-** vous devez définir 'weechat_init' et appeler 'register' dedans
-** les fonctions sont appelées par `Weechat.xxx(arg1, arg2, ...)`
-* tcl :
-** les fonctions sont appelées par `weechat::xxx arg1 arg2 ...`
+* Vous devez utiliser `import weechat`
+* Les fonctions `print*` se nomment `prnt*` en python (car 'print' est un mot
+ clé réservé)
+* Les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...)`
+
+Perl
+^^^^
+
+* Les fonctions sont appelées par `weechat::xxx(arg1, arg2, ...);`
+
+Ruby
+^^^^
+
+* Vous devez définir 'weechat_init' et appeler 'register' dedans
+* Les fonctions sont appelées par `Weechat.xxx(arg1, arg2, ...)`
+
+Lua
+^^^
+
+* Les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...)`
+
+Tcl
+^^^
+
+* Les fonctions sont appelées par `weechat::xxx arg1 arg2 ...`
+
+Guile (scheme)
+^^^^^^^^^^^^^^
+
+* Les fonctions sont appelées par `(weechat:xxx arg1 arg2 ...)`
+* Les fonctions suivantes prennent une liste de paramètres en entrée (au lieu
+ de plusieurs paramètres pour les autres fonctions), car le nombre de
+ paramètres excède la limite de Guile :
+** config_new_section
+** config_new_option
+** bar_new
[[register_function]]
Fonction register
@@ -76,14 +108,6 @@ Paramètres :
Exemple, pour chaque langage :
-* perl :
-
-[source,perl]
-----------------------------------------
-weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Script de test", "", "");
-weechat::print("", "Bonjour, du script perl !");
-----------------------------------------
-
* python :
[source,python]
@@ -94,6 +118,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Script de test", ""
weechat.prnt("", "Bonjour, du script python !")
----------------------------------------
+* perl :
+
+[source,perl]
+----------------------------------------
+weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Script de test", "", "");
+weechat::print("", "Bonjour, du script perl !");
+----------------------------------------
+
* ruby :
[source,ruby]
@@ -115,12 +147,20 @@ weechat.print("", "Bonjour, du script lua !")
* tcl :
-// [source,tcl]
+[source,tcl]
----------------------------------------
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Script de test" "" ""
weechat::print "" "Bonjour, du script tcl !"
----------------------------------------
+* guile (scheme):
+
+[source,lisp]
+----------------------------------------
+(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Script de test" "" "")
+(weechat:print "" "Bonjour, du script scheme !")
+----------------------------------------
+
[[load_script]]
Chargement du script
~~~~~~~~~~~~~~~~~~~~
@@ -128,11 +168,12 @@ Chargement du script
Vous devez utiliser la commande, dépendant du langage :
----------------------------------------
-/perl load perl/script.pl
/python load python/script.py
+/perl load perl/script.pl
/ruby load ruby/script.rb
/lua load lua/script.lua
/tcl load tcl/script.tcl
+/guile load guile/script.scm
----------------------------------------
Vous pouvez faire un lien dans le répertoire 'langage/autoload' pour charger
diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt
index ae4a135dd..641c57633 100644
--- a/doc/fr/weechat_user.fr.txt
+++ b/doc/fr/weechat_user.fr.txt
@@ -88,23 +88,24 @@ Dépendances
Le tableau suivant liste les paquets qui sont requis ou optionnels pour
compiler WeeChat.
-[width="80%",cols="4,^2,13",options="header"]
+[width="100%",cols="5,^3,^3,13",options="header"]
|========================================
-| Paquet ^(1)^ | Requis | Fonctionnalité
-| cmake | *oui* | construction (autotools toujours possible, mais cmake est recommandé)
-| libncursesw5-dev ^(2)^ | *oui* | interface ncurses
-| gettext | non | internationalisation (traduction des messages; la langue de base est l'anglais)
-| libgcrypt11-dev | non | authentification SASL avec le serveur IRC, en utilisant le mécanisme DH-BLOWFISH
-| libgnutls-dev (≥ 2.2.0) | non | connexion SSL au serveur IRC
-| ca-certificates | no | certificats pour les connexions SSL
-| libaspell-dev | non | extension aspell
-| libperl-dev | non | extension perl
-| python-dev | non | extension python
-| ruby1.8-dev | non | extension ruby
-| liblua5.1-0-dev | non | extension lua
-| tcl-dev (≥ 8.5) | non | extension tcl
-| asciidoc (≥ 8.5.0) | non | construction de la documentation (fichiers HTML)
-| source-highlight | non | coloration des sources dans la documentation HTML
+| Paquet ^(1)^ | Version | Requis | Fonctionnalité
+| cmake | | *oui* | construction (autotools toujours possible, mais cmake est recommandé)
+| libncursesw5-dev ^(2)^ | | *oui* | interface ncurses
+| gettext | | | internationalisation (traduction des messages; la langue de base est l'anglais)
+| libgcrypt11-dev | | | authentification SASL avec le serveur IRC, en utilisant le mécanisme DH-BLOWFISH
+| libgnutls-dev | ≥ 2.2.0 | | connexion SSL au serveur IRC
+| ca-certificates | | | certificats pour les connexions SSL
+| libaspell-dev | | | extension aspell
+| python-dev | 2.5 → 2.7 | | extension python
+| libperl-dev | | | extension perl
+| ruby1.8-dev | | | extension ruby
+| liblua5.1-0-dev | | | extension lua
+| tcl-dev | ≥ 8.5 | | extension tcl
+| guile-1.8-dev | | | extention guile (scheme)
+| asciidoc | ≥ 8.5.0 | | construction de la documentation (fichiers HTML)
+| source-highlight | | | coloration des sources dans la documentation HTML
|========================================
[NOTE]
@@ -1020,7 +1021,7 @@ WeeChat tourne.
Il est important de bien faire la différence entre une 'extension' et un
'script' : une 'extension' est un fichier binaire compilé et chargé avec la
commande `/plugin`, tandis qu'un 'script' est un fichier texte chargé par une
-extension comme 'perl' par la commande `perl`.
+extension comme 'python' par la commande `/python`.
Vous pouvez utiliser la commande `/plugin` pour charger/décharger une
extension, ou afficher les extensions chargées.
@@ -1049,11 +1050,12 @@ Les extensions par défaut sont :
| logger | Enregistrement des tampons dans des fichiers
| relay | Relai de données via le réseau (proxy IRC)
| rmodifier | Modification des chaînes de "modifier" avec des expressions régulières
-| perl | Interface (API) pour scripts Perl
| python | Interface (API) pour scripts Python
+| perl | Interface (API) pour scripts Perl
| ruby | Interface (API) pour scripts Ruby
| lua | Interface (API) pour scripts Lua
| tcl | Interface (API) pour scripts Tcl
+| guile | Interface (API) pour scripts Guile (scheme)
| xfer | Transfert de fichier et discussion directe
|========================================
@@ -1258,11 +1260,11 @@ $ echo 'irc.freenode.#weechat *bonjour !' >~/.weechat/weechat_fifo_12345
$ echo '*bonjour !' >~/.weechat/weechat_fifo_12345
----------------------------------------
-* envoyer deux commandes pour décharger/recharger les scripts Perl (vous devez
+* envoyer deux commandes pour décharger/recharger les scripts Python (vous devez
les séparer par "\n") :
----------------------------------------
-$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
+$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
----------------------------------------
Vous pouvez écrire un script qui envoie les commandes à tous les WeeChat qui
@@ -1971,7 +1973,8 @@ sera : `/oper nick ********`.
Extensions Scripts
~~~~~~~~~~~~~~~~~~
-WeeChat fournit 5 extensions pour scripts : Perl, Python, Ruby, Lua et Tcl.
+WeeChat fournit 6 extensions pour scripts : Python, Perl, Ruby, Lua, Tcl et
+Guile (scheme).
Ces extensions peuvent charger, exécuter et décharger des scripts pour ces
langages.
@@ -1981,18 +1984,18 @@ WeeChat pour les scripts, merci de lire le 'Le Guide pour Scripts WeeChat'.
Vous pouvez trouver des scripts pour WeeChat ici :
http://www.weechat.org/scripts
-[[perl_commands]]
-Commandes Perl
-^^^^^^^^^^^^^^
-
-include::autogen/user/perl_commands.txt[]
-
[[python_commands]]
Commandes Python
^^^^^^^^^^^^^^^^
include::autogen/user/python_commands.txt[]
+[[perl_commands]]
+Commandes Perl
+^^^^^^^^^^^^^^
+
+include::autogen/user/perl_commands.txt[]
+
[[ruby_commands]]
Commandes Ruby
^^^^^^^^^^^^^^
@@ -2011,6 +2014,12 @@ Commandes Tcl
include::autogen/user/tcl_commands.txt[]
+[[guile_commands]]
+Commandes Guile
+^^^^^^^^^^^^^^^
+
+include::autogen/user/guile_commands.txt[]
+
[[xfer_plugin]]
Extension Xfer
~~~~~~~~~~~~~~
diff --git a/doc/it/autogen/plugin_api/completions.txt b/doc/it/autogen/plugin_api/completions.txt
index 8d145f62b..3d8b2a5cc 100644
--- a/doc/it/autogen/plugin_api/completions.txt
+++ b/doc/it/autogen/plugin_api/completions.txt
@@ -8,6 +8,8 @@
| aspell | aspell_langs | elenco di lingue supportate per aspell
+| guile | guile_script | elenco degli script
+
| irc | irc_channel | canale IRC corrente
| irc | irc_channel_nicks_hosts | nick e host del canale IRC corrente
diff --git a/doc/it/autogen/plugin_api/infolists.txt b/doc/it/autogen/plugin_api/infolists.txt
index 70cfd165f..7dcf002ef 100644
--- a/doc/it/autogen/plugin_api/infolists.txt
+++ b/doc/it/autogen/plugin_api/infolists.txt
@@ -4,6 +4,8 @@
| alias | alias | elenco di alias | puntatore all'alias (opzionale) | nome alias (può iniziare o terminare con "*" come carattere jolly) (opzionale)
+| guile | guile_script | elenco degli script | puntatore allo script (opzionale) | nome script (può iniziare o terminare con "*" come carattere jolly) (opzionale)
+
| irc | irc_channel | elenco dei canali per un server IRC | puntatore al canale (opzionale) | server,canale (canale è opzionale)
| irc | irc_ignore | elenco di ignore IRC | puntatore all'ignore (opzionale) | -
diff --git a/doc/it/autogen/user/guile_commands.txt b/doc/it/autogen/user/guile_commands.txt
new file mode 100644
index 000000000..989c5e3fa
--- /dev/null
+++ b/doc/it/autogen/user/guile_commands.txt
@@ -0,0 +1,20 @@
+[[command_guile_guile]]
+[command]*`guile`* elenca/carica/scarica script::
+........................................
+/guile list|listfull [<nome>]
+ load <nomefile>
+ autoload
+ reload|unload [<nome>]
+
+ list: elenca i plugin caricati
+ listfull: elenca i plugin caricati (dettagliato)
+ load: carica un plugin
+ autoload: carica automaticamente i plugin nella cartella utente o di sistema
+ reload: ricarica un plugin (se non specificato, scarica i plugin e li ricarica automaticamente)
+ unload: scarica uno o tutti i plugin
+nome_file: (file) script da caricare
+ nome: il nome di uno script (usato nella chiamata alla funzione "register")
+
+Senza argomento, questo comando elenca tutti i plugin caricati.
+........................................
+
diff --git a/doc/it/weechat_scripting.it.txt b/doc/it/weechat_scripting.it.txt
index 0f72b68b2..912c10552 100644
--- a/doc/it/weechat_scripting.it.txt
+++ b/doc/it/weechat_scripting.it.txt
@@ -17,9 +17,16 @@ Introduzione
WeeChat (Wee Enhanced Environment for Chat) è un client di chat libero,
veloce e leggero, realizzato per molti sistemi operativi.
-Questo manuale documenta i metodi per la realizzazione di script per
-WeeChat, utilizzando uno dei cinque linguaggi di script supportati: perl,
-python, ruby, lua o tcl.
+// TRANSLATION MISSING
+This manual documents way to write scripts for WeeChat, using one of supported
+script languages:
+
+* python
+* perl
+* ruby
+* lua
+* tcl
+* guile (scheme)
[NOTE]
Quasi tutti gli esempi in questo manuale sono scritti in Python, ma l'API
@@ -33,20 +40,46 @@ Script in WeeChat
Specifiche per i linguaggi
~~~~~~~~~~~~~~~~~~~~~~~~~~
-Alcune cose sono specifiche per i linguaggi:
+Python
+^^^^^^
-* perl:
-** le funzioni sono chiamate con `weechat::xxx(arg1, arg2, ...);`
-* python:
-** è necessario `import weechat`
-** le funzioni `print*` sono chiamate `prnt*` in python (dato che 'print'
- è una parola riservata)
-** le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...)`
-* ruby:
-** è necessario definire 'weechat_init' e chiamare 'register' all'interno
-** le funzioni sono chiamate con `Weechat.xxx(arg1, arg2, ...)`
-* tcl:
-** le funzioni sono chiamate con `weechat::xxx arg1 arg2 ...`
+* E necessario `import weechat`
+* Le funzioni `print*` sono chiamate `prnt*` in python (dato che 'print'
+ è una parola riservata)
+* Le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...)`
+
+Perl
+^^^^
+
+* Le funzioni sono chiamate con `weechat::xxx(arg1, arg2, ...);`
+
+Ruby
+^^^^
+
+* E necessario definire 'weechat_init' e chiamare 'register' all'interno
+* Le funzioni sono chiamate con `Weechat.xxx(arg1, arg2, ...)`
+
+Lua
+^^^
+
+* Le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...)`
+
+Tcl
+^^^
+
+* Le funzioni sono chiamate con `weechat::xxx arg1 arg2 ...`
+
+Guile (scheme)
+^^^^^^^^^^^^^^
+
+// TRANSLATION MISSING
+* Functions are called with `(weechat:xxx arg1 arg2 ...)`
+* Following functions take one list of arguments (instead of many arguments
+ for other functions), because number of arguments exceed number of allowed
+ arguments in Guile:
+** config_new_section
+** config_new_option
+** bar_new
[[register_function]]
Registrare una funzione
@@ -76,14 +109,6 @@ Argomenti:
Esempio di script, per ogni linguaggio:
-* perl:
-
-[source,perl]
-----------------------------------------
-weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
-weechat::print("", "Hello, from perl script!");
-----------------------------------------
-
* python:
[source,python]
@@ -94,6 +119,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Test script", "", "
weechat.prnt("", "Hello, from python script!")
----------------------------------------
+* perl:
+
+[source,perl]
+----------------------------------------
+weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
+weechat::print("", "Hello, from perl script!");
+----------------------------------------
+
* ruby:
[source,ruby]
@@ -115,12 +148,20 @@ weechat.print("", "Hello, from lua script!")
* tcl:
-// [source,tcl]
+[source,tcl]
----------------------------------------
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Test script" "" ""
weechat::print "" "Hello, from tcl script!"
----------------------------------------
+* guile (scheme):
+
+[source,lisp]
+----------------------------------------
+(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
+(weechat:print "" "Hello, from scheme script!")
+----------------------------------------
+
[[load_script]]
Caricare uno script
~~~~~~~~~~~~~~~~~~~
@@ -128,11 +169,12 @@ Caricare uno script
Il comando da utilizzare, in base al linguaggio:
----------------------------------------
-/perl load perl/script.pl
/python load python/script.py
+/perl load perl/script.pl
/ruby load ruby/script.rb
/lua load lua/script.lua
/tcl load tcl/script.tcl
+/guile load guile/script.scm
----------------------------------------
È possibile creare un link nella cartella 'linguaggio/autoload' per caricare
diff --git a/doc/it/weechat_user.it.txt b/doc/it/weechat_user.it.txt
index c15b210b7..c9ec6f63f 100644
--- a/doc/it/weechat_user.it.txt
+++ b/doc/it/weechat_user.it.txt
@@ -90,23 +90,24 @@ Dipendenze
La seguente tabella mostra l'elenco di pacchetti richiesti o opzionali per
compilare WeeChat.
-[width="80%",cols="4,^2,13",options="header"]
+[width="100%",cols="5,^3,^3,13",options="header"]
|========================================
-| Pacchetto ^(1)^ | Richiesto | Caratteristica
-| cmake | *sì* | compilazione (ancora possibile con autotools, ma si raccomanda cmake)
-| libncursesw5-dev ^(2)^ | *sì* | interfaccia ncurses
-| gettext | no | internazionalizzazione (traduzione dei messaggi; la lingua base è l'inglese)
-| libgcrypt11-dev | no | autenticazione SASL per i server IRC che utilizzano il meccanismo DH-BLOWFISH
-| libgnutls-dev (≥ 2.2.0) | no | connessione SSL al server IRC
-| ca-certificates | no | certificati per le connessioni SSL
-| libaspell-dev | no | plugin aspell
-| libperl-dev | no | plugin perl
-| python-dev | no | plugin python
-| ruby1.8-dev | no | plugin ruby
-| liblua5.1-0-dev | no | plugin lua
-| tcl-dev (≥ 8.5) | no | plugin tcl
-| asciidoc (≥ 8.5.0) | no | compilazione della documentazione (file HTML)
-| source-highlight | no | evidenziazione della sintassi per i sorgenti nella documentazione HTML
+| Pacchetto ^(1)^ | Versione | Richiesto | Caratteristica
+| cmake | | *sì* | compilazione (ancora possibile con autotools, ma si raccomanda cmake)
+| libncursesw5-dev ^(2)^ | | *sì* | interfaccia ncurses
+| gettext | | | internazionalizzazione (traduzione dei messaggi; la lingua base è l'inglese)
+| libgcrypt11-dev | | | autenticazione SASL per i server IRC che utilizzano il meccanismo DH-BLOWFISH
+| libgnutls-dev | ≥ 2.2.0 | | connessione SSL al server IRC
+| ca-certificates | | | certificati per le connessioni SSL
+| libaspell-dev | | | plugin aspell
+| python-dev | 2.5 → 2.7 | | plugin python
+| libperl-dev | | | plugin perl
+| ruby1.8-dev | | | plugin ruby
+| liblua5.1-0-dev | | | plugin lua
+| tcl-dev | ≥ 8.5 | | plugin tcl
+| guile-1.8-dev | | | plugin guile (scheme)
+| asciidoc | ≥ 8.5.0 | | compilazione della documentazione (file HTML)
+| source-highlight | | | evidenziazione della sintassi per i sorgenti nella documentazione HTML
|========================================
[NOTE]
@@ -1011,8 +1012,8 @@ I plugin trovati vengono caricati automaticamente all'avvio di WeeChat, ed
È importante evidenziare la differenza tra un 'plugin' ed uno 'script': un
'plugin' è un file binario compilato e caricato con il comando `/plugin`,
-mentre uno 'script' è un file di testo caricato con un plugin come 'perl'
-con il comando `/perl`.
+mentre uno 'script' è un file di testo caricato con un plugin come 'python'
+con il comando `/python`.
È possibile utilizzare il comando `/plugin` per caricare/scaricare un plugin,
oppure elencare tutti i plugin caricati.
@@ -1041,11 +1042,12 @@ I plugin predefiniti sono:
| logger | Registra i buffer su file
| relay | Relay dei dati via rete (proxy IRC)
| rmodifier | Cambia le stringhe del modificatore con espressioni regolari
-| perl | API per lo scripting in Perl
| python | API per lo scripting in Python
+| perl | API per lo scripting in Perl
| ruby | API per lo scripting in Ruby
| lua | API per lo scripting in Lua
| tcl | API per lo scripting in TCL
+| guile | API per lo scripting in Guile (scheme)
| xfer | Trasferimento file e chat diretta
|=======================================
@@ -1244,11 +1246,11 @@ $ echo 'irc.freenode.#weechat *hello!' >~/.weechat/weechat_fifo_12345
$ echo '*hello!' >~/.weechat/weechat_fifo_12345
----------------------------------------
-* inviare due comandi per scaricare/caricare gli script Perl (è necessario
+* inviare due comandi per scaricare/caricare gli script Python (è necessario
separarli con "\n"):
----------------------------------------
-$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
+$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
----------------------------------------
È possibile realizzare uno script per inviare un comando a tutte le istanze di
@@ -1956,7 +1958,8 @@ Se la riga di comando contiene: `/oper nick password` allora sullo schermo diven
Plugin per gli script
~~~~~~~~~~~~~~~~~~~~~
-WeeChat fornisce 5 plugin per lo scripting: Perl, Python, Ruby, Lua, Tcl.
+WeeChat fornisce 6 plugin per lo scripting: Python, Perl, Ruby, Lua, Tcl, Guile
+(scheme).
Questi plugin possono caricare, eseguire e scaricare gli script per questi
linguaggi.
@@ -1965,18 +1968,18 @@ per gli script, consultare la 'Guida allo Scripting di WeeChat'.
È possibile trovare alcuni script qui: http://www.weechat.org/scripts
-[[perl_commands]]
-Comandi Perl
-^^^^^^^^^^^^
-
-include::autogen/user/perl_commands.txt[]
-
[[python_commands]]
Comandi Python
^^^^^^^^^^^^^^
include::autogen/user/python_commands.txt[]
+[[perl_commands]]
+Comandi Perl
+^^^^^^^^^^^^
+
+include::autogen/user/perl_commands.txt[]
+
[[ruby_commands]]
Comandi Ruby
^^^^^^^^^^^^
@@ -1995,6 +1998,12 @@ Comandi Tcl
include::autogen/user/tcl_commands.txt[]
+[[guile_commands]]
+Comandi Guile
+^^^^^^^^^^^^^
+
+include::autogen/user/guile_commands.txt[]
+
[[xfer_plugin]]
Plugin Xfer
~~~~~~~~~~~
diff --git a/doc/pl/weechat_scripting.pl.txt b/doc/pl/weechat_scripting.pl.txt
index a2fcce3ca..497e8ae7f 100644
--- a/doc/pl/weechat_scripting.pl.txt
+++ b/doc/pl/weechat_scripting.pl.txt
@@ -16,8 +16,16 @@ Wprowadzenie
WeeChat (Wee Enhanced Environment for Chat) jest darmowym klientem rozmów, szybkim
i lekkim, zaprojektowanym dla wielu systemów operacyjnych.
-Ten podręcznik dokumentuje sposób pisania skryptów dla WeeChat, używając jednego
-z pięciu wspieranych języków skryptowych: perl, python, ruby, lua lub tcl.
+// TRANSLATION MISSING
+This manual documents way to write scripts for WeeChat, using one of supported
+script languages:
+
+* python
+* perl
+* ruby
+* lua
+* tcl
+* guile (scheme)
[NOTE]
Prawie wszystkie przykłady umieszczone w tym dokumencie są napisane w Pythonie,
@@ -31,20 +39,46 @@ Skrypty w WeeChat
Specyfika języków
~~~~~~~~~~~~~~~~~
-Niektóre rzeczy są specyficzne dla danego języka:
+Python
+^^^^^^
-* perl:
-** funkcje są wywoływane za pomocą `weechat::xxx(arg1, arg2, ...);`
-* python:
-** należy wykonać `import weechat`
-** funkcje `print*` są nazwane `prnt*` w pythonie (ponieważ 'print' jest zastrzeżonym
- słowem kluczowym)
-** funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...)`
-* ruby:
-** trzeba zdefiniować 'weechat_init' i wywołać 'register' wewnątrz
-** funkcje są wywoływane za pomocą `Weechat.xxx(arg1, arg2, ...)`
-* tcl:
-** funkcje są wywoływane za pomocą `weechat::xxx arg1 arg2 ...`
+* Należy wykonać `import weechat`
+* Funkcje `print*` są nazwane `prnt*` w pythonie (ponieważ 'print' jest zastrzeżonym
+ słowem kluczowym)
+* Funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...)`
+
+Perl
+^^^^
+
+* Funkcje są wywoływane za pomocą `weechat::xxx(arg1, arg2, ...);`
+
+Ruby
+^^^^
+
+* Trzeba zdefiniować 'weechat_init' i wywołać 'register' wewnątrz
+* Funkcje są wywoływane za pomocą `Weechat.xxx(arg1, arg2, ...)`
+
+Lua
+^^^
+
+* Funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...)`
+
+Tcl
+^^^
+
+* Funkcje są wywoływane za pomocą `weechat::xxx arg1 arg2 ...`
+
+Guile (scheme)
+^^^^^^^^^^^^^^
+
+// TRANSLATION MISSING
+* Functions are called with `(weechat:xxx arg1 arg2 ...)`
+* Following functions take one list of arguments (instead of many arguments
+ for other functions), because number of arguments exceed number of allowed
+ arguments in Guile:
+** config_new_section
+** config_new_option
+** bar_new
[[register_function]]
Funkcja rejestrująca
@@ -73,14 +107,6 @@ Argumenty:
Przykład dla skryptu w każdym z języków:
-* perl:
-
-[source,perl]
-----------------------------------------
-weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Skrypt testowy", "", "");
-weechat::print("", "Witaj, z perlowego skryptu!");
-----------------------------------------
-
* python:
[source,python]
@@ -91,6 +117,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Skrypt testowy", ""
weechat.prnt("", "Witaj, z pythonowego skryptu!")
----------------------------------------
+* perl:
+
+[source,perl]
+----------------------------------------
+weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Skrypt testowy", "", "");
+weechat::print("", "Witaj, z perlowego skryptu!");
+----------------------------------------
+
* ruby:
[source,ruby]
@@ -112,12 +146,20 @@ weechat.print("", "Witaj, ze skryptu lua!")
* tcl:
-// [source,tcl]
+[source,tcl]
----------------------------------------
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Skrypt testowy" "" ""
weechat::print "" "Witaj, ze skryptu tcl!"
----------------------------------------
+* guile (scheme):
+
+[source,lisp]
+----------------------------------------
+(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
+(weechat:print "" "Hello, from scheme script!")
+----------------------------------------
+
[[load_script]]
Ładowanie skryptu
~~~~~~~~~~~~~~~~~
@@ -125,11 +167,12 @@ weechat::print "" "Witaj, ze skryptu tcl!"
Musisz użyć komendy dla danego języka:
----------------------------------------
-/perl load perl/skrypt.pl
/python load python/skrypt.py
+/perl load perl/skrypt.pl
/ruby load ruby/skrypt.rb
/lua load lua/skrypt.lua
/tcl load tcl/skrypt.tcl
+/guile load guile/skrypt.scm
----------------------------------------
Możesz zrobić dowiązanie w katalogu 'język/autoload' jeśli chcesz automatycznie
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fd880ee57..0ec6a5cd7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -213,6 +213,10 @@
./src/plugins/rmodifier/rmodifier.h
./src/plugins/rmodifier/rmodifier-info.c
./src/plugins/rmodifier/rmodifier-info.h
+./src/plugins/scripts/guile/weechat-guile-api.c
+./src/plugins/scripts/guile/weechat-guile-api.h
+./src/plugins/scripts/guile/weechat-guile.c
+./src/plugins/scripts/guile/weechat-guile.h
./src/plugins/scripts/lua/weechat-lua-api.c
./src/plugins/scripts/lua/weechat-lua-api.h
./src/plugins/scripts/lua/weechat-lua.c
diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake
index 0f994b4f2..6923c4548 100644
--- a/po/srcfiles.cmake
+++ b/po/srcfiles.cmake
@@ -214,6 +214,10 @@ SET(WEECHAT_SOURCES
./src/plugins/rmodifier/rmodifier.h
./src/plugins/rmodifier/rmodifier-info.c
./src/plugins/rmodifier/rmodifier-info.h
+./src/plugins/scripts/guile/weechat-guile-api.c
+./src/plugins/scripts/guile/weechat-guile-api.h
+./src/plugins/scripts/guile/weechat-guile.c
+./src/plugins/scripts/guile/weechat-guile.h
./src/plugins/scripts/lua/weechat-lua-api.c
./src/plugins/scripts/lua/weechat-lua-api.h
./src/plugins/scripts/lua/weechat-lua.c
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index e884731d3..04ab71f2d 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -74,9 +74,9 @@ 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)
+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)
+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 )
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index c43ea99ba..0b8f1dc82 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -86,6 +86,10 @@ if PLUGIN_TCL
script_dir = scripts
endif
+if PLUGIN_GUILE
+script_dir = scripts
+endif
+
if PLUGIN_XFER
xfer_dir = xfer
endif
diff --git a/src/plugins/scripts/CMakeLists.txt b/src/plugins/scripts/CMakeLists.txt
index 02e929a35..f00b5172c 100644
--- a/src/plugins/scripts/CMakeLists.txt
+++ b/src/plugins/scripts/CMakeLists.txt
@@ -58,3 +58,10 @@ IF(ENABLE_TCL)
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
index b115e8929..8692e499c 100644
--- a/src/plugins/scripts/Makefile.am
+++ b/src/plugins/scripts/Makefile.am
@@ -48,6 +48,10 @@ if PLUGIN_TCL
tcl_dir = tcl
endif
-SUBDIRS = . $(perl_dir) $(python_dir) $(ruby_dir) $(lua_dir) $(tcl_dir)
+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/guile/CMakeLists.txt b/src/plugins/scripts/guile/CMakeLists.txt
new file mode 100644
index 000000000..f4549fec2
--- /dev/null
+++ b/src/plugins/scripts/guile/CMakeLists.txt
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2011 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/>.
+#
+
+ADD_LIBRARY(guile MODULE weechat-guile.c weechat-guile.h
+weechat-guile-api.c weechat-guile-api.h)
+
+SET_TARGET_PROPERTIES(guile PROPERTIES PREFIX "")
+
+IF(GUILE_FOUND)
+ INCLUDE_DIRECTORIES(${GUILE_INCLUDE_PATH})
+ SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GUILE_LFLAGS}")
+ TARGET_LINK_LIBRARIES(guile ${GUILE_LIBRARY} weechat_scripts)
+ENDIF(GUILE_FOUND)
+
+INSTALL(TARGETS guile LIBRARY DESTINATION ${LIBDIR}/plugins)
diff --git a/src/plugins/scripts/guile/Makefile.am b/src/plugins/scripts/guile/Makefile.am
new file mode 100644
index 000000000..7cf79b4e2
--- /dev/null
+++ b/src/plugins/scripts/guile/Makefile.am
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 2011 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\" $(GUILE_CFLAGS)
+
+libdir = ${weechat_libdir}/plugins
+
+lib_LTLIBRARIES = guile.la
+
+guile_la_SOURCES = weechat-guile.c \
+ weechat-guile.h \
+ weechat-guile-api.c \
+ weechat-guile-api.h
+guile_la_LDFLAGS = -module
+guile_la_LIBADD = ../lib_weechat_plugins_scripts.la $(GUILE_LFLAGS)
+
+EXTRA_DIST = CMakeLists.txt
diff --git a/src/plugins/scripts/guile/weechat-guile-api.c b/src/plugins/scripts/guile/weechat-guile-api.c
new file mode 100644
index 000000000..8d5856976
--- /dev/null
+++ b/src/plugins/scripts/guile/weechat-guile-api.c
@@ -0,0 +1,5502 @@
+/*
+ * Copyright (C) 2011 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/>.
+ */
+
+/*
+ * weechat-guile-api.c: guile API functions
+ */
+
+#undef _
+
+#include <libguile.h>
+#include <time.h>
+
+#include "../../weechat-plugin.h"
+#include "../script.h"
+#include "../script-api.h"
+#include "../script-callback.h"
+#include "weechat-guile.h"
+
+
+#define API_FUNC(__init, __name, __ret) \
+ char *guile_function_name = __name; \
+ if (__init \
+ && (!guile_current_script || !guile_current_script->name)) \
+ { \
+ WEECHAT_SCRIPT_MSG_NOT_INIT(GUILE_CURRENT_SCRIPT_NAME, \
+ guile_function_name); \
+ __ret; \
+ }
+#define API_WRONG_ARGS(__ret) \
+ { \
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(GUILE_CURRENT_SCRIPT_NAME, \
+ guile_function_name); \
+ __ret; \
+ }
+#define API_RETURN_OK return SCM_BOOL_T;
+#define API_RETURN_ERROR return SCM_BOOL_F;
+#define API_RETURN_EMPTY \
+ return scm_from_locale_string("");
+#define API_RETURN_STRING(__string) \
+ if (__string) \
+ return scm_from_locale_string(__string); \
+ return scm_from_locale_string("")
+#define API_RETURN_STRING_FREE(__string) \
+ if (__string) \
+ { \
+ return_value = scm_from_locale_string (__string); \
+ free (__string); \
+ return return_value; \
+ } \
+ return scm_from_locale_string("")
+#define API_RETURN_INT(__int) \
+ return scm_from_int (__int);
+#define API_RETURN_LONG(__long) \
+ return scm_from_long (__long);
+
+
+/*
+ * weechat_guile_api_register: startup function for all WeeChat Guile scripts
+ */
+
+SCM
+weechat_guile_api_register (SCM name, SCM author, SCM version, SCM license,
+ SCM description, SCM shutdown_func, SCM charset)
+{
+ API_FUNC(0, "register", API_RETURN_ERROR);
+ guile_current_script = NULL;
+ guile_registered_script = NULL;
+ if (!scm_is_string (name) || !scm_is_string (author)
+ || !scm_is_string (version) || !scm_is_string (license)
+ || !scm_is_string (description) || !scm_is_string (shutdown_func)
+ || !scm_is_string (charset))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ if (script_search (weechat_guile_plugin, guile_scripts,
+ scm_i_string_chars (name)))
+ {
+ /* error: another scripts already exists with this name! */
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: unable to register script "
+ "\"%s\" (another script already "
+ "exists with this name)"),
+ weechat_prefix ("error"), GUILE_PLUGIN_NAME, name);
+ API_RETURN_ERROR;
+ }
+
+ /* 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));
+ if (guile_current_script)
+ {
+ guile_registered_script = guile_current_script;
+ if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s: registered script \"%s\", "
+ "version %s (%s)"),
+ GUILE_PLUGIN_NAME,
+ scm_i_string_chars (name),
+ scm_i_string_chars (version),
+ scm_i_string_chars (description));
+ }
+ }
+ else
+ {
+ API_RETURN_ERROR;
+ }
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_plugin_get_name: get name of plugin (return "core" for
+ * WeeChat core)
+ */
+
+SCM
+weechat_guile_api_plugin_get_name (SCM plugin)
+{
+ const char *result;
+
+ API_FUNC(1, "plugin_get_name", API_RETURN_EMPTY);
+ if (!scm_is_string (plugin))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_plugin_get_name (script_str2ptr (scm_i_string_chars (plugin)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_charset_set: set script charset
+ */
+
+SCM
+weechat_guile_api_charset_set (SCM charset)
+{
+ API_FUNC(1, "charset_set", API_RETURN_ERROR);
+ if (!scm_is_string (charset))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_charset_set (guile_current_script, scm_i_string_chars (charset));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_iconv_to_internal: convert string to internal WeeChat charset
+ */
+
+SCM
+weechat_guile_api_iconv_to_internal (SCM charset, SCM string)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "iconv_to_internal", API_RETURN_EMPTY);
+ if (!scm_is_string (charset) || !scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_iconv_to_internal (scm_i_string_chars (charset),
+ scm_i_string_chars (string));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_iconv_from_internal: convert string from WeeChat internal
+ * charset to another one
+ */
+
+SCM
+weechat_guile_api_iconv_from_internal (SCM charset, SCM string)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "iconv_from_internal", API_RETURN_EMPTY);
+ if (!scm_is_string (charset) || !scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_iconv_from_internal (scm_i_string_chars (charset),
+ scm_i_string_chars (string));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_gettext: get translated string
+ */
+
+SCM
+weechat_guile_api_gettext (SCM string)
+{
+ const char *result;
+
+ API_FUNC(1, "gettext", API_RETURN_EMPTY);
+ if (!scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_gettext (scm_i_string_chars (string));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_ngettext: get translated string with plural form
+ */
+
+SCM
+weechat_guile_api_ngettext (SCM single, SCM plural, SCM count)
+{
+ const char *result;
+
+ API_FUNC(1, "ngettext", API_RETURN_EMPTY);
+ if (!scm_is_string (single) || !scm_is_string (plural)
+ || !scm_is_integer (count))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_ngettext (scm_i_string_chars (single),
+ scm_i_string_chars (plural),
+ scm_to_int (count));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_string_match: return 1 if string matches a mask
+ * mask can begin or end with "*", no other "*"
+ * are allowed inside mask
+ */
+
+SCM
+weechat_guile_api_string_match (SCM string, SCM mask, SCM case_sensitive)
+{
+ int value;
+
+ API_FUNC(1, "string_match", API_RETURN_INT(0));
+ if (!scm_is_string (string) || !scm_is_string (mask)
+ || !scm_is_integer (case_sensitive))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_string_match (scm_i_string_chars (string),
+ scm_i_string_chars (mask),
+ scm_to_int (case_sensitive));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_string_has_highlight: return 1 if string contains a
+ * highlight (using list of words to
+ * highlight)
+ * return 0 if no highlight is found in
+ * string
+ */
+
+SCM
+weechat_guile_api_string_has_highlight (SCM string, SCM highlight_words)
+{
+ int value;
+
+ API_FUNC(1, "string_has_highlight", API_RETURN_INT(0));
+ if (!scm_is_string (string) || !scm_is_string (highlight_words))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_string_has_highlight (scm_i_string_chars (string),
+ scm_i_string_chars (highlight_words));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_string_has_highlight_regex: return 1 if string contains a
+ * highlight (using regular
+ * expression)
+ * return 0 if no highlight is
+ * found in string
+ */
+
+SCM
+weechat_guile_api_string_has_highlight_regex (SCM string, SCM regex)
+{
+ int value;
+
+ API_FUNC(1, "string_has_highlight_regex", API_RETURN_INT(0));
+ if (!scm_is_string (string) || !scm_is_string (regex))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_string_has_highlight_regex (scm_i_string_chars (string),
+ scm_i_string_chars (regex));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_string_mask_to_regex: convert a mask (string with only
+ * "*" as wildcard) to a regex, paying
+ * attention to special chars in a
+ * regex
+ */
+
+SCM
+weechat_guile_api_string_mask_to_regex (SCM mask)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "string_mask_to_regex", API_RETURN_EMPTY);
+ if (!scm_is_string (mask))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_string_mask_to_regex (scm_i_string_chars (mask));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_string_remove_color: remove WeeChat color codes from string
+ */
+
+SCM
+weechat_guile_api_string_remove_color (SCM string, SCM replacement)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "string_remove_color", API_RETURN_EMPTY);
+ if (!scm_is_string (string) || !scm_is_string (replacement))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_string_remove_color (scm_i_string_chars (string),
+ scm_i_string_chars (replacement));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_string_is_command_char: check if first char of string is a
+ * command char
+ */
+
+SCM
+weechat_guile_api_string_is_command_char (SCM string)
+{
+ int value;
+
+ API_FUNC(1, "string_is_command_char", API_RETURN_INT(0));
+ if (!scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_string_is_command_char (scm_i_string_chars (string));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_string_input_for_buffer: return string with input text
+ * for buffer or empty string if
+ * it's a command
+ */
+
+SCM
+weechat_guile_api_string_input_for_buffer (SCM string)
+{
+ const char *result;
+
+ API_FUNC(1, "string_input_for_buffer", API_RETURN_EMPTY);
+ if (!scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_string_input_for_buffer (scm_i_string_chars (string));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_mkdir_home: create a directory in WeeChat home
+ */
+
+SCM
+weechat_guile_api_mkdir_home (SCM directory, SCM mode)
+{
+ API_FUNC(1, "mkdir_home", API_RETURN_ERROR);
+ if (!scm_is_string (directory) || !scm_is_integer (mode))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ if (weechat_mkdir_home (scm_i_string_chars (directory), scm_to_int (mode)))
+ API_RETURN_OK;
+
+ API_RETURN_ERROR;
+}
+
+/*
+ * weechat_guile_api_mkdir: create a directory
+ */
+
+SCM
+weechat_guile_api_mkdir (SCM directory, SCM mode)
+{
+ API_FUNC(1, "mkdir", API_RETURN_ERROR);
+ if (!scm_is_string (directory) || !scm_is_integer (mode))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ if (weechat_mkdir (scm_i_string_chars (directory), scm_to_int (mode)))
+ API_RETURN_OK;
+
+ API_RETURN_ERROR;
+}
+
+/*
+ * weechat_guile_api_mkdir_parents: create a directory and make parent
+ * directories as needed
+ */
+
+SCM
+weechat_guile_api_mkdir_parents (SCM directory, SCM mode)
+{
+ API_FUNC(1, "mkdir_parents", API_RETURN_ERROR);
+ if (!scm_is_string (directory) || !scm_is_integer (mode))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ if (weechat_mkdir_parents (scm_i_string_chars (directory), scm_to_int (mode)))
+ API_RETURN_OK;
+
+ API_RETURN_ERROR;
+}
+
+/*
+ * weechat_guile_api_list_new: create a new list
+ */
+
+SCM
+weechat_guile_api_list_new ()
+{
+ char *result;
+
+ API_FUNC(1, "list_new", API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_list_new ());
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_add: add a string to list
+ */
+
+SCM
+weechat_guile_api_list_add (SCM weelist, SCM data, SCM where, SCM user_data)
+{
+ char *result;
+
+ API_FUNC(1, "list_add", API_RETURN_EMPTY);
+ if (!scm_is_string (weelist) || !scm_is_string (data)
+ || !scm_is_string (where) || !scm_is_string (user_data))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_list_add (script_str2ptr(scm_i_string_chars (weelist)),
+ scm_i_string_chars (data),
+ scm_i_string_chars (where),
+ script_str2ptr (scm_i_string_chars (user_data))));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_search: search a string in list
+ */
+
+SCM
+weechat_guile_api_list_search (SCM weelist, SCM data)
+{
+ char *result;
+
+ API_FUNC(1, "list_search", API_RETURN_EMPTY);
+ if (!scm_is_string (weelist) || !scm_is_string (data))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_list_search (script_str2ptr(scm_i_string_chars (weelist)),
+ scm_i_string_chars (data)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_search_pos: search position of a string in list
+ */
+
+SCM
+weechat_guile_api_list_search_pos (SCM weelist, SCM data)
+{
+ int pos;
+
+ API_FUNC(1, "list_search_pos", API_RETURN_INT(-1));
+ if (!scm_is_string (weelist) || !scm_is_string (data))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ pos = weechat_list_search_pos (script_str2ptr (scm_i_string_chars (weelist)),
+ scm_i_string_chars (data));
+
+ API_RETURN_INT(pos);
+}
+
+/*
+ * weechat_guile_api_list_casesearch: search a string in list (ignore case)
+ */
+
+SCM
+weechat_guile_api_list_casesearch (SCM weelist, SCM data)
+{
+ char *result;
+
+ API_FUNC(1, "list_casesearch", API_RETURN_EMPTY);
+ if (!scm_is_string (weelist) || !scm_is_string (data))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_list_casesearch (script_str2ptr (scm_i_string_chars (weelist)),
+ scm_i_string_chars (data)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_casesearch_pos: search position of a string in list
+ * (ignore case)
+ */
+
+SCM
+weechat_guile_api_list_casesearch_pos (SCM weelist, SCM data)
+{
+ int pos;
+
+ API_FUNC(1, "list_casesearch_pos", API_RETURN_INT(-1));
+ if (!scm_is_string (weelist) || !scm_is_string (data))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ pos = weechat_list_casesearch_pos (script_str2ptr (scm_i_string_chars (weelist)),
+ scm_i_string_chars (data));
+
+ API_RETURN_INT(pos);
+}
+
+/*
+ * weechat_guile_api_list_get: get item by position
+ */
+
+SCM
+weechat_guile_api_list_get (SCM weelist, SCM position)
+{
+ char *result;
+
+ API_FUNC(1, "list_get", API_RETURN_EMPTY);
+ if (!scm_is_string (weelist) || !scm_is_integer (position))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_list_get (script_str2ptr (scm_i_string_chars (weelist)),
+ scm_to_int (position)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_set: set new value for item
+ */
+
+SCM
+weechat_guile_api_list_set (SCM item, SCM new_value)
+{
+ API_FUNC(1, "list_set", API_RETURN_ERROR);
+ if (!scm_is_string (item) || !scm_is_string (new_value))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_list_set (script_str2ptr (scm_i_string_chars (item)),
+ scm_i_string_chars (new_value));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_list_next: get next item
+ */
+
+SCM
+weechat_guile_api_list_next (SCM item)
+{
+ char *result;
+
+ API_FUNC(1, "list_next", API_RETURN_EMPTY);
+ if (!scm_is_string (item))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_list_next (script_str2ptr (scm_i_string_chars (item))));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_prev: get previous item
+ */
+
+SCM
+weechat_guile_api_list_prev (SCM item)
+{
+ char *result;
+
+ API_FUNC(1, "list_prev", API_RETURN_EMPTY);
+ if (!scm_is_string (item))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_list_prev (script_str2ptr (scm_i_string_chars (item))));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_string: get string value of item
+ */
+
+SCM
+weechat_guile_api_list_string (SCM item)
+{
+ const char *result;
+
+ API_FUNC(1, "list_string", API_RETURN_EMPTY);
+ if (!scm_is_string (item))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_list_string (script_str2ptr (scm_i_string_chars (item)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_list_size: get number of elements in list
+ */
+
+SCM
+weechat_guile_api_list_size (SCM weelist)
+{
+ int size;
+
+ API_FUNC(1, "list_size", API_RETURN_INT(0));
+ if (!scm_is_string (weelist))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ size = weechat_list_size (script_str2ptr (scm_i_string_chars (weelist)));
+
+ API_RETURN_INT(size);
+}
+
+/*
+ * weechat_guile_api_list_remove: remove item from list
+ */
+
+SCM
+weechat_guile_api_list_remove (SCM weelist, SCM item)
+{
+ API_FUNC(1, "list_remove", API_RETURN_ERROR);
+ if (!scm_is_string (weelist) || !scm_is_string (item))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_list_remove (script_str2ptr (scm_i_string_chars (weelist)),
+ script_str2ptr (scm_i_string_chars (item)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_list_remove_all: remove all items from list
+ */
+
+SCM
+weechat_guile_api_list_remove_all (SCM weelist)
+{
+ API_FUNC(1, "list_remove_all", API_RETURN_ERROR);
+ if (!scm_is_string (weelist))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_list_remove_all (script_str2ptr (scm_i_string_chars (weelist)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_list_free: free list
+ */
+
+SCM
+weechat_guile_api_list_free (SCM weelist)
+{
+ API_FUNC(1, "list_free", API_RETURN_ERROR);
+ if (!scm_is_string (weelist))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_list_free (script_str2ptr (scm_i_string_chars (weelist)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_reload_cb: callback for config reload
+ */
+
+int
+weechat_guile_api_config_reload_cb (void *data,
+ struct t_config_file *config_file)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[2];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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);
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
+}
+
+/*
+ * weechat_guile_api_config_new: create a new configuration file
+ */
+
+SCM
+weechat_guile_api_config_new (SCM name, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "config_new", API_RETURN_EMPTY);
+ if (!scm_is_string (name) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_config_read_cb: callback for reading option in section
+ */
+
+int
+weechat_guile_api_config_read_cb (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ const char *option_name, const char *value)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[5];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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] = (option_name) ? (char *)option_name : empty_arg;
+ func_argv[4] = (value) ? (char *)value : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[2])
+ free (func_argv[2]);
+
+ return ret;
+ }
+
+ return WEECHAT_CONFIG_OPTION_SET_ERROR;
+}
+
+/*
+ * weechat_guile_api_config_section_write_cb: callback for writing section
+ */
+
+int
+weechat_guile_api_config_section_write_cb (void *data,
+ struct t_config_file *config_file,
+ const char *section_name)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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] = (section_name) ? (char *)section_name : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_CONFIG_WRITE_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return WEECHAT_CONFIG_WRITE_ERROR;
+}
+
+/*
+ * weechat_guile_api_config_section_write_default_cb: callback for writing
+ * default values for section
+ */
+
+int
+weechat_guile_api_config_section_write_default_cb (void *data,
+ struct t_config_file *config_file,
+ const char *section_name)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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] = (section_name) ? (char *)section_name : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_CONFIG_WRITE_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return WEECHAT_CONFIG_WRITE_ERROR;
+}
+
+/*
+ * weechat_guile_api_config_section_create_option_cb: callback to create an
+ * option
+ */
+
+int
+weechat_guile_api_config_section_create_option_cb (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ const char *option_name,
+ const char *value)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[5];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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] = (option_name) ? (char *)option_name : empty_arg;
+ func_argv[4] = (value) ? (char *)value : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[2])
+ free (func_argv[2]);
+
+ return ret;
+ }
+
+ return WEECHAT_CONFIG_OPTION_SET_ERROR;
+}
+
+/*
+ * weechat_guile_api_config_section_delete_option_cb: callback to delete an
+ * option
+ */
+
+int
+weechat_guile_api_config_section_delete_option_cb (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ struct t_config_option *option)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[4];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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);
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[2])
+ free (func_argv[2]);
+ if (func_argv[3])
+ free (func_argv[3]);
+
+ return ret;
+ }
+
+ return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
+}
+
+/*
+ * weechat_guile_api_config_new_section: create a new section in configuration file
+ */
+
+SCM
+weechat_guile_api_config_new_section (SCM args)
+{
+ SCM config_file, name, user_can_add_options, user_can_delete_options;
+ SCM function_read, data_read, function_write, data_write;
+ SCM function_write_default, data_write_default, function_create_option;
+ SCM data_create_option, function_delete_option, data_delete_option;
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "config_new_section", API_RETURN_EMPTY);
+ if (!scm_list_p (args) || (scm_to_int (scm_length (args)) != 14))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ config_file = scm_list_ref (args, scm_from_int (0));
+ name = scm_list_ref (args, scm_from_int (1));
+ user_can_add_options = scm_list_ref (args, scm_from_int (2));
+ user_can_delete_options = scm_list_ref (args, scm_from_int (3));
+ function_read = scm_list_ref (args, scm_from_int (4));
+ data_read = scm_list_ref (args, scm_from_int (5));
+ function_write = scm_list_ref (args, scm_from_int (6));
+ data_write = scm_list_ref (args, scm_from_int (7));
+ function_write_default = scm_list_ref (args, scm_from_int (8));
+ data_write_default = scm_list_ref (args, scm_from_int (9));
+ function_create_option = scm_list_ref (args, scm_from_int (10));
+ data_create_option = scm_list_ref (args, scm_from_int (11));
+ function_delete_option = scm_list_ref (args, scm_from_int (12));
+ data_delete_option = scm_list_ref (args, scm_from_int (13));
+
+ if (!scm_is_string (config_file) || !scm_is_string (name)
+ || !scm_is_integer (user_can_add_options) || !scm_is_integer (user_can_delete_options)
+ || !scm_is_string (function_read) || !scm_is_string (data_read)
+ || !scm_is_string (function_write) || !scm_is_string (data_write)
+ || !scm_is_string (function_write_default) || !scm_is_string (data_write_default)
+ || !scm_is_string (function_create_option) || !scm_is_string (data_create_option)
+ || !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,
+ script_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);
+}
+
+/*
+ * weechat_guile_api_config_search_section: search section in configuration file
+ */
+
+SCM
+weechat_guile_api_config_search_section (SCM config_file, SCM section_name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "config_search_section", API_RETURN_EMPTY);
+ if (!scm_is_string (config_file) || !scm_is_string (section_name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_config_search_section (script_str2ptr (scm_i_string_chars (config_file)),
+ scm_i_string_chars (section_name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_config_option_check_value_cb: callback for checking new
+ * value for option
+ */
+
+int
+weechat_guile_api_config_option_check_value_cb (void *data,
+ struct t_config_option *option,
+ const char *value)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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[2] = (value) ? (char *)value : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = 0;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
+ * weechat_guile_api_config_option_change_cb: callback for option changed
+ */
+
+void
+weechat_guile_api_config_option_change_cb (void *data,
+ struct t_config_option *option)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[2];
+ char empty_arg[1] = { '\0' };
+ int *rc;
+
+ script_callback = (struct t_script_callback *)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);
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ss", func_argv);
+
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ if (rc)
+ free (rc);
+ }
+}
+
+/*
+ * weechat_guile_api_config_option_delete_cb: callback when option is deleted
+ */
+
+void
+weechat_guile_api_config_option_delete_cb (void *data,
+ struct t_config_option *option)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[2];
+ char empty_arg[1] = { '\0' };
+ int *rc;
+
+ script_callback = (struct t_script_callback *)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);
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ss", func_argv);
+
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ if (rc)
+ free (rc);
+ }
+}
+
+/*
+ * weechat_guile_api_config_new_option: create a new option in section
+ */
+
+SCM
+weechat_guile_api_config_new_option (SCM args)
+{
+ SCM config_file, section, name, type, description, string_values, min;
+ SCM max, default_value, value, null_value_allowed, function_check_value;
+ SCM data_check_value, function_change, data_change, function_delete;
+ SCM data_delete;
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "config_new_option", API_RETURN_EMPTY);
+ if (!scm_list_p (args) || (scm_to_int (scm_length (args)) != 17))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ config_file = scm_list_ref (args, scm_from_int (0));
+ section = scm_list_ref (args, scm_from_int (1));
+ name = scm_list_ref (args, scm_from_int (2));
+ type = scm_list_ref (args, scm_from_int (3));
+ description = scm_list_ref (args, scm_from_int (4));
+ string_values = scm_list_ref (args, scm_from_int (5));
+ min = scm_list_ref (args, scm_from_int (6));
+ max = scm_list_ref (args, scm_from_int (7));
+ default_value = scm_list_ref (args, scm_from_int (8));
+ value = scm_list_ref (args, scm_from_int (9));
+ null_value_allowed = scm_list_ref (args, scm_from_int (10));
+ function_check_value = scm_list_ref (args, scm_from_int (11));
+ data_check_value = scm_list_ref (args, scm_from_int (12));
+ function_change = scm_list_ref (args, scm_from_int (13));
+ data_change = scm_list_ref (args, scm_from_int (14));
+ function_delete = scm_list_ref (args, scm_from_int (15));
+ data_delete = scm_list_ref (args, scm_from_int (16));
+
+ if (!scm_is_string (config_file) || !scm_is_string (section)
+ || !scm_is_string (name) || !scm_is_string (type)
+ || !scm_is_string (description) || !scm_is_string (string_values)
+ || !scm_is_integer (min) || !scm_is_integer (max)
+ || !scm_is_string (default_value) || !scm_is_string (value)
+ || !scm_is_integer (null_value_allowed)
+ || !scm_is_string (function_check_value)
+ || !scm_is_string (data_check_value)
+ || !scm_is_string (function_change) || !scm_is_string (data_change)
+ || !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,
+ script_str2ptr (scm_i_string_chars (config_file)),
+ script_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);
+}
+
+/*
+ * weechat_guile_api_config_search_option: search option in configuration file
+ * or section
+ */
+
+SCM
+weechat_guile_api_config_search_option (SCM config_file, SCM section,
+ SCM option_name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "config_search_option", API_RETURN_EMPTY);
+ if (!scm_is_string (config_file) || !scm_is_string (section)
+ || !scm_is_string (option_name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_config_search_option (script_str2ptr (scm_i_string_chars (config_file)),
+ script_str2ptr (scm_i_string_chars (section)),
+ scm_i_string_chars (option_name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_config_string_to_boolean: return boolean value of a string
+ */
+
+SCM
+weechat_guile_api_config_string_to_boolean (SCM text)
+{
+ int value;
+
+ API_FUNC(1, "config_string_to_boolean", API_RETURN_INT(0));
+ if (!scm_is_string (text))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_config_string_to_boolean (scm_i_string_chars (text));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_config_option_reset: reset option with default value
+ */
+
+SCM
+weechat_guile_api_config_option_reset (SCM option, SCM run_callback)
+{
+ int rc;
+
+ API_FUNC(1, "config_option_reset", API_RETURN_INT(0));
+ if (!scm_is_string (option) || !scm_is_integer (run_callback))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ rc = weechat_config_option_reset (script_str2ptr (scm_i_string_chars (option)),
+ scm_to_int (run_callback));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_option_set: set new value for option
+ */
+
+SCM
+weechat_guile_api_config_option_set (SCM option, SCM new_value,
+ SCM run_callback)
+{
+ int rc;
+
+ API_FUNC(1, "config_option_set", API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR));
+ if (!scm_is_string (option) || !scm_is_string (new_value)
+ || !scm_is_integer (run_callback))
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR));
+
+ rc = weechat_config_option_set (script_str2ptr (scm_i_string_chars (option)),
+ scm_i_string_chars (new_value),
+ scm_to_int (run_callback));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_option_set_null: set null (undefined) value for
+ * option
+ */
+
+SCM
+weechat_guile_api_config_option_set_null (SCM option, SCM run_callback)
+{
+ int rc;
+
+ API_FUNC(1, "config_option_set_null", API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR));
+ if (!scm_is_string (option) || !scm_is_integer (run_callback))
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR));
+
+ rc = weechat_config_option_set_null (script_str2ptr (scm_i_string_chars (option)),
+ scm_to_int (run_callback));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_option_unset: unset an option
+ */
+
+SCM
+weechat_guile_api_config_option_unset (SCM option)
+{
+ int rc;
+
+ API_FUNC(1, "config_option_unset", API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR));
+
+ rc = weechat_config_option_unset (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_option_rename: rename an option
+ */
+
+SCM
+weechat_guile_api_config_option_rename (SCM option, SCM new_name)
+{
+ API_FUNC(1, "config_option_rename", API_RETURN_ERROR);
+ if (!scm_is_string (option) || !scm_is_string (new_name))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_config_option_rename (script_str2ptr (scm_i_string_chars (option)),
+ scm_i_string_chars (new_name));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_option_is_null: return 1 if value of option is null
+ */
+
+SCM
+weechat_guile_api_config_option_is_null (SCM option)
+{
+ int value;
+
+ API_FUNC(1, "config_option_is_null", API_RETURN_INT(1));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(1));
+
+ value = weechat_config_option_is_null (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_config_option_default_is_null: return 1 if value of option
+ * is null
+ */
+
+SCM
+weechat_guile_api_config_option_default_is_null (SCM option)
+{
+ int value;
+
+ API_FUNC(1, "config_option_default_is_null", API_RETURN_INT(1));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(1));
+
+ value = weechat_config_option_default_is_null (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_config_boolean: return boolean value of option
+ */
+
+SCM
+weechat_guile_api_config_boolean (SCM option)
+{
+ int value;
+
+ API_FUNC(1, "config_boolean", API_RETURN_INT(0));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_config_boolean (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_config_boolean_default: return default boolean value of option
+ */
+
+SCM
+weechat_guile_api_config_boolean_default (SCM option)
+{
+ int value;
+
+ API_FUNC(1, "config_boolean_default", API_RETURN_INT(0));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_config_boolean_default (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_config_integer: return integer value of option
+ */
+
+SCM
+weechat_guile_api_config_integer (SCM option)
+{
+ int value;
+
+ API_FUNC(1, "config_integer", API_RETURN_INT(0));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_config_integer (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_config_integer_default: return default integer value of option
+ */
+
+SCM
+weechat_guile_api_config_integer_default (SCM option)
+{
+ int value;
+
+ API_FUNC(1, "config_integer_default", API_RETURN_INT(0));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_config_integer_default (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_config_string: return string value of option
+ */
+
+SCM
+weechat_guile_api_config_string (SCM option)
+{
+ const char *result;
+
+ API_FUNC(1, "config_string", API_RETURN_EMPTY);
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_config_string (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_config_string_default: return default string value of option
+ */
+
+SCM
+weechat_guile_api_config_string_default (SCM option)
+{
+ const char *result;
+
+ API_FUNC(1, "config_string_default", API_RETURN_EMPTY);
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_config_string_default (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_config_color: return color value of option
+ */
+
+SCM
+weechat_guile_api_config_color (SCM option)
+{
+ const char *result;
+
+ API_FUNC(1, "config_color", API_RETURN_INT(0));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ result = weechat_config_color (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_config_color_default: return default color value of option
+ */
+
+SCM
+weechat_guile_api_config_color_default (SCM option)
+{
+ const char *result;
+
+ API_FUNC(1, "config_color_default", API_RETURN_INT(0));
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ result = weechat_config_color_default (script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_config_write_option: write an option in configuration file
+ */
+
+SCM
+weechat_guile_api_config_write_option (SCM config_file, SCM option)
+{
+ API_FUNC(1, "config_write_option", API_RETURN_ERROR);
+ if (!scm_is_string (config_file) || !scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_config_write_option (script_str2ptr (scm_i_string_chars (config_file)),
+ script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_write_line: write a line in configuration file
+ */
+
+SCM
+weechat_guile_api_config_write_line (SCM config_file,
+ SCM option_name, SCM value)
+{
+ API_FUNC(1, "config_write_line", API_RETURN_ERROR);
+ if (!scm_is_string (config_file) || !scm_is_string (option_name) || !scm_is_string (value))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_config_write_line (script_str2ptr (scm_i_string_chars (config_file)),
+ scm_i_string_chars (option_name),
+ "%s",
+ scm_i_string_chars (value));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_write: write configuration file
+ */
+
+SCM
+weechat_guile_api_config_write (SCM config_file)
+{
+ int rc;
+
+ API_FUNC(1, "config_write", API_RETURN_INT(-1));
+ if (!scm_is_string (config_file))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ rc = weechat_config_write (script_str2ptr (scm_i_string_chars (config_file)));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_read: read configuration file
+ */
+
+SCM
+weechat_guile_api_config_read (SCM config_file)
+{
+ int rc;
+
+ API_FUNC(1, "config_read", API_RETURN_INT(-1));
+ if (!scm_is_string (config_file))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ rc = weechat_config_read (script_str2ptr (scm_i_string_chars (config_file)));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_reload: reload configuration file
+ */
+
+SCM
+weechat_guile_api_config_reload (SCM config_file)
+{
+ int rc;
+
+ API_FUNC(1, "config_reload", API_RETURN_INT(-1));
+ if (!scm_is_string (config_file))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ rc = weechat_config_reload (script_str2ptr (scm_i_string_chars (config_file)));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_option_free: free an option in configuration file
+ */
+
+SCM
+weechat_guile_api_config_option_free (SCM option)
+{
+ API_FUNC(1, "config_option_free", API_RETURN_ERROR);
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_config_option_free (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (option)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_section_free_options: free all options of a section
+ * in configuration file
+ */
+
+SCM
+weechat_guile_api_config_section_free_options (SCM section)
+{
+ API_FUNC(1, "config_section_free_options", API_RETURN_ERROR);
+ if (!scm_is_string (section))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_config_section_free_options (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (section)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_section_free: free section in configuration file
+ */
+
+SCM
+weechat_guile_api_config_section_free (SCM section)
+{
+ API_FUNC(1, "config_section_free", API_RETURN_ERROR);
+ if (!scm_is_string (section))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_config_section_free (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (section)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_free: free configuration file
+ */
+
+SCM
+weechat_guile_api_config_free (SCM config_file)
+{
+ API_FUNC(1, "config_free", API_RETURN_ERROR);
+ if (!scm_is_string (config_file))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_config_free (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (config_file)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_get: get config option
+ */
+
+SCM
+weechat_guile_api_config_get (SCM option)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "config_get", API_RETURN_EMPTY);
+ if (!scm_is_string (option))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_config_get (scm_i_string_chars (option)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_config_get_plugin: get value of a plugin option
+ */
+
+SCM
+weechat_guile_api_config_get_plugin (SCM option)
+{
+ const char *result;
+
+ API_FUNC(1, "config_get_plugin", API_RETURN_EMPTY);
+ 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));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_config_is_set_plugin: check if a plugin option is set
+ */
+
+SCM
+weechat_guile_api_config_is_set_plugin (SCM option)
+{
+ int rc;
+
+ API_FUNC(1, "config_is_set_plugin", API_RETURN_INT(0));
+ 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));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_set_plugin: set value of a plugin option
+ */
+
+SCM
+weechat_guile_api_config_set_plugin (SCM option, SCM value)
+{
+ int rc;
+
+ API_FUNC(1, "config_set_plugin", API_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR));
+ 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));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_config_set_desc_plugin: set description of a plugin option
+ */
+
+SCM
+weechat_guile_api_config_set_desc_plugin (SCM option, SCM description)
+{
+ API_FUNC(1, "config_set_desc_plugin", API_RETURN_ERROR);
+ 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));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_config_unset_plugin: unset plugin option
+ */
+
+SCM
+weechat_guile_api_config_unset_plugin (SCM option)
+{
+ int rc;
+
+ API_FUNC(1, "config_unset_plugin", API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR));
+ 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));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_key_bind: bind key(s)
+ */
+
+SCM
+weechat_guile_api_key_bind (SCM context, SCM keys)
+{
+ struct t_hashtable *c_keys;
+ int num_keys;
+
+ API_FUNC(1, "key_bind", API_RETURN_INT(0));
+ if (!scm_is_string (context) || !scm_list_p (keys))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ c_keys = weechat_guile_alist_to_hashtable (keys,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+
+ num_keys = weechat_key_bind (scm_i_string_chars (context), c_keys);
+
+ if (c_keys)
+ weechat_hashtable_free (c_keys);
+
+ API_RETURN_INT(num_keys);
+}
+
+/*
+ * weechat_guile_api_key_unbind: unbind key(s)
+ */
+
+SCM
+weechat_guile_api_key_unbind (SCM context, SCM key)
+{
+ int num_keys;
+
+ API_FUNC(1, "key_unbind", API_RETURN_INT(0));
+ if (!scm_is_string (context) || !scm_is_string (key))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ num_keys = weechat_key_unbind (scm_i_string_chars (context),
+ scm_i_string_chars (key));
+
+ API_RETURN_INT(num_keys);
+}
+
+/*
+ * weechat_guile_api_prefix: get a prefix, used for display
+ */
+
+SCM
+weechat_guile_api_prefix (SCM prefix)
+{
+ const char *result;
+
+ API_FUNC(0, "prefix", API_RETURN_EMPTY);
+ if (!scm_is_string (prefix))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_prefix (scm_i_string_chars (prefix));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_color: get a color code, used for display
+ */
+
+SCM
+weechat_guile_api_color (SCM color)
+{
+ const char *result;
+
+ API_FUNC(0, "color", API_RETURN_EMPTY);
+ if (!scm_is_string (color))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_color (scm_i_string_chars (color));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_print: print message in a buffer
+ */
+
+SCM
+weechat_guile_api_print (SCM buffer, SCM message)
+{
+ API_FUNC(0, "print", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (message))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_printf (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (buffer)),
+ "%s", scm_i_string_chars (message));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_print_date_tags: print message in a buffer with optional
+ * date and tags
+ */
+
+SCM
+weechat_guile_api_print_date_tags (SCM buffer, SCM date, SCM tags, SCM message)
+{
+ API_FUNC(1, "print_date_tags", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_integer (date)
+ || !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,
+ script_str2ptr (scm_i_string_chars (buffer)),
+ scm_to_int (date),
+ scm_i_string_chars (tags),
+ "%s", scm_i_string_chars (message));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_print_y: print message in a buffer with free content
+ */
+
+SCM
+weechat_guile_api_print_y (SCM buffer, SCM y, SCM message)
+{
+ API_FUNC(1, "print_y", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_integer (y)
+ || !scm_is_string (message))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_printf_y (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (buffer)),
+ scm_to_int (y),
+ "%s", scm_i_string_chars (message));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_log_print: print message in WeeChat log file
+ */
+
+SCM
+weechat_guile_api_log_print (SCM message)
+{
+ API_FUNC(1, "log_print", API_RETURN_ERROR);
+ 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));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_hook_command_cb: callback for command hooked
+ */
+
+int
+weechat_guile_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
+ int argc, char **argv, char **argv_eol)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ /* make C compiler happy */
+ (void) argv;
+
+ script_callback = (struct t_script_callback *)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 (buffer);
+ func_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_command: hook a command
+ */
+
+SCM
+weechat_guile_api_hook_command (SCM command, SCM description, SCM args,
+ SCM args_description, SCM completion,
+ SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_command", API_RETURN_EMPTY);
+ if (!scm_is_string (command) || !scm_is_string (description)
+ || !scm_is_string (args) || !scm_is_string (args_description)
+ || !scm_is_string (completion) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_command_run_cb: callback for command_run hooked
+ */
+
+int
+weechat_guile_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
+ const char *command)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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 (buffer);
+ func_argv[2] = (command) ? (char *)command : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_command_run: hook a command_run
+ */
+
+SCM
+weechat_guile_api_hook_command_run (SCM command, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_command_run", API_RETURN_EMPTY);
+ if (!scm_is_string (command) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_timer_cb: callback for timer hooked
+ */
+
+int
+weechat_guile_api_hook_timer_cb (void *data, int remaining_calls)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[2];
+ char str_remaining_calls[32], empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback && script_callback->function && script_callback->function[0])
+ {
+ snprintf (str_remaining_calls, sizeof (str_remaining_calls),
+ "%d", remaining_calls);
+
+ func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[1] = str_remaining_calls;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_timer: hook a timer
+ */
+
+SCM
+weechat_guile_api_hook_timer (SCM interval, SCM align_second, SCM max_calls,
+ SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_timer", API_RETURN_EMPTY);
+ if (!scm_is_integer (interval) || !scm_is_integer (align_second)
+ || !scm_is_integer (max_calls) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_fd_cb: callback for fd hooked
+ */
+
+int
+weechat_guile_api_hook_fd_cb (void *data, int fd)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[2];
+ char str_fd[32], empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback && script_callback->function && script_callback->function[0])
+ {
+ snprintf (str_fd, sizeof (str_fd), "%d", fd);
+
+ func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[1] = str_fd;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_fd: hook a fd
+ */
+
+SCM
+weechat_guile_api_hook_fd (SCM fd, SCM read, SCM write, SCM exception,
+ SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_fd", API_RETURN_EMPTY);
+ if (!scm_is_integer (fd) || !scm_is_integer (read)
+ || !scm_is_integer (write) || !scm_is_integer (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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_process_cb: callback for process hooked
+ */
+
+int
+weechat_guile_api_hook_process_cb (void *data,
+ const char *command, int return_code,
+ const char *out, const char *err)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[5];
+ char str_rc[32], empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback && script_callback->function && script_callback->function[0])
+ {
+ snprintf (str_rc, sizeof (str_rc), "%d", return_code);
+
+ func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[1] = (command) ? (char *)command : empty_arg;
+ func_argv[2] = str_rc;
+ func_argv[3] = (out) ? (char *)out : empty_arg;
+ func_argv[4] = (err) ? (char *)err : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_process: hook a process
+ */
+
+SCM
+weechat_guile_api_hook_process (SCM command, SCM timeout, SCM function,
+ SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_process", API_RETURN_EMPTY);
+ if (!scm_is_string (command) || !scm_is_integer (timeout)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_connect_cb: callback for connect hooked
+ */
+
+int
+weechat_guile_api_hook_connect_cb (void *data, int status, int gnutls_rc,
+ const char *error, const char *ip_address)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[5];
+ char str_status[32], str_gnutls_rc[32];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback && script_callback->function && script_callback->function[0])
+ {
+ snprintf (str_status, sizeof (str_status), "%d", status);
+ snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
+
+ func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[1] = str_status;
+ func_argv[2] = str_gnutls_rc;
+ func_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
+ func_argv[4] = (error) ? (char *)error : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_connect: hook a connection
+ */
+
+SCM
+weechat_guile_api_hook_connect (SCM proxy, SCM address, SCM port, SCM sock,
+ SCM ipv6, SCM local_hostname, SCM function,
+ SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_connect", API_RETURN_EMPTY);
+ if (!scm_is_string (proxy) || !scm_is_string (address)
+ || !scm_is_integer (port) || !scm_is_integer (sock)
+ || !scm_is_integer (ipv6) || !scm_is_string (local_hostname)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_print_cb: callback for print hooked
+ */
+
+int
+weechat_guile_api_hook_print_cb (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)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[8];
+ char empty_arg[1] = { '\0' };
+ static char timebuffer[64];
+ int *rc, ret;
+
+ /* make C compiler happy */
+ (void) tags_count;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback && script_callback->function && script_callback->function[0])
+ {
+ 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[2] = timebuffer;
+ func_argv[3] = weechat_string_build_with_split_string (tags, ",");
+ if (!func_argv[3])
+ func_argv[3] = strdup ("");
+ func_argv[4] = (displayed) ? strdup ("1") : strdup ("0");
+ func_argv[5] = (highlight) ? strdup ("1") : strdup ("0");
+ func_argv[6] = (prefix) ? (char *)prefix : empty_arg;
+ func_argv[7] = (message) ? (char *)message : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ssssssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[3])
+ free (func_argv[3]);
+ if (func_argv[4])
+ free (func_argv[4]);
+ if (func_argv[5])
+ free (func_argv[5]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_print: hook a print
+ */
+
+SCM
+weechat_guile_api_hook_print (SCM buffer, SCM tags, SCM message,
+ SCM strip_colors, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_print", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (tags)
+ || !scm_is_string (message) || !scm_is_integer (strip_colors)
+ || !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,
+ script_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);
+}
+
+/*
+ * weechat_guile_api_hook_signal_cb: callback for signal hooked
+ */
+
+int
+weechat_guile_api_hook_signal_cb (void *data, const char *signal,
+ const char *type_data, void *signal_data)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ static char value_str[64];
+ int *rc, ret, free_needed;
+
+ script_callback = (struct t_script_callback *)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] = (signal) ? (char *)signal : empty_arg;
+ free_needed = 0;
+ if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
+ {
+ func_argv[2] = (signal_data) ? (char *)signal_data : empty_arg;
+ }
+ else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
+ {
+ snprintf (value_str, sizeof (value_str) - 1,
+ "%d", *((int *)signal_data));
+ func_argv[2] = value_str;
+ }
+ else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
+ {
+ func_argv[2] = script_ptr2str (signal_data);
+ free_needed = 1;
+ }
+ else
+ func_argv[2] = empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (free_needed && func_argv[2])
+ free (func_argv[2]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_signal: hook a signal
+ */
+
+SCM
+weechat_guile_api_hook_signal (SCM signal, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_signal", API_RETURN_EMPTY);
+ 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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_signal_send: send a signal
+ */
+
+SCM
+weechat_guile_api_hook_signal_send (SCM signal, SCM type_data,
+ SCM signal_data)
+{
+ int number;
+
+ API_FUNC(1, "hook_signal_send", API_RETURN_ERROR);
+ if (!scm_is_string (signal) || !scm_is_string (type_data))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ if (strcmp (scm_i_string_chars (type_data), WEECHAT_HOOK_SIGNAL_STRING) == 0)
+ {
+ if (!scm_is_string (signal_data))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+ weechat_hook_signal_send (scm_i_string_chars (signal),
+ scm_i_string_chars (type_data),
+ (void *)scm_i_string_chars (signal_data));
+ API_RETURN_OK;
+ }
+ else if (strcmp (scm_i_string_chars (type_data), WEECHAT_HOOK_SIGNAL_INT) == 0)
+ {
+ if (!scm_is_integer (signal_data))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+ number = scm_to_int (signal_data);
+ weechat_hook_signal_send (scm_i_string_chars (signal),
+ scm_i_string_chars (type_data),
+ &number);
+ API_RETURN_OK;
+ }
+ else if (strcmp (scm_i_string_chars (type_data), WEECHAT_HOOK_SIGNAL_POINTER) == 0)
+ {
+ if (!scm_is_string (signal_data))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+ weechat_hook_signal_send (scm_i_string_chars (signal),
+ scm_i_string_chars (type_data),
+ script_str2ptr (scm_i_string_chars (signal_data)));
+ API_RETURN_OK;
+ }
+
+ API_RETURN_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_hsignal_cb: callback for hsignal hooked
+ */
+
+int
+weechat_guile_api_hook_hsignal_cb (void *data, const char *signal,
+ struct t_hashtable *hashtable)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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] = (signal) ? (char *)signal : empty_arg;
+ func_argv[2] = hashtable;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ssh", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_hsignal: hook a hsignal
+ */
+
+SCM
+weechat_guile_api_hook_hsignal (SCM signal, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_hsignal", API_RETURN_EMPTY);
+ 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_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);
+}
+
+/*
+ * weechat_guile_api_hook_hsignal_send: send a hsignal
+ */
+
+SCM
+weechat_guile_api_hook_hsignal_send (SCM signal, SCM hashtable)
+{
+ struct t_hashtable *c_hashtable;
+
+ API_FUNC(1, "hook_hsignal_send", API_RETURN_ERROR);
+ if (!scm_is_string (signal) || !scm_list_p (hashtable))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ c_hashtable = weechat_guile_alist_to_hashtable (hashtable,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+
+ weechat_hook_hsignal_send (scm_i_string_chars (signal), c_hashtable);
+
+ if (c_hashtable)
+ weechat_hashtable_free (c_hashtable);
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_hook_config_cb: callback for config option hooked
+ */
+
+int
+weechat_guile_api_hook_config_cb (void *data, const char *option, const char *value)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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] = (option) ? (char *)option : empty_arg;
+ func_argv[2] = (value) ? (char *)value : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_config: hook a config option
+ */
+
+SCM
+weechat_guile_api_hook_config (SCM option, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_config", API_RETURN_EMPTY);
+ if (!scm_is_string (option) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_completion_cb: callback for completion hooked
+ */
+
+int
+weechat_guile_api_hook_completion_cb (void *data, const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[4];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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] = (completion_item) ? (char *)completion_item : empty_arg;
+ func_argv[2] = script_ptr2str (buffer);
+ func_argv[3] = script_ptr2str (completion);
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[2])
+ free (func_argv[2]);
+ if (func_argv[3])
+ free (func_argv[3]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_hook_completion: hook a completion
+ */
+
+SCM
+weechat_guile_api_hook_completion (SCM completion, SCM description,
+ SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_completion", API_RETURN_EMPTY);
+ if (!scm_is_string (completion) || !scm_is_string (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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_completion_list_add: add a word to list for a completion
+ */
+
+SCM
+weechat_guile_api_hook_completion_list_add (SCM completion, SCM word,
+ SCM nick_completion, SCM where)
+{
+ API_FUNC(1, "hook_completion_list_add", API_RETURN_ERROR);
+ if (!scm_is_string (completion) || !scm_is_string (word)
+ || !scm_is_integer (nick_completion) || !scm_is_string (where))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_hook_completion_list_add (script_str2ptr (scm_i_string_chars (completion)),
+ scm_i_string_chars (word),
+ scm_to_int (nick_completion),
+ scm_i_string_chars (where));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_hook_modifier_cb: callback for modifier hooked
+ */
+
+char *
+weechat_guile_api_hook_modifier_cb (void *data, const char *modifier,
+ const char *modifier_data, const char *string)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[4];
+ char empty_arg[1] = { '\0' };
+
+ script_callback = (struct t_script_callback *)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] = (modifier) ? (char *)modifier : empty_arg;
+ func_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
+ func_argv[3] = (string) ? (char *)string : empty_arg;
+
+ return (char *)weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ script_callback->function,
+ "ssss", func_argv);
+ }
+
+ return NULL;
+}
+
+/*
+ * weechat_guile_api_hook_modifier: hook a modifier
+ */
+
+SCM
+weechat_guile_api_hook_modifier (SCM modifier, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_modifier", API_RETURN_EMPTY);
+ if (!scm_is_string (modifier) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_modifier_exec: execute a modifier hook
+ */
+
+SCM
+weechat_guile_api_hook_modifier_exec (SCM modifier, SCM modifier_data,
+ SCM string)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_modifier_exec", API_RETURN_EMPTY);
+ if (!scm_is_string (modifier) || !scm_is_string (modifier_data)
+ || !scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_hook_modifier_exec (scm_i_string_chars (modifier),
+ scm_i_string_chars (modifier_data),
+ scm_i_string_chars (string));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_info_cb: callback for info hooked
+ */
+
+const char *
+weechat_guile_api_hook_info_cb (void *data, const char *info_name,
+ const char *arguments)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+
+ script_callback = (struct t_script_callback *)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] = (info_name) ? (char *)info_name : empty_arg;
+ func_argv[2] = (arguments) ? (char *)arguments : empty_arg;
+
+ return (const char *)weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ script_callback->function,
+ "sss", func_argv);
+ }
+
+ return NULL;
+}
+
+/*
+ * weechat_guile_api_hook_info: hook an info
+ */
+
+SCM
+weechat_guile_api_hook_info (SCM info_name, SCM description,
+ SCM args_description, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_info", API_RETURN_EMPTY);
+ if (!scm_is_string (info_name) || !scm_is_string (description)
+ || !scm_is_string (args_description) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_info_hashtable_cb: callback for info_hashtable hooked
+ */
+
+struct t_hashtable *
+weechat_guile_api_hook_info_hashtable_cb (void *data, const char *info_name,
+ struct t_hashtable *hashtable)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+
+ script_callback = (struct t_script_callback *)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] = (info_name) ? (char *)info_name : empty_arg;
+ func_argv[2] = hashtable;
+
+ return (struct t_hashtable *)weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ script_callback->function,
+ "ssh", func_argv);
+ }
+
+ return NULL;
+}
+
+/*
+ * weechat_guile_api_hook_info_hashtable: hook an info_hashtable
+ */
+
+SCM
+weechat_guile_api_hook_info_hashtable (SCM info_name, SCM description,
+ SCM args_description,
+ SCM output_description, SCM function,
+ SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_info_hashtable", API_RETURN_EMPTY);
+ if (!scm_is_string (info_name) || !scm_is_string (description)
+ || !scm_is_string (args_description) || !scm_is_string (output_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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_infolist_cb: callback for infolist hooked
+ */
+
+struct t_infolist *
+weechat_guile_api_hook_infolist_cb (void *data, const char *infolist_name,
+ void *pointer, const char *arguments)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[4];
+ char empty_arg[1] = { '\0' };
+ struct t_infolist *result;
+
+ script_callback = (struct t_script_callback *)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] = (infolist_name) ? (char *)infolist_name : empty_arg;
+ func_argv[2] = script_ptr2str (pointer);
+ func_argv[3] = (arguments) ? (char *)arguments : empty_arg;
+
+ result = (struct t_infolist *)weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ script_callback->function,
+ "ssss", func_argv);
+
+ if (func_argv[2])
+ free (func_argv[2]);
+
+ return result;
+ }
+
+ return NULL;
+}
+
+/*
+ * weechat_guile_api_hook_infolist: hook an infolist
+ */
+
+SCM
+weechat_guile_api_hook_infolist (SCM infolist_name, SCM description,
+ SCM pointer_description, SCM args_description,
+ SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_infolist", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist_name) || !scm_is_string (description)
+ || !scm_is_string (pointer_description) || !scm_is_string (args_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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hook_focus_cb: callback for focus hooked
+ */
+
+struct t_hashtable *
+weechat_guile_api_hook_focus_cb (void *data, struct t_hashtable *info)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[2];
+ char empty_arg[1] = { '\0' };
+
+ script_callback = (struct t_script_callback *)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] = info;
+
+ return (struct t_hashtable *)weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ script_callback->function,
+ "sh", func_argv);
+ }
+
+ return NULL;
+}
+
+/*
+ * weechat_guile_api_hook_focus: hook a focus
+ */
+
+SCM
+weechat_guile_api_hook_focus (SCM area, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hook_focus", API_RETURN_EMPTY);
+ if (!scm_is_string (area) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_unhook: unhook something
+ */
+
+SCM
+weechat_guile_api_unhook (SCM hook)
+{
+ API_FUNC(1, "unhook", API_RETURN_ERROR);
+ if (!scm_is_string (hook))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_unhook (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (hook)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_unhook_all: unhook all for script
+ */
+
+SCM
+weechat_guile_api_unhook_all ()
+{
+ API_FUNC(1, "unhook_all", API_RETURN_ERROR);
+
+ script_api_unhook_all (guile_current_script);
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_buffer_input_data_cb: callback for input data in a buffer
+ */
+
+int
+weechat_guile_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
+ const char *input_data)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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 (buffer);
+ func_argv[2] = (input_data) ? (char *)input_data : empty_arg;
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_buffer_close_cb: callback for closed buffer
+ */
+
+int
+weechat_guile_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[2];
+ char empty_arg[1] = { '\0' };
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)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 (buffer);
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_buffer_new: create a new buffer
+ */
+
+SCM
+weechat_guile_api_buffer_new (SCM name, SCM function_input, SCM data_input,
+ SCM function_close, SCM data_close)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "buffer_new", API_RETURN_EMPTY);
+ if (!scm_is_string (name) || !scm_is_string (function_input)
+ || !scm_is_string (data_input) || !scm_is_string (function_close)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_buffer_search: search a buffer
+ */
+
+SCM
+weechat_guile_api_buffer_search (SCM plugin, SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "buffer_search", API_RETURN_EMPTY);
+ 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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_buffer_search_main: search main buffer (WeeChat core buffer)
+ */
+
+SCM
+weechat_guile_api_buffer_search_main ()
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "buffer_search_main", API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_buffer_search_main ());
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_current_buffer: get current buffer
+ */
+
+SCM
+weechat_guile_api_current_buffer ()
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "current_buffer", API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_current_buffer ());
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_buffer_clear: clear a buffer
+ */
+
+SCM
+weechat_guile_api_buffer_clear (SCM buffer)
+{
+ API_FUNC(1, "buffer_clear", API_RETURN_ERROR);
+ if (!scm_is_string (buffer))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_buffer_clear (script_str2ptr (scm_i_string_chars (buffer)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_buffer_close: close a buffer
+ */
+
+SCM
+weechat_guile_api_buffer_close (SCM buffer)
+{
+ API_FUNC(1, "buffer_close", API_RETURN_ERROR);
+ if (!scm_is_string (buffer))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_buffer_close (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (buffer)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_buffer_merge: merge a buffer to another buffer
+ */
+
+SCM
+weechat_guile_api_buffer_merge (SCM buffer, SCM target_buffer)
+{
+ API_FUNC(1, "buffer_merge", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (target_buffer))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_buffer_merge (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (target_buffer)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_buffer_unmerge: unmerge a buffer from a group of merged
+ * buffers
+ */
+
+SCM
+weechat_guile_api_buffer_unmerge (SCM buffer, SCM number)
+{
+ API_FUNC(1, "buffer_unmerge", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_integer (number))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_buffer_unmerge (script_str2ptr (scm_i_string_chars (buffer)),
+ scm_to_int (number));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_buffer_get_integer: get a buffer property as integer
+ */
+
+SCM
+weechat_guile_api_buffer_get_integer (SCM buffer, SCM property)
+{
+ int value;
+
+ API_FUNC(1, "buffer_get_integer", API_RETURN_INT(-1));
+ if (!scm_is_string (buffer) || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ value = weechat_buffer_get_integer (script_str2ptr (scm_i_string_chars (buffer)),
+ scm_i_string_chars (property));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_buffer_get_string: get a buffer property as string
+ */
+
+SCM
+weechat_guile_api_buffer_get_string (SCM buffer, SCM property)
+{
+ const char *result;
+
+ API_FUNC(1, "buffer_get_string", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_buffer_get_string (script_str2ptr (scm_i_string_chars (buffer)),
+ scm_i_string_chars (property));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_buffer_get_pointer: get a buffer property as pointer
+ */
+
+SCM
+weechat_guile_api_buffer_get_pointer (SCM buffer, SCM property)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "buffer_get_pointer", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (scm_i_string_chars (buffer)),
+ scm_i_string_chars (property)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_buffer_set: set a buffer property
+ */
+
+SCM
+weechat_guile_api_buffer_set (SCM buffer, SCM property, SCM value)
+{
+ API_FUNC(1, "buffer_set", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (property)
+ || !scm_is_string (value))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_buffer_set (script_str2ptr (scm_i_string_chars (buffer)),
+ scm_i_string_chars (property),
+ scm_i_string_chars (value));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_buffer_string_replace_local_var: replace local variables
+ * ($var) in a string, using
+ * value of local variables
+ */
+
+SCM
+weechat_guile_api_buffer_string_replace_local_var (SCM buffer, SCM string)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "buffer_string_replace_local_var", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ result = weechat_buffer_string_replace_local_var (script_str2ptr (scm_i_string_chars (buffer)),
+ scm_i_string_chars (string));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_buffer_match_list: return 1 if buffer matches list of buffers
+ */
+
+SCM
+weechat_guile_api_buffer_match_list (SCM buffer, SCM string)
+{
+ int value;
+
+ API_FUNC(1, "buffer_match_list", API_RETURN_INT(0));
+ if (!scm_is_string (buffer) || !scm_is_string (string))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_buffer_match_list (script_str2ptr (scm_i_string_chars (buffer)),
+ scm_i_string_chars (string));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_current_window: get current window
+ */
+
+SCM
+weechat_guile_api_current_window ()
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "current_window", API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_current_window ());
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_window_search_with_buffer: search a window with buffer
+ * pointer
+ */
+
+SCM
+weechat_guile_api_window_search_with_buffer (SCM buffer)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "window_search_with_buffer", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (scm_i_string_chars (buffer))));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_window_get_integer: get a window property as integer
+ */
+
+SCM
+weechat_guile_api_window_get_integer (SCM window, SCM property)
+{
+ int value;
+
+ API_FUNC(1, "window_get_integer", API_RETURN_INT(-1));
+ if (!scm_is_string (window) || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ value = weechat_window_get_integer (script_str2ptr (scm_i_string_chars (window)),
+ scm_i_string_chars (property));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_window_get_string: get a window property as string
+ */
+
+SCM
+weechat_guile_api_window_get_string (SCM window, SCM property)
+{
+ const char *result;
+
+ API_FUNC(1, "window_get_string", API_RETURN_EMPTY);
+ if (!scm_is_string (window) || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_window_get_string (script_str2ptr (scm_i_string_chars (window)),
+ scm_i_string_chars (property));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_window_get_pointer: get a window property as pointer
+ */
+
+SCM
+weechat_guile_api_window_get_pointer (SCM window, SCM property)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "window_get_pointer", API_RETURN_EMPTY);
+ if (!scm_is_string (window) || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (scm_i_string_chars (window)),
+ scm_i_string_chars (property)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_window_set_title: set window title
+ */
+
+SCM
+weechat_guile_api_window_set_title (SCM title)
+{
+ API_FUNC(1, "window_set_title", API_RETURN_ERROR);
+ if (!scm_is_string (title))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_window_set_title (scm_i_string_chars (title));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_nicklist_add_group: add a group in nicklist
+ */
+
+SCM
+weechat_guile_api_nicklist_add_group (SCM buffer, SCM parent_group, SCM name,
+ SCM color, SCM visible)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "nicklist_add_group", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (parent_group)
+ || !scm_is_string (name) || !scm_is_string (color)
+ || !scm_is_integer (visible))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_nicklist_add_group (script_str2ptr (scm_i_string_chars (buffer)),
+ script_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);
+}
+
+/*
+ * weechat_guile_api_nicklist_search_group: search a group in nicklist
+ */
+
+SCM
+weechat_guile_api_nicklist_search_group (SCM buffer, SCM from_group, SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "nicklist_search_group", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (from_group)
+ || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_nicklist_search_group (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (from_group)),
+ scm_i_string_chars (name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_nicklist_add_nick: add a nick in nicklist
+ */
+
+SCM
+weechat_guile_api_nicklist_add_nick (SCM buffer, SCM group, SCM name,
+ SCM color, SCM prefix, SCM prefix_color,
+ SCM visible)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "nicklist_add_nick", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (group)
+ || !scm_is_string (name) || !scm_is_string (color)
+ || !scm_is_string (prefix) || !scm_is_string (prefix_color)
+ || !scm_is_integer (visible))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_nicklist_add_nick (script_str2ptr (scm_i_string_chars (buffer)),
+ script_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);
+}
+
+/*
+ * weechat_guile_api_nicklist_search_nick: search a nick in nicklist
+ */
+
+SCM
+weechat_guile_api_nicklist_search_nick (SCM buffer, SCM from_group, SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "nicklist_search_nick", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (from_group)
+ || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_nicklist_search_nick (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (from_group)),
+ scm_i_string_chars (name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_nicklist_remove_group: remove a group from nicklist
+ */
+
+SCM
+weechat_guile_api_nicklist_remove_group (SCM buffer, SCM group)
+{
+ API_FUNC(1, "nicklist_remove_group", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (group))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_nicklist_remove_group (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (group)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_nicklist_remove_nick: remove a nick from nicklist
+ */
+
+SCM
+weechat_guile_api_nicklist_remove_nick (SCM buffer, SCM nick)
+{
+ API_FUNC(1, "nicklist_remove_nick", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (nick))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_nicklist_remove_nick (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (nick)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_nicklist_remove_all: remove all groups/nicks from nicklist
+ */
+
+SCM
+weechat_guile_api_nicklist_remove_all (SCM buffer)
+{
+ API_FUNC(1, "nicklist_remove_all", API_RETURN_ERROR);
+ if (!scm_is_string (buffer))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_nicklist_remove_all (script_str2ptr (scm_i_string_chars (buffer)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_nicklist_group_get_integer: get a group property as integer
+ */
+
+SCM
+weechat_guile_api_nicklist_group_get_integer (SCM buffer, SCM group,
+ SCM property)
+{
+ int value;
+
+ API_FUNC(1, "nicklist_group_get_integer", API_RETURN_INT(-1));
+ if (!scm_is_string (buffer) || !scm_is_string (group)
+ || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ value = weechat_nicklist_group_get_integer (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (group)),
+ scm_i_string_chars (property));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_nicklist_group_get_string: get a group property as string
+ */
+
+SCM
+weechat_guile_api_nicklist_group_get_string (SCM buffer, SCM group,
+ SCM property)
+{
+ const char *result;
+
+ API_FUNC(1, "nicklist_group_get_string", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (group)
+ || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_nicklist_group_get_string (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (group)),
+ scm_i_string_chars (property));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_nicklist_group_get_pointer: get a group property as pointer
+ */
+
+SCM
+weechat_guile_api_nicklist_group_get_pointer (SCM buffer, SCM group,
+ SCM property)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "nicklist_group_get_pointer", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (group)
+ || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_nicklist_group_get_pointer (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (group)),
+ scm_i_string_chars (property)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_nicklist_group_set: set a group property
+ */
+
+SCM
+weechat_guile_api_nicklist_group_set (SCM buffer, SCM group, SCM property,
+ SCM value)
+{
+ API_FUNC(1, "nicklist_group_set", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (group) || !scm_is_string (property) || !scm_is_string (value))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_nicklist_group_set (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (group)),
+ scm_i_string_chars (property),
+ scm_i_string_chars (value));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_nicklist_nick_get_integer: get a nick property as integer
+ */
+
+SCM
+weechat_guile_api_nicklist_nick_get_integer (SCM buffer, SCM nick, SCM property)
+{
+ int value;
+
+ API_FUNC(1, "nicklist_nick_get_integer", API_RETURN_INT(-1));
+ if (!scm_is_string (buffer) || !scm_is_string (nick)
+ || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_INT(-1));
+
+ value = weechat_nicklist_nick_get_integer (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (nick)),
+ scm_i_string_chars (property));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_nicklist_nick_get_string: get a nick property as string
+ */
+
+SCM
+weechat_guile_api_nicklist_nick_get_string (SCM buffer, SCM nick, SCM property)
+{
+ const char *result;
+
+ API_FUNC(1, "nicklist_nick_get_string", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (nick)
+ || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_nicklist_nick_get_string (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (nick)),
+ scm_i_string_chars (property));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_nicklist_nick_get_pointer: get a nick property as pointer
+ */
+
+SCM
+weechat_guile_api_nicklist_nick_get_pointer (SCM buffer, SCM nick, SCM property)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "nicklist_nick_get_pointer", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer) || !scm_is_string (nick)
+ || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_nicklist_nick_get_pointer (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (nick)),
+ scm_i_string_chars (property)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_nicklist_nick_set: set a nick property
+ */
+
+SCM
+weechat_guile_api_nicklist_nick_set (SCM buffer, SCM nick, SCM property,
+ SCM value)
+{
+ API_FUNC(1, "nicklist_nick_set", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (nick)
+ || !scm_is_string (property) || !scm_is_string (value))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_nicklist_nick_set (script_str2ptr (scm_i_string_chars (buffer)),
+ script_str2ptr (scm_i_string_chars (nick)),
+ scm_i_string_chars (property),
+ scm_i_string_chars (value));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_bar_item_search: search a bar item
+ */
+
+SCM
+weechat_guile_api_bar_item_search (SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "bar_item_search", API_RETURN_EMPTY);
+ if (!scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_bar_item_search (scm_i_string_chars (name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_bar_item_build_cb: callback for building bar item
+ */
+
+char *
+weechat_guile_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
+ struct t_gui_window *window)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[3];
+ char empty_arg[1] = { '\0' }, *ret;
+
+ script_callback = (struct t_script_callback *)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 (item);
+ func_argv[2] = script_ptr2str (window);
+
+ ret = (char *)weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[2])
+ free (func_argv[2]);
+
+ return ret;
+ }
+
+ return NULL;
+}
+
+/*
+ * weechat_guile_api_bar_item_new: add a new bar item
+ */
+
+SCM
+weechat_guile_api_bar_item_new (SCM name, SCM function, SCM data)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "bar_item_new", API_RETURN_EMPTY);
+ if (!scm_is_string (name) || !scm_is_string (function)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_bar_item_update: update a bar item on screen
+ */
+
+SCM
+weechat_guile_api_bar_item_update (SCM name)
+{
+ API_FUNC(1, "bar_item_update", API_RETURN_ERROR);
+ if (!scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_bar_item_update (scm_i_string_chars (name));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_bar_item_remove: remove a bar item
+ */
+
+SCM
+weechat_guile_api_bar_item_remove (SCM item)
+{
+ API_FUNC(1, "bar_item_remove", API_RETURN_ERROR);
+ if (!scm_is_string (item))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_bar_item_remove (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (item)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_bar_search: search a bar
+ */
+
+SCM
+weechat_guile_api_bar_search (SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "bar_search", API_RETURN_EMPTY);
+ if (!scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_bar_search (scm_i_string_chars (name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_bar_new: add a new bar
+ */
+
+SCM
+weechat_guile_api_bar_new (SCM args)
+{
+ SCM name, hidden, priority, type, conditions, position, filling_top_bottom;
+ SCM filling_left_right, size, size_max, color_fg, color_delim, color_bg;
+ SCM separator, items;
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "bar_new", API_RETURN_EMPTY);
+ if (!scm_list_p (args) || (scm_to_int (scm_length (args)) != 15))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ name = scm_list_ref (args, scm_from_int (0));
+ hidden = scm_list_ref (args, scm_from_int (1));
+ priority = scm_list_ref (args, scm_from_int (2));
+ type = scm_list_ref (args, scm_from_int (3));
+ conditions = scm_list_ref (args, scm_from_int (4));
+ position = scm_list_ref (args, scm_from_int (5));
+ filling_top_bottom = scm_list_ref (args, scm_from_int (6));
+ filling_left_right = scm_list_ref (args, scm_from_int (7));
+ size = scm_list_ref (args, scm_from_int (8));
+ size_max = scm_list_ref (args, scm_from_int (9));
+ color_fg = scm_list_ref (args, scm_from_int (10));
+ color_delim = scm_list_ref (args, scm_from_int (11));
+ color_bg = scm_list_ref (args, scm_from_int (12));
+ separator = scm_list_ref (args, scm_from_int (13));
+ items = scm_list_ref (args, scm_from_int (14));
+
+ if (!scm_is_string (name) || !scm_is_string (hidden)
+ || !scm_is_string (priority) || !scm_is_string (type)
+ || !scm_is_string (conditions) || !scm_is_string (position)
+ || !scm_is_string (filling_top_bottom) || !scm_is_string (filling_left_right)
+ || !scm_is_string (size) || !scm_is_string (size_max)
+ || !scm_is_string (color_fg) || !scm_is_string (color_delim)
+ || !scm_is_string (color_bg) || !scm_is_string (separator)
+ || !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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_bar_set: set a bar property
+ */
+
+SCM
+weechat_guile_api_bar_set (SCM bar, SCM property, SCM value)
+{
+ API_FUNC(1, "bar_set", API_RETURN_ERROR);
+ if (!scm_is_string (bar) || !scm_is_string (property)
+ || !scm_is_string (value))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_bar_set (script_str2ptr (scm_i_string_chars (bar)),
+ scm_i_string_chars (property),
+ scm_i_string_chars (value));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_bar_update: update a bar on screen
+ */
+
+SCM
+weechat_guile_api_bar_update (SCM name)
+{
+ API_FUNC(1, "bar_update", API_RETURN_ERROR);
+ if (!scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_bar_update (scm_i_string_chars (name));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_bar_remove: remove a bar
+ */
+
+SCM
+weechat_guile_api_bar_remove (SCM bar)
+{
+ API_FUNC(1, "bar_remove", API_RETURN_ERROR);
+ if (!scm_is_string (bar))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_bar_remove (script_str2ptr (scm_i_string_chars (bar)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_command: send command to server
+ */
+
+SCM
+weechat_guile_api_command (SCM buffer, SCM command)
+{
+ API_FUNC(1, "command", API_RETURN_ERROR);
+ if (!scm_is_string (buffer) || !scm_is_string (command))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ script_api_command (weechat_guile_plugin,
+ guile_current_script,
+ script_str2ptr (scm_i_string_chars (buffer)),
+ scm_i_string_chars (command));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_info_get: get info (as string)
+ */
+
+SCM
+weechat_guile_api_info_get (SCM info_name, SCM arguments)
+{
+ const char *result;
+
+ API_FUNC(1, "info_get", API_RETURN_EMPTY);
+ if (!scm_is_string (info_name) || !scm_is_string (arguments))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_info_get (scm_i_string_chars (info_name),
+ scm_i_string_chars (arguments));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_info_get_hashtable: get info (as hashtable)
+ */
+
+SCM
+weechat_guile_api_info_get_hashtable (SCM info_name, SCM hash)
+{
+ struct t_hashtable *c_hashtable, *result_hashtable;
+ SCM result_hash;
+
+ API_FUNC(1, "info_get_hashtable", API_RETURN_EMPTY);
+ if (!scm_is_string (info_name) || !scm_list_p (hash))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ c_hashtable = weechat_guile_alist_to_hashtable (hash,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+
+ result_hashtable = weechat_info_get_hashtable (scm_i_string_chars (info_name),
+ c_hashtable);
+ result_hash = weechat_guile_hashtable_to_alist (result_hashtable);
+
+ if (c_hashtable)
+ weechat_hashtable_free (c_hashtable);
+ if (result_hashtable)
+ weechat_hashtable_free (result_hashtable);
+
+ return result_hash;
+}
+
+/*
+ * weechat_guile_api_infolist_new: create new infolist
+ */
+
+SCM
+weechat_guile_api_infolist_new ()
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_new", API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_new ());
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_new_item: create new item in infolist
+ */
+
+SCM
+weechat_guile_api_infolist_new_item (SCM infolist)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_new_item", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_new_item (script_str2ptr (scm_i_string_chars (infolist))));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_new_var_integer: create new integer variable in
+ * infolist
+ */
+
+SCM
+weechat_guile_api_infolist_new_var_integer (SCM infolist, SCM name, SCM value)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_new_var_integer", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist) || !scm_is_string (name)
+ || !scm_is_integer (value))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_new_var_integer (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (name),
+ scm_to_int (value)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_new_var_string: create new string variable in
+ * infolist
+ */
+
+SCM
+weechat_guile_api_infolist_new_var_string (SCM infolist, SCM name, SCM value)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_new_var_string", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist) || !scm_is_string (name)
+ || !scm_is_string (value))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (name),
+ scm_i_string_chars (value)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_new_var_pointer: create new pointer variable in
+ * infolist
+ */
+
+SCM
+weechat_guile_api_infolist_new_var_pointer (SCM infolist, SCM name, SCM value)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_new_var_pointer", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist) || !scm_is_string (name)
+ || !scm_is_string (value))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_new_var_pointer (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (name),
+ script_str2ptr (scm_i_string_chars (value))));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_new_var_time: create new time variable in infolist
+ */
+
+SCM
+weechat_guile_api_infolist_new_var_time (SCM infolist, SCM name, SCM value)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist) || !scm_is_string (name)
+ || !scm_is_integer (value))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_new_var_time (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (name),
+ scm_to_int (value)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_get: get list with infos
+ */
+
+SCM
+weechat_guile_api_infolist_get (SCM name, SCM pointer, SCM arguments)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_get", API_RETURN_EMPTY);
+ if (!scm_is_string (name) || !scm_is_string (pointer)
+ || !scm_is_string (arguments))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_get (scm_i_string_chars (name),
+ script_str2ptr (scm_i_string_chars (pointer)),
+ scm_i_string_chars (arguments)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_next: move item pointer to next item in infolist
+ */
+
+SCM
+weechat_guile_api_infolist_next (SCM infolist)
+{
+ int value;
+
+ API_FUNC(1, "infolist_next", API_RETURN_INT(0));
+ if (!scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_infolist_next (script_str2ptr (scm_i_string_chars (infolist)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_infolist_prev: move item pointer to previous item in
+ * infolist
+ */
+
+SCM
+weechat_guile_api_infolist_prev (SCM infolist)
+{
+ int value;
+
+ API_FUNC(1, "infolist_prev", API_RETURN_INT(0));
+ if (!scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_infolist_prev (script_str2ptr (scm_i_string_chars (infolist)));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_infolist_reset_item_cursor: reset pointer to current item
+ * in infolist
+ */
+
+SCM
+weechat_guile_api_infolist_reset_item_cursor (SCM infolist)
+{
+ API_FUNC(1, "infolist_reset_item_cursor", API_RETURN_ERROR);
+ if (!scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_infolist_reset_item_cursor (script_str2ptr (scm_i_string_chars (infolist)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_infolist_fields: get list of fields for current item of infolist
+ */
+
+SCM
+weechat_guile_api_infolist_fields (SCM infolist)
+{
+ const char *result;
+
+ API_FUNC(1, "infolist_fields", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_infolist_fields (script_str2ptr (scm_i_string_chars (infolist)));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_infolist_integer: get integer value of a variable in
+ * infolist
+ */
+
+SCM
+weechat_guile_api_infolist_integer (SCM infolist, SCM variable)
+{
+ int value;
+
+ API_FUNC(1, "infolist_integer", API_RETURN_INT(0));
+ if (!scm_is_string (infolist) || !scm_is_string (variable))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_infolist_integer (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (variable));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_infolist_string: get string value of a variable in infolist
+ */
+
+SCM
+weechat_guile_api_infolist_string (SCM infolist, SCM variable)
+{
+ const char *result;
+
+ API_FUNC(1, "infolist_string", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist) || !scm_is_string (variable))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_infolist_string (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (variable));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_infolist_pointer: get pointer value of a variable in
+ * infolist
+ */
+
+SCM
+weechat_guile_api_infolist_pointer (SCM infolist, SCM variable)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_pointer", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist) || !scm_is_string (variable))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_infolist_pointer (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (variable)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_time: get time value of a variable in infolist
+ */
+
+SCM
+weechat_guile_api_infolist_time (SCM infolist, SCM variable)
+{
+ char timebuffer[64], *result;
+ time_t time;
+ SCM return_value;
+
+ API_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ if (!scm_is_string (infolist) || !scm_is_string (variable))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ time = weechat_infolist_time (script_str2ptr (scm_i_string_chars (infolist)),
+ scm_i_string_chars (variable));
+ strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
+ result = strdup (timebuffer);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_infolist_free: free infolist
+ */
+
+SCM
+weechat_guile_api_infolist_free (SCM infolist)
+{
+ API_FUNC(1, "infolist_free", API_RETURN_ERROR);
+ if (!scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_infolist_free (script_str2ptr (scm_i_string_chars (infolist)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_hdata_get: get hdata
+ */
+
+SCM
+weechat_guile_api_hdata_get (SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hdata_get", API_RETURN_EMPTY);
+ if (!scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_hdata_get (scm_i_string_chars (name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hdata_get_var_offset: get offset of variable in hdata
+ */
+
+SCM
+weechat_guile_api_hdata_get_var_offset (SCM hdata, SCM name)
+{
+ int value;
+
+ API_FUNC(1, "hdata_get_var_offset", API_RETURN_INT(0));
+ if (!scm_is_string (hdata) || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_hdata_get_var_offset (script_str2ptr (scm_i_string_chars (hdata)),
+ scm_i_string_chars (name));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_hdata_get_var_type_string: get type of variable as string
+ * in hdata
+ */
+
+SCM
+weechat_guile_api_hdata_get_var_type_string (SCM hdata, SCM name)
+{
+ const char *result;
+
+ API_FUNC(1, "hdata_get_var_type_string", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_hdata_get_var_type_string (script_str2ptr (scm_i_string_chars (hdata)),
+ scm_i_string_chars (name));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_hdata_get_var_hdata: get hdata for variable in hdata
+ */
+
+SCM
+weechat_guile_api_hdata_get_var_hdata (SCM hdata, SCM name)
+{
+ const char *result;
+
+ API_FUNC(1, "hdata_get_var_hdata", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_hdata_get_var_hdata (script_str2ptr (scm_i_string_chars (hdata)),
+ scm_i_string_chars (name));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_hdata_get_list: get list pointer in hdata
+ */
+
+SCM
+weechat_guile_api_hdata_get_list (SCM hdata, SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hdata_get_list", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_hdata_get_list (script_str2ptr (scm_i_string_chars (hdata)),
+ scm_i_string_chars (name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hdata_move: move pointer to another element in list
+ */
+
+SCM
+weechat_guile_api_hdata_move (SCM hdata, SCM pointer, SCM count)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hdata_move", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (pointer)
+ || !scm_is_integer (count))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_hdata_move (script_str2ptr (scm_i_string_chars (hdata)),
+ script_str2ptr (scm_i_string_chars (pointer)),
+ scm_to_int (count));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hdata_integer: get integer value of a variable in structure
+ * using hdata
+ */
+
+SCM
+weechat_guile_api_hdata_integer (SCM hdata, SCM pointer, SCM name)
+{
+ int value;
+
+ API_FUNC(1, "hdata_integer", API_RETURN_INT(0));
+ if (!scm_is_string (hdata) || !scm_is_string (pointer)
+ || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ value = weechat_hdata_integer (script_str2ptr (scm_i_string_chars (hdata)),
+ script_str2ptr (scm_i_string_chars (pointer)),
+ scm_i_string_chars (name));
+
+ API_RETURN_INT(value);
+}
+
+/*
+ * weechat_guile_api_hdata_long: get long value of a variable in structure using
+ * hdata
+ */
+
+SCM
+weechat_guile_api_hdata_long (SCM hdata, SCM pointer, SCM name)
+{
+ long value;
+
+ API_FUNC(1, "hdata_long", API_RETURN_LONG(0));
+ if (!scm_is_string (hdata) || !scm_is_string (pointer)
+ || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ value = weechat_hdata_long (script_str2ptr (scm_i_string_chars (hdata)),
+ script_str2ptr (scm_i_string_chars (pointer)),
+ scm_i_string_chars (name));
+
+ API_RETURN_LONG(value);
+}
+
+/*
+ * weechat_guile_api_hdata_string: get string value of a variable in structure
+ * using hdata
+ */
+
+SCM
+weechat_guile_api_hdata_string (SCM hdata, SCM pointer, SCM name)
+{
+ const char *result;
+
+ API_FUNC(1, "hdata_string", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (pointer)
+ || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_hdata_string (script_str2ptr (scm_i_string_chars (hdata)),
+ script_str2ptr (scm_i_string_chars (pointer)),
+ scm_i_string_chars (name));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_hdata_pointer: get pointer value of a variable in structure
+ * using hdata
+ */
+
+SCM
+weechat_guile_api_hdata_pointer (SCM hdata, SCM pointer, SCM name)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "hdata_pointer", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (pointer)
+ || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = script_ptr2str (weechat_hdata_pointer (script_str2ptr (scm_i_string_chars (hdata)),
+ script_str2ptr (scm_i_string_chars (pointer)),
+ scm_i_string_chars (name)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hdata_time: get time value of a variable in structure using
+ * hdata
+ */
+
+SCM
+weechat_guile_api_hdata_time (SCM hdata, SCM pointer, SCM name)
+{
+ char timebuffer[64], *result;
+ time_t time;
+ SCM return_value;
+
+ API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (pointer) || !scm_is_string (name))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ time = weechat_hdata_time (script_str2ptr (scm_i_string_chars (hdata)),
+ script_str2ptr (scm_i_string_chars (pointer)),
+ scm_i_string_chars (name));
+ strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
+ result = strdup (timebuffer);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_hdata_get_string: get hdata property as string
+ */
+
+SCM
+weechat_guile_api_hdata_get_string (SCM hdata, SCM property)
+{
+ const char *result;
+
+ API_FUNC(1, "hdata_get_string", API_RETURN_EMPTY);
+ if (!scm_is_string (hdata) || !scm_is_string (property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_hdata_get_var_type_string (script_str2ptr (scm_i_string_chars (hdata)),
+ scm_i_string_chars (property));
+
+ API_RETURN_STRING(result);
+}
+
+/*
+ * weechat_guile_api_upgrade_new: create an upgrade file
+ */
+
+SCM
+weechat_guile_api_upgrade_new (SCM filename, SCM write)
+{
+ char *result;
+ SCM return_value;
+
+ API_FUNC(1, "upgrade_new", API_RETURN_EMPTY);
+ 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)));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
+ * weechat_guile_api_upgrade_write_object: write object in upgrade file
+ */
+
+SCM
+weechat_guile_api_upgrade_write_object (SCM upgrade_file, SCM object_id,
+ SCM infolist)
+{
+ int rc;
+
+ API_FUNC(1, "upgrade_write_object", API_RETURN_INT(0));
+ if (!scm_is_string (upgrade_file) || !scm_is_integer (object_id)
+ || !scm_is_string (infolist))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ rc = weechat_upgrade_write_object (script_str2ptr (scm_i_string_chars (upgrade_file)),
+ scm_to_int (object_id),
+ script_str2ptr (scm_i_string_chars (infolist)));
+
+ API_RETURN_INT(rc);
+}
+
+/*
+ * weechat_guile_api_upgrade_read_cb: callback for reading object in upgrade
+ * file
+ */
+
+int
+weechat_guile_api_upgrade_read_cb (void *data,
+ struct t_upgrade_file *upgrade_file,
+ int object_id,
+ struct t_infolist *infolist)
+{
+ struct t_script_callback *script_callback;
+ void *func_argv[4];
+ char empty_arg[1] = { '\0' }, str_object_id[32];
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback && script_callback->function && script_callback->function[0])
+ {
+ 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[2] = str_object_id;
+ func_argv[3] = script_ptr2str (infolist);
+
+ rc = (int *) weechat_guile_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ "ssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[3])
+ free (func_argv[3]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+/*
+ * weechat_guile_api_upgrade_read: read upgrade file
+ */
+
+SCM
+weechat_guile_api_upgrade_read (SCM upgrade_file, SCM function, SCM data)
+{
+ int rc;
+
+ API_FUNC(1, "upgrade_read", API_RETURN_INT(0));
+ if (!scm_is_string (upgrade_file) || !scm_is_string (function)
+ || !scm_is_string (data))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ rc = script_api_upgrade_read (weechat_guile_plugin,
+ guile_current_script,
+ script_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);
+}
+
+/*
+ * weechat_guile_api_upgrade_close: close upgrade file
+ */
+
+SCM
+weechat_guile_api_upgrade_close (SCM upgrade_file)
+{
+ API_FUNC(1, "upgrade_close", API_RETURN_ERROR);
+ if (!scm_is_string (upgrade_file))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_upgrade_close (script_str2ptr (scm_i_string_chars (upgrade_file)));
+
+ API_RETURN_OK;
+}
+
+/*
+ * weechat_guile_api_module_init: init main module with API
+ */
+
+void
+weechat_guile_api_module_init (void *data)
+{
+ scm_t_bits port_type;
+ scm_t_port *pt;
+
+ /* make C compiler happy */
+ (void) data;
+
+ /* Setting up the xchat output window as our default output ports */
+ port_type = scm_make_port_type ("weechat_stdout",
+ &weechat_guile_port_fill_input,
+ &weechat_guile_port_write);
+ guile_port = scm_new_port_table_entry (port_type);
+ SCM_SET_CELL_TYPE (guile_port, port_type | SCM_OPN | SCM_WRTNG);
+ pt = SCM_PTAB_ENTRY (guile_port);
+ pt->rw_random = 0;
+ scm_set_current_output_port (guile_port);
+ scm_set_current_error_port (guile_port);
+
+ /* interface functions */
+ scm_c_define_gsubr ("weechat:register", 7, 0, 0, &weechat_guile_api_register);
+ scm_c_define_gsubr ("weechat:plugin_get_name", 1, 0, 0, &weechat_guile_api_plugin_get_name);
+ scm_c_define_gsubr ("weechat:charset_set", 1, 0, 0, &weechat_guile_api_charset_set);
+ scm_c_define_gsubr ("weechat:iconv_to_internal", 2, 0, 0, &weechat_guile_api_iconv_to_internal);
+ scm_c_define_gsubr ("weechat:iconv_from_internal", 2, 0, 0, &weechat_guile_api_iconv_from_internal);
+ scm_c_define_gsubr ("weechat:gettext", 1, 0, 0, &weechat_guile_api_gettext);
+ scm_c_define_gsubr ("weechat:ngettext", 3, 0, 0, &weechat_guile_api_ngettext);
+ scm_c_define_gsubr ("weechat:string_match", 3, 0, 0, &weechat_guile_api_string_match);
+ scm_c_define_gsubr ("weechat:string_has_highlight", 2, 0, 0, &weechat_guile_api_string_has_highlight);
+ scm_c_define_gsubr ("weechat:string_has_highlight_regex", 2, 0, 0, &weechat_guile_api_string_has_highlight_regex);
+ scm_c_define_gsubr ("weechat:string_mask_to_regex", 1, 0, 0, &weechat_guile_api_string_mask_to_regex);
+ scm_c_define_gsubr ("weechat:string_remove_color", 2, 0, 0, &weechat_guile_api_string_remove_color);
+ scm_c_define_gsubr ("weechat:string_is_command_char", 1, 0, 0, &weechat_guile_api_string_is_command_char);
+ scm_c_define_gsubr ("weechat:string_input_for_buffer", 1, 0, 0, &weechat_guile_api_string_input_for_buffer);
+ scm_c_define_gsubr ("weechat:mkdir_home", 2, 0, 0, &weechat_guile_api_mkdir_home);
+ scm_c_define_gsubr ("weechat:mkdir", 2, 0, 0, &weechat_guile_api_mkdir);
+ scm_c_define_gsubr ("weechat:mkdir_parents", 2, 0, 0, &weechat_guile_api_mkdir_parents);
+ scm_c_define_gsubr ("weechat:list_new", 0, 0, 0, &weechat_guile_api_list_new);
+ scm_c_define_gsubr ("weechat:list_add", 4, 0, 0, &weechat_guile_api_list_add);
+ scm_c_define_gsubr ("weechat:list_search", 2, 0, 0, &weechat_guile_api_list_search);
+ scm_c_define_gsubr ("weechat:list_search_pos", 2, 0, 0, &weechat_guile_api_list_search_pos);
+ scm_c_define_gsubr ("weechat:list_casesearch", 2, 0, 0, &weechat_guile_api_list_casesearch);
+ scm_c_define_gsubr ("weechat:list_casesearch_pos", 2, 0, 0, &weechat_guile_api_list_casesearch_pos);
+ scm_c_define_gsubr ("weechat:list_get", 2, 0, 0, &weechat_guile_api_list_get);
+ scm_c_define_gsubr ("weechat:list_set", 2, 0, 0, &weechat_guile_api_list_set);
+ scm_c_define_gsubr ("weechat:list_next", 1, 0, 0, &weechat_guile_api_list_next);
+ scm_c_define_gsubr ("weechat:list_prev", 1, 0, 0, &weechat_guile_api_list_prev);
+ scm_c_define_gsubr ("weechat:list_string", 1, 0, 0, &weechat_guile_api_list_string);
+ scm_c_define_gsubr ("weechat:list_size", 1, 0, 0, &weechat_guile_api_list_size);
+ scm_c_define_gsubr ("weechat:list_remove", 2, 0, 0, &weechat_guile_api_list_remove);
+ scm_c_define_gsubr ("weechat:list_remove_all", 1, 0, 0, &weechat_guile_api_list_remove_all);
+ scm_c_define_gsubr ("weechat:list_free", 1, 0, 0, &weechat_guile_api_list_free);
+ scm_c_define_gsubr ("weechat:config_new", 3, 0, 0, &weechat_guile_api_config_new);
+ scm_c_define_gsubr ("weechat:config_new_section", 1, 0, 0, &weechat_guile_api_config_new_section);
+ scm_c_define_gsubr ("weechat:config_search_section", 2, 0, 0, &weechat_guile_api_config_search_section);
+ scm_c_define_gsubr ("weechat:config_new_option", 1, 0, 0, &weechat_guile_api_config_new_option);
+ scm_c_define_gsubr ("weechat:config_search_option", 3, 0, 0, &weechat_guile_api_config_search_option);
+ scm_c_define_gsubr ("weechat:config_string_to_boolean", 1, 0, 0, &weechat_guile_api_config_string_to_boolean);
+ scm_c_define_gsubr ("weechat:config_option_reset", 2, 0, 0, &weechat_guile_api_config_option_reset);
+ scm_c_define_gsubr ("weechat:config_option_set", 3, 0, 0, &weechat_guile_api_config_option_set);
+ scm_c_define_gsubr ("weechat:config_option_set_null", 2, 0, 0, &weechat_guile_api_config_option_set_null);
+ scm_c_define_gsubr ("weechat:config_option_unset", 1, 0, 0, &weechat_guile_api_config_option_unset);
+ scm_c_define_gsubr ("weechat:config_option_rename", 2, 0, 0, &weechat_guile_api_config_option_rename);
+ scm_c_define_gsubr ("weechat:config_option_is_null", 1, 0, 0, &weechat_guile_api_config_option_is_null);
+ scm_c_define_gsubr ("weechat:config_option_default_is_null", 1, 0, 0, &weechat_guile_api_config_option_default_is_null);
+ scm_c_define_gsubr ("weechat:config_boolean", 1, 0, 0, &weechat_guile_api_config_boolean);
+ scm_c_define_gsubr ("weechat:config_boolean_default", 1, 0, 0, &weechat_guile_api_config_boolean_default);
+ scm_c_define_gsubr ("weechat:config_integer", 1, 0, 0, &weechat_guile_api_config_integer);
+ scm_c_define_gsubr ("weechat:config_integer_default", 1, 0, 0, &weechat_guile_api_config_integer_default);
+ scm_c_define_gsubr ("weechat:config_string", 1, 0, 0, &weechat_guile_api_config_string);
+ scm_c_define_gsubr ("weechat:config_string_default", 1, 0, 0, &weechat_guile_api_config_string_default);
+ scm_c_define_gsubr ("weechat:config_color", 1, 0, 0, &weechat_guile_api_config_color);
+ scm_c_define_gsubr ("weechat:config_color_default", 1, 0, 0, &weechat_guile_api_config_color_default);
+ scm_c_define_gsubr ("weechat:config_write_option", 2, 0, 0, &weechat_guile_api_config_write_option);
+ scm_c_define_gsubr ("weechat:config_write_line", 3, 0, 0, &weechat_guile_api_config_write_line);
+ scm_c_define_gsubr ("weechat:config_write", 1, 0, 0, &weechat_guile_api_config_write);
+ scm_c_define_gsubr ("weechat:config_read", 1, 0, 0, &weechat_guile_api_config_read);
+ scm_c_define_gsubr ("weechat:config_reload", 1, 0, 0, &weechat_guile_api_config_reload);
+ scm_c_define_gsubr ("weechat:config_option_free", 1, 0, 0, &weechat_guile_api_config_option_free);
+ scm_c_define_gsubr ("weechat:config_section_free_options", 1, 0, 0, &weechat_guile_api_config_section_free_options);
+ scm_c_define_gsubr ("weechat:config_section_free", 1, 0, 0, &weechat_guile_api_config_section_free);
+ scm_c_define_gsubr ("weechat:config_free", 1, 0, 0, &weechat_guile_api_config_free);
+ scm_c_define_gsubr ("weechat:config_get", 1, 0, 0, &weechat_guile_api_config_get);
+ scm_c_define_gsubr ("weechat:config_get_plugin", 1, 0, 0, &weechat_guile_api_config_get_plugin);
+ scm_c_define_gsubr ("weechat:config_is_set_plugin", 1, 0, 0, &weechat_guile_api_config_is_set_plugin);
+ scm_c_define_gsubr ("weechat:config_set_plugin", 2, 0, 0, &weechat_guile_api_config_set_plugin);
+ scm_c_define_gsubr ("weechat:config_set_desc_plugin", 2, 0, 0, &weechat_guile_api_config_set_desc_plugin);
+ scm_c_define_gsubr ("weechat:config_unset_plugin", 1, 0, 0, &weechat_guile_api_config_unset_plugin);
+ scm_c_define_gsubr ("weechat:key_bind", 2, 0, 0, &weechat_guile_api_key_bind);
+ scm_c_define_gsubr ("weechat:key_unbind", 2, 0, 0, &weechat_guile_api_key_unbind);
+ scm_c_define_gsubr ("weechat:prefix", 1, 0, 0, &weechat_guile_api_prefix);
+ scm_c_define_gsubr ("weechat:color", 1, 0, 0, &weechat_guile_api_color);
+ scm_c_define_gsubr ("weechat:print", 2, 0, 0, &weechat_guile_api_print);
+ scm_c_define_gsubr ("weechat:print_date_tags", 4, 0, 0, &weechat_guile_api_print_date_tags);
+ scm_c_define_gsubr ("weechat:print_y", 3, 0, 0, &weechat_guile_api_print_y);
+ scm_c_define_gsubr ("weechat:log_print", 1, 0, 0, &weechat_guile_api_log_print);
+ scm_c_define_gsubr ("weechat:hook_command", 7, 0, 0, &weechat_guile_api_hook_command);
+ scm_c_define_gsubr ("weechat:hook_command_run", 3, 0, 0, &weechat_guile_api_hook_command_run);
+ scm_c_define_gsubr ("weechat:hook_timer", 5, 0, 0, &weechat_guile_api_hook_timer);
+ scm_c_define_gsubr ("weechat:hook_fd", 6, 0, 0, &weechat_guile_api_hook_fd);
+ scm_c_define_gsubr ("weechat:hook_process", 4, 0, 0, &weechat_guile_api_hook_process);
+ scm_c_define_gsubr ("weechat:hook_connect", 8, 0, 0, &weechat_guile_api_hook_connect);
+ scm_c_define_gsubr ("weechat:hook_print", 6, 0, 0, &weechat_guile_api_hook_print);
+ scm_c_define_gsubr ("weechat:hook_signal", 3, 0, 0, &weechat_guile_api_hook_signal);
+ scm_c_define_gsubr ("weechat:hook_signal_send", 3, 0, 0, &weechat_guile_api_hook_signal_send);
+ scm_c_define_gsubr ("weechat:hook_hsignal", 3, 0, 0, &weechat_guile_api_hook_hsignal);
+ scm_c_define_gsubr ("weechat:hook_hsignal_send", 2, 0, 0, &weechat_guile_api_hook_hsignal_send);
+ scm_c_define_gsubr ("weechat:hook_config", 3, 0, 0, &weechat_guile_api_hook_config);
+ scm_c_define_gsubr ("weechat:hook_completion", 4, 0, 0, &weechat_guile_api_hook_completion);
+ scm_c_define_gsubr ("weechat:hook_completion_list_add", 4, 0, 0, &weechat_guile_api_hook_completion_list_add);
+ scm_c_define_gsubr ("weechat:hook_modifier", 3, 0, 0, &weechat_guile_api_hook_modifier);
+ scm_c_define_gsubr ("weechat:hook_modifier_exec", 3, 0, 0, &weechat_guile_api_hook_modifier_exec);
+ scm_c_define_gsubr ("weechat:hook_info", 5, 0, 0, &weechat_guile_api_hook_info);
+ scm_c_define_gsubr ("weechat:hook_info_hashtable", 6, 0, 0, &weechat_guile_api_hook_info_hashtable);
+ scm_c_define_gsubr ("weechat:hook_infolist", 6, 0, 0, &weechat_guile_api_hook_infolist);
+ scm_c_define_gsubr ("weechat:hook_focus", 3, 0, 0, &weechat_guile_api_hook_focus);
+ scm_c_define_gsubr ("weechat:unhook", 1, 0, 0, &weechat_guile_api_unhook);
+ scm_c_define_gsubr ("weechat:unhook_all", 0, 0, 0, &weechat_guile_api_unhook_all);
+ scm_c_define_gsubr ("weechat:buffer_new", 5, 0, 0, &weechat_guile_api_buffer_new);
+ scm_c_define_gsubr ("weechat:buffer_search", 2, 0, 0, &weechat_guile_api_buffer_search);
+ scm_c_define_gsubr ("weechat:buffer_search_main", 0, 0, 0, &weechat_guile_api_buffer_search_main);
+ scm_c_define_gsubr ("weechat:current_buffer", 0, 0, 0, &weechat_guile_api_current_buffer);
+ scm_c_define_gsubr ("weechat:buffer_clear", 1, 0, 0, &weechat_guile_api_buffer_clear);
+ scm_c_define_gsubr ("weechat:buffer_close", 1, 0, 0, &weechat_guile_api_buffer_close);
+ scm_c_define_gsubr ("weechat:buffer_merge", 2, 0, 0, &weechat_guile_api_buffer_merge);
+ scm_c_define_gsubr ("weechat:buffer_unmerge", 2, 0, 0, &weechat_guile_api_buffer_unmerge);
+ scm_c_define_gsubr ("weechat:buffer_get_integer", 2, 0, 0, &weechat_guile_api_buffer_get_integer);
+ scm_c_define_gsubr ("weechat:buffer_get_string", 2, 0, 0, &weechat_guile_api_buffer_get_string);
+ scm_c_define_gsubr ("weechat:buffer_get_pointer", 2, 0, 0, &weechat_guile_api_buffer_get_pointer);
+ scm_c_define_gsubr ("weechat:buffer_set", 3, 0, 0, &weechat_guile_api_buffer_set);
+ scm_c_define_gsubr ("weechat:buffer_string_replace_local_var", 2, 0, 0, &weechat_guile_api_buffer_string_replace_local_var);
+ scm_c_define_gsubr ("weechat:buffer_match_list", 2, 0, 0, &weechat_guile_api_buffer_match_list);
+ scm_c_define_gsubr ("weechat:current_window", 0, 0, 0, &weechat_guile_api_current_window);
+ scm_c_define_gsubr ("weechat:window_search_with_buffer", 1, 0, 0, &weechat_guile_api_window_search_with_buffer);
+ scm_c_define_gsubr ("weechat:window_get_integer", 2, 0, 0, &weechat_guile_api_window_get_integer);
+ scm_c_define_gsubr ("weechat:window_get_string", 2, 0, 0, &weechat_guile_api_window_get_string);
+ scm_c_define_gsubr ("weechat:window_get_pointer", 2, 0, 0, &weechat_guile_api_window_get_pointer);
+ scm_c_define_gsubr ("weechat:window_set_title", 1, 0, 0, &weechat_guile_api_window_set_title);
+ scm_c_define_gsubr ("weechat:nicklist_add_group", 5, 0, 0, &weechat_guile_api_nicklist_add_group);
+ scm_c_define_gsubr ("weechat:nicklist_search_group", 3, 0, 0, &weechat_guile_api_nicklist_search_group);
+ scm_c_define_gsubr ("weechat:nicklist_add_nick", 7, 0, 0, &weechat_guile_api_nicklist_add_nick);
+ scm_c_define_gsubr ("weechat:nicklist_search_nick", 3, 0, 0, &weechat_guile_api_nicklist_search_nick);
+ scm_c_define_gsubr ("weechat:nicklist_remove_group", 2, 0, 0, &weechat_guile_api_nicklist_remove_group);
+ scm_c_define_gsubr ("weechat:nicklist_remove_nick", 2, 0, 0, &weechat_guile_api_nicklist_remove_nick);
+ scm_c_define_gsubr ("weechat:nicklist_remove_all", 1, 0, 0, &weechat_guile_api_nicklist_remove_all);
+ scm_c_define_gsubr ("weechat:nicklist_group_get_integer", 3, 0, 0, &weechat_guile_api_nicklist_group_get_integer);
+ scm_c_define_gsubr ("weechat:nicklist_group_get_string", 3, 0, 0, &weechat_guile_api_nicklist_group_get_string);
+ scm_c_define_gsubr ("weechat:nicklist_group_get_pointer", 3, 0, 0, &weechat_guile_api_nicklist_group_get_pointer);
+ scm_c_define_gsubr ("weechat:nicklist_group_set", 4, 0, 0, &weechat_guile_api_nicklist_group_set);
+ scm_c_define_gsubr ("weechat:nicklist_nick_get_integer", 3, 0, 0, &weechat_guile_api_nicklist_nick_get_integer);
+ scm_c_define_gsubr ("weechat:nicklist_nick_get_string", 3, 0, 0, &weechat_guile_api_nicklist_nick_get_string);
+ scm_c_define_gsubr ("weechat:nicklist_nick_get_pointer", 3, 0, 0, &weechat_guile_api_nicklist_nick_get_pointer);
+ scm_c_define_gsubr ("weechat:nicklist_nick_set", 4, 0, 0, &weechat_guile_api_nicklist_nick_set);
+ scm_c_define_gsubr ("weechat:bar_item_search", 1, 0, 0, &weechat_guile_api_bar_item_search);
+ scm_c_define_gsubr ("weechat:bar_item_new", 3, 0, 0, &weechat_guile_api_bar_item_new);
+ scm_c_define_gsubr ("weechat:bar_item_update", 1, 0, 0, &weechat_guile_api_bar_item_update);
+ scm_c_define_gsubr ("weechat:bar_item_remove", 1, 0, 0, &weechat_guile_api_bar_item_remove);
+ scm_c_define_gsubr ("weechat:bar_search", 1, 0, 0, &weechat_guile_api_bar_search);
+ scm_c_define_gsubr ("weechat:bar_new", 1, 0, 0, &weechat_guile_api_bar_new);
+ scm_c_define_gsubr ("weechat:bar_set", 3, 0, 0, &weechat_guile_api_bar_set);
+ scm_c_define_gsubr ("weechat:bar_update", 1, 0, 0, &weechat_guile_api_bar_update);
+ scm_c_define_gsubr ("weechat:bar_remove", 1, 0, 0, &weechat_guile_api_bar_remove);
+ scm_c_define_gsubr ("weechat:command", 2, 0, 0, &weechat_guile_api_command);
+ scm_c_define_gsubr ("weechat:info_get", 2, 0, 0, &weechat_guile_api_info_get);
+ scm_c_define_gsubr ("weechat:info_get_hashtable", 2, 0, 0, &weechat_guile_api_info_get_hashtable);
+ scm_c_define_gsubr ("weechat:infolist_new", 0, 0, 0, &weechat_guile_api_infolist_new);
+ scm_c_define_gsubr ("weechat:infolist_new_item", 1, 0, 0, &weechat_guile_api_infolist_new_item);
+ scm_c_define_gsubr ("weechat:infolist_new_var_integer", 3, 0, 0, &weechat_guile_api_infolist_new_var_integer);
+ scm_c_define_gsubr ("weechat:infolist_new_var_string", 3, 0, 0, &weechat_guile_api_infolist_new_var_string);
+ scm_c_define_gsubr ("weechat:infolist_new_var_pointer", 3, 0, 0, &weechat_guile_api_infolist_new_var_pointer);
+ scm_c_define_gsubr ("weechat:infolist_new_var_time", 3, 0, 0, &weechat_guile_api_infolist_new_var_time);
+ scm_c_define_gsubr ("weechat:infolist_get", 3, 0, 0, &weechat_guile_api_infolist_get);
+ scm_c_define_gsubr ("weechat:infolist_next", 1, 0, 0, &weechat_guile_api_infolist_next);
+ scm_c_define_gsubr ("weechat:infolist_prev", 1, 0, 0, &weechat_guile_api_infolist_prev);
+ scm_c_define_gsubr ("weechat:infolist_reset_item_cursor", 1, 0, 0, &weechat_guile_api_infolist_reset_item_cursor);
+ scm_c_define_gsubr ("weechat:infolist_fields", 1, 0, 0, &weechat_guile_api_infolist_fields);
+ scm_c_define_gsubr ("weechat:infolist_integer", 2, 0, 0, &weechat_guile_api_infolist_integer);
+ scm_c_define_gsubr ("weechat:infolist_string", 2, 0, 0, &weechat_guile_api_infolist_string);
+ scm_c_define_gsubr ("weechat:infolist_pointer", 2, 0, 0, &weechat_guile_api_infolist_pointer);
+ scm_c_define_gsubr ("weechat:infolist_time", 2, 0, 0, &weechat_guile_api_infolist_time);
+ scm_c_define_gsubr ("weechat:infolist_free", 1, 0, 0, &weechat_guile_api_infolist_free);
+ scm_c_define_gsubr ("weechat:hdata_get", 1, 0, 0, &weechat_guile_api_hdata_get);
+ scm_c_define_gsubr ("weechat:hdata_get_var_offset", 2, 0, 0, &weechat_guile_api_hdata_get_var_offset);
+ scm_c_define_gsubr ("weechat:hdata_get_var_type_string", 2, 0, 0, &weechat_guile_api_hdata_get_var_type_string);
+ scm_c_define_gsubr ("weechat:hdata_get_var_hdata", 2, 0, 0, &weechat_guile_api_hdata_get_var_hdata);
+ scm_c_define_gsubr ("weechat:hdata_get_list", 2, 0, 0, &weechat_guile_api_hdata_get_list);
+ scm_c_define_gsubr ("weechat:hdata_move", 3, 0, 0, &weechat_guile_api_hdata_move);
+ scm_c_define_gsubr ("weechat:hdata_integer", 3, 0, 0, &weechat_guile_api_hdata_integer);
+ scm_c_define_gsubr ("weechat:hdata_long", 3, 0, 0, &weechat_guile_api_hdata_long);
+ scm_c_define_gsubr ("weechat:hdata_string", 3, 0, 0, &weechat_guile_api_hdata_string);
+ scm_c_define_gsubr ("weechat:hdata_pointer", 3, 0, 0, &weechat_guile_api_hdata_pointer);
+ scm_c_define_gsubr ("weechat:hdata_time", 3, 0, 0, &weechat_guile_api_hdata_time);
+ scm_c_define_gsubr ("weechat:hdata_get_string", 2, 0, 0, &weechat_guile_api_hdata_get_string);
+ scm_c_define_gsubr ("weechat:upgrade_new", 2, 0, 0, &weechat_guile_api_upgrade_new);
+ scm_c_define_gsubr ("weechat:upgrade_write_object", 3, 0, 0, &weechat_guile_api_upgrade_write_object);
+ scm_c_define_gsubr ("weechat:upgrade_read", 3, 0, 0, &weechat_guile_api_upgrade_read);
+ scm_c_define_gsubr ("weechat:upgrade_close", 1, 0, 0, &weechat_guile_api_upgrade_close);
+
+ scm_c_export ("weechat:register", "weechat:plugin_get_name",
+ "weechat:charset_set", "weechat:iconv_to_internal",
+ "weechat:iconv_from_internal", "weechat:gettext",
+ "weechat:ngettext", "weechat:string_match",
+ "weechat:string_has_highlight", "weechat:string_has_highlight_regex",
+ "weechat:string_mask_to_regex", "weechat:string_remove_color",
+ "weechat:string_is_command_char", "weechat:string_input_for_buffer",
+ "weechat:mkdir_home", "weechat:mkdir",
+ "weechat:mkdir_parents", "weechat:list_new",
+ "weechat:list_add", "weechat:list_search",
+ "weechat:list_search_pos", "weechat:list_casesearch",
+ "weechat:list_casesearch_pos", "weechat:list_get",
+ "weechat:list_set", "weechat:list_next",
+ "weechat:list_prev", "weechat:list_string",
+ "weechat:list_size", "weechat:list_remove",
+ "weechat:list_remove_all", "weechat:list_free",
+ "weechat:config_new", "weechat:config_new_section",
+ "weechat:config_search_section", "weechat:config_new_option",
+ "weechat:config_search_option", "weechat:config_string_to_boolean",
+ "weechat:config_option_reset", "weechat:config_option_set",
+ "weechat:config_option_set_null", "weechat:config_option_unset",
+ "weechat:config_option_rename", "weechat:config_option_is_null",
+ "weechat:config_option_default_is_null", "weechat:config_boolean",
+ "weechat:config_boolean_default", "weechat:config_integer",
+ "weechat:config_integer_default", "weechat:config_string",
+ "weechat:config_string_default", "weechat:config_color",
+ "weechat:config_color_default", "weechat:config_write_option",
+ "weechat:config_write_line", "weechat:config_write",
+ "weechat:config_read", "weechat:config_reload",
+ "weechat:config_option_free", "weechat:config_section_free_options",
+ "weechat:config_section_free", "weechat:config_free",
+ "weechat:config_get", "weechat:config_get_plugin",
+ "weechat:config_is_set_plugin", "weechat:config_set_plugin",
+ "weechat:config_set_desc_plugin", "weechat:config_unset_plugin",
+ "weechat:key_bind", "weechat:key_unbind",
+ "weechat:prefix", "weechat:color",
+ "weechat:print", "weechat:print_date_tags",
+ "weechat:print_y", "weechat:log_print",
+ "weechat:hook_command", "weechat:hook_command_run",
+ "weechat:hook_timer", "weechat:hook_fd",
+ "weechat:hook_process", "weechat:hook_connect",
+ "weechat:hook_print", "weechat:hook_signal",
+ "weechat:hook_signal_send", "weechat:hook_hsignal",
+ "weechat:hook_hsignal_send", "weechat:hook_config",
+ "weechat:hook_completion", "weechat:hook_completion_list_add",
+ "weechat:hook_modifier", "weechat:hook_modifier_exec",
+ "weechat:hook_info", "weechat:hook_info_hashtable",
+ "weechat:hook_infolist", "weechat:hook_focus",
+ "weechat:unhook", "weechat:unhook_all",
+ "weechat:buffer_new", "weechat:buffer_search",
+ "weechat:buffer_search_main", "weechat:current_buffer",
+ "weechat:buffer_clear", "weechat:buffer_close",
+ "weechat:buffer_merge", "weechat:buffer_unmerge",
+ "weechat:buffer_get_integer", "weechat:buffer_get_string",
+ "weechat:buffer_get_pointer", "weechat:buffer_set",
+ "weechat:buffer_string_replace_local_var", "weechat:buffer_match_list",
+ "weechat:current_window", "weechat:window_search_with_buffer",
+ "weechat:window_get_integer", "weechat:window_get_string",
+ "weechat:window_get_pointer", "weechat:window_set_title",
+ "weechat:nicklist_add_group", "weechat:nicklist_search_group",
+ "weechat:nicklist_add_nick", "weechat:nicklist_search_nick",
+ "weechat:nicklist_remove_group", "weechat:nicklist_remove_nick",
+ "weechat:nicklist_remove_all", "weechat:nicklist_group_get_integer",
+ "weechat:nicklist_group_get_string", "weechat:nicklist_group_get_pointer",
+ "weechat:nicklist_group_set", "weechat:nicklist_nick_get_integer",
+ "weechat:nicklist_nick_get_string", "weechat:nicklist_nick_get_pointer",
+ "weechat:nicklist_nick_set", "weechat:bar_item_search",
+ "weechat:bar_item_new", "weechat:bar_item_update",
+ "weechat:bar_item_remove", "weechat:bar_search",
+ "weechat:bar_new", "weechat:bar_set",
+ "weechat:bar_update", "weechat:bar_remove",
+ "weechat:command", "weechat:info_get",
+ "weechat:info_get_hashtable", "weechat:infolist_new",
+ "weechat:infolist_new_item", "weechat:infolist_new_var_integer",
+ "weechat:infolist_new_var_string", "weechat:infolist_new_var_pointer",
+ "weechat:infolist_new_var_time", "weechat:infolist_get",
+ "weechat:infolist_next", "weechat:infolist_prev",
+ "weechat:infolist_reset_item_cursor", "weechat:infolist_fields",
+ "weechat:infolist_integer", "weechat:infolist_string",
+ "weechat:infolist_pointer", "weechat:infolist_time",
+ "weechat:infolist_free", "weechat:hdata_get",
+ "weechat:hdata_get_var_offset", "weechat:hdata_get_var_type_string",
+ "weechat:hdata_get_var_hdata", "weechat:hdata_get_list",
+ "weechat:hdata_move", "weechat:hdata_integer",
+ "weechat:hdata_long", "weechat:hdata_string",
+ "weechat:hdata_pointer", "weechat:hdata_time",
+ "weechat:hdata_get_string", "weechat:upgrade_new",
+ "weechat:upgrade_write_object", "weechat:upgrade_read",
+ "weechat:upgrade_close",
+ NULL);
+
+ /* interface constants */
+ scm_c_define ("weechat:WEECHAT_RC_OK", scm_from_int (WEECHAT_RC_OK));
+ scm_c_define ("weechat:WEECHAT_RC_OK_EAT", scm_from_int (WEECHAT_RC_OK_EAT));
+ scm_c_define ("weechat:WEECHAT_RC_ERROR", scm_from_int (WEECHAT_RC_ERROR));
+
+ scm_c_define ("weechat:WEECHAT_CONFIG_READ_OK", scm_from_int (WEECHAT_CONFIG_READ_OK));
+ scm_c_define ("weechat:WEECHAT_CONFIG_READ_MEMORY_ERROR", scm_from_int (WEECHAT_CONFIG_READ_MEMORY_ERROR));
+ scm_c_define ("weechat:WEECHAT_CONFIG_READ_FILE_NOT_FOUND", scm_from_int (WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
+ scm_c_define ("weechat:WEECHAT_CONFIG_WRITE_OK", scm_from_int (WEECHAT_CONFIG_WRITE_OK));
+ scm_c_define ("weechat:WEECHAT_CONFIG_WRITE_ERROR", scm_from_int (WEECHAT_CONFIG_WRITE_ERROR));
+ scm_c_define ("weechat:WEECHAT_CONFIG_WRITE_MEMORY_ERROR", scm_from_int (WEECHAT_CONFIG_WRITE_MEMORY_ERROR));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", scm_from_int (WEECHAT_CONFIG_OPTION_SET_OK_CHANGED));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", scm_from_int (WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_SET_ERROR", scm_from_int (WEECHAT_CONFIG_OPTION_SET_ERROR));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", scm_from_int (WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", scm_from_int (WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", scm_from_int (WEECHAT_CONFIG_OPTION_UNSET_OK_RESET));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", scm_from_int (WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED));
+ scm_c_define ("weechat:WEECHAT_CONFIG_OPTION_UNSET_ERROR", scm_from_int (WEECHAT_CONFIG_OPTION_UNSET_ERROR));
+
+ scm_c_define ("weechat:WEECHAT_LIST_POS_SORT", scm_from_locale_string (WEECHAT_LIST_POS_SORT));
+ scm_c_define ("weechat:WEECHAT_LIST_POS_BEGINNING", scm_from_locale_string (WEECHAT_LIST_POS_BEGINNING));
+ scm_c_define ("weechat:WEECHAT_LIST_POS_END", scm_from_locale_string (WEECHAT_LIST_POS_END));
+
+ scm_c_define ("weechat:WEECHAT_HOTLIST_LOW", scm_from_locale_string (WEECHAT_HOTLIST_LOW));
+ scm_c_define ("weechat:WEECHAT_HOTLIST_MESSAGE", scm_from_locale_string (WEECHAT_HOTLIST_MESSAGE));
+ scm_c_define ("weechat:WEECHAT_HOTLIST_PRIVATE", scm_from_locale_string (WEECHAT_HOTLIST_PRIVATE));
+ scm_c_define ("weechat:WEECHAT_HOTLIST_HIGHLIGHT", scm_from_locale_string (WEECHAT_HOTLIST_HIGHLIGHT));
+
+ scm_c_define ("weechat:WEECHAT_HOOK_PROCESS_RUNNING", scm_from_int (WEECHAT_HOOK_PROCESS_RUNNING));
+ scm_c_define ("weechat:WEECHAT_HOOK_PROCESS_ERROR", scm_from_int (WEECHAT_HOOK_PROCESS_ERROR));
+
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_OK", scm_from_int (WEECHAT_HOOK_CONNECT_OK));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", scm_from_int (WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", scm_from_int (WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED", scm_from_int (WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_PROXY_ERROR", scm_from_int (WEECHAT_HOOK_CONNECT_PROXY_ERROR));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR", scm_from_int (WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", scm_from_int (WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", scm_from_int (WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR));
+ scm_c_define ("weechat:WEECHAT_HOOK_CONNECT_MEMORY_ERROR", scm_from_int (WEECHAT_HOOK_CONNECT_MEMORY_ERROR));
+
+ scm_c_define ("weechat:WEECHAT_HOOK_SIGNAL_STRING", scm_from_locale_string (WEECHAT_HOOK_SIGNAL_STRING));
+ scm_c_define ("weechat:WEECHAT_HOOK_SIGNAL_INT", scm_from_locale_string (WEECHAT_HOOK_SIGNAL_INT));
+ scm_c_define ("weechat:WEECHAT_HOOK_SIGNAL_POINTER", scm_from_locale_string (WEECHAT_HOOK_SIGNAL_POINTER));
+
+ scm_c_export ("weechat:WEECHAT_RC_OK",
+ "weechat:WEECHAT_RC_OK_EAT",
+ "weechat:WEECHAT_RC_ERROR",
+ "weechat:WEECHAT_CONFIG_READ_OK",
+ "weechat:WEECHAT_CONFIG_READ_MEMORY_ERROR",
+ "weechat:WEECHAT_CONFIG_READ_FILE_NOT_FOUND",
+ "weechat:WEECHAT_CONFIG_WRITE_OK",
+ "weechat:WEECHAT_CONFIG_WRITE_ERROR",
+ "weechat:WEECHAT_CONFIG_WRITE_MEMORY_ERROR",
+ "weechat:WEECHAT_CONFIG_OPTION_SET_OK_CHANGED",
+ "weechat:WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE",
+ "weechat:WEECHAT_CONFIG_OPTION_SET_ERROR",
+ "weechat:WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND",
+ "weechat:WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET",
+ "weechat:WEECHAT_CONFIG_OPTION_UNSET_OK_RESET",
+ "weechat:WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED",
+ "weechat:WEECHAT_CONFIG_OPTION_UNSET_ERROR",
+ "weechat:WEECHAT_LIST_POS_SORT",
+ "weechat:WEECHAT_LIST_POS_BEGINNING",
+ "weechat:WEECHAT_LIST_POS_END",
+ "weechat:WEECHAT_HOTLIST_LOW",
+ "weechat:WEECHAT_HOTLIST_MESSAGE",
+ "weechat:WEECHAT_HOTLIST_PRIVATE",
+ "weechat:WEECHAT_HOTLIST_HIGHLIGHT",
+ "weechat:WEECHAT_HOOK_PROCESS_RUNNING",
+ "weechat:WEECHAT_HOOK_PROCESS_ERROR",
+ "weechat:WEECHAT_HOOK_CONNECT_OK",
+ "weechat:WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND",
+ "weechat:WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND",
+ "weechat:WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED",
+ "weechat:WEECHAT_HOOK_CONNECT_PROXY_ERROR",
+ "weechat:WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR",
+ "weechat:WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR",
+ "weechat:WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR",
+ "weechat:WEECHAT_HOOK_CONNECT_MEMORY_ERROR",
+ "weechat:WEECHAT_HOOK_SIGNAL_STRING",
+ "weechat:WEECHAT_HOOK_SIGNAL_INT",
+ "weechat:WEECHAT_HOOK_SIGNAL_POINTER",
+ NULL);
+}
diff --git a/src/plugins/scripts/guile/weechat-guile-api.h b/src/plugins/scripts/guile/weechat-guile-api.h
new file mode 100644
index 000000000..7620a5f0a
--- /dev/null
+++ b/src/plugins/scripts/guile/weechat-guile-api.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 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_GUILE_API_H
+#define __WEECHAT_GUILE_API_H 1
+
+extern int weechat_guile_api_buffer_input_data_cb (void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data);
+extern int weechat_guile_api_buffer_close_cb (void *data,
+ struct t_gui_buffer *buffer);
+extern void weechat_guile_api_module_init (void *data);
+
+#endif /* __WEECHAT_GUILE_API_H */
diff --git a/src/plugins/scripts/guile/weechat-guile.c b/src/plugins/scripts/guile/weechat-guile.c
new file mode 100644
index 000000000..e698f3d0c
--- /dev/null
+++ b/src/plugins/scripts/guile/weechat-guile.c
@@ -0,0 +1,891 @@
+/*
+ * Copyright (C) 2011 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/>.
+ */
+
+/*
+ * weechat-guile.c: guile (scheme) plugin for WeeChat
+ */
+
+#undef _
+
+#include <libguile.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <libgen.h>
+
+#include "../../weechat-plugin.h"
+#include "../script.h"
+#include "weechat-guile.h"
+#include "weechat-guile-api.h"
+
+
+WEECHAT_PLUGIN_NAME(GUILE_PLUGIN_NAME);
+WEECHAT_PLUGIN_DESCRIPTION("Guile (scheme) plugin for WeeChat");
+WEECHAT_PLUGIN_AUTHOR("Sebastien Helleu <flashcode@flashtux.org>");
+WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
+WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE);
+
+struct t_weechat_plugin *weechat_guile_plugin = NULL;
+
+int guile_quiet;
+struct t_plugin_script *guile_scripts = NULL;
+struct t_plugin_script *last_guile_script = NULL;
+struct t_plugin_script *guile_current_script = NULL;
+struct t_plugin_script *guile_registered_script = NULL;
+const char *guile_current_script_filename = NULL;
+SCM guile_module_weechat;
+SCM guile_port;
+char *guile_stdout = NULL;
+
+struct t_guile_function
+{
+ SCM proc;
+ SCM args;
+};
+
+/*
+ * string used to execute action "install":
+ * when signal "guile_install_script" is received, name of string
+ * is added to this string, to be installed later by a timer (when nothing is
+ * running in script)
+ */
+char *guile_action_install_list = NULL;
+
+/*
+ * string used to execute action "remove":
+ * when signal "guile_remove_script" is received, name of string
+ * is added to this string, to be removed later by a timer (when nothing is
+ * running in script)
+ */
+char *guile_action_remove_list = NULL;
+
+
+/*
+ * weechat_guile_stdout_flush: flush stdout
+ */
+
+void
+weechat_guile_stdout_flush ()
+{
+ if (guile_stdout)
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s: stdout/stderr: %s%s"),
+ GUILE_PLUGIN_NAME, guile_stdout, "");
+ free (guile_stdout);
+ guile_stdout = NULL;
+ }
+}
+
+/*
+ * weechat_guile_catch: execute scheme procedure with internal catch
+ * and return value
+ */
+
+SCM
+weechat_guile_catch (void *procedure, void *data)
+{
+ SCM value;
+
+ value = scm_internal_catch (SCM_BOOL_T,
+ (scm_t_catch_body)procedure,
+ data,
+ (scm_t_catch_handler) scm_handle_by_message_noexit,
+ NULL);
+ return value;
+}
+
+/*
+ * weechat_guile_scm_call_1: encapsulate call to scm_call_1 (to give arguments)
+ */
+
+SCM
+weechat_guile_scm_call_1 (void *proc)
+{
+ struct t_guile_function *guile_function;
+
+ guile_function = (struct t_guile_function *)proc;
+
+ return scm_call_1 (guile_function->proc, guile_function->args);
+}
+
+/*
+ * weechat_guile_exec_function: execute scheme function (with optional args)
+ * and return value
+ */
+
+SCM
+weechat_guile_exec_function (const char *function, SCM args)
+{
+ SCM func, func2, value;
+ struct t_guile_function guile_function;
+
+ func = weechat_guile_catch (scm_c_lookup, (void *)function);
+ func2 = weechat_guile_catch (scm_variable_ref, func);
+
+ if (args)
+ {
+ guile_function.proc = func2;
+ guile_function.args = args;
+ value = weechat_guile_catch (weechat_guile_scm_call_1, &guile_function);
+ }
+ else
+ {
+ value = weechat_guile_catch (scm_call_0, func2);
+ }
+
+ return value;
+}
+
+/*
+ * weechat_guile_hashtable_map_cb: callback called for each key/value in a
+ * hashtable
+ */
+
+void
+weechat_guile_hashtable_map_cb (void *data,
+ struct t_hashtable *hashtable,
+ const void *key,
+ const void *value)
+{
+ SCM *alist, pair, list;
+
+ /* make C compiler happy */
+ (void) hashtable;
+
+ alist = (SCM *)data;
+
+ pair = scm_cons (scm_from_locale_string ((const char *)key),
+ scm_from_locale_string ((const char *)value));
+ list = scm_list_1 (pair);
+
+ *alist = scm_append (scm_list_2 (*alist, list));
+}
+
+/*
+ * weechat_guile_hashtable_to_alist: get Guile alist with a WeeChat hashtable
+ */
+
+SCM
+weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable)
+{
+ SCM alist;
+
+ alist = scm_list_n (SCM_UNDEFINED);
+
+ weechat_hashtable_map (hashtable,
+ &weechat_guile_hashtable_map_cb,
+ &alist);
+
+ return alist;
+}
+
+/*
+ * weechat_guile_alist_to_hashtable: get WeeChat hashtable with Guile alist
+ * Hashtable returned has type string for
+ * both keys and values
+ * Note: hashtable has to be released after
+ * use with call to weechat_hashtable_free()
+ */
+
+struct t_hashtable *
+weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
+{
+ struct t_hashtable *hashtable;
+ int length, i;
+ SCM pair;
+
+ hashtable = weechat_hashtable_new (hashtable_size,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+ if (!hashtable)
+ return NULL;
+
+ length = scm_to_int (scm_length (alist));
+ for (i = 0; i < length; i++)
+ {
+ pair = scm_list_ref (alist, scm_from_int (i));
+ weechat_hashtable_set (hashtable,
+ scm_i_string_chars (scm_list_ref (pair,
+ scm_from_int (0))),
+ scm_i_string_chars (scm_list_ref (pair,
+ scm_from_int (1))));
+ }
+
+ return hashtable;
+}
+
+/*
+ * weechat_guile_exec: execute a Guile function
+ */
+
+void *
+weechat_guile_exec (struct t_plugin_script *script,
+ int ret_type, const char *function,
+ char *format, void **argv)
+{
+ struct t_plugin_script *old_guile_current_script;
+ SCM argv_list, rc;
+ void *argv2[17], *ret_value;
+ int i, argc, *ret_int;
+
+ old_guile_current_script = guile_current_script;
+ scm_set_current_module ((SCM)(script->interpreter));
+ guile_current_script = script;
+
+ if (argv && argv[0])
+ {
+ argc = strlen (format);
+ for (i = 0; i < argc; i++)
+ {
+ switch (format[i])
+ {
+ case 's': /* string */
+ argv2[i] = scm_from_locale_string ((char *)argv[i]);
+ break;
+ case 'i': /* integer */
+ argv2[i] = scm_from_int (*((int *)argv[i]));
+ break;
+ case 'h': /* hash */
+ argv2[i] = weechat_guile_hashtable_to_alist (argv[i]);
+ break;
+ }
+ }
+ for (i = argc; i < 17; i++)
+ {
+ argv2[i] = SCM_UNDEFINED;
+ }
+ argv_list = scm_list_n (argv2[0], argv2[1],
+ argv2[2], argv2[3],
+ argv2[4], argv2[5],
+ argv2[6], argv2[7],
+ argv2[8], argv2[9],
+ argv2[10], argv2[11],
+ argv2[12], argv2[13],
+ argv2[14], argv2[15],
+ argv2[16]);
+ rc = weechat_guile_exec_function (function, argv_list);
+ }
+ else
+ {
+ rc = weechat_guile_exec_function (function, NULL);
+ }
+
+ ret_value = NULL;
+
+ if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (scm_is_string (rc)))
+ {
+ ret_value = scm_to_locale_string (rc);
+ }
+ else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (scm_is_integer (rc)))
+ {
+ ret_int = malloc (sizeof (*ret_int));
+ if (ret_int)
+ *ret_int = scm_to_int (rc);
+ ret_value = ret_int;
+ }
+ else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
+ {
+ ret_value = weechat_guile_alist_to_hashtable (rc,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ }
+ else
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: function \"%s\" must return "
+ "a valid value"),
+ weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
+ }
+
+ if (ret_value == NULL)
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: error in function \"%s\""),
+ weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
+ }
+
+ if (old_guile_current_script)
+ scm_set_current_module ((SCM)(old_guile_current_script->interpreter));
+
+ guile_current_script = old_guile_current_script;
+
+ return ret_value;
+}
+
+/*
+ * weechat_guile_module_init_script: init Guile module for script
+ */
+
+void
+weechat_guile_module_init_script (void *data)
+{
+ weechat_guile_catch (scm_c_eval_string, "(use-modules (weechat))");
+ weechat_guile_catch (scm_c_primitive_load, data);
+}
+
+/*
+ * weechat_guile_load: load a Guile script
+ */
+
+int
+weechat_guile_load (const char *filename)
+{
+ char *filename2, *ptr_base_name, *base_name;
+ SCM module;
+
+ if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s: loading script \"%s\""),
+ GUILE_PLUGIN_NAME, filename);
+ }
+
+ guile_current_script = NULL;
+ guile_registered_script = NULL;
+ guile_current_script_filename = filename;
+
+ filename2 = strdup (filename);
+ if (!filename2)
+ return 0;
+
+ ptr_base_name = basename (filename2);
+ base_name = strdup (ptr_base_name);
+ module = scm_c_define_module (base_name,
+ &weechat_guile_module_init_script, filename2);
+ free (filename2);
+
+ if (!guile_registered_script)
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: function \"register\" not "
+ "found (or failed) in file \"%s\""),
+ weechat_prefix ("error"), GUILE_PLUGIN_NAME, filename);
+ return 0;
+ }
+
+ scm_gc_protect_object (module);
+
+ guile_current_script = guile_registered_script;
+ guile_current_script->interpreter = (void *)module;
+
+ /*
+ * 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);
+
+ return 1;
+}
+
+/*
+ * weechat_guile_load_cb: callback for script_auto_load() function
+ */
+
+void
+weechat_guile_load_cb (void *data, const char *filename)
+{
+ /* make C compiler happy */
+ (void) data;
+
+ weechat_guile_load (filename);
+}
+
+/*
+ * weechat_guile_unload: unload a Guile script
+ */
+
+void
+weechat_guile_unload (struct t_plugin_script *script)
+{
+ int *rc;
+
+ if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s: unloading script \"%s\""),
+ GUILE_PLUGIN_NAME, script->name);
+ }
+
+ if (script->shutdown_func && script->shutdown_func[0])
+ {
+ rc = (int *)weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT,
+ script->shutdown_func, NULL, NULL);
+ if (rc)
+ free (rc);
+ }
+
+ scm_gc_unprotect_object (script->interpreter);
+
+ if (guile_current_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);
+}
+
+/*
+ * weechat_guile_unload_name: unload a Guile script by name
+ */
+
+void
+weechat_guile_unload_name (const char *name)
+{
+ struct t_plugin_script *ptr_script;
+
+ ptr_script = script_search (weechat_guile_plugin, guile_scripts, name);
+ if (ptr_script)
+ {
+ weechat_guile_unload (ptr_script);
+ weechat_printf (NULL,
+ weechat_gettext ("%s: script \"%s\" unloaded"),
+ GUILE_PLUGIN_NAME, name);
+ }
+ else
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: script \"%s\" not loaded"),
+ weechat_prefix ("error"), GUILE_PLUGIN_NAME, name);
+ }
+}
+
+/*
+ * weechat_guile_unload_all: unload all Guile scripts
+ */
+
+void
+weechat_guile_unload_all ()
+{
+ while (guile_scripts)
+ {
+ weechat_guile_unload (guile_scripts);
+ }
+}
+
+/*
+ * weechat_guile_reload_name: reload a Guile script by name
+ */
+
+void
+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);
+ if (ptr_script)
+ {
+ filename = strdup (ptr_script->filename);
+ if (filename)
+ {
+ weechat_guile_unload (ptr_script);
+ weechat_printf (NULL,
+ weechat_gettext ("%s: script \"%s\" unloaded"),
+ GUILE_PLUGIN_NAME, name);
+ weechat_guile_load (filename);
+ free (filename);
+ }
+ }
+ else
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: script \"%s\" not loaded"),
+ weechat_prefix ("error"), GUILE_PLUGIN_NAME, name);
+ }
+}
+
+/*
+ * weechat_guile_cmd: callback for "/guile" command
+ */
+
+int
+weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
+ int argc, char **argv, char **argv_eol)
+{
+ char *path_script;
+ SCM value;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) buffer;
+
+ if (argc == 1)
+ {
+ 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);
+ }
+ else if (weechat_strcasecmp (argv[1], "listfull") == 0)
+ {
+ 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);
+ }
+ else if (weechat_strcasecmp (argv[1], "reload") == 0)
+ {
+ weechat_guile_unload_all ();
+ script_auto_load (weechat_guile_plugin, &weechat_guile_load_cb);
+ }
+ else if (weechat_strcasecmp (argv[1], "unload") == 0)
+ {
+ weechat_guile_unload_all ();
+ }
+ }
+ else
+ {
+ if (weechat_strcasecmp (argv[1], "list") == 0)
+ {
+ 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);
+ }
+ else if (weechat_strcasecmp (argv[1], "load") == 0)
+ {
+ /* load Guile script */
+ path_script = 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);
+ }
+ else if (weechat_strcasecmp (argv[1], "reload") == 0)
+ {
+ /* reload one Guile script */
+ weechat_guile_reload_name (argv_eol[2]);
+ }
+ else if (weechat_strcasecmp (argv[1], "unload") == 0)
+ {
+ /* unload Guile script */
+ weechat_guile_unload_name (argv_eol[2]);
+ }
+ else if (weechat_strcasecmp (argv[1], "eval") == 0)
+ {
+ /* eval Guile code */
+ value = weechat_guile_catch (scm_c_eval_string, argv_eol[2]);
+ if (!SCM_EQ_P (value, SCM_UNDEFINED)
+ && !SCM_EQ_P (value, SCM_UNSPECIFIED))
+ {
+ scm_display (value, guile_port);
+ }
+ weechat_guile_stdout_flush ();
+ }
+ else
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: unknown option for "
+ "command \"%s\""),
+ weechat_prefix ("error"), GUILE_PLUGIN_NAME,
+ "guile");
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_guile_completion_cb: callback for script completion
+ */
+
+int
+weechat_guile_completion_cb (void *data, const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) completion_item;
+ (void) buffer;
+
+ script_completion (weechat_guile_plugin, completion, guile_scripts);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_guile_infolist_cb: callback for infolist
+ */
+
+struct t_infolist *
+weechat_guile_infolist_cb (void *data, const char *infolist_name,
+ void *pointer, const char *arguments)
+{
+ /* make C compiler happy */
+ (void) data;
+
+ if (!infolist_name || !infolist_name[0])
+ return NULL;
+
+ if (weechat_strcasecmp (infolist_name, "guile_script") == 0)
+ {
+ return script_infolist_list_scripts (weechat_guile_plugin,
+ guile_scripts, pointer,
+ arguments);
+ }
+
+ return NULL;
+}
+
+/*
+ * weechat_guile_signal_debug_dump_cb: dump Guile plugin data in WeeChat log
+ * file
+ */
+
+int
+weechat_guile_signal_debug_dump_cb (void *data, const char *signal,
+ const char *type_data, void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+ (void) type_data;
+
+ if (!signal_data
+ || (weechat_strcasecmp ((char *)signal_data, GUILE_PLUGIN_NAME) == 0))
+ {
+ script_print_log (weechat_guile_plugin, guile_scripts);
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_guile_signal_buffer_closed_cb: callback called when a buffer is
+ * closed
+ */
+
+int
+weechat_guile_signal_buffer_closed_cb (void *data, const char *signal,
+ const char *type_data,
+ void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+ (void) type_data;
+
+ if (signal_data)
+ script_remove_buffer_callbacks (guile_scripts, signal_data);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_guile_timer_action_cb: timer for executing actions
+ */
+
+int
+weechat_guile_timer_action_cb (void *data, int remaining_calls)
+{
+ /* make C compiler happy */
+ (void) remaining_calls;
+
+ if (data)
+ {
+ if (data == &guile_action_install_list)
+ {
+ 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);
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_guile_signal_script_action_cb: callback called when a script action
+ * is asked (install/remove a script)
+ */
+
+int
+weechat_guile_signal_script_action_cb (void *data, const char *signal,
+ const char *type_data,
+ void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+
+ if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
+ {
+ if (strcmp (signal, "guile_script_install") == 0)
+ {
+ 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);
+ weechat_hook_timer (1, 0, 1,
+ &weechat_guile_timer_action_cb,
+ &guile_action_remove_list);
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_guile_port_fill_input: fill input
+ */
+
+int
+weechat_guile_port_fill_input (SCM port)
+{
+ /* make C compiler happy */
+ (void) port;
+
+ return ' ';
+}
+
+/*
+ * weechat_guile_port_write: write
+ */
+
+void
+weechat_guile_port_write (SCM port, const void *data, size_t size)
+{
+ char *new_stdout;
+ int length_stdout;
+
+ /* make C compiler happy */
+ (void) port;
+
+ /* concatenate str to guile_stdout */
+ if (guile_stdout)
+ {
+ length_stdout = strlen (guile_stdout);
+ new_stdout = realloc (guile_stdout, length_stdout + size + 1);
+ if (!new_stdout)
+ {
+ free (guile_stdout);
+ return;
+ }
+ guile_stdout = new_stdout;
+ memcpy (guile_stdout + length_stdout, data, size);
+ guile_stdout[length_stdout + size] = '\0';
+ }
+ else
+ {
+ guile_stdout = malloc (size + 1);
+ if (guile_stdout)
+ {
+ memcpy (guile_stdout, data, size);
+ guile_stdout[size] = '\0';
+ }
+ }
+
+ /* flush stdout if at least "\n" is in string */
+ if (guile_stdout && (strchr (guile_stdout, '\n')))
+ weechat_guile_stdout_flush ();
+}
+
+/*
+ * weechat_plugin_init: initialize Guile plugin
+ */
+
+int
+weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
+{
+ weechat_guile_plugin = plugin;
+
+ guile_stdout = NULL;
+
+ scm_init_guile ();
+
+ guile_module_weechat = scm_c_define_module ("weechat",
+ &weechat_guile_api_module_init,
+ NULL);
+ scm_c_use_module ("weechat");
+ scm_gc_protect_object (guile_module_weechat);
+
+ guile_quiet = 1;
+ script_init (weechat_guile_plugin,
+ argc,
+ argv,
+ &weechat_guile_command_cb,
+ &weechat_guile_completion_cb,
+ &weechat_guile_infolist_cb,
+ &weechat_guile_signal_debug_dump_cb,
+ &weechat_guile_signal_buffer_closed_cb,
+ &weechat_guile_signal_script_action_cb,
+ &weechat_guile_load_cb);
+ guile_quiet = 0;
+
+ script_display_short_list (weechat_guile_plugin,
+ guile_scripts);
+
+ /* init ok */
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_plugin_end: shutdown Guile interface
+ */
+
+int
+weechat_plugin_end (struct t_weechat_plugin *plugin)
+{
+ /* unload all scripts */
+ guile_quiet = 1;
+ script_end (plugin, &guile_scripts, &weechat_guile_unload_all);
+ guile_quiet = 0;
+
+ /* unprotect module */
+ scm_gc_unprotect_object (guile_module_weechat);
+
+ /* free some data */
+ if (guile_action_install_list)
+ free (guile_action_install_list);
+ if (guile_action_remove_list)
+ free (guile_action_remove_list);
+
+ return WEECHAT_RC_OK;
+}
diff --git a/src/plugins/scripts/guile/weechat-guile.h b/src/plugins/scripts/guile/weechat-guile.h
new file mode 100644
index 000000000..c7df69a1b
--- /dev/null
+++ b/src/plugins/scripts/guile/weechat-guile.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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_GUILE_H
+#define __WEECHAT_GUILE_H 1
+
+#define weechat_plugin weechat_guile_plugin
+#define GUILE_PLUGIN_NAME "guile"
+
+#define GUILE_CURRENT_SCRIPT_NAME ((guile_current_script) ? guile_current_script->name : "-")
+
+extern struct t_weechat_plugin *weechat_guile_plugin;
+
+extern int guile_quiet;
+extern struct t_plugin_script *guile_scripts;
+extern struct t_plugin_script *last_guile_script;
+extern struct t_plugin_script *guile_current_script;
+extern struct t_plugin_script *guile_registered_script;
+extern const char *guile_current_script_filename;
+extern SCM guile_port;
+
+extern SCM weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable);
+extern struct t_hashtable *weechat_guile_alist_to_hashtable (SCM dict,
+ int hashtable_size);
+extern void *weechat_guile_exec (struct t_plugin_script *script,
+ int ret_type, const char *function,
+ char *format, void **argv);
+extern int weechat_guile_port_fill_input (SCM port);
+extern void weechat_guile_port_write (SCM port, const void *data, size_t size);
+
+#endif /* __WEECHAT_GUILE_H */