1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

Add Tcl script plugin (thanks to Dmitry Kobylin)

This commit is contained in:
Sebastien Helleu
2008-10-05 19:06:46 +02:00
parent 269bf55b1e
commit 44944ef01f
36 changed files with 5984 additions and 14 deletions
+1
View File
@@ -55,6 +55,7 @@ OPTION(DISABLE_PERL "Disable Perl scripting language")
OPTION(DISABLE_PYTHON "Disable Python scripting language")
OPTION(DISABLE_RUBY "Disable Ruby scripting language")
OPTION(DISABLE_LUA "Disable Lua scripting language")
OPTION(DISABLE_TCL "Disable Tcl scripting language")
OPTION(ENABLE_TRIGGER "Enable Trigger plugin")
OPTION(DISABLE_XFER "Disable Xfer (file transfert) plugin")
OPTION(DISABLE_DOC "Disable Doc")
+3 -2
View File
@@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2008-10-03
ChangeLog - 2008-10-05
Version 0.2.7 (under dev!):
@@ -39,7 +39,8 @@ Version 0.2.7 (under dev!):
* improve main loop: higher timout in select(), less CPU usage
* add /reload command to reload WeeChat and plugins config files
(signal SIGHUP is catched to reload config files)
* new plugins: alias, debug, demo, fifo, irc, logger, notify, trigger, xfer
* new plugins: alias, debug, demo, fifo, irc, logger, notify, tcl, trigger,
xfer
* add hooks: command, timer, file descriptor, connection, print, signal,
config, completion, modifier, info, infolist
* new plugin API with many new functions: hooks, buffer management, bars,
+62
View File
@@ -106,6 +106,7 @@ AH_VERBATIM([PLUGIN_PERL], [#undef PLUGIN_PERL])
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_TRIGGER], [#undef PLUGIN_TRIGGER])
AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER])
AH_VERBATIM([DOC], [#undef DOC])
@@ -132,6 +133,7 @@ AC_ARG_ENABLE(perl, [ --disable-perl turn off Perl script plug
AC_ARG_ENABLE(python, [ --disable-python turn off Python script plugin (default=compiled if found)],enable_python=$enableval,enable_python=yes)
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(trigger, [ --enable-trigger turn on Trigger plugin (default=off)],enable_trigger=$enableval,enable_trigger=no)
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='')
@@ -281,6 +283,7 @@ if test "x$enable_scripts" = "xno" ; then
enable_python="no"
enable_ruby="no"
enable_lua="no"
enable_tcl="no"
fi
# ---------------------------------- alias -------------------------------------
@@ -684,6 +687,60 @@ if test "x$enable_lua" = "xyes" ; then
AC_DEFINE(PLUGIN_LUA)
fi
# --------------------------------- tcl -------------------------------------
TCL_VERSION=
if test "x$enable_tcl" = "xyes" ; then
enable_plugins="yes"
AC_PATH_PROGS(TCL, tclsh tclsh8.5 tclsh8.4)
if test -z $TCL ; then
AC_MSG_WARN([
*** Tcl must be installed on your system but tcl interpreter couldn't be found in path.
*** Please check that tclsh is in path, or install it with your software package manager.
*** WeeChat will be built without Tcl support.])
enable_tcl="no"
not_found="$not_found tcl"
else
echo "for grepp"
TCL_VERSION=`echo 'puts $tcl_version' | $TCL`
TCL_PATCHLEVEL=`echo 'puts $tcl_patchLevel' | $TCL`
AC_MSG_CHECKING(for Tcl headers files)
TCL_HEADER_TEST=`TT=tcltest.c ; echo "#include <tcl.h>" > $TT; echo "int main() { return 0; }" >> $TT ; $CC -Wall $TT -o $TT.out 1>/dev/null 2>&1; echo $?; rm -f $TT $TT.out 1>/dev/null 2>&1`
if test "x$TCL_HEADER_TEST" = "x0" ; then
TCL_CFLAGS="-fPIC"
AC_MSG_RESULT(found)
AC_MSG_CHECKING(for Tcl library)
TCL_LIB_TEST=`TT=tcltest.c ; echo "int main() { return 0; }" > $TT ; $CC -Wall $TT -o $TT.out -ltcl$TCL_VERSION 1>/dev/null 2>&1; echo $?; rm -f $TT $TT.out 1>/dev/null 2>&1`
if test "x$TCL_LIB_TEST" = "x0" ; then
TCL_LFLAGS="-ltcl$TCL_VERSION -ldl -export-dynamic"
AC_MSG_RESULT(found)
else
AC_MSG_WARN([
*** Tcl library couldn't be found in your system.
*** Try to install it with your software package manager.
*** WeeChat will be built without Tcl support.])
enable_tcl="no"
not_found="$not_found tcl"
fi
else
AC_MSG_WARN([
*** Tcl headers couldn't be found in your system.
*** Try to install it with your software package manager.
*** WeeChat will be built without Tcl support.])
enable_tcl="no"
not_found="$not_found tcl"
fi
fi
fi
if test "x$enable_tcl" = "xyes" ; then
AC_SUBST(TCL_CFLAGS)
AC_SUBST(TCL_LFLAGS)
AC_DEFINE(PLUGIN_TCL)
fi
# --------------------------------- trigger ------------------------------------
if test "x$enable_trigger" = "xyes" ; then
@@ -923,6 +980,7 @@ AM_CONDITIONAL(PLUGIN_PERL, test "$enable_perl" = "yes")
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_TRIGGER, test "$enable_trigger" = "yes")
AM_CONDITIONAL(PLUGIN_XFER, test "$enable_xfer" = "yes")
AM_CONDITIONAL(DOC, test "$enable_doc" = "yes")
@@ -954,6 +1012,7 @@ AC_OUTPUT([Makefile
src/plugins/scripts/python/Makefile
src/plugins/scripts/ruby/Makefile
src/plugins/scripts/lua/Makefile
src/plugins/scripts/tcl/Makefile
src/plugins/trigger/Makefile
src/plugins/xfer/Makefile
src/gui/Makefile
@@ -1028,6 +1087,9 @@ fi
if test "x$enable_lua" = "xyes"; then
listplugins="$listplugins lua($LUA_VERSION)"
fi
if test "x$enable_tcl" = "xyes"; then
listplugins="$listplugins tcl($TCL_PATCHLEVEL)"
fi
if test "x$enable_trigger" = "xyes"; then
listplugins="$listplugins trigger"
fi
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
********* WARNING! *********
This file is autogenerated with docgen.pl script. *** DO NOT EDIT! ***
docgen.pl builds XML doc files to include in many languages
-->
<command>tcl [list [name]] | [listfull [name]] [load filename] | [autoload] | [reload] | [unload [name]]</command>
<programlisting>
list/load/unload scripts
filename: script (file) to load
name: a script name
Without argument, this command lists all loaded scripts.
</programlisting>
+2 -1
View File
@@ -68,7 +68,8 @@ my %plugin_list = ("weechat" => "co", "alias" => "",
"irc" => "co", "logger" => "co",
"notify" => "co", "perl" => "",
"python" => "", "ruby" => "",
"lua" => "", "xfer" => "co");
"lua" => "", "tcl" => "",
"xfer" => "co");
# options to ignore
my @ignore_options = ("weechat\\.bar\\..*",
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
********* WARNING! *********
This file is autogenerated with docgen.pl script. *** DO NOT EDIT! ***
docgen.pl builds XML doc files to include in many languages
-->
<command>tcl [list [name]] | [listfull [name]] [load filename] | [autoload] | [reload] | [unload [name]]</command>
<programlisting>
list/load/unload scripts
filename: script (file) to load
name: a script name
Without argument, this command lists all loaded scripts.
</programlisting>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
********* WARNING! *********
This file is autogenerated with docgen.pl script. *** DO NOT EDIT! ***
docgen.pl builds XML doc files to include in many languages
-->
<command>tcl [list [nom]] | [listfull [nom]] | [load fichier] | [autoload] | [reload] | [unload [nom]]</command>
<programlisting>
liste/charge/décharge des scripts
fichier: script (fichier) à charger
nom: un nom de script
Sans argument, cette commande liste tous les scripts chargés.
</programlisting>
+1
View File
@@ -10,6 +10,7 @@
<!ENTITY perl_commands.xml SYSTEM "autogen/perl_commands.xml">
<!ENTITY python_commands.xml SYSTEM "autogen/python_commands.xml">
<!ENTITY ruby_commands.xml SYSTEM "autogen/ruby_commands.xml">
<!ENTITY tcl_commands.xml SYSTEM "autogen/tcl_commands.xml">
<!ENTITY weechat_commands.xml SYSTEM "autogen/weechat_commands.xml">
<!ENTITY xfer_commands.xml SYSTEM "autogen/xfer_commands.xml">
+4
View File
@@ -171,6 +171,10 @@
./src/plugins/scripts/script-callback.c
./src/plugins/scripts/script-callback.h
./src/plugins/scripts/script.h
./src/plugins/scripts/tcl/weechat-tcl-api.c
./src/plugins/scripts/tcl/weechat-tcl-api.h
./src/plugins/scripts/tcl/weechat-tcl.c
./src/plugins/scripts/tcl/weechat-tcl.h
./src/plugins/trigger/dump.c
./src/plugins/trigger/trigger.c
./src/plugins/trigger/trigger.h
+13 -1
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-10-03 17:17+0200\n"
"POT-Creation-Date: 2008-10-05 17:39+0200\n"
"PO-Revision-Date: 2008-09-17 16:19+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4382,6 +4382,18 @@ msgstr "%s%s: nemohu zavolat funkci \"%s\", skript není inicializován"
msgid "%s%s: wrong arguments for function \"%s\""
msgstr "%s špatné parametry pro příkaz \"%s\"\n"
#, fuzzy, c-format
msgid "%s%s unable to run function \"%s\": %s"
msgstr "Nemůžu zapsat log soubor \"%s\"\n"
#, fuzzy, c-format
msgid "%s%s: unable to create new interpreter"
msgstr "%s nemohu vytvořit server\n"
#, fuzzy, c-format
msgid "%s%s: error occured while parsing file \"%s\": %s"
msgstr "Nemůžu zapsat log soubor \"%s\"\n"
msgid "bytes"
msgstr "bajtů"
+13 -1
View File
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-10-03 17:17+0200\n"
"POT-Creation-Date: 2008-10-05 17:39+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4284,6 +4284,18 @@ msgstr ""
msgid "%s%s: wrong arguments for function \"%s\""
msgstr "%s fehlerhafte Argumente für der \"%s\"-Befehl\n"
#, fuzzy, c-format
msgid "%s%s unable to run function \"%s\": %s"
msgstr "Kann das Logfile nicht schreiben\n"
#, fuzzy, c-format
msgid "%s%s: unable to create new interpreter"
msgstr "%s kann den Server nicht anlegen\n"
#, fuzzy, c-format
msgid "%s%s: error occured while parsing file \"%s\": %s"
msgstr "Kann das Logfile nicht schreiben\n"
msgid "bytes"
msgstr "Bytes"
+13 -1
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-10-03 17:17+0200\n"
"POT-Creation-Date: 2008-10-05 17:39+0200\n"
"PO-Revision-Date: 2007-09-19 12:09+0200\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4284,6 +4284,18 @@ msgstr ""
msgid "%s%s: wrong arguments for function \"%s\""
msgstr "%s argumentos incorrectos para el comando \"%s\"\n"
#, fuzzy, c-format
msgid "%s%s unable to run function \"%s\": %s"
msgstr "No es posible escribir un fichero de log para un búfer\n"
#, fuzzy, c-format
msgid "%s%s: unable to create new interpreter"
msgstr "%s no es posible crear el servidor\n"
#, fuzzy, c-format
msgid "%s%s: error occured while parsing file \"%s\": %s"
msgstr "No es posible escribir un fichero de log para un búfer\n"
msgid "bytes"
msgstr "bytes"
+14 -2
View File
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-10-03 17:17+0200\n"
"PO-Revision-Date: 2008-10-03 17:17+0200\n"
"POT-Creation-Date: 2008-10-05 17:39+0200\n"
"PO-Revision-Date: 2008-10-05 17:39+0200\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n"
@@ -4328,6 +4328,18 @@ msgstr ""
msgid "%s%s: wrong arguments for function \"%s\""
msgstr "%s%s: paramètres invalides pour la fonction \"%s\""
#, c-format
msgid "%s%s unable to run function \"%s\": %s"
msgstr "%s%s impossible de lancer la fonction \"%s\": %s"
#, c-format
msgid "%s%s: unable to create new interpreter"
msgstr "%s%s: impossible de créer l'interpréteur"
#, c-format
msgid "%s%s: error occured while parsing file \"%s\": %s"
msgstr "%s%s: erreur d'analyse du fichier \"%s\": %s"
msgid "bytes"
msgstr "octets"
+13 -1
View File
@@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-10-03 17:17+0200\n"
"POT-Creation-Date: 2008-10-05 17:39+0200\n"
"PO-Revision-Date: 2007-10-10 18:07+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4309,6 +4309,18 @@ msgstr ""
msgid "%s%s: wrong arguments for function \"%s\""
msgstr "%s rossz argumentum a \"%s\" parancsnak\n"
#, fuzzy, c-format
msgid "%s%s unable to run function \"%s\": %s"
msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n"
#, fuzzy, c-format
msgid "%s%s: unable to create new interpreter"
msgstr "%s nem sikerült a szervert létrehozni\n"
#, fuzzy, c-format
msgid "%s%s: error occured while parsing file \"%s\": %s"
msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n"
msgid "bytes"
msgstr "byte"
+13 -1
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-10-03 17:17+0200\n"
"POT-Creation-Date: 2008-10-05 17:39+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -4297,6 +4297,18 @@ msgstr ""
msgid "%s%s: wrong arguments for function \"%s\""
msgstr "%s некорректные аргументы команды \"%s\"\n"
#, fuzzy, c-format
msgid "%s%s unable to run function \"%s\": %s"
msgstr "Не могу записать лог-файл \"%s\"\n"
#, fuzzy, c-format
msgid "%s%s: unable to create new interpreter"
msgstr "%s не могу создать сервер\n"
#, fuzzy, c-format
msgid "%s%s: error occured while parsing file \"%s\": %s"
msgstr "Не могу записать лог-файл \"%s\"\n"
msgid "bytes"
msgstr "байтов"
+4
View File
@@ -172,6 +172,10 @@ SET(WEECHAT_SOURCES
./src/plugins/scripts/script-callback.c
./src/plugins/scripts/script-callback.h
./src/plugins/scripts/script.h
./src/plugins/scripts/tcl/weechat-tcl-api.c
./src/plugins/scripts/tcl/weechat-tcl-api.h
./src/plugins/scripts/tcl/weechat-tcl.c
./src/plugins/scripts/tcl/weechat-tcl.h
./src/plugins/trigger/dump.c
./src/plugins/trigger/trigger.c
./src/plugins/trigger/trigger.h
+13 -1
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-10-03 17:17+0200\n"
"POT-Creation-Date: 2008-10-05 17:39+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -3716,6 +3716,18 @@ msgstr ""
msgid "%s%s: wrong arguments for function \"%s\""
msgstr ""
#, c-format
msgid "%s%s unable to run function \"%s\": %s"
msgstr ""
#, c-format
msgid "%s%s: unable to create new interpreter"
msgstr ""
#, c-format
msgid "%s%s: error occured while parsing file \"%s\": %s"
msgstr ""
msgid "bytes"
msgstr ""
+2 -2
View File
@@ -70,9 +70,9 @@ IF(NOT DISABLE_NOTIFY)
ADD_SUBDIRECTORY( notify )
ENDIF(NOT DISABLE_NOTIFY)
IF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
IF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA AND NOT DISABLE_TCL)
ADD_SUBDIRECTORY( scripts )
ENDIF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
ENDIF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA AND NOT DISABLE_TCL)
IF(ENABLE_TRIGGER)
ADD_SUBDIRECTORY( trigger )
+4
View File
@@ -78,6 +78,10 @@ if PLUGIN_LUA
script_dir = scripts
endif
if PLUGIN_TCL
script_dir = scripts
endif
if PLUGIN_TRIGGER
trigger_dir = trigger
endif
+1
View File
@@ -20,6 +20,7 @@
#ifndef __WEECHAT_IRC_SERVER_H
#define __WEECHAT_IRC_SERVER_H 1
#include <sys/time.h>
#include <regex.h>
#ifdef HAVE_GNUTLS
+7
View File
@@ -48,3 +48,10 @@ IF(NOT DISABLE_LUA)
ADD_SUBDIRECTORY( lua )
ENDIF(LUA_FOUND)
ENDIF(NOT DISABLE_LUA)
IF(NOT DISABLE_TCL)
FIND_PACKAGE(TCL)
IF(TCL_FOUND)
ADD_SUBDIRECTORY( tcl )
ENDIF(TCL_FOUND)
ENDIF(NOT DISABLE_TCL)
+5 -1
View File
@@ -41,4 +41,8 @@ if PLUGIN_LUA
lua_dir = lua
endif
SUBDIRS = . $(perl_dir) $(python_dir) $(ruby_dir) $(lua_dir)
if PLUGIN_TCL
tcl_dir = tcl
endif
SUBDIRS = . $(perl_dir) $(python_dir) $(ruby_dir) $(lua_dir) $(tcl_dir)
@@ -18,6 +18,7 @@
/* weechat-lua-api.c: Lua API functions */
#undef _
#include <lua.h>
+1
View File
@@ -18,6 +18,7 @@
/* weechat-lua.c: Lua plugin for WeeChat */
#undef _
#include <lua.h>
@@ -18,6 +18,7 @@
/* weechat-perl-api.c: Perl API functions */
#undef _
#include <EXTERN.h>
+1
View File
@@ -18,6 +18,7 @@
/* weechat-perl.c: Perl plugin for WeeChat */
#undef _
#include <EXTERN.h>
@@ -18,6 +18,7 @@
/* weechat-python-api.c: Python API functions */
#undef _
#include <Python.h>
@@ -18,6 +18,7 @@
/* weechat-python.c: Python plugin for WeeChat */
#undef _
#include <Python.h>
@@ -18,6 +18,7 @@
/* weechat-ruby-api.c: Ruby API functions */
#undef _
#include <ruby.h>
+1
View File
@@ -18,6 +18,7 @@
/* weechat-ruby.c: Ruby plugin for WeeChat */
#undef _
#include <ruby.h>
+28
View File
@@ -0,0 +1,28 @@
# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
ADD_LIBRARY(tcl MODULE weechat-tcl.c weechat-tcl.h
weechat-tcl-api.c weechat-tcl-api.h)
SET_TARGET_PROPERTIES(tcl PROPERTIES PREFIX "")
IF(TCL_FOUND)
INCLUDE_DIRECTORIES(${TCL_INCLUDE_PATH})
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${TCL_LFLAGS}")
TARGET_LINK_LIBRARIES(tcl ${TCL_LIBRARY} weechat_scripts)
ENDIF(TCL_FOUND)
INSTALL(TARGETS tcl LIBRARY DESTINATION lib/weechat/plugins)
+28
View File
@@ -0,0 +1,28 @@
# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(TCL_CFLAGS)
libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = tcl.la
tcl_la_SOURCES = weechat-tcl.c \
weechat-tcl.h \
weechat-tcl-api.c \
weechat-tcl-api.h
tcl_la_LDFLAGS = -module
tcl_la_LIBADD = ../lib_weechat_plugins_scripts.la $(TCL_LFLAGS)
File diff suppressed because it is too large Load Diff
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_TCL_API_H
#define __WEECHAT_TCL_API_H 1
extern void weechat_tcl_api_init (Tcl_Interp *interp);
#endif /* weechat-tcl.h */
+458
View File
@@ -0,0 +1,458 @@
/*
* Copyright (C) 2008 Dmitry Kobylin <fnfal@academ.tsc.ru>
* See README for License detail, AUTHORS for developers list.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* weechat-tcl.c: Tcl plugin for WeeChat */
#undef _
#include <tcl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "../../weechat-plugin.h"
#include "../script.h"
#include "weechat-tcl.h"
#include "weechat-tcl-api.h"
WEECHAT_PLUGIN_NAME(TCL_PLUGIN_NAME);
WEECHAT_PLUGIN_DESCRIPTION("Tcl plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("Dmitry Kobylin <fnfal@academ.tsc.ru>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_tcl_plugin = NULL;
struct t_plugin_script *tcl_scripts = NULL;
struct t_plugin_script *tcl_current_script = NULL;
const char *tcl_current_script_filename = NULL;
Tcl_Interp* cinterp;
/*
* weechat_tcl_exec: execute a Tcl script
*/
void *
weechat_tcl_exec (struct t_plugin_script *script,
int ret_type, const char *function, char **argv)
{
int i;
int *ret_i;
char *ret_cv;
void *ret_val;
Tcl_DString ds;
Tcl_Obj *scptr;
Tcl_Interp *interp;
struct t_plugin_script *old_tcl_script;
old_tcl_script = tcl_current_script;
tcl_current_script = script;
interp = (Tcl_Interp*)script->interpreter;
Tcl_DStringInit (&ds);
if (function && function[0])
Tcl_DStringAppend (&ds,function, -1);
else
{
tcl_current_script = old_tcl_script;
return NULL;
}
if (argv)
{
for (i = 0; argv[i] && (i<6); i++)
{
Tcl_DStringAppend (&ds, " \"", -1);
Tcl_DStringAppend (&ds, argv[i], -1);
Tcl_DStringAppend (&ds, "\"", -1);
}
}
scptr = Tcl_NewStringObj (Tcl_DStringValue(&ds), -1);
Tcl_IncrRefCount (scptr);
Tcl_DStringFree (&ds);
if (Tcl_EvalObjEx (interp, scptr, TCL_EVAL_DIRECT) == TCL_OK)
{
Tcl_DecrRefCount (scptr);
ret_val = NULL;
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
{
ret_cv = Tcl_GetStringFromObj (Tcl_GetObjResult (interp), &i);
if (ret_cv && ret_cv[0])
ret_val = (void *)strdup (ret_cv);
else
ret_val = NULL;
}
else if ( ret_type == WEECHAT_SCRIPT_EXEC_INT
&& Tcl_GetIntFromObj (interp, Tcl_GetObjResult (interp), &i) == TCL_OK)
{
ret_i = (int *)malloc (sizeof (*ret_i));
if (ret_i)
*ret_i = i;
ret_val = (void *)ret_i;
}
tcl_current_script = old_tcl_script;
if (ret_val)
return ret_val;
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"%s\" must return a "
"valid value"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, function);
return NULL;
}
Tcl_DecrRefCount(scptr);
weechat_printf (NULL,
weechat_gettext ("%s%s unable to run function \"%s\": %s"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, function,
Tcl_GetStringFromObj (Tcl_GetObjResult (interp), &i));
tcl_current_script = old_tcl_script;
return NULL;
}
/*
* weechat_tcl_load: load a Tcl script
*/
int
weechat_tcl_load (const char *filename)
{
int i;
Tcl_Interp *interp;
struct stat buf;
if (stat (filename, &buf) != 0)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not found"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, filename);
return 0;
}
weechat_printf (NULL,
weechat_gettext ("%s: loading script \"%s\""),
TCL_PLUGIN_NAME, filename);
tcl_current_script = NULL;
if (!(interp = Tcl_CreateInterp ())) {
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to create new "
"interpreter"),
weechat_prefix ("error"), TCL_PLUGIN_NAME);
return 0;
}
tcl_current_script_filename = filename;
weechat_tcl_api_init (interp);
if (Tcl_EvalFile (interp, filename) != TCL_OK)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: error occured while "
"parsing file \"%s\": %s"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, filename,
Tcl_GetStringFromObj (Tcl_GetObjResult (interp), &i));
/* this ok, maybe "register" was called, so not return */
/* return 0; */
}
if (!tcl_current_script)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"register\" not "
"found (or failed) in file \"%s\""),
weechat_prefix ("error"), TCL_PLUGIN_NAME, filename);
Tcl_DeleteInterp (interp);
return 0;
}
return 1;
}
/*
* weechat_tcl_load_cb: callback for weechat_script_auto_load() function
*/
void
weechat_tcl_load_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
weechat_tcl_load (filename);
}
/*
* weechat_tcl_unload: unload a Tcl script
*/
void
weechat_tcl_unload (struct t_plugin_script *script)
{
Tcl_Interp* interp;
void *pointer;
weechat_printf (NULL,
weechat_gettext ("%s: unloading script \"%s\""),
TCL_PLUGIN_NAME, script->name);
if (script->shutdown_func && script->shutdown_func[0])
{
pointer = weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func,
NULL);
if (pointer)
free (pointer);
}
interp = (Tcl_Interp*)script->interpreter;
script_remove (weechat_tcl_plugin, &tcl_scripts, script);
Tcl_DeleteInterp(interp);
}
/*
* weechat_tcl_unload_name: unload a Tcl script by name
*/
void
weechat_tcl_unload_name (const char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name);
if (ptr_script)
{
weechat_tcl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
TCL_PLUGIN_NAME, name);
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not loaded"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, name);
}
}
/*
* weechat_tcl_unload_all: unload all Tcl scripts
*/
void
weechat_tcl_unload_all ()
{
while (tcl_scripts)
{
weechat_tcl_unload (tcl_scripts);
}
}
/*
* weechat_tcl_command_cb: callback for "/tcl" command
*/
int
weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc == 1)
{
script_display_list (weechat_tcl_plugin, tcl_scripts,
NULL, 0);
}
else if (argc == 2)
{
if (weechat_strcasecmp (argv[1], "list") == 0)
{
script_display_list (weechat_tcl_plugin, tcl_scripts,
NULL, 0);
}
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
{
script_display_list (weechat_tcl_plugin, tcl_scripts,
NULL, 1);
}
else if (weechat_strcasecmp (argv[1], "autoload") == 0)
{
script_auto_load (weechat_tcl_plugin, &weechat_tcl_load_cb);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
weechat_tcl_unload_all ();
script_auto_load (weechat_tcl_plugin, &weechat_tcl_load_cb);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
weechat_tcl_unload_all ();
}
}
else
{
if (weechat_strcasecmp (argv[1], "list") == 0)
{
script_display_list (weechat_tcl_plugin, tcl_scripts,
argv_eol[2], 0);
}
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
{
script_display_list (weechat_tcl_plugin, tcl_scripts,
argv_eol[2], 1);
}
else if (weechat_strcasecmp (argv[1], "load") == 0)
{
/* load Tcl script */
path_script = script_search_full_name (weechat_tcl_plugin,
argv_eol[2]);
weechat_tcl_load ((path_script) ? path_script : argv_eol[2]);
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Tcl script */
weechat_tcl_unload_name (argv_eol[2]);
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unknown option for "
"command \"%s\""),
weechat_prefix ("error"), TCL_PLUGIN_NAME, "tcl");
}
}
return WEECHAT_RC_OK;
}
/*
* weechat_tcl_completion_cb: callback for script completion
*/
int
weechat_tcl_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_tcl_plugin, completion, tcl_scripts);
return WEECHAT_RC_OK;
}
/*
* weechat_tcl_debug_dump_cb: dump Tcl plugin data in WeeChat log file
*/
int
weechat_tcl_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;
(void) signal_data;
script_print_log (weechat_tcl_plugin, tcl_scripts);
return WEECHAT_RC_OK;
}
/*
* weechat_tcl_buffer_closed_cb: callback called when a buffer is closed
*/
int
weechat_tcl_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 (tcl_scripts, signal_data);
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_init: initialize Tcl plugin
*/
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
/* make C compiler happy */
(void) argc;
(void) argv;
weechat_tcl_plugin = plugin;
script_init (weechat_tcl_plugin,
weechat_tcl_command_cb,
weechat_tcl_completion_cb,
weechat_tcl_debug_dump_cb,
weechat_tcl_buffer_closed_cb,
weechat_tcl_load_cb);
/* init ok */
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_end: end Tcl plugin
*/
int
weechat_plugin_end (struct t_weechat_plugin *plugin)
{
(void) plugin;
/* unload all scripts */
weechat_tcl_unload_all ();
return WEECHAT_RC_OK;
}
+36
View File
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_TCL_H
#define __WEECHAT_TCL_H 1
#define weechat_plugin weechat_tcl_plugin
#define TCL_PLUGIN_NAME "tcl"
extern struct t_weechat_plugin *weechat_tcl_plugin;
extern struct t_plugin_script *tcl_scripts;
extern struct t_plugin_script *tcl_current_script;
extern const char *tcl_current_script_filename;
extern void *weechat_tcl_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char **argv);
#endif /* weechat-tcl.h */