📄 gtk-server.c
字号:
/**************************************************************************** This is the infamous GTK-SERVER. The purpose of this program is to enable* access to graphical GTK widgets for shell scripts and interpreted* languages. This is realized by offering a streaming interface to GTK.** Please read the documentation on how to use this program.* The CREDITS file lists all people who have helped improving the GTK-server.** Original idea and design by Peter van Eerten, september 2003 - 2008* Mail: peter@gtk-server.org** This source has become a little bit messy. What started as a quick hack, grew out* to a large program. For GTK-server 3.0 a complete redesign of the source* is planned.** 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 2 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, write to the Free Software* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA** See http://www.gnu.org/licenses/gpl.txt for the full version of this license.** CHANGES GTK-SERVER 1.0* ----------------------* - BUILD 1: . Intitial release* - BUILD 2: . Fixed bug in parsing GTK-function arguments with Trim_Spaces* - BUILD 3: . Removed the child process counter, the Linux TCP version will run standalone now,* and an explicit kill is required.* - BUILD 4: . Show help even when configfile is not available* . Lines in configfile 'gtk-server.cfg' may be empty now* . Name of the external gtk-library is configurable now* - BUILD 5: . Changed the format of the gtk-server.cfg file* . Added callback signal "RELEASE"* - BUILD 6: . Added ability to return a LONG from a GTK-function* . Code cleaning* - BUILD 7: . Enable logging facility* - BUILD 8: . A lot of code optimizations - source has become smaller* - BUILD 9: . Implemented workaround for floating point arguments* . Changed logfile name to 'gtk-server.log'** CHANGES GTK-SERVER 1.1* ----------------------* - BUILD 1: . Redesigned the callback mechanism, hence the new release number (1.1)* . Updated the Check_Exceptions routine with GTK2.x functions* . Changed Widget casting from GtkWidget to GtkObject* . Added ability to return a FLOAT from a GTK-function* - BUILD 2: . Improved logging facility; returned string will be logged as well* - BUILD 3: . Determine maximum clients as an argument to the gtk-server (Linux)* - BUILD 4: . Look for global gtk-server.cfg as well (Linux: /etc directory)* - BUILD 5: . Path for logfile is configurable now in the gtk-server.cfg file* - BUILD 6: . Removed the GTK_LIB_SIGNAL keyword, signals can be configured directly now.* . Also search the /usr/local/etc directory for a configfile* - BUILD 7: . Added code to compile a self-containing GTK-server with all the GTK libs included* . Fixed compile problem with GCC 2.96 Redhat 7.1 (thanks Larry Richardson)* - BUILD 8: . Fixed some illegal memory writes and leaks pointed out by Valgrind* . Changed Win32 functionality: server will kill itself if a client* script disconnects* - BUILD 9: . Named pipe support (Unix/Linux)* . Some small code optimizations* - BUILD 10: . Support for named pipes in Win32* - BUILD 11: . Support for STDIN in Win32 (CLisp, Prolog, VB Script)* - BUILD 12: . Workaround for passing strings containing comma's as argument - introducing* the GTK_SERVER_COMMA config option* . Added some GTK2 float functions* . Win32 logic for finding the configfile* - BUILD 13: . Improved Named Pipe support for Windows* . Fixed potential bug with creating the logfile* - BUILD 14: . Introducing environment variable GTK_SERVER_CONFIG to point to configfile (WIN + LINUX)* . The Win32 version is not console based anymore. Adjusted all error warnings* to messageboxes.* - BUILD 15: . Solved crash when GTK_SERVER_COMMA option is not present* . Installer for Win32* . Autoconf source for Linux* - BUILD 16: . Implemented UDP communication interface: gtk-server udp <host:ip> [log]* . Argument syntax for TCP has changed: gtk-server tcp <host:ip[:max]> [log]* . Improved Makefile for Windows* - BUILD 17: . Added float functions for GTK2* . Corrected the Linux help prompt* . Removed redundant code* - BUILD 18: . Centralized version indication of GTK-server* . Added internal 'gtk_server_version' command to retrieve version* . If a LONG argument contains letters it will switch to STRING automatically* . Some large code improvements* . Win32: always create a logfile to capture GTK errors* . Bugfix: the GTK-server will not crash anymore when sending empty arguments* . Bugfix: float values are parsed correctly now in Win32 environments (Linux was already working)* - BUILD 19: . Linux: FIFO communication will return result string with newline attached* . Linux: improved FIFO to synchronous writing (added O_SYNC flag)* . Linux: Added experimental FILE interface (SLOW!)* . Win/Linux: Fixed bug with ')' symbol - introducing GTK_SERVER_BRACKET config option* . Linux distribution provides convenient KILL script to kill hanging gtk-servers** CHANGES GTK-SERVER 1.2* ----------------------* - BUILD 1: . Major changes in callback functionality by ideas of mr. Joe Armstrong; hence new releasenumber* . Ability to add extra signals per widget, each with own identifier* . Bugfix: returning empty STRING from GTK widget does not crash GTK-server anymore* . Bugfix: do not crash with '-1' as widget reference* . Improvements in the GTK-server KILL-script (Linux)* - BUILD 2: . The callback function only returns registered events now if called with 'WAIT'* . The callback function now knows asynchronous "update" as argument* . Generate error message when arguments to GTK-server are not recognized* . Bugfix: reading CONFIG environment variable (Linux)* . More improvements in the GTK-server KILL-script (Linux)* . HOTFIX: STDIN interface can read newlines now* - BUILD 3: . Improved configure script to force compilation with GTK2* . Corrected 'gtk-server.cfg' search order for Linux* . Corrected format of logging with TCP and UDP* . The GTK-server now compiles with -pedantic flag and is ISO-C compatible (Linux)* . Added scripts to create sourcepackage, Slackware installpackage and SRC rpm* * CHANGES GTK-SERVER 1.3* ----------------------* - BUILD 1: . Major changes in passing strings to GTK-server; concept by Norman Deppendbroek, parser* created by Jim Bailey, slightly modified for GTK-server (me)* . The configoptions 'GTK_SERVER_COMMA' and 'GTK_SERVER_BRACKET' are redundant now* . Improved Trim_String function by Jim Bailey* . Linux: search for configfile '.gtk-server.cfg' in homedirectory of user also* - BUILD 2: . Fixed severe memory leak in callback routines* . GTK-server should compile without problems on FreeBSD now* - BUILD 3: . Finalized complete solution for FLOAT arguments* . Support for opening extra library with GTK_LIB_EXTRA* . Removed the experimental FILE interface* - BUILD 4: . Fixed compile warning with GTK1.x* . Fixed environment variable mixup (Felix Winkelmann, Sebastiaan van Erk)* . Fixed STDIN loop exit problems (Sebastiaan van Erk)* . Changes in MAN pages* . Changes in static Makefile* . Removed FILE interface from GTK-server KILL script* . Updated gtk-server.cfg file to latest** CHANGES GTK-SERVER 2.0* ----------------------* - BUILD 1: . Major changes in passing arguments and realizing GTK functions. Using FFI now, which* also solves the FLOAT problem structurally* . Ability to capture incoming values in callback function* . Improved the Print_Error routine* . All error warnings go to the same function now* - BUILD 2: . Fixed erronuous Errormessages with DLOPEN* . Added floattype to FFI structure for compatibility with GTK 1.x* . Fixed compilewarnings for sprintf and vsprintf on OpenBSD* . Fixed issue with 'strtof' on OpenBSD* . Fixed unresolved PTHREAD symbol on OpenBSD* . Applied patches to obey --prefix flag (Peter Bui)* - BUILD 3: . Fixed bug with listening to extra signals (Woflgang Oertl)* . Up to 8 callback arguments can be retrieved now* . Implemented BOOL type, interchangable with LONG* . Returnbuffer is now of flexible size* . Option GTK_SERVER_ENABLE_C_STRING_ESCAPING to set escaping in returned strings (Jeremy Shute)* . Code cleanups* - BUILD 4: . Fixed minor bug with returning widgetID in "gtk_server_callback_value"* . Added support for mouse events with "gtk_server_mouse"* . Updated and corrected the manpages* - BUILD 5: . Added errormessage when returnvalue of GTK call in configfile is not correct* . Added GDK_LIB_NAME and GLIB_LIB_NAME in configfile* . Improved the Win32 Makefile* . Added "gtk_server_redefine" to change API calls on the fly* . Fixed OpenBSD compilewarning with sprintf* - BUILD 6: . Changed the signal connect functions to 'signal_connect_after'* . Fixed configure script to compile on Solaris* . Now the GTK-server in FIFO mode removes pipe file by itself at normal exit (Linux, BSD)* . Removed the O_SYNC from the FIFO interface, Linux does not need it and MacOSX cannot compile with it* . Code optimizations in the Call_Realize function* . Added LIBRARY interface -> GTK-server can be compiled as SO/DLL now* . GTK-server also can be compiled as S-Lang module* - BUILD 7: . GTK-server can be compiled as 64bit on AMD X64 now* . Fixed architecture recognition problems in configure script* . Added ScriptBasic module target* . Fixed bug with 'gtk_server_redefine' (Leonardo Cecchi)* . Added BASE64 type so client program can send binary data to GTK functions* . Added internal call 'gtk_server_echo' for debugging purposes* . When compiled as library the call 'gtk_server_logging' wil enable logfile* - BUILD 8: . Fixed bug when returning empty strings in C_ESCAPE mode (Todd Dukes)* . Fixed bug when returning special characters in C_ESCAPE mode (Leonardo Cecchi)* . Backslashes are also escaped now in C_ESCAPE mode (Leonardo Cecchi)* . Defined 'gtk_server_connect' and 'gtk_server_connect_after' as separate calls* . New: 'gtk_server_disconnect'* . Callback routines return FALSE by default now, so all signals can be captured by client program* . Basic support for GLADE files* . Added 'cfg' argument to point to location of configfile* . Arguments to gtk-server can be used in random order* . Format FIFO argument changed (Linux)* . Configure scripts will recognize MacOSX (Darwin) now (Leonardo Cecchi)* - BUILD 9: . XML calls return pointer to object* . New: 'gtk_server_glade_string' to create user interfaces from memory instead of file* . Callback routines return FALSE as option* . Fixed bug with 'gtk_server_callback update', now it catches callback arguments correctly* . Fixed bug: FIFO for Win32 works again* - BUILD 10: . New arguments 'pre' and 'post' to GTK-server determining the format of the returnstring (Christian Thaeter)* . Argument format 'tcp' and 'udp' to 'tcp=host:port' and 'udp=host:port'* . As LIBRARY pass to "gtk"-function: 'cfg=' for configfile, 'pre=' and 'post=' for format of returnstring* . String arguments can be grouped using single quotes (Christian Thaeter)* . Improved memory management with returnstrings containing STRING type* . Autoconnect signals in Glade XML if they are defined* - BUILD 11: . New: 'gtk_server_timeout' to let GTK return after some idle time in WAIT callback (async event)* . Improvements on the GtkScript interpreter (see GtkScript/docs/manual.txt)* . Compile with GLADE by default* . Improved memory management, cleaned up some ugly code* - BUILD 12: . Fixed bug with FLOAT and DOUBLE type mixup (thanks Norm Kaiser)* . Improved the configurescripts and generation of Makefile* . Windows version now only will create a logfle when "log" argument is given* . Introducing PANGO_LIB_NAME, ATK_LIB_NAME, PIXBUF_LIB_NAME, changed some configfile keywords to more logical words* . Code optimizations* . Improved documentation** CHANGES GTK-SERVER 2.1* ----------------------* - BUILD 1: . GTK-server now supports both libFFI and also FFCall, one of these should be available for compilation* . Banned Glib g_list routines from parser* . Added another backend: XForms (Linux/Unix/BSD only)* . Improved configure scripts even more, also put Glade support to autodetect* . In LIBRARY mode, removed the command 'gtk_server_logging', put it at same line as 'cfg=', 'post=', 'pre=' to be more consistent* - BUILD 2: . Added macro for 'snprintf' (lacks on Tru64Unix)* . Adapted configure scripts and implemented minor codefixes to avoid compilewarnings on Tru64Unix* . Code cleaning so compilation with Compaq C Compiler works now* . Improved KILL script, also added manpage* . Unix: improved gracefull exit in FIFO mode* . Some esthetic changes in sourcecode and GTK-server errors* - BUILD 3: . Unix: added IPC communication interface* . Unix: adjusted error warnings to messageboxes* . Unix: define exit signal to send to client program when GTK-server exits* . Win32: Improved configure-scripts to compile in MinGW natively* . Simplified signal handler registration for TCP* . Improved timeout handling, now more than one gtk_timeout can be created* . Timeouts to be removed with 'gtk_server_timeout_remove'* . New command 'gtk_server_exit'* . Added support for C/Invoke* . Fixed potential bug with opening GTK library* . Fixed bug with configure-scripts and GTK1 detection* . More code cleaning, simplification and beautification* - BUILD 4: . Fixed bug in demo scripts with Glade, also added demoscript with IPC* . Fixed bug in configure script when creating a Shared Object for Solaris* . Removed the GtkScript project from the sourcepackage* . Updated to the latest configfile* . Argument 'showconf' dumps current GTK-configuration to stdout* . Argument 'nocreate' avoids pipefile being created automatically (FIFO for Unix)* . Spawn to background automatically in Unix UDP, TCP, IPC and FIFO mode, this solves* all timing issues* . New command 'gtk_server_pid' (Unix only)* . Small fixes in UDP error messages* . Argument 'nodetach' prevents spawning to background* . Fixed bug in Windows Print_Error routine* - BUILD 5: . Removed all Glade stuf, now Glade needs to be called just as GTK* . Code cleaning* - BUILD 6: . Fixed bug in BOOL returnvalue when compiled with C/Invoke* . Fixed bug when compiling with FFCALL, introducing DOUBLE as valid returnvalue ** CHANGES GTK-SERVER 2.2* ----------------------* - BUILD 1: . Added GTK info in Windows about dialog* . Improved KILL script for IPC* . Improved configure scripts* . Added 'build' script (Unix)* . Fixed the 'create_distro' buildscript to create TGZ packages (Slackware, Gentoo, Zenwalk)* . New call for getting key events: gtk_server_key* . Ability to define macros in the configfile, hence new version number* . Trim_String now also removes '\r'* . gtk_server_disconnect now always works (previously only in a callback function)* . The default signal connection handler now sends the signal name as a string* . Fixed installmodes for configfile and manpages* - BUILD 2: . Fixed compile error with XForms* . Many small fixes in the demoscripts, added AWK dict client* . Fixed error messages in macro parser* . Support for scrollbutton events (GTK2.x)* . New: 'gtk_server_property_get/-set' to retrieve and set property values of widgets* . Check on duplicate function definitions in configfile during startup* . Arguments preceding with dash is also accepted now, e.g. 'log' and '-log' etc.* . Corrected help information* . Updated to the latest configfile* . Fixed bug with macro variables initialization* - BUILD 3: . Macros can assign strings to variables* . If a GTK function returns a result in pointer arguments, these can be retrieved now (request by Ben Kelly)* . Also all value types can be passed as pointers* . Check: when GTK call expects argument and client doesn't pass one* . 'gtk_server_property_get/-set' redundant, use 'g_object_get'* . New: 'gtk_server_set_c_string_escaping' to define particular set of characters to be escaped* . New: 'gtk_server_define' to define new GTK calls on-the-fly* . Fixes in the autoconf file for 64bit library compilation* . Improved Scriptbasic makefile* . New: 'gtk_server_opaque' to define memory for widgets like GtkIter, GdkColor etc. (request by Jean-Marc Farinas)* . Improved manpages* . Set the correct libraries in the configfile during installation (BSD/Unix/Linux)* . Fixed bug with C/Invoke and doubles as returnvalue* . Fixed bug with FFI and doubles as returnvalue (bug not noticable on X86 platforms)* . Updated to the latest configfile* - BUILD 4: . Moved to UTHASH library, fixing the following problems:* - Fixed slow lookup performance with large configfile* - Fixed crash when no macro definitions were found in configfile* - Fixed crash when no GTK definitions were found in configfile* . Fixed potential bug: memset in TCP and UDP interface to secure size* . Fixed some illegal memory writes in macro routines (Valgrind)* . Fixed some illegal memory writes in gtk_server_define/-redefine (Valgrind)* . Added tool to extract configfile from GTK/GDK headers* . Fixed crash during parsing configfile when arguments of GTK functions were not defined* . Fixed crash during parsing configfile when logfile was not defined* . Implemented flexible mechanism for defining libraries, now anything can be added to a max of 32* . Fixed EXIT handling with 'gtk_server_exit' and STDIN interface* . Fixed crash when a defined library could not be opened* . Return type 'ADDRESS' returns the address in memory of function* . Fixed bug in IPC interface when sent string contains a '=' (bug found by Tim Launchbury)* . Added 'INCLUDE' keyword in configfile to include additional configfiles (request by John Spikowski)* . Within macros it is possible to perform relative jumps: 'VALUE', 'EMPTY', 'JUMP'* . General improvements in macroparser, starting 'Highlevel Universal GUI' (HUG) in configfile* . Removed EXIT_SIGNAL from configfile, specify 'signal=' on commandline* . Cleaned up exit handling, works better with error exit and FIFO now* . Documentation: improved manpages, added more demoscripts* - BUILD 5 . Fixed crash when no libs were defined in configfile (bug found by Joonas Pihlaja)* . Fixed crash when empty string was sent to UDP interface (bug found by Joonas Pihlaja)* . Fixed deadlock in UDP interface because hostent was never initialized properly (bug found by Joonas Pihlaja)* . Fixed static compilation: optimized code, Makefile was missing linker flag '-export-dynamic'* . Static binary does not need configfile anymore, can define GTK calls on-the-fly* . Get LONG or STRING with 'gtk_server_callback_value'* . Support for Kornshell93 library interface* . Fixed crash when empty string was sent to LIB interface* . Also show libraries and log file location with '-showconf'* . Fixed issues with removing message queues and pipefiles in stopscript* . Added support for readline with interactive STDIN interface* . Fixed crash in OpenBSD 4.3 when libs could not be found* . Removed check that WidgetID should be > 0, does not work with OpenBSD 4.3* . Improved Makefile.in and configure.in for OpenBSD* . Some minor code improvements to clear compilewarnings on OpenBSD* . Security improvements on finding configfile
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -