📄 gtk-server.c
字号:
* . Fixed bug in c_string_escaping after redefinition of chars to be escaped* . More improvements in stopscript. Compatible with BSD-type systems now* - BUILD 6 . Added demoscript with the Poppler library, added demoscripts demonstrating HUG* . Stopscript now also can show current running GTK-server processes* . Added configurescript options to specify sourcetree locations* . Option 'showconf' also shows defined macros* . New: 'gtk_server_require' to test actual availability of libraries and define libraries on-the-fly* . Fixed bug: compilation with C/Invoke did not open XForms library* . Code improvements in the macroparser* . Major improvements in the GUI abstraction layer "HUG"* . Macros can define associative arrays with ASSOC, retrieve values with GET* . Fixed configurescript complaints about missing 'datarootdir'* . Logdirectory definition removed from configfile, now specify logdir as argument '-log=<dir>', better* consistency with other options, and GTK-server can function completely without configfile now* . Macros: added DEBUG to print contents of macrovariables in logfile* . Static compilation also possible for XForms now* . Fixed duplicate hash-value which occurs in rare situations* . Compilation with 'TCC' possible (export CC=tcc)* . Fixed bug: when using GTK-server as shared object and enabling logging* - BUILD 7 . Bugfix: gtk_server_require would overwrite library statically compiled in* . Minor fix in 'gen_conf' script so it does not add logdir anymore* . Added 'libm' to default configfile, also some of it's math functions (easy for shellscripts)* . Added ability to define enumerations 'ENUM_NAME' in configfile* . XForms: improved demoscripts, added OpenGL demoscripts* . XForms bugfix: initialize library before the first Print_Error occurs* . Corrected definition of 'glTranslatef' in configfile, compilation with FFI revealed this bug* . Added librarypath when compiling for 64bit platform (XForms)* . Put code in place for static compilation in Win32* . Removed workaround code to fallback to STRING if LONG was not detected (use 'gtk_server_redefine' instead)* . Upgraded to uthash 1.3 (uthash.sourceforge.net)* . Make strong differentiation between LONG and INT (important for Win32 platforms)* . Generate error when argument type is not recognized* . Bugfix: static compilation with GTK1/Xforms using C/Invoke crashed because of uninitialized context* . Hotfix: on 64-bit platforms explicitely cast to 'INT' with gtk_server_callback_value* . Hotfix: Valgrind detects illegal write of 1 byte in macro parser* . Hotfix: initialize max arguments to NULL for each new GTK function, else redefintion may crash* - BUILD 8 . Added support for DynCall (www.dyncall.org)* . Fixed potential bug in defining new GTK functions with 'gtk_server_define'* . Removed 'ok' from returnstring when PTR_* argument contains result* . VOID is also legal returnvalue for function* . POINTER as valid argumenttype and returnvalue for generic pointers from GLib calls and some non-GTK libs* . Returnvalue of 'gtk_server_require' will give 'ok', or errorstring (for debugging)* . Less memory usage in PTR_* return code* . Macros can use COMPARE to compare variables* . Improved some errormessages, added more function definitions to configfile* . Fixed bug with LONG typecast and FFCALL* . Fixed bug with some erronous array declarations* . Added possibility to register GtkDataFuncs (user functions), introducing 'MACRO' and 'DATA' as argument type* . Check on duplicate macro names during startup* . Hotfix: no space between results when GTK function returns value and also uses PTR_ arguments* . Hotfix: removed unnecessary free in Print_Error routine for Win32** CHANGES GTK-SERVER 2.3* ----------------------* - BUILD 1 . Added 'gtk_server_toolkit' command to retrieve backend for which GTK-server was compiled* . Arguments 'MACRO'-'DATA' are also usable for Xforms now* . Make sure the 'MACRO'/'DATA' callbacks are not reading from illegal memory* . Fixed minor bug with counting linenumbers when parsing configfile* . Added option to define aliases for functionnames, so clientprograms can avoid collisions with existing statements* . STDIN, FIFO, TCP and IPC interfaces can take and return any amount of data now* . The UDP interface can take data as much as the system's Socket receive buffer size (SO_RCVBUF)* . Fixed minor issues in stop-script with IPC GTK-server processes* . 'gtk_server_macro_define'/'-redefine' to (re-)define macros on the fly, renamed 'gtk_server_macro' to '-_var' to get value of variables* . Added '-sock' mode to connect as TCP client (idea Danie Brink)* . Withdrawn the READLINE option as scripts using STDIN ran into inconsistent programs, use external 'rlwrap' instead* . Upgraded to uthash 1.4 (uthash.sourceforge.net)* . Major code cleanup for returning info to client, improving simplicity, readability and performance* . Added commandline option '-start' to start GTK-server with a macro (idea Danie Brink)* . 'gtk_server_os' to determine platform where GTK-server is running (idea Danie Brink)* . Added commandline option '-init' to send string in '-sock' mode (idea Danie Brink)* . Added support for SSL in '-sock' mode (idea Danie Brink)* . Using the GTK functionnames as keys for UTHASH; less code, best reliability for unique keys* . Fixed bug with XForms initialization in LIB mode* . Base64 decoder can decode unlimited amount of data* . Fixed bug: using 'gtk_server_require' multiple times would overwrite eachother* . Added option '-this' to run standalone configfile using shebang* . Compilation without GTK/Xforms/X is possible now, console mode for opening any library in a script* . Added '-handle' so client can send unique identifier per request (synchronize communication, UDP, debugging)* . XForms can get key, mouse events and coordinates too* . Adjusted size for XForms Error dialog, it didn't show all errors correctly* . Key events and scrollbutton events (GTK) were optimized so they can return any user defined string* . Fixed bug: remove the check on negative numbers in LIB interface, this check prevented UTF-8 to be accepted* . MacOSX: adjustments in makefile and configurescripts* . MacOSX: changed retrieval of mouse button, MacOSX does not pass all GdkModifierTypes (no X but Quartz!)* . MacOSX, BSD, Solaris: self-spawning not always works, now use '-detach' to try to selfspawn, shells use ampersand '&'* . Corrections in documentation and manpages (2.3.1 Second Release)* . Standardized all 'config.h' macros because of conflict with newer GCC versions (2.3.1 Second Release)* . Cleaned up redundant C macros (2.3.1 Second Release)* . Fixed compilation problems with TCC compiler (2.3.1 Second Release)* . Corrected OpenGL libraries in configfile for MacOSX (2.3.1 Second Release)* . More fixes in manpages (2.3.1 Second Release)****************************************************************************/#ifdef HAVE_CONFIG_H#include "config.h"#endif#ifdef GTK_SERVER_KSH93#include <shell.h>#include <stdio.h>#endif#ifdef GTK_SERVER_SLANG#include <slang.h>#endif#if GTK_SERVER_GTK1x || GTK_SERVER_GTK2x#include <gtk/gtk.h>#endif#ifdef GTK_SERVER_XF#include <forms.h>#endif#ifdef GTK_SERVER_USE_SSL#include <openssl/ssl.h>#include <openssl/err.h>#endif#ifndef GTK_SERVER_KSH93#include <stdio.h>#endif#include <stdlib.h>#include <string.h>#include <errno.h>#include <locale.h>#include <unistd.h>#include <sys/stat.h>#include "uthash.h"#ifdef GTK_SERVER_FFI#include <ffi.h>#elif GTK_SERVER_FFCALL#include <avcall.h>#elif GTK_SERVER_CINV#include <cinvoke.h>#elif GTK_SERVER_DYNCALL#include <dyncall.h>#include <dynload.h>#endif#ifdef GTK_SERVER_UNIX#include <netdb.h>#include <sys/socket.h>#include <sys/wait.h>#include <arpa/inet.h>#include <signal.h>#include <dlfcn.h>#include <stdarg.h>/* Needed for FIFO files */#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>/* Needed for IPC msg queue */#include <sys/ipc.h>#include <sys/msg.h>#define FUNC_POINTER void (*func)()#endif#ifdef GTK_SERVER_BSD#include <netinet/in.h>#endif#ifdef GTK_SERVER_SCRIPTBASIC#include <basext.h>#endif#ifdef GTK_SERVER_WIN32#include <strings.h>#include <winsock.h>#include <windows.h>#include <shlwapi.h>#define FUNC_POINTER FARPROC *func#endif#ifndef LOCALCFG#define LOCALCFG "/usr/local/etc/gtk-server.cfg"#endif/* Max length of a STDIN coming from script or configfile */#define MAX_LEN 1024/* how many libs we may open and check */#define MAX_LIBS 32/* Define how many arguments may be used in a GTK function */#define MAX_ARGS 32/* Maximum digits to return */#define MAX_DIG 32/* Define callback signals */#define GTK_SERVER_NONE 0/* Define GTK-server version - macro 'VERSION' also used by FFI on some platforms */#define GTK_SERVER_VERSION "2.3 build 1"/* Define backlog for tcp-connections */#define BACKLOG 4/* Define printable length of LONG type - use same type as returntype of the Widget_GUI() function */#define LONG_SIZE 32/* Verify if a pointer is valid - taken from 'jkr' from www.experts-exchange.com */#ifdef GTK_SERVER_UNIXstruct stat sb;#define illegal_pointer(p) (stat(p, &sb) == -1 && errno == EFAULT)#elif GTK_SERVER_WIN32/* http://msdn.microsoft.com/en-us/library/aa366713(VS.85).aspx */#define illegal_pointer(p) IsBadReadPtr(p, MAX_LEN)#endif/* Define some inputs and outputs */enum { STDIN, STDOUT, STDERR };/* Define structure containing configuration data */typedef struct config_struct { char *name; char *callbacktype; char *returnvalue; char *argamount; char *args[MAX_ARGS]; UT_hash_handle hh; /* makes this structure hashable */} CONFIG;/* Needed for hashtable */struct config_struct *gtk_protos = NULL;/* Define structures to keep macro definitions */typedef struct macro_body { char *text; /* Keep a line of the macro */ struct macro_body *next; /* Pointer to next line */ struct macro_body *prev; /* Pointer to previous line */} BODY;typedef struct macro_struct { char *name; /* Name of the macro */ char *args[10]; /* Up to 10 arguments for a macro */ char *var[26]; /* Values of 26 variables used in macro */ struct macro_body *body; /* Pointer to body of the macro */ UT_hash_handle hh; /* makes this structure hashable */} MACRO;/* Needed for hashtable */struct macro_struct *macro_protos = NULL;/* Define structure to define enumerations */typedef struct enum_struct { char *name; /* Name of the enum */ int value; /* Actual value of the enum */ UT_hash_handle hh; /* makes this structure hashable */} ENUM;/* Needed for hashtable */struct enum_struct *enum_protos = NULL;/* This defines assocs created in configfile macro's */typedef struct macro_assoc_struct { char assoc[LONG_SIZE]; /* The associated widgetID */ char *key; /* Holder for the key of the assoc */ UT_hash_handle hh; /* makes this structure hashable */} MACRO_ASSOC;/* Needed for hashtable */struct macro_assoc_struct *macro_assoc_protos = NULL;/* Define structure to define arguments of MACRO type */typedef struct arg_struct { char *name; /* Name of the macro to execute */ char *data; /* Additional data */ UT_hash_handle hh; /* makes this structure hashable */} ARG;/* Needed for corresponding hashtable */struct arg_struct *arg_protos = NULL;ARG *Macro_Type = NULL;/* Define structure to define function aliases */typedef struct alias_struct { char *name; /* Name of the alias */ struct config_struct *real; /* Pointer to the real function name */ UT_hash_handle hh; /* makes this structure hashable */} ALIAS;/* Needed for hashtable */struct alias_struct *alias_protos = NULL;/* Define union for FFI and CINVOKE */typedef union { long lvalue; int ivalue; float fvalue; double dvalue; char *pvalue; #if GTK_SERVER_GTK1x || GTK_SERVER_GTK2x GtkObject *wvalue; #elif GTK_SERVER_XF FL_OBJECT *wvalue; #else void *wvalue; #endif /* These are needed for GTK functions which use pointer arguments to return results in */ long *p_lvalue; int *p_ivalue; float *p_fvalue; double *p_dvalue; char **p_svalue; #if GTK_SERVER_GTK1x || GTK_SERVER_GTK2x GtkObject **p_wvalue; #elif GTK_SERVER_XF FL_OBJECT **p_wvalue; #else void **p_wvalue; #endif} TYPE;/* Struct to pass data to callback function for timeouts */typedef struct { long widget; char *signal; unsigned int id;} TIMEOUT;/* Define current 'callbacked' object */struct callback { #if GTK_SERVER_GTK1x || GTK_SERVER_GTK2x GtkWidget *object; int button; #elif GTK_SERVER_XF FL_OBJECT *object;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -