sl@0: /* sl@0: * tcl.h -- sl@0: * sl@0: * This header file describes the externally-visible facilities sl@0: * of the Tcl interpreter. sl@0: * sl@0: * Copyright (c) 1987-1994 The Regents of the University of California. sl@0: * Copyright (c) 1993-1996 Lucent Technologies. sl@0: * Copyright (c) 1994-1998 Sun Microsystems, Inc. sl@0: * Copyright (c) 1998-2000 by Scriptics Corporation. sl@0: * Copyright (c) 2002 by Kevin B. Kenny. All rights reserved. sl@0: * Portions Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiaries. All rights reserved. sl@0: * sl@0: * See the file "license.terms" for information on usage and redistribution sl@0: * of this file, and for a DISCLAIMER OF ALL WARRANTIES. sl@0: * sl@0: * RCS: @(#) $Id: tcl.h,v 1.153.2.30 2006/10/23 17:53:26 dgp Exp $ sl@0: */ sl@0: sl@0: #ifndef _TCL sl@0: #define _TCL sl@0: sl@0: /* sl@0: * For C++ compilers, use extern "C" sl@0: */ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: /* sl@0: * The following defines are used to indicate the various release levels. sl@0: */ sl@0: sl@0: #define TCL_ALPHA_RELEASE 0 sl@0: #define TCL_BETA_RELEASE 1 sl@0: #define TCL_FINAL_RELEASE 2 sl@0: sl@0: /* sl@0: * When version numbers change here, must also go into the following files sl@0: * and update the version numbers: sl@0: * sl@0: * library/init.tcl (only if Major.minor changes, not patchlevel) 1 LOC sl@0: * unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch) sl@0: * win/configure.in (as above) sl@0: * win/tcl.m4 (not patchlevel) sl@0: * win/makefile.vc (not patchlevel) 2 LOC sl@0: * README (sections 0 and 2) sl@0: * mac/README (2 LOC, not patchlevel) sl@0: * macosx/Tcl.pbproj/project.pbxproj (not patchlevel) 1 LOC sl@0: * macosx/Tcl.pbproj/default.pbxuser (not patchlevel) 1 LOC sl@0: * win/README.binary (sections 0-4) sl@0: * win/README (not patchlevel) (sections 0 and 2) sl@0: * unix/tcl.spec (2 LOC Major/Minor, 1 LOC patch) sl@0: * tests/basic.test (1 LOC M/M, not patchlevel) sl@0: * tools/tcl.hpj.in (not patchlevel, for windows installer) sl@0: * tools/tcl.wse.in (for windows installer) sl@0: * tools/tclSplash.bmp (not patchlevel) sl@0: */ sl@0: #define TCL_MAJOR_VERSION 8 sl@0: #define TCL_MINOR_VERSION 4 sl@0: #define TCL_RELEASE_LEVEL TCL_FINAL_RELEASE sl@0: #define TCL_RELEASE_SERIAL 15 sl@0: sl@0: #define TCL_VERSION "8.4" sl@0: #define TCL_PATCH_LEVEL "8.4.15" sl@0: sl@0: /* sl@0: * The following definitions set up the proper options for Windows sl@0: * compilers. We use this method because there is no autoconf equivalent. sl@0: */ sl@0: sl@0: // Only if not compiling for Symbian on a PC with a Windows compiler sl@0: #ifndef __SYMBIAN32__ sl@0: #ifndef __WIN32__ sl@0: # if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) || defined(__BORLANDC__) sl@0: # define __WIN32__ sl@0: # ifndef WIN32 sl@0: # define WIN32 sl@0: # endif sl@0: # endif sl@0: #endif sl@0: #endif sl@0: sl@0: /* sl@0: * STRICT: See MSDN Article Q83456 sl@0: */ sl@0: #ifdef __WIN32__ sl@0: # ifndef STRICT sl@0: # define STRICT sl@0: # endif sl@0: #endif /* __WIN32__ */ sl@0: sl@0: /* sl@0: * The following definitions set up the proper options for Macintosh sl@0: * compilers. We use this method because there is no autoconf equivalent. sl@0: */ sl@0: sl@0: #ifdef MAC_TCL sl@0: #include sl@0: # ifndef USE_TCLALLOC sl@0: # define USE_TCLALLOC 1 sl@0: # endif sl@0: # ifndef NO_STRERROR sl@0: # define NO_STRERROR 1 sl@0: # endif sl@0: # define INLINE sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Utility macros: STRINGIFY takes an argument and wraps it in "" (double sl@0: * quotation marks), JOIN joins two arguments. sl@0: */ sl@0: #ifndef STRINGIFY sl@0: # define STRINGIFY(x) STRINGIFY1(x) sl@0: # define STRINGIFY1(x) #x sl@0: #endif sl@0: #ifndef JOIN sl@0: # define JOIN(a,b) JOIN1(a,b) sl@0: # define JOIN1(a,b) a##b sl@0: #endif sl@0: sl@0: /* sl@0: * A special definition used to allow this header file to be included sl@0: * from windows or mac resource files so that they can obtain version sl@0: * information. RC_INVOKED is defined by default by the windows RC tool sl@0: * and manually set for macintosh. sl@0: * sl@0: * Resource compilers don't like all the C stuff, like typedefs and sl@0: * procedure declarations, that occur below, so block them out. sl@0: */ sl@0: sl@0: #ifndef RC_INVOKED sl@0: sl@0: /* sl@0: * Special macro to define mutexes, that doesn't do anything sl@0: * if we are not using threads. sl@0: */ sl@0: sl@0: #ifdef TCL_THREADS sl@0: #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name; sl@0: #else sl@0: #define TCL_DECLARE_MUTEX(name) sl@0: #endif sl@0: sl@0: /* sl@0: * Macros that eliminate the overhead of the thread synchronization sl@0: * functions when compiling without thread support. sl@0: */ sl@0: sl@0: #ifndef TCL_THREADS sl@0: #define Tcl_MutexLock(mutexPtr) sl@0: #define Tcl_MutexUnlock(mutexPtr) sl@0: #define Tcl_MutexFinalize(mutexPtr) sl@0: #define Tcl_ConditionNotify(condPtr) sl@0: #define Tcl_ConditionWait(condPtr, mutexPtr, timePtr) sl@0: #define Tcl_ConditionFinalize(condPtr) sl@0: #endif /* TCL_THREADS */ sl@0: sl@0: sl@0: #ifndef BUFSIZ sl@0: # include sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Definitions that allow Tcl functions with variable numbers of sl@0: * arguments to be used with either varargs.h or stdarg.h. TCL_VARARGS sl@0: * is used in procedure prototypes. TCL_VARARGS_DEF is used to declare sl@0: * the arguments in a function definiton: it takes the type and name of sl@0: * the first argument and supplies the appropriate argument declaration sl@0: * string for use in the function definition. TCL_VARARGS_START sl@0: * initializes the va_list data structure and returns the first argument. sl@0: */ sl@0: #if !defined(NO_STDARG) sl@0: # include sl@0: # define TCL_VARARGS(type, name) (type name, ...) sl@0: # define TCL_VARARGS_DEF(type, name) (type name, ...) sl@0: # define TCL_VARARGS_START(type, name, list) (va_start(list, name), name) sl@0: #else sl@0: # include sl@0: # define TCL_VARARGS(type, name) () sl@0: # define TCL_VARARGS_DEF(type, name) (va_alist) sl@0: # define TCL_VARARGS_START(type, name, list) \ sl@0: (va_start(list), va_arg(list, type)) sl@0: #endif sl@0: sl@0: /* sl@0: * Macros used to declare a function to be exported by a DLL. sl@0: * Used by Windows, maps to no-op declarations on non-Windows systems. sl@0: * The default build on windows is for a DLL, which causes the DLLIMPORT sl@0: * and DLLEXPORT macros to be nonempty. To build a static library, the sl@0: * macro STATIC_BUILD should be defined. sl@0: */ sl@0: sl@0: #ifdef STATIC_BUILD sl@0: # define DLLIMPORT sl@0: # define DLLEXPORT sl@0: #else sl@0: # if (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || (defined(__GNUC__) && defined(__declspec)))) || (defined(MAC_TCL) && FUNCTION_DECLSPEC) sl@0: # define DLLIMPORT __declspec(dllimport) sl@0: # define DLLEXPORT __declspec(dllexport) sl@0: # else sl@0: # define DLLIMPORT sl@0: # define DLLEXPORT sl@0: # endif sl@0: #endif sl@0: sl@0: /* sl@0: * These macros are used to control whether functions are being declared for sl@0: * import or export. If a function is being declared while it is being built sl@0: * to be included in a shared library, then it should have the DLLEXPORT sl@0: * storage class. If is being declared for use by a module that is going to sl@0: * link against the shared library, then it should have the DLLIMPORT storage sl@0: * class. If the symbol is beind declared for a static build or for use from a sl@0: * stub library, then the storage class should be empty. sl@0: * sl@0: * The convention is that a macro called BUILD_xxxx, where xxxx is the sl@0: * name of a library we are building, is set on the compile line for sources sl@0: * that are to be placed in the library. When this macro is set, the sl@0: * storage class will be set to DLLEXPORT. At the end of the header file, the sl@0: * storage class will be reset to DLLIMPORT. sl@0: */ sl@0: #undef TCL_STORAGE_CLASS sl@0: #ifdef BUILD_tcl sl@0: # define TCL_STORAGE_CLASS DLLEXPORT sl@0: #else sl@0: # ifdef USE_TCL_STUBS sl@0: # define TCL_STORAGE_CLASS sl@0: # else sl@0: # define TCL_STORAGE_CLASS DLLIMPORT sl@0: # endif sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Definitions that allow this header file to be used either with or sl@0: * without ANSI C features like function prototypes. sl@0: */ sl@0: #undef _ANSI_ARGS_ sl@0: #undef CONST sl@0: #ifndef INLINE sl@0: # define INLINE sl@0: #endif sl@0: sl@0: #ifndef NO_CONST sl@0: # define CONST const sl@0: #else sl@0: # define CONST sl@0: #endif sl@0: sl@0: #ifndef NO_PROTOTYPES sl@0: # define _ANSI_ARGS_(x) x sl@0: #else sl@0: # define _ANSI_ARGS_(x) () sl@0: #endif sl@0: sl@0: #ifdef USE_NON_CONST sl@0: # ifdef USE_COMPAT_CONST sl@0: # error define at most one of USE_NON_CONST and USE_COMPAT_CONST sl@0: # endif sl@0: # define CONST84 sl@0: # define CONST84_RETURN sl@0: #else sl@0: # ifdef USE_COMPAT_CONST sl@0: # define CONST84 sl@0: # define CONST84_RETURN CONST sl@0: # else sl@0: # define CONST84 CONST sl@0: # define CONST84_RETURN CONST sl@0: # endif sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Make sure EXTERN isn't defined elsewhere sl@0: */ sl@0: #ifdef EXTERN sl@0: # undef EXTERN sl@0: #endif /* EXTERN */ sl@0: sl@0: #ifdef __cplusplus sl@0: # define EXTERN extern "C" TCL_STORAGE_CLASS sl@0: #else sl@0: # define EXTERN extern TCL_STORAGE_CLASS sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: #ifdef EXTERN sl@0: # undef EXTERN sl@0: #endif sl@0: #ifdef __cplusplus sl@0: # define EXTERN extern "C" sl@0: #else sl@0: # define EXTERN extern sl@0: #endif sl@0: #endif sl@0: sl@0: /* sl@0: * The following code is copied from winnt.h. sl@0: * If we don't replicate it here, then can't be included sl@0: * after tcl.h, since tcl.h also defines VOID. sl@0: * This block is skipped under Cygwin and Mingw. sl@0: * sl@0: * sl@0: */ sl@0: #if defined(__WIN32__) && !defined(HAVE_WINNT_IGNORE_VOID) sl@0: #ifndef VOID sl@0: #define VOID void sl@0: typedef char CHAR; sl@0: typedef short SHORT; sl@0: typedef long LONG; sl@0: #endif sl@0: #endif /* __WIN32__ && !HAVE_WINNT_IGNORE_VOID */ sl@0: sl@0: /* sl@0: * Macro to use instead of "void" for arguments that must have sl@0: * type "void *" in ANSI C; maps them to type "char *" in sl@0: * non-ANSI systems. sl@0: */ sl@0: sl@0: #ifndef NO_VOID sl@0: # define VOID void sl@0: #else sl@0: # define VOID char sl@0: #endif sl@0: sl@0: /* sl@0: * Miscellaneous declarations. sl@0: */ sl@0: sl@0: #ifndef _CLIENTDATA sl@0: # ifndef NO_VOID sl@0: typedef void *ClientData; sl@0: # else sl@0: typedef int *ClientData; sl@0: # endif sl@0: # define _CLIENTDATA sl@0: #endif sl@0: sl@0: /* sl@0: * Darwin specifc configure overrides (to support fat compiles, where sl@0: * configure runs only once for multiple architectures): sl@0: */ sl@0: sl@0: #ifdef __APPLE__ sl@0: # ifdef __LP64__ sl@0: # undef TCL_WIDE_INT_TYPE sl@0: # define TCL_WIDE_INT_IS_LONG 1 sl@0: # else /* !__LP64__ */ sl@0: # define TCL_WIDE_INT_TYPE long long sl@0: # undef TCL_WIDE_INT_IS_LONG sl@0: # endif /* __LP64__ */ sl@0: # undef HAVE_STRUCT_STAT64 sl@0: #endif /* __APPLE__ */ sl@0: sl@0: /* sl@0: * Define Tcl_WideInt to be a type that is (at least) 64-bits wide, sl@0: * and define Tcl_WideUInt to be the unsigned variant of that type sl@0: * (assuming that where we have one, we can have the other.) sl@0: * sl@0: * Also defines the following macros: sl@0: * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on sl@0: * a real 64-bit system.) sl@0: * Tcl_WideAsLong - forgetful converter from wideInt to long. sl@0: * Tcl_LongAsWide - sign-extending converter from long to wideInt. sl@0: * Tcl_WideAsDouble - converter from wideInt to double. sl@0: * Tcl_DoubleAsWide - converter from double to wideInt. sl@0: * sl@0: * The following invariant should hold for any long value 'longVal': sl@0: * longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal)) sl@0: * sl@0: * Note on converting between Tcl_WideInt and strings. This sl@0: * implementation (in tclObj.c) depends on the functions strtoull() sl@0: * and sprintf(...,"%" TCL_LL_MODIFIER "d",...). TCL_LL_MODIFIER_SIZE sl@0: * is the length of the modifier string, which is "ll" on most 32-bit sl@0: * Unix systems. It has to be split up like this to allow for the more sl@0: * complex formats sometimes needed (e.g. in the format(n) command.) sl@0: */ sl@0: sl@0: #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) sl@0: # if defined(__GNUC__) sl@0: # define TCL_WIDE_INT_TYPE long long sl@0: # if defined(__WIN32__) && !defined(__CYGWIN__) sl@0: # define TCL_LL_MODIFIER "I64" sl@0: # define TCL_LL_MODIFIER_SIZE 3 sl@0: # else sl@0: # define TCL_LL_MODIFIER "L" sl@0: # define TCL_LL_MODIFIER_SIZE 1 sl@0: # endif sl@0: typedef struct stat Tcl_StatBuf; sl@0: # elif defined(__WIN32__) sl@0: # define TCL_WIDE_INT_TYPE __int64 sl@0: # ifdef __BORLANDC__ sl@0: typedef struct stati64 Tcl_StatBuf; sl@0: # define TCL_LL_MODIFIER "L" sl@0: # define TCL_LL_MODIFIER_SIZE 1 sl@0: # else /* __BORLANDC__ */ sl@0: # if _MSC_VER < 1400 || !defined(_M_IX86) sl@0: typedef struct _stati64 Tcl_StatBuf; sl@0: # else sl@0: typedef struct _stat64 Tcl_StatBuf; sl@0: # endif /* _MSC_VER < 1400 */ sl@0: # define TCL_LL_MODIFIER "I64" sl@0: # define TCL_LL_MODIFIER_SIZE 3 sl@0: # endif /* __BORLANDC__ */ sl@0: # else /* __WIN32__ */ sl@0: /* sl@0: * Don't know what platform it is and configure hasn't discovered what sl@0: * is going on for us. Try to guess... sl@0: */ sl@0: # ifdef NO_LIMITS_H sl@0: # error please define either TCL_WIDE_INT_TYPE or TCL_WIDE_INT_IS_LONG sl@0: # else /* !NO_LIMITS_H */ sl@0: # include sl@0: # if (INT_MAX < LONG_MAX) sl@0: # define TCL_WIDE_INT_IS_LONG 1 sl@0: # else sl@0: # define TCL_WIDE_INT_TYPE long long sl@0: # endif sl@0: # endif /* NO_LIMITS_H */ sl@0: # endif /* __WIN32__ */ sl@0: #endif /* !TCL_WIDE_INT_TYPE & !TCL_WIDE_INT_IS_LONG */ sl@0: #ifdef TCL_WIDE_INT_IS_LONG sl@0: # undef TCL_WIDE_INT_TYPE sl@0: # define TCL_WIDE_INT_TYPE long sl@0: #endif /* TCL_WIDE_INT_IS_LONG */ sl@0: sl@0: typedef TCL_WIDE_INT_TYPE Tcl_WideInt; sl@0: typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; sl@0: sl@0: #ifdef TCL_WIDE_INT_IS_LONG sl@0: typedef struct stat Tcl_StatBuf; sl@0: # define Tcl_WideAsLong(val) ((long)(val)) sl@0: # define Tcl_LongAsWide(val) ((long)(val)) sl@0: # define Tcl_WideAsDouble(val) ((double)((long)(val))) sl@0: # define Tcl_DoubleAsWide(val) ((long)((double)(val))) sl@0: # ifndef TCL_LL_MODIFIER sl@0: # define TCL_LL_MODIFIER "l" sl@0: # define TCL_LL_MODIFIER_SIZE 1 sl@0: # endif /* !TCL_LL_MODIFIER */ sl@0: #else /* TCL_WIDE_INT_IS_LONG */ sl@0: /* sl@0: * The next short section of defines are only done when not running on sl@0: * Windows or some other strange platform. sl@0: */ sl@0: # ifndef TCL_LL_MODIFIER sl@0: # ifdef HAVE_STRUCT_STAT64 sl@0: typedef struct stat64 Tcl_StatBuf; sl@0: # else sl@0: typedef struct stat Tcl_StatBuf; sl@0: # endif /* HAVE_STRUCT_STAT64 */ sl@0: # define TCL_LL_MODIFIER "ll" sl@0: # define TCL_LL_MODIFIER_SIZE 2 sl@0: # endif /* !TCL_LL_MODIFIER */ sl@0: # define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val))) sl@0: # define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val))) sl@0: # define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val))) sl@0: # define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) sl@0: #endif /* TCL_WIDE_INT_IS_LONG */ sl@0: sl@0: sl@0: /* sl@0: * This flag controls whether binary compatability is maintained with sl@0: * extensions built against a previous version of Tcl. This is true sl@0: * by default. sl@0: */ sl@0: #ifndef TCL_PRESERVE_BINARY_COMPATABILITY sl@0: # define TCL_PRESERVE_BINARY_COMPATABILITY 1 sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Data structures defined opaquely in this module. The definitions below sl@0: * just provide dummy types. A few fields are made visible in Tcl_Interp sl@0: * structures, namely those used for returning a string result from sl@0: * commands. Direct access to the result field is discouraged in Tcl 8.0. sl@0: * The interpreter result is either an object or a string, and the two sl@0: * values are kept consistent unless some C code sets interp->result sl@0: * directly. Programmers should use either the procedure Tcl_GetObjResult() sl@0: * or Tcl_GetStringResult() to read the interpreter's result. See the sl@0: * SetResult man page for details. sl@0: * sl@0: * Note: any change to the Tcl_Interp definition below must be mirrored sl@0: * in the "real" definition in tclInt.h. sl@0: * sl@0: * Note: Tcl_ObjCmdProc procedures do not directly set result and freeProc. sl@0: * Instead, they set a Tcl_Obj member in the "real" structure that can be sl@0: * accessed with Tcl_GetObjResult() and Tcl_SetObjResult(). sl@0: */ sl@0: sl@0: typedef struct Tcl_Interp { sl@0: char *result; /* If the last command returned a string sl@0: * result, this points to it. */ sl@0: void (*freeProc) _ANSI_ARGS_((char *blockPtr)); sl@0: /* Zero means the string result is sl@0: * statically allocated. TCL_DYNAMIC means sl@0: * it was allocated with ckalloc and should sl@0: * be freed with ckfree. Other values give sl@0: * the address of procedure to invoke to sl@0: * free the result. Tcl_Eval must free it sl@0: * before executing next command. */ sl@0: int errorLine; /* When TCL_ERROR is returned, this gives sl@0: * the line number within the command where sl@0: * the error occurred (1 if first line). */ sl@0: } Tcl_Interp; sl@0: sl@0: typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler; sl@0: typedef struct Tcl_Channel_ *Tcl_Channel; sl@0: typedef struct Tcl_Command_ *Tcl_Command; sl@0: typedef struct Tcl_Condition_ *Tcl_Condition; sl@0: typedef struct Tcl_EncodingState_ *Tcl_EncodingState; sl@0: typedef struct Tcl_Encoding_ *Tcl_Encoding; sl@0: typedef struct Tcl_Event Tcl_Event; sl@0: typedef struct Tcl_Mutex_ *Tcl_Mutex; sl@0: typedef struct Tcl_Pid_ *Tcl_Pid; sl@0: typedef struct Tcl_RegExp_ *Tcl_RegExp; sl@0: typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey; sl@0: typedef struct Tcl_ThreadId_ *Tcl_ThreadId; sl@0: typedef struct Tcl_TimerToken_ *Tcl_TimerToken; sl@0: typedef struct Tcl_Trace_ *Tcl_Trace; sl@0: typedef struct Tcl_Var_ *Tcl_Var; sl@0: typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion; sl@0: typedef struct Tcl_LoadHandle_ *Tcl_LoadHandle; sl@0: sl@0: /* sl@0: * Definition of the interface to procedures implementing threads. sl@0: * A procedure following this definition is given to each call of sl@0: * 'Tcl_CreateThread' and will be called as the main fuction of sl@0: * the new thread created by that call. sl@0: */ sl@0: #ifdef MAC_TCL sl@0: typedef pascal void *(Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); sl@0: #elif defined __WIN32__ sl@0: typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); sl@0: #else sl@0: typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Threading function return types used for abstracting away platform sl@0: * differences when writing a Tcl_ThreadCreateProc. See the NewThread sl@0: * function in generic/tclThreadTest.c for it's usage. sl@0: */ sl@0: #ifdef MAC_TCL sl@0: # define Tcl_ThreadCreateType pascal void * sl@0: # define TCL_THREAD_CREATE_RETURN return NULL sl@0: #elif defined __WIN32__ sl@0: # define Tcl_ThreadCreateType unsigned __stdcall sl@0: # define TCL_THREAD_CREATE_RETURN return 0 sl@0: #else sl@0: # define Tcl_ThreadCreateType void sl@0: # define TCL_THREAD_CREATE_RETURN sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Definition of values for default stacksize and the possible flags to be sl@0: * given to Tcl_CreateThread. sl@0: */ sl@0: #define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack */ sl@0: #define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default behaviour */ sl@0: #define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable */ sl@0: sl@0: /* sl@0: * Flag values passed to Tcl_GetRegExpFromObj. sl@0: */ sl@0: #define TCL_REG_BASIC 000000 /* BREs (convenience) */ sl@0: #define TCL_REG_EXTENDED 000001 /* EREs */ sl@0: #define TCL_REG_ADVF 000002 /* advanced features in EREs */ sl@0: #define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs) */ sl@0: #define TCL_REG_QUOTE 000004 /* no special characters, none */ sl@0: #define TCL_REG_NOCASE 000010 /* ignore case */ sl@0: #define TCL_REG_NOSUB 000020 /* don't care about subexpressions */ sl@0: #define TCL_REG_EXPANDED 000040 /* expanded format, white space & sl@0: * comments */ sl@0: #define TCL_REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */ sl@0: #define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before */ sl@0: #define TCL_REG_NEWLINE 000300 /* newlines are line terminators */ sl@0: #define TCL_REG_CANMATCH 001000 /* report details on partial/limited sl@0: * matches */ sl@0: sl@0: /* sl@0: * The following flag is experimental and only intended for use by Expect. It sl@0: * will probably go away in a later release. sl@0: */ sl@0: #define TCL_REG_BOSONLY 002000 /* prepend \A to pattern so it only sl@0: * matches at the beginning of the sl@0: * string. */ sl@0: sl@0: /* sl@0: * Flags values passed to Tcl_RegExpExecObj. sl@0: */ sl@0: #define TCL_REG_NOTBOL 0001 /* Beginning of string does not match ^. */ sl@0: #define TCL_REG_NOTEOL 0002 /* End of string does not match $. */ sl@0: sl@0: /* sl@0: * Structures filled in by Tcl_RegExpInfo. Note that all offset values are sl@0: * relative to the start of the match string, not the beginning of the sl@0: * entire string. sl@0: */ sl@0: typedef struct Tcl_RegExpIndices { sl@0: long start; /* character offset of first character in match */ sl@0: long end; /* character offset of first character after the sl@0: * match. */ sl@0: } Tcl_RegExpIndices; sl@0: sl@0: typedef struct Tcl_RegExpInfo { sl@0: int nsubs; /* number of subexpressions in the sl@0: * compiled expression */ sl@0: Tcl_RegExpIndices *matches; /* array of nsubs match offset sl@0: * pairs */ sl@0: long extendStart; /* The offset at which a subsequent sl@0: * match might begin. */ sl@0: long reserved; /* Reserved for later use. */ sl@0: } Tcl_RegExpInfo; sl@0: sl@0: /* sl@0: * Picky compilers complain if this typdef doesn't appear before the sl@0: * struct's reference in tclDecls.h. sl@0: */ sl@0: typedef Tcl_StatBuf *Tcl_Stat_; sl@0: typedef struct stat *Tcl_OldStat_; sl@0: sl@0: /* sl@0: * When a TCL command returns, the interpreter contains a result from the sl@0: * command. Programmers are strongly encouraged to use one of the sl@0: * procedures Tcl_GetObjResult() or Tcl_GetStringResult() to read the sl@0: * interpreter's result. See the SetResult man page for details. Besides sl@0: * this result, the command procedure returns an integer code, which is sl@0: * one of the following: sl@0: * sl@0: * TCL_OK Command completed normally; the interpreter's sl@0: * result contains the command's result. sl@0: * TCL_ERROR The command couldn't be completed successfully; sl@0: * the interpreter's result describes what went wrong. sl@0: * TCL_RETURN The command requests that the current procedure sl@0: * return; the interpreter's result contains the sl@0: * procedure's return value. sl@0: * TCL_BREAK The command requests that the innermost loop sl@0: * be exited; the interpreter's result is meaningless. sl@0: * TCL_CONTINUE Go on to the next iteration of the current loop; sl@0: * the interpreter's result is meaningless. sl@0: */ sl@0: #define TCL_OK 0 sl@0: #define TCL_ERROR 1 sl@0: #define TCL_RETURN 2 sl@0: #define TCL_BREAK 3 sl@0: #define TCL_CONTINUE 4 sl@0: sl@0: #define TCL_RESULT_SIZE 200 sl@0: sl@0: /* sl@0: * Flags to control what substitutions are performed by Tcl_SubstObj(): sl@0: */ sl@0: #define TCL_SUBST_COMMANDS 001 sl@0: #define TCL_SUBST_VARIABLES 002 sl@0: #define TCL_SUBST_BACKSLASHES 004 sl@0: #define TCL_SUBST_ALL 007 sl@0: sl@0: sl@0: /* sl@0: * Argument descriptors for math function callbacks in expressions: sl@0: */ sl@0: typedef enum { sl@0: TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT sl@0: } Tcl_ValueType; sl@0: typedef struct Tcl_Value { sl@0: Tcl_ValueType type; /* Indicates intValue or doubleValue is sl@0: * valid, or both. */ sl@0: long intValue; /* Integer value. */ sl@0: double doubleValue; /* Double-precision floating value. */ sl@0: Tcl_WideInt wideValue; /* Wide (min. 64-bit) integer value. */ sl@0: } Tcl_Value; sl@0: sl@0: /* sl@0: * Forward declaration of Tcl_Obj to prevent an error when the forward sl@0: * reference to Tcl_Obj is encountered in the procedure types declared sl@0: * below. sl@0: */ sl@0: struct Tcl_Obj; sl@0: sl@0: sl@0: /* sl@0: * Procedure types defined by Tcl: sl@0: */ sl@0: sl@0: typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); sl@0: typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int code)); sl@0: typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask)); sl@0: typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data)); sl@0: typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int argc, CONST84 char *argv[])); sl@0: typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc, sl@0: ClientData cmdClientData, int argc, CONST84 char *argv[])); sl@0: typedef int (Tcl_CmdObjTraceProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int level, CONST char *command, sl@0: Tcl_Command commandInfo, int objc, struct Tcl_Obj * CONST * objv)); sl@0: typedef void (Tcl_CmdObjTraceDeleteProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, sl@0: struct Tcl_Obj *dupPtr)); sl@0: typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData, sl@0: CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, sl@0: char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, sl@0: int *dstCharsPtr)); sl@0: typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData)); sl@0: typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); sl@0: typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData, sl@0: int flags)); sl@0: typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr, sl@0: ClientData clientData)); sl@0: typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData, sl@0: int flags)); sl@0: typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask)); sl@0: typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); sl@0: typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr)); sl@0: typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp)); sl@0: typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr)); sl@0: typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv)); sl@0: typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); sl@0: typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(CONST char *, format)); sl@0: typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData, sl@0: Tcl_Channel chan, char *address, int port)); sl@0: typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: struct Tcl_Obj *objPtr)); sl@0: typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); sl@0: typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, CONST84 char *part1, CONST84 char *part2, int flags)); sl@0: typedef void (Tcl_CommandTraceProc) _ANSI_ARGS_((ClientData clientData, sl@0: Tcl_Interp *interp, CONST char *oldName, CONST char *newName, sl@0: int flags)); sl@0: typedef void (Tcl_CreateFileHandlerProc) _ANSI_ARGS_((int fd, int mask, sl@0: Tcl_FileProc *proc, ClientData clientData)); sl@0: typedef void (Tcl_DeleteFileHandlerProc) _ANSI_ARGS_((int fd)); sl@0: typedef void (Tcl_AlertNotifierProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef void (Tcl_ServiceModeHookProc) _ANSI_ARGS_((int mode)); sl@0: typedef ClientData (Tcl_InitNotifierProc) _ANSI_ARGS_((VOID)); sl@0: typedef void (Tcl_FinalizeNotifierProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef void (Tcl_MainLoopProc) _ANSI_ARGS_((void)); sl@0: sl@0: sl@0: /* sl@0: * The following structure represents a type of object, which is a sl@0: * particular internal representation for an object plus a set of sl@0: * procedures that provide standard operations on objects of that type. sl@0: */ sl@0: sl@0: typedef struct Tcl_ObjType { sl@0: char *name; /* Name of the type, e.g. "int". */ sl@0: Tcl_FreeInternalRepProc *freeIntRepProc; sl@0: /* Called to free any storage for the type's sl@0: * internal rep. NULL if the internal rep sl@0: * does not need freeing. */ sl@0: Tcl_DupInternalRepProc *dupIntRepProc; sl@0: /* Called to create a new object as a copy sl@0: * of an existing object. */ sl@0: Tcl_UpdateStringProc *updateStringProc; sl@0: /* Called to update the string rep from the sl@0: * type's internal representation. */ sl@0: Tcl_SetFromAnyProc *setFromAnyProc; sl@0: /* Called to convert the object's internal sl@0: * rep to this type. Frees the internal rep sl@0: * of the old type. Returns TCL_ERROR on sl@0: * failure. */ sl@0: } Tcl_ObjType; sl@0: sl@0: sl@0: /* sl@0: * One of the following structures exists for each object in the Tcl sl@0: * system. An object stores a value as either a string, some internal sl@0: * representation, or both. sl@0: */ sl@0: sl@0: typedef struct Tcl_Obj { sl@0: int refCount; /* When 0 the object will be freed. */ sl@0: char *bytes; /* This points to the first byte of the sl@0: * object's string representation. The array sl@0: * must be followed by a null byte (i.e., at sl@0: * offset length) but may also contain sl@0: * embedded null characters. The array's sl@0: * storage is allocated by ckalloc. NULL sl@0: * means the string rep is invalid and must sl@0: * be regenerated from the internal rep. sl@0: * Clients should use Tcl_GetStringFromObj sl@0: * or Tcl_GetString to get a pointer to the sl@0: * byte array as a readonly value. */ sl@0: int length; /* The number of bytes at *bytes, not sl@0: * including the terminating null. */ sl@0: Tcl_ObjType *typePtr; /* Denotes the object's type. Always sl@0: * corresponds to the type of the object's sl@0: * internal rep. NULL indicates the object sl@0: * has no internal rep (has no type). */ sl@0: union { /* The internal representation: */ sl@0: long longValue; /* - an long integer value */ sl@0: double doubleValue; /* - a double-precision floating value */ sl@0: VOID *otherValuePtr; /* - another, type-specific value */ sl@0: Tcl_WideInt wideValue; /* - a long long value */ sl@0: struct { /* - internal rep as two pointers */ sl@0: VOID *ptr1; sl@0: VOID *ptr2; sl@0: } twoPtrValue; sl@0: } internalRep; sl@0: } Tcl_Obj; sl@0: sl@0: sl@0: /* sl@0: * Macros to increment and decrement a Tcl_Obj's reference count, and to sl@0: * test whether an object is shared (i.e. has reference count > 1). sl@0: * Note: clients should use Tcl_DecrRefCount() when they are finished using sl@0: * an object, and should never call TclFreeObj() directly. TclFreeObj() is sl@0: * only defined and made public in tcl.h to support Tcl_DecrRefCount's macro sl@0: * definition. Note also that Tcl_DecrRefCount() refers to the parameter sl@0: * "obj" twice. This means that you should avoid calling it with an sl@0: * expression that is expensive to compute or has side effects. sl@0: */ sl@0: void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); sl@0: void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); sl@0: int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr)); sl@0: sl@0: #ifdef TCL_MEM_DEBUG sl@0: # define Tcl_IncrRefCount(objPtr) \ sl@0: Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__) sl@0: # define Tcl_DecrRefCount(objPtr) \ sl@0: Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__) sl@0: # define Tcl_IsShared(objPtr) \ sl@0: Tcl_DbIsShared(objPtr, __FILE__, __LINE__) sl@0: #else sl@0: # define Tcl_IncrRefCount(objPtr) \ sl@0: ++(objPtr)->refCount sl@0: /* sl@0: * Use empty if ; else to handle use in unbraced outer if/else conditions sl@0: */ sl@0: # define Tcl_DecrRefCount(objPtr) \ sl@0: if (--(objPtr)->refCount > 0) ; else TclFreeObj(objPtr) sl@0: # define Tcl_IsShared(objPtr) \ sl@0: ((objPtr)->refCount > 1) sl@0: #endif sl@0: sl@0: /* sl@0: * Macros and definitions that help to debug the use of Tcl objects. sl@0: * When TCL_MEM_DEBUG is defined, the Tcl_New declarations are sl@0: * overridden to call debugging versions of the object creation procedures. sl@0: */ sl@0: sl@0: #ifdef TCL_MEM_DEBUG sl@0: # define Tcl_NewBooleanObj(val) \ sl@0: Tcl_DbNewBooleanObj(val, __FILE__, __LINE__) sl@0: # define Tcl_NewByteArrayObj(bytes, len) \ sl@0: Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__) sl@0: # define Tcl_NewDoubleObj(val) \ sl@0: Tcl_DbNewDoubleObj(val, __FILE__, __LINE__) sl@0: # define Tcl_NewIntObj(val) \ sl@0: Tcl_DbNewLongObj(val, __FILE__, __LINE__) sl@0: # define Tcl_NewListObj(objc, objv) \ sl@0: Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__) sl@0: # define Tcl_NewLongObj(val) \ sl@0: Tcl_DbNewLongObj(val, __FILE__, __LINE__) sl@0: # define Tcl_NewObj() \ sl@0: Tcl_DbNewObj(__FILE__, __LINE__) sl@0: # define Tcl_NewStringObj(bytes, len) \ sl@0: Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__) sl@0: # define Tcl_NewWideIntObj(val) \ sl@0: Tcl_DbNewWideIntObj(val, __FILE__, __LINE__) sl@0: #endif /* TCL_MEM_DEBUG */ sl@0: sl@0: sl@0: /* sl@0: * The following structure contains the state needed by sl@0: * Tcl_SaveResult. No-one outside of Tcl should access any of these sl@0: * fields. This structure is typically allocated on the stack. sl@0: */ sl@0: typedef struct Tcl_SavedResult { sl@0: char *result; sl@0: Tcl_FreeProc *freeProc; sl@0: Tcl_Obj *objResultPtr; sl@0: char *appendResult; sl@0: int appendAvl; sl@0: int appendUsed; sl@0: char resultSpace[TCL_RESULT_SIZE+1]; sl@0: } Tcl_SavedResult; sl@0: sl@0: sl@0: /* sl@0: * The following definitions support Tcl's namespace facility. sl@0: * Note: the first five fields must match exactly the fields in a sl@0: * Namespace structure (see tclInt.h). sl@0: */ sl@0: sl@0: typedef struct Tcl_Namespace { sl@0: char *name; /* The namespace's name within its parent sl@0: * namespace. This contains no ::'s. The sl@0: * name of the global namespace is "" sl@0: * although "::" is an synonym. */ sl@0: char *fullName; /* The namespace's fully qualified name. sl@0: * This starts with ::. */ sl@0: ClientData clientData; /* Arbitrary value associated with this sl@0: * namespace. */ sl@0: Tcl_NamespaceDeleteProc* deleteProc; sl@0: /* Procedure invoked when deleting the sl@0: * namespace to, e.g., free clientData. */ sl@0: struct Tcl_Namespace* parentPtr; sl@0: /* Points to the namespace that contains sl@0: * this one. NULL if this is the global sl@0: * namespace. */ sl@0: } Tcl_Namespace; sl@0: sl@0: sl@0: /* sl@0: * The following structure represents a call frame, or activation record. sl@0: * A call frame defines a naming context for a procedure call: its local sl@0: * scope (for local variables) and its namespace scope (used for non-local sl@0: * variables; often the global :: namespace). A call frame can also define sl@0: * the naming context for a namespace eval or namespace inscope command: sl@0: * the namespace in which the command's code should execute. The sl@0: * Tcl_CallFrame structures exist only while procedures or namespace sl@0: * eval/inscope's are being executed, and provide a Tcl call stack. sl@0: * sl@0: * A call frame is initialized and pushed using Tcl_PushCallFrame and sl@0: * popped using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be sl@0: * provided by the Tcl_PushCallFrame caller, and callers typically allocate sl@0: * them on the C call stack for efficiency. For this reason, Tcl_CallFrame sl@0: * is defined as a structure and not as an opaque token. However, most sl@0: * Tcl_CallFrame fields are hidden since applications should not access sl@0: * them directly; others are declared as "dummyX". sl@0: * sl@0: * WARNING!! The structure definition must be kept consistent with the sl@0: * CallFrame structure in tclInt.h. If you change one, change the other. sl@0: */ sl@0: sl@0: typedef struct Tcl_CallFrame { sl@0: Tcl_Namespace *nsPtr; sl@0: int dummy1; sl@0: int dummy2; sl@0: char *dummy3; sl@0: char *dummy4; sl@0: char *dummy5; sl@0: int dummy6; sl@0: char *dummy7; sl@0: char *dummy8; sl@0: int dummy9; sl@0: char* dummy10; sl@0: } Tcl_CallFrame; sl@0: sl@0: sl@0: /* sl@0: * Information about commands that is returned by Tcl_GetCommandInfo and sl@0: * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based sl@0: * command procedure while proc is a traditional Tcl argc/argv sl@0: * string-based procedure. Tcl_CreateObjCommand and Tcl_CreateCommand sl@0: * ensure that both objProc and proc are non-NULL and can be called to sl@0: * execute the command. However, it may be faster to call one instead of sl@0: * the other. The member isNativeObjectProc is set to 1 if an sl@0: * object-based procedure was registered by Tcl_CreateObjCommand, and to sl@0: * 0 if a string-based procedure was registered by Tcl_CreateCommand. sl@0: * The other procedure is typically set to a compatibility wrapper that sl@0: * does string-to-object or object-to-string argument conversions then sl@0: * calls the other procedure. sl@0: */ sl@0: sl@0: typedef struct Tcl_CmdInfo { sl@0: int isNativeObjectProc; /* 1 if objProc was registered by a call to sl@0: * Tcl_CreateObjCommand; 0 otherwise. sl@0: * Tcl_SetCmdInfo does not modify this sl@0: * field. */ sl@0: Tcl_ObjCmdProc *objProc; /* Command's object-based procedure. */ sl@0: ClientData objClientData; /* ClientData for object proc. */ sl@0: Tcl_CmdProc *proc; /* Command's string-based procedure. */ sl@0: ClientData clientData; /* ClientData for string proc. */ sl@0: Tcl_CmdDeleteProc *deleteProc; sl@0: /* Procedure to call when command is sl@0: * deleted. */ sl@0: ClientData deleteData; /* Value to pass to deleteProc (usually sl@0: * the same as clientData). */ sl@0: Tcl_Namespace *namespacePtr; /* Points to the namespace that contains sl@0: * this command. Note that Tcl_SetCmdInfo sl@0: * will not change a command's namespace; sl@0: * use Tcl_RenameCommand to do that. */ sl@0: sl@0: } Tcl_CmdInfo; sl@0: sl@0: /* sl@0: * The structure defined below is used to hold dynamic strings. The only sl@0: * field that clients should use is the string field, accessible via the sl@0: * macro Tcl_DStringValue. sl@0: */ sl@0: #define TCL_DSTRING_STATIC_SIZE 200 sl@0: typedef struct Tcl_DString { sl@0: char *string; /* Points to beginning of string: either sl@0: * staticSpace below or a malloced array. */ sl@0: int length; /* Number of non-NULL characters in the sl@0: * string. */ sl@0: int spaceAvl; /* Total number of bytes available for the sl@0: * string and its terminating NULL char. */ sl@0: char staticSpace[TCL_DSTRING_STATIC_SIZE]; sl@0: /* Space to use in common case where string sl@0: * is small. */ sl@0: } Tcl_DString; sl@0: sl@0: #define Tcl_DStringLength(dsPtr) ((dsPtr)->length) sl@0: #define Tcl_DStringValue(dsPtr) ((dsPtr)->string) sl@0: #define Tcl_DStringTrunc Tcl_DStringSetLength sl@0: sl@0: /* sl@0: * Definitions for the maximum number of digits of precision that may sl@0: * be specified in the "tcl_precision" variable, and the number of sl@0: * bytes of buffer space required by Tcl_PrintDouble. sl@0: */ sl@0: #define TCL_MAX_PREC 17 sl@0: #define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10) sl@0: sl@0: /* sl@0: * Definition for a number of bytes of buffer space sufficient to hold the sl@0: * string representation of an integer in base 10 (assuming the existence sl@0: * of 64-bit integers). sl@0: */ sl@0: #define TCL_INTEGER_SPACE 24 sl@0: sl@0: /* sl@0: * Flag that may be passed to Tcl_ConvertElement to force it not to sl@0: * output braces (careful! if you change this flag be sure to change sl@0: * the definitions at the front of tclUtil.c). sl@0: */ sl@0: #define TCL_DONT_USE_BRACES 1 sl@0: sl@0: /* sl@0: * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow sl@0: * abbreviated strings. sl@0: */ sl@0: #define TCL_EXACT 1 sl@0: sl@0: /* sl@0: * Flag values passed to Tcl_RecordAndEval and/or Tcl_EvalObj. sl@0: * WARNING: these bit choices must not conflict with the bit choices sl@0: * for evalFlag bits in tclInt.h!! sl@0: */ sl@0: #define TCL_NO_EVAL 0x10000 sl@0: #define TCL_EVAL_GLOBAL 0x20000 sl@0: #define TCL_EVAL_DIRECT 0x40000 sl@0: #define TCL_EVAL_INVOKE 0x80000 sl@0: sl@0: /* sl@0: * Special freeProc values that may be passed to Tcl_SetResult (see sl@0: * the man page for details): sl@0: */ sl@0: #define TCL_VOLATILE ((Tcl_FreeProc *) 1) sl@0: #define TCL_STATIC ((Tcl_FreeProc *) 0) sl@0: #define TCL_DYNAMIC ((Tcl_FreeProc *) 3) sl@0: sl@0: /* sl@0: * Flag values passed to variable-related procedures. sl@0: */ sl@0: #define TCL_GLOBAL_ONLY 1 sl@0: #define TCL_NAMESPACE_ONLY 2 sl@0: #define TCL_APPEND_VALUE 4 sl@0: #define TCL_LIST_ELEMENT 8 sl@0: #define TCL_TRACE_READS 0x10 sl@0: #define TCL_TRACE_WRITES 0x20 sl@0: #define TCL_TRACE_UNSETS 0x40 sl@0: #define TCL_TRACE_DESTROYED 0x80 sl@0: #define TCL_INTERP_DESTROYED 0x100 sl@0: #define TCL_LEAVE_ERR_MSG 0x200 sl@0: #define TCL_TRACE_ARRAY 0x800 sl@0: #ifndef TCL_REMOVE_OBSOLETE_TRACES sl@0: /* Required to support old variable/vdelete/vinfo traces */ sl@0: #define TCL_TRACE_OLD_STYLE 0x1000 sl@0: #endif sl@0: /* Indicate the semantics of the result of a trace */ sl@0: #define TCL_TRACE_RESULT_DYNAMIC 0x8000 sl@0: #define TCL_TRACE_RESULT_OBJECT 0x10000 sl@0: sl@0: /* sl@0: * Flag values passed to command-related procedures. sl@0: */ sl@0: sl@0: #define TCL_TRACE_RENAME 0x2000 sl@0: #define TCL_TRACE_DELETE 0x4000 sl@0: sl@0: #define TCL_ALLOW_INLINE_COMPILATION 0x20000 sl@0: sl@0: /* sl@0: * Flag values passed to Tcl_CreateObjTrace, and used internally sl@0: * by command execution traces. Slots 4,8,16 and 32 are sl@0: * used internally by execution traces (see tclCmdMZ.c) sl@0: */ sl@0: #define TCL_TRACE_ENTER_EXEC 1 sl@0: #define TCL_TRACE_LEAVE_EXEC 2 sl@0: sl@0: /* sl@0: * The TCL_PARSE_PART1 flag is deprecated and has no effect. sl@0: * The part1 is now always parsed whenever the part2 is NULL. sl@0: * (This is to avoid a common error when converting code to sl@0: * use the new object based APIs and forgetting to give the sl@0: * flag) sl@0: */ sl@0: #ifndef TCL_NO_DEPRECATED sl@0: # define TCL_PARSE_PART1 0x400 sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Types for linked variables: sl@0: */ sl@0: #define TCL_LINK_INT 1 sl@0: #define TCL_LINK_DOUBLE 2 sl@0: #define TCL_LINK_BOOLEAN 3 sl@0: #define TCL_LINK_STRING 4 sl@0: #define TCL_LINK_WIDE_INT 5 sl@0: #define TCL_LINK_READ_ONLY 0x80 sl@0: sl@0: sl@0: /* sl@0: * Forward declarations of Tcl_HashTable and related types. sl@0: */ sl@0: typedef struct Tcl_HashKeyType Tcl_HashKeyType; sl@0: typedef struct Tcl_HashTable Tcl_HashTable; sl@0: typedef struct Tcl_HashEntry Tcl_HashEntry; sl@0: sl@0: typedef unsigned int (Tcl_HashKeyProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, sl@0: VOID *keyPtr)); sl@0: typedef int (Tcl_CompareHashKeysProc) _ANSI_ARGS_((VOID *keyPtr, sl@0: Tcl_HashEntry *hPtr)); sl@0: typedef Tcl_HashEntry *(Tcl_AllocHashEntryProc) _ANSI_ARGS_(( sl@0: Tcl_HashTable *tablePtr, VOID *keyPtr)); sl@0: typedef void (Tcl_FreeHashEntryProc) _ANSI_ARGS_((Tcl_HashEntry *hPtr)); sl@0: sl@0: /* sl@0: * This flag controls whether the hash table stores the hash of a key, or sl@0: * recalculates it. There should be no reason for turning this flag off sl@0: * as it is completely binary and source compatible unless you directly sl@0: * access the bucketPtr member of the Tcl_HashTableEntry structure. This sl@0: * member has been removed and the space used to store the hash value. sl@0: */ sl@0: #ifndef TCL_HASH_KEY_STORE_HASH sl@0: # define TCL_HASH_KEY_STORE_HASH 1 sl@0: #endif sl@0: sl@0: /* sl@0: * Structure definition for an entry in a hash table. No-one outside sl@0: * Tcl should access any of these fields directly; use the macros sl@0: * defined below. sl@0: */ sl@0: sl@0: struct Tcl_HashEntry { sl@0: Tcl_HashEntry *nextPtr; /* Pointer to next entry in this sl@0: * hash bucket, or NULL for end of sl@0: * chain. */ sl@0: Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ sl@0: #if TCL_HASH_KEY_STORE_HASH sl@0: # if TCL_PRESERVE_BINARY_COMPATABILITY sl@0: VOID *hash; /* Hash value, stored as pointer to sl@0: * ensure that the offsets of the sl@0: * fields in this structure are not sl@0: * changed. */ sl@0: # else sl@0: unsigned int hash; /* Hash value. */ sl@0: # endif sl@0: #else sl@0: Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to sl@0: * first entry in this entry's chain: sl@0: * used for deleting the entry. */ sl@0: #endif sl@0: ClientData clientData; /* Application stores something here sl@0: * with Tcl_SetHashValue. */ sl@0: union { /* Key has one of these forms: */ sl@0: char *oneWordValue; /* One-word value for key. */ sl@0: Tcl_Obj *objPtr; /* Tcl_Obj * key value. */ sl@0: int words[1]; /* Multiple integer words for key. sl@0: * The actual size will be as large sl@0: * as necessary for this table's sl@0: * keys. */ sl@0: char string[4]; /* String for key. The actual size sl@0: * will be as large as needed to hold sl@0: * the key. */ sl@0: } key; /* MUST BE LAST FIELD IN RECORD!! */ sl@0: }; sl@0: sl@0: /* sl@0: * Flags used in Tcl_HashKeyType. sl@0: * sl@0: * TCL_HASH_KEY_RANDOMIZE_HASH: sl@0: * There are some things, pointers for example sl@0: * which don't hash well because they do not use sl@0: * the lower bits. If this flag is set then the sl@0: * hash table will attempt to rectify this by sl@0: * randomising the bits and then using the upper sl@0: * N bits as the index into the table. sl@0: */ sl@0: #define TCL_HASH_KEY_RANDOMIZE_HASH 0x1 sl@0: sl@0: /* sl@0: * Structure definition for the methods associated with a hash table sl@0: * key type. sl@0: */ sl@0: #define TCL_HASH_KEY_TYPE_VERSION 1 sl@0: struct Tcl_HashKeyType { sl@0: int version; /* Version of the table. If this structure is sl@0: * extended in future then the version can be sl@0: * used to distinguish between different sl@0: * structures. sl@0: */ sl@0: sl@0: int flags; /* Flags, see above for details. */ sl@0: sl@0: /* Calculates a hash value for the key. If this is NULL then the pointer sl@0: * itself is used as a hash value. sl@0: */ sl@0: Tcl_HashKeyProc *hashKeyProc; sl@0: sl@0: /* Compares two keys and returns zero if they do not match, and non-zero sl@0: * if they do. If this is NULL then the pointers are compared. sl@0: */ sl@0: Tcl_CompareHashKeysProc *compareKeysProc; sl@0: sl@0: /* Called to allocate memory for a new entry, i.e. if the key is a sl@0: * string then this could allocate a single block which contains enough sl@0: * space for both the entry and the string. Only the key field of the sl@0: * allocated Tcl_HashEntry structure needs to be filled in. If something sl@0: * else needs to be done to the key, i.e. incrementing a reference count sl@0: * then that should be done by this function. If this is NULL then Tcl_Alloc sl@0: * is used to allocate enough space for a Tcl_HashEntry and the key pointer sl@0: * is assigned to key.oneWordValue. sl@0: */ sl@0: Tcl_AllocHashEntryProc *allocEntryProc; sl@0: sl@0: /* Called to free memory associated with an entry. If something else needs sl@0: * to be done to the key, i.e. decrementing a reference count then that sl@0: * should be done by this function. If this is NULL then Tcl_Free is used sl@0: * to free the Tcl_HashEntry. sl@0: */ sl@0: Tcl_FreeHashEntryProc *freeEntryProc; sl@0: }; sl@0: sl@0: /* sl@0: * Structure definition for a hash table. Must be in tcl.h so clients sl@0: * can allocate space for these structures, but clients should never sl@0: * access any fields in this structure. sl@0: */ sl@0: sl@0: #define TCL_SMALL_HASH_TABLE 4 sl@0: struct Tcl_HashTable { sl@0: Tcl_HashEntry **buckets; /* Pointer to bucket array. Each sl@0: * element points to first entry in sl@0: * bucket's hash chain, or NULL. */ sl@0: Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; sl@0: /* Bucket array used for small tables sl@0: * (to avoid mallocs and frees). */ sl@0: int numBuckets; /* Total number of buckets allocated sl@0: * at **bucketPtr. */ sl@0: int numEntries; /* Total number of entries present sl@0: * in table. */ sl@0: int rebuildSize; /* Enlarge table when numEntries gets sl@0: * to be this large. */ sl@0: int downShift; /* Shift count used in hashing sl@0: * function. Designed to use high- sl@0: * order bits of randomized keys. */ sl@0: int mask; /* Mask value used in hashing sl@0: * function. */ sl@0: int keyType; /* Type of keys used in this table. sl@0: * It's either TCL_CUSTOM_KEYS, sl@0: * TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, sl@0: * or an integer giving the number of sl@0: * ints that is the size of the key. sl@0: */ sl@0: #if TCL_PRESERVE_BINARY_COMPATABILITY sl@0: Tcl_HashEntry *(*findProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, sl@0: CONST char *key)); sl@0: Tcl_HashEntry *(*createProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, sl@0: CONST char *key, int *newPtr)); sl@0: #endif sl@0: Tcl_HashKeyType *typePtr; /* Type of the keys used in the sl@0: * Tcl_HashTable. */ sl@0: }; sl@0: sl@0: /* sl@0: * Structure definition for information used to keep track of searches sl@0: * through hash tables: sl@0: */ sl@0: sl@0: typedef struct Tcl_HashSearch { sl@0: Tcl_HashTable *tablePtr; /* Table being searched. */ sl@0: int nextIndex; /* Index of next bucket to be sl@0: * enumerated after present one. */ sl@0: Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the sl@0: * the current bucket. */ sl@0: } Tcl_HashSearch; sl@0: sl@0: /* sl@0: * Acceptable key types for hash tables: sl@0: * sl@0: * TCL_STRING_KEYS: The keys are strings, they are copied into sl@0: * the entry. sl@0: * TCL_ONE_WORD_KEYS: The keys are pointers, the pointer is stored sl@0: * in the entry. sl@0: * TCL_CUSTOM_TYPE_KEYS: The keys are arbitrary types which are copied sl@0: * into the entry. sl@0: * TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the sl@0: * pointer is stored in the entry. sl@0: * sl@0: * While maintaining binary compatability the above have to be distinct sl@0: * values as they are used to differentiate between old versions of the sl@0: * hash table which don't have a typePtr and new ones which do. Once binary sl@0: * compatability is discarded in favour of making more wide spread changes sl@0: * TCL_STRING_KEYS can be the same as TCL_CUSTOM_TYPE_KEYS, and sl@0: * TCL_ONE_WORD_KEYS can be the same as TCL_CUSTOM_PTR_KEYS because they sl@0: * simply determine how the key is accessed from the entry and not the sl@0: * behaviour. sl@0: */ sl@0: sl@0: #define TCL_STRING_KEYS 0 sl@0: #define TCL_ONE_WORD_KEYS 1 sl@0: sl@0: #if TCL_PRESERVE_BINARY_COMPATABILITY sl@0: # define TCL_CUSTOM_TYPE_KEYS -2 sl@0: # define TCL_CUSTOM_PTR_KEYS -1 sl@0: #else sl@0: # define TCL_CUSTOM_TYPE_KEYS TCL_STRING_KEYS sl@0: # define TCL_CUSTOM_PTR_KEYS TCL_ONE_WORD_KEYS sl@0: #endif sl@0: sl@0: /* sl@0: * Macros for clients to use to access fields of hash entries: sl@0: */ sl@0: sl@0: #define Tcl_GetHashValue(h) ((h)->clientData) sl@0: #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value)) sl@0: #if TCL_PRESERVE_BINARY_COMPATABILITY sl@0: # define Tcl_GetHashKey(tablePtr, h) \ sl@0: ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \ sl@0: (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \ sl@0: ? (h)->key.oneWordValue \ sl@0: : (h)->key.string)) sl@0: #else sl@0: # define Tcl_GetHashKey(tablePtr, h) \ sl@0: ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) \ sl@0: ? (h)->key.oneWordValue \ sl@0: : (h)->key.string)) sl@0: #endif sl@0: sl@0: /* sl@0: * Macros to use for clients to use to invoke find and create procedures sl@0: * for hash tables: sl@0: */ sl@0: sl@0: #if TCL_PRESERVE_BINARY_COMPATABILITY sl@0: # define Tcl_FindHashEntry(tablePtr, key) \ sl@0: (*((tablePtr)->findProc))(tablePtr, key) sl@0: # define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ sl@0: (*((tablePtr)->createProc))(tablePtr, key, newPtr) sl@0: #else /* !TCL_PRESERVE_BINARY_COMPATABILITY */ sl@0: /* sl@0: * Macro to use new extended version of Tcl_InitHashTable. sl@0: */ sl@0: # define Tcl_InitHashTable(tablePtr, keyType) \ sl@0: Tcl_InitHashTableEx(tablePtr, keyType, NULL) sl@0: #endif /* TCL_PRESERVE_BINARY_COMPATABILITY */ sl@0: sl@0: sl@0: /* sl@0: * Flag values to pass to Tcl_DoOneEvent to disable searches sl@0: * for some kinds of events: sl@0: */ sl@0: #define TCL_DONT_WAIT (1<<1) sl@0: #define TCL_WINDOW_EVENTS (1<<2) sl@0: #define TCL_FILE_EVENTS (1<<3) sl@0: #define TCL_TIMER_EVENTS (1<<4) sl@0: #define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */ sl@0: #define TCL_ALL_EVENTS (~TCL_DONT_WAIT) sl@0: sl@0: /* sl@0: * The following structure defines a generic event for the Tcl event sl@0: * system. These are the things that are queued in calls to Tcl_QueueEvent sl@0: * and serviced later by Tcl_DoOneEvent. There can be many different sl@0: * kinds of events with different fields, corresponding to window events, sl@0: * timer events, etc. The structure for a particular event consists of sl@0: * a Tcl_Event header followed by additional information specific to that sl@0: * event. sl@0: */ sl@0: struct Tcl_Event { sl@0: Tcl_EventProc *proc; /* Procedure to call to service this event. */ sl@0: struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */ sl@0: }; sl@0: sl@0: /* sl@0: * Positions to pass to Tcl_QueueEvent: sl@0: */ sl@0: typedef enum { sl@0: TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK sl@0: } Tcl_QueuePosition; sl@0: sl@0: /* sl@0: * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier sl@0: * event routines. sl@0: */ sl@0: #define TCL_SERVICE_NONE 0 sl@0: #define TCL_SERVICE_ALL 1 sl@0: sl@0: sl@0: /* sl@0: * The following structure keeps is used to hold a time value, either as sl@0: * an absolute time (the number of seconds from the epoch) or as an sl@0: * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT. sl@0: * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT. sl@0: */ sl@0: typedef struct Tcl_Time { sl@0: long sec; /* Seconds. */ sl@0: long usec; /* Microseconds. */ sl@0: } Tcl_Time; sl@0: sl@0: typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr)); sl@0: typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr)); sl@0: sl@0: sl@0: /* sl@0: * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler sl@0: * to indicate what sorts of events are of interest: sl@0: */ sl@0: #define TCL_READABLE (1<<1) sl@0: #define TCL_WRITABLE (1<<2) sl@0: #define TCL_EXCEPTION (1<<3) sl@0: sl@0: /* sl@0: * Flag values to pass to Tcl_OpenCommandChannel to indicate the sl@0: * disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, sl@0: * are also used in Tcl_GetStdChannel. sl@0: */ sl@0: #define TCL_STDIN (1<<1) sl@0: #define TCL_STDOUT (1<<2) sl@0: #define TCL_STDERR (1<<3) sl@0: #define TCL_ENFORCE_MODE (1<<4) sl@0: sl@0: /* sl@0: * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel sl@0: * should be closed. sl@0: */ sl@0: #define TCL_CLOSE_READ (1<<1) sl@0: #define TCL_CLOSE_WRITE (1<<2) sl@0: sl@0: /* sl@0: * Value to use as the closeProc for a channel that supports the sl@0: * close2Proc interface. sl@0: */ sl@0: #define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1) sl@0: sl@0: /* sl@0: * Channel version tag. This was introduced in 8.3.2/8.4. sl@0: */ sl@0: #define TCL_CHANNEL_VERSION_1 ((Tcl_ChannelTypeVersion) 0x1) sl@0: #define TCL_CHANNEL_VERSION_2 ((Tcl_ChannelTypeVersion) 0x2) sl@0: #define TCL_CHANNEL_VERSION_3 ((Tcl_ChannelTypeVersion) 0x3) sl@0: #define TCL_CHANNEL_VERSION_4 ((Tcl_ChannelTypeVersion) 0x4) sl@0: sl@0: /* sl@0: * TIP #218: Channel Actions, Ids for Tcl_DriverThreadActionProc sl@0: */ sl@0: sl@0: #define TCL_CHANNEL_THREAD_INSERT (0) sl@0: #define TCL_CHANNEL_THREAD_REMOVE (1) sl@0: sl@0: /* sl@0: * Typedefs for the various operations in a channel type: sl@0: */ sl@0: typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_(( sl@0: ClientData instanceData, int mode)); sl@0: typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData, sl@0: Tcl_Interp *interp)); sl@0: typedef int (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData, sl@0: Tcl_Interp *interp, int flags)); sl@0: typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData, sl@0: char *buf, int toRead, int *errorCodePtr)); sl@0: typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData, sl@0: CONST84 char *buf, int toWrite, int *errorCodePtr)); sl@0: typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData, sl@0: long offset, int mode, int *errorCodePtr)); sl@0: typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_(( sl@0: ClientData instanceData, Tcl_Interp *interp, sl@0: CONST char *optionName, CONST char *value)); sl@0: typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_(( sl@0: ClientData instanceData, Tcl_Interp *interp, sl@0: CONST84 char *optionName, Tcl_DString *dsPtr)); sl@0: typedef void (Tcl_DriverWatchProc) _ANSI_ARGS_(( sl@0: ClientData instanceData, int mask)); sl@0: typedef int (Tcl_DriverGetHandleProc) _ANSI_ARGS_(( sl@0: ClientData instanceData, int direction, sl@0: ClientData *handlePtr)); sl@0: typedef int (Tcl_DriverFlushProc) _ANSI_ARGS_(( sl@0: ClientData instanceData)); sl@0: typedef int (Tcl_DriverHandlerProc) _ANSI_ARGS_(( sl@0: ClientData instanceData, int interestMask)); sl@0: typedef Tcl_WideInt (Tcl_DriverWideSeekProc) _ANSI_ARGS_(( sl@0: ClientData instanceData, Tcl_WideInt offset, sl@0: int mode, int *errorCodePtr)); sl@0: sl@0: /* TIP #218, Channel Thread Actions */ sl@0: typedef void (Tcl_DriverThreadActionProc) _ANSI_ARGS_ (( sl@0: ClientData instanceData, int action)); sl@0: sl@0: /* sl@0: * The following declarations either map ckalloc and ckfree to sl@0: * malloc and free, or they map them to procedures with all sorts sl@0: * of debugging hooks defined in tclCkalloc.c. sl@0: */ sl@0: #ifdef TCL_MEM_DEBUG sl@0: sl@0: # define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__) sl@0: # define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__) sl@0: # define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__) sl@0: # define attemptckalloc(x) Tcl_AttemptDbCkalloc(x, __FILE__, __LINE__) sl@0: # define attemptckrealloc(x,y) Tcl_AttemptDbCkrealloc((x), (y), __FILE__, __LINE__) sl@0: #else /* !TCL_MEM_DEBUG */ sl@0: sl@0: /* sl@0: * If we are not using the debugging allocator, we should call the sl@0: * Tcl_Alloc, et al. routines in order to guarantee that every module sl@0: * is using the same memory allocator both inside and outside of the sl@0: * Tcl library. sl@0: */ sl@0: # define ckalloc(x) Tcl_Alloc(x) sl@0: # define ckfree(x) Tcl_Free(x) sl@0: # define ckrealloc(x,y) Tcl_Realloc(x,y) sl@0: # define attemptckalloc(x) Tcl_AttemptAlloc(x) sl@0: # define attemptckrealloc(x,y) Tcl_AttemptRealloc(x,y) sl@0: # define Tcl_InitMemory(x) sl@0: # define Tcl_DumpActiveMemory(x) sl@0: # define Tcl_ValidateAllMemory(x,y) sl@0: sl@0: #endif /* !TCL_MEM_DEBUG */ sl@0: sl@0: /* sl@0: * struct Tcl_ChannelType: sl@0: * sl@0: * One such structure exists for each type (kind) of channel. sl@0: * It collects together in one place all the functions that are sl@0: * part of the specific channel type. sl@0: * sl@0: * It is recommend that the Tcl_Channel* functions are used to access sl@0: * elements of this structure, instead of direct accessing. sl@0: */ sl@0: typedef struct Tcl_ChannelType { sl@0: char *typeName; /* The name of the channel type in Tcl sl@0: * commands. This storage is owned by sl@0: * channel type. */ sl@0: Tcl_ChannelTypeVersion version; /* Version of the channel type. */ sl@0: Tcl_DriverCloseProc *closeProc; /* Procedure to call to close the sl@0: * channel, or TCL_CLOSE2PROC if the sl@0: * close2Proc should be used sl@0: * instead. */ sl@0: Tcl_DriverInputProc *inputProc; /* Procedure to call for input sl@0: * on channel. */ sl@0: Tcl_DriverOutputProc *outputProc; /* Procedure to call for output sl@0: * on channel. */ sl@0: Tcl_DriverSeekProc *seekProc; /* Procedure to call to seek sl@0: * on the channel. May be NULL. */ sl@0: Tcl_DriverSetOptionProc *setOptionProc; sl@0: /* Set an option on a channel. */ sl@0: Tcl_DriverGetOptionProc *getOptionProc; sl@0: /* Get an option from a channel. */ sl@0: Tcl_DriverWatchProc *watchProc; /* Set up the notifier to watch sl@0: * for events on this channel. */ sl@0: Tcl_DriverGetHandleProc *getHandleProc; sl@0: /* Get an OS handle from the channel sl@0: * or NULL if not supported. */ sl@0: Tcl_DriverClose2Proc *close2Proc; /* Procedure to call to close the sl@0: * channel if the device supports sl@0: * closing the read & write sides sl@0: * independently. */ sl@0: Tcl_DriverBlockModeProc *blockModeProc; sl@0: /* Set blocking mode for the sl@0: * raw channel. May be NULL. */ sl@0: /* sl@0: * Only valid in TCL_CHANNEL_VERSION_2 channels or later sl@0: */ sl@0: Tcl_DriverFlushProc *flushProc; /* Procedure to call to flush a sl@0: * channel. May be NULL. */ sl@0: Tcl_DriverHandlerProc *handlerProc; /* Procedure to call to handle a sl@0: * channel event. This will be passed sl@0: * up the stacked channel chain. */ sl@0: /* sl@0: * Only valid in TCL_CHANNEL_VERSION_3 channels or later sl@0: */ sl@0: Tcl_DriverWideSeekProc *wideSeekProc; sl@0: /* Procedure to call to seek sl@0: * on the channel which can sl@0: * handle 64-bit offsets. May be sl@0: * NULL, and must be NULL if sl@0: * seekProc is NULL. */ sl@0: sl@0: /* sl@0: * Only valid in TCL_CHANNEL_VERSION_4 channels or later sl@0: * TIP #218, Channel Thread Actions sl@0: */ sl@0: Tcl_DriverThreadActionProc *threadActionProc; sl@0: /* Procedure to call to notify sl@0: * the driver of thread specific sl@0: * activity for a channel. sl@0: * May be NULL. */ sl@0: } Tcl_ChannelType; sl@0: sl@0: /* sl@0: * The following flags determine whether the blockModeProc above should sl@0: * set the channel into blocking or nonblocking mode. They are passed sl@0: * as arguments to the blockModeProc procedure in the above structure. sl@0: */ sl@0: #define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */ sl@0: #define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking sl@0: * mode. */ sl@0: sl@0: /* sl@0: * Enum for different types of file paths. sl@0: */ sl@0: typedef enum Tcl_PathType { sl@0: TCL_PATH_ABSOLUTE, sl@0: TCL_PATH_RELATIVE, sl@0: TCL_PATH_VOLUME_RELATIVE sl@0: } Tcl_PathType; sl@0: sl@0: sl@0: /* sl@0: * The following structure is used to pass glob type data amongst sl@0: * the various glob routines and Tcl_FSMatchInDirectory. sl@0: */ sl@0: typedef struct Tcl_GlobTypeData { sl@0: /* Corresponds to bcdpfls as in 'find -t' */ sl@0: int type; sl@0: /* Corresponds to file permissions */ sl@0: int perm; sl@0: /* Acceptable mac type */ sl@0: Tcl_Obj* macType; sl@0: /* Acceptable mac creator */ sl@0: Tcl_Obj* macCreator; sl@0: } Tcl_GlobTypeData; sl@0: sl@0: /* sl@0: * type and permission definitions for glob command sl@0: */ sl@0: #define TCL_GLOB_TYPE_BLOCK (1<<0) sl@0: #define TCL_GLOB_TYPE_CHAR (1<<1) sl@0: #define TCL_GLOB_TYPE_DIR (1<<2) sl@0: #define TCL_GLOB_TYPE_PIPE (1<<3) sl@0: #define TCL_GLOB_TYPE_FILE (1<<4) sl@0: #define TCL_GLOB_TYPE_LINK (1<<5) sl@0: #define TCL_GLOB_TYPE_SOCK (1<<6) sl@0: #define TCL_GLOB_TYPE_MOUNT (1<<7) sl@0: sl@0: #define TCL_GLOB_PERM_RONLY (1<<0) sl@0: #define TCL_GLOB_PERM_HIDDEN (1<<1) sl@0: #define TCL_GLOB_PERM_R (1<<2) sl@0: #define TCL_GLOB_PERM_W (1<<3) sl@0: #define TCL_GLOB_PERM_X (1<<4) sl@0: sl@0: sl@0: /* sl@0: * Typedefs for the various filesystem operations: sl@0: */ sl@0: typedef int (Tcl_FSStatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf)); sl@0: typedef int (Tcl_FSAccessProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, int mode)); sl@0: typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) sl@0: _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *pathPtr, sl@0: int mode, int permissions)); sl@0: typedef int (Tcl_FSMatchInDirectoryProc) _ANSI_ARGS_((Tcl_Interp* interp, sl@0: Tcl_Obj *result, Tcl_Obj *pathPtr, CONST char *pattern, sl@0: Tcl_GlobTypeData * types)); sl@0: typedef Tcl_Obj* (Tcl_FSGetCwdProc) _ANSI_ARGS_((Tcl_Interp *interp)); sl@0: typedef int (Tcl_FSChdirProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: typedef int (Tcl_FSLstatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: Tcl_StatBuf *buf)); sl@0: typedef int (Tcl_FSCreateDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: typedef int (Tcl_FSDeleteFileProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: typedef int (Tcl_FSCopyDirectoryProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, sl@0: Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr)); sl@0: typedef int (Tcl_FSCopyFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, sl@0: Tcl_Obj *destPathPtr)); sl@0: typedef int (Tcl_FSRemoveDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: int recursive, Tcl_Obj **errorPtr)); sl@0: typedef int (Tcl_FSRenameFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, sl@0: Tcl_Obj *destPathPtr)); sl@0: typedef void (Tcl_FSUnloadFileProc) _ANSI_ARGS_((Tcl_LoadHandle loadHandle)); sl@0: typedef Tcl_Obj* (Tcl_FSListVolumesProc) _ANSI_ARGS_((void)); sl@0: /* We have to declare the utime structure here. */ sl@0: struct utimbuf; sl@0: typedef int (Tcl_FSUtimeProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: struct utimbuf *tval)); sl@0: typedef int (Tcl_FSNormalizePathProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: Tcl_Obj *pathPtr, int nextCheckpoint)); sl@0: typedef int (Tcl_FSFileAttrsGetProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int index, Tcl_Obj *pathPtr, sl@0: Tcl_Obj **objPtrRef)); sl@0: typedef CONST char** (Tcl_FSFileAttrStringsProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: Tcl_Obj** objPtrRef)); sl@0: typedef int (Tcl_FSFileAttrsSetProc) _ANSI_ARGS_((Tcl_Interp *interp, sl@0: int index, Tcl_Obj *pathPtr, sl@0: Tcl_Obj *objPtr)); sl@0: typedef Tcl_Obj* (Tcl_FSLinkProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: Tcl_Obj *toPtr, int linkType)); sl@0: typedef int (Tcl_FSLoadFileProc) _ANSI_ARGS_((Tcl_Interp * interp, sl@0: Tcl_Obj *pathPtr, sl@0: Tcl_LoadHandle *handlePtr, sl@0: Tcl_FSUnloadFileProc **unloadProcPtr)); sl@0: typedef int (Tcl_FSPathInFilesystemProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, sl@0: ClientData *clientDataPtr)); sl@0: typedef Tcl_Obj* (Tcl_FSFilesystemPathTypeProc) sl@0: _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: typedef Tcl_Obj* (Tcl_FSFilesystemSeparatorProc) sl@0: _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: typedef void (Tcl_FSFreeInternalRepProc) _ANSI_ARGS_((ClientData clientData)); sl@0: typedef ClientData (Tcl_FSDupInternalRepProc) sl@0: _ANSI_ARGS_((ClientData clientData)); sl@0: typedef Tcl_Obj* (Tcl_FSInternalToNormalizedProc) sl@0: _ANSI_ARGS_((ClientData clientData)); sl@0: typedef ClientData (Tcl_FSCreateInternalRepProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); sl@0: sl@0: typedef struct Tcl_FSVersion_ *Tcl_FSVersion; sl@0: sl@0: /* sl@0: *---------------------------------------------------------------- sl@0: * Data structures related to hooking into the filesystem sl@0: *---------------------------------------------------------------- sl@0: */ sl@0: sl@0: /* sl@0: * Filesystem version tag. This was introduced in 8.4. sl@0: */ sl@0: #define TCL_FILESYSTEM_VERSION_1 ((Tcl_FSVersion) 0x1) sl@0: sl@0: /* sl@0: * struct Tcl_Filesystem: sl@0: * sl@0: * One such structure exists for each type (kind) of filesystem. sl@0: * It collects together in one place all the functions that are sl@0: * part of the specific filesystem. Tcl always accesses the sl@0: * filesystem through one of these structures. sl@0: * sl@0: * Not all entries need be non-NULL; any which are NULL are simply sl@0: * ignored. However, a complete filesystem should provide all of sl@0: * these functions. The explanations in the structure show sl@0: * the importance of each function. sl@0: */ sl@0: sl@0: typedef struct Tcl_Filesystem { sl@0: CONST char *typeName; /* The name of the filesystem. */ sl@0: int structureLength; /* Length of this structure, so future sl@0: * binary compatibility can be assured. */ sl@0: Tcl_FSVersion version; sl@0: /* Version of the filesystem type. */ sl@0: Tcl_FSPathInFilesystemProc *pathInFilesystemProc; sl@0: /* Function to check whether a path is in sl@0: * this filesystem. This is the most sl@0: * important filesystem procedure. */ sl@0: Tcl_FSDupInternalRepProc *dupInternalRepProc; sl@0: /* Function to duplicate internal fs rep. May sl@0: * be NULL (but then fs is less efficient). */ sl@0: Tcl_FSFreeInternalRepProc *freeInternalRepProc; sl@0: /* Function to free internal fs rep. Must sl@0: * be implemented, if internal representations sl@0: * need freeing, otherwise it can be NULL. */ sl@0: Tcl_FSInternalToNormalizedProc *internalToNormalizedProc; sl@0: /* Function to convert internal representation sl@0: * to a normalized path. Only required if sl@0: * the fs creates pure path objects with no sl@0: * string/path representation. */ sl@0: Tcl_FSCreateInternalRepProc *createInternalRepProc; sl@0: /* Function to create a filesystem-specific sl@0: * internal representation. May be NULL sl@0: * if paths have no internal representation, sl@0: * or if the Tcl_FSPathInFilesystemProc sl@0: * for this filesystem always immediately sl@0: * creates an internal representation for sl@0: * paths it accepts. */ sl@0: Tcl_FSNormalizePathProc *normalizePathProc; sl@0: /* Function to normalize a path. Should sl@0: * be implemented for all filesystems sl@0: * which can have multiple string sl@0: * representations for the same path sl@0: * object. */ sl@0: Tcl_FSFilesystemPathTypeProc *filesystemPathTypeProc; sl@0: /* Function to determine the type of a sl@0: * path in this filesystem. May be NULL. */ sl@0: Tcl_FSFilesystemSeparatorProc *filesystemSeparatorProc; sl@0: /* Function to return the separator sl@0: * character(s) for this filesystem. Must sl@0: * be implemented. */ sl@0: Tcl_FSStatProc *statProc; sl@0: /* sl@0: * Function to process a 'Tcl_FSStat()' sl@0: * call. Must be implemented for any sl@0: * reasonable filesystem. sl@0: */ sl@0: Tcl_FSAccessProc *accessProc; sl@0: /* sl@0: * Function to process a 'Tcl_FSAccess()' sl@0: * call. Must be implemented for any sl@0: * reasonable filesystem. sl@0: */ sl@0: Tcl_FSOpenFileChannelProc *openFileChannelProc; sl@0: /* sl@0: * Function to process a sl@0: * 'Tcl_FSOpenFileChannel()' call. Must be sl@0: * implemented for any reasonable sl@0: * filesystem. sl@0: */ sl@0: Tcl_FSMatchInDirectoryProc *matchInDirectoryProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSMatchInDirectory()'. If not sl@0: * implemented, then glob and recursive sl@0: * copy functionality will be lacking in sl@0: * the filesystem. */ sl@0: Tcl_FSUtimeProc *utimeProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSUtime()' call. Required to sl@0: * allow setting (not reading) of times sl@0: * with 'file mtime', 'file atime' and sl@0: * the open-r/open-w/fcopy implementation sl@0: * of 'file copy'. */ sl@0: Tcl_FSLinkProc *linkProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSLink()' call. Should be sl@0: * implemented only if the filesystem supports sl@0: * links (reading or creating). */ sl@0: Tcl_FSListVolumesProc *listVolumesProc; sl@0: /* Function to list any filesystem volumes sl@0: * added by this filesystem. Should be sl@0: * implemented only if the filesystem adds sl@0: * volumes at the head of the filesystem. */ sl@0: Tcl_FSFileAttrStringsProc *fileAttrStringsProc; sl@0: /* Function to list all attributes strings sl@0: * which are valid for this filesystem. sl@0: * If not implemented the filesystem will sl@0: * not support the 'file attributes' command. sl@0: * This allows arbitrary additional information sl@0: * to be attached to files in the filesystem. */ sl@0: Tcl_FSFileAttrsGetProc *fileAttrsGetProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSFileAttrsGet()' call, used by sl@0: * 'file attributes'. */ sl@0: Tcl_FSFileAttrsSetProc *fileAttrsSetProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSFileAttrsSet()' call, used by sl@0: * 'file attributes'. */ sl@0: Tcl_FSCreateDirectoryProc *createDirectoryProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSCreateDirectory()' call. Should sl@0: * be implemented unless the FS is sl@0: * read-only. */ sl@0: Tcl_FSRemoveDirectoryProc *removeDirectoryProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSRemoveDirectory()' call. Should sl@0: * be implemented unless the FS is sl@0: * read-only. */ sl@0: Tcl_FSDeleteFileProc *deleteFileProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSDeleteFile()' call. Should sl@0: * be implemented unless the FS is sl@0: * read-only. */ sl@0: Tcl_FSCopyFileProc *copyFileProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSCopyFile()' call. If not sl@0: * implemented Tcl will fall back sl@0: * on open-r, open-w and fcopy as sl@0: * a copying mechanism, for copying sl@0: * actions initiated in Tcl (not C). */ sl@0: Tcl_FSRenameFileProc *renameFileProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSRenameFile()' call. If not sl@0: * implemented, Tcl will fall back on sl@0: * a copy and delete mechanism, for sl@0: * rename actions initiated in Tcl (not C). */ sl@0: Tcl_FSCopyDirectoryProc *copyDirectoryProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSCopyDirectory()' call. If sl@0: * not implemented, Tcl will fall back sl@0: * on a recursive create-dir, file copy sl@0: * mechanism, for copying actions sl@0: * initiated in Tcl (not C). */ sl@0: Tcl_FSLstatProc *lstatProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSLstat()' call. If not implemented, sl@0: * Tcl will attempt to use the 'statProc' sl@0: * defined above instead. */ sl@0: Tcl_FSLoadFileProc *loadFileProc; sl@0: /* Function to process a sl@0: * 'Tcl_FSLoadFile()' call. If not sl@0: * implemented, Tcl will fall back on sl@0: * a copy to native-temp followed by a sl@0: * Tcl_FSLoadFile on that temporary copy. */ sl@0: Tcl_FSGetCwdProc *getCwdProc; sl@0: /* sl@0: * Function to process a 'Tcl_FSGetCwd()' sl@0: * call. Most filesystems need not sl@0: * implement this. It will usually only be sl@0: * called once, if 'getcwd' is called sl@0: * before 'chdir'. May be NULL. sl@0: */ sl@0: Tcl_FSChdirProc *chdirProc; sl@0: /* sl@0: * Function to process a 'Tcl_FSChdir()' sl@0: * call. If filesystems do not implement sl@0: * this, it will be emulated by a series of sl@0: * directory access checks. Otherwise, sl@0: * virtual filesystems which do implement sl@0: * it need only respond with a positive sl@0: * return result if the dirName is a valid sl@0: * directory in their filesystem. They sl@0: * need not remember the result, since that sl@0: * will be automatically remembered for use sl@0: * by GetCwd. Real filesystems should sl@0: * carry out the correct action (i.e. call sl@0: * the correct system 'chdir' api). If not sl@0: * implemented, then 'cd' and 'pwd' will sl@0: * fail inside the filesystem. sl@0: */ sl@0: } Tcl_Filesystem; sl@0: sl@0: /* sl@0: * The following definitions are used as values for the 'linkAction' flag sl@0: * to Tcl_FSLink, or the linkProc of any filesystem. Any combination sl@0: * of flags can be given. For link creation, the linkProc should create sl@0: * a link which matches any of the types given. sl@0: * sl@0: * TCL_CREATE_SYMBOLIC_LINK: Create a symbolic or soft link. sl@0: * TCL_CREATE_HARD_LINK: Create a hard link. sl@0: */ sl@0: #define TCL_CREATE_SYMBOLIC_LINK 0x01 sl@0: #define TCL_CREATE_HARD_LINK 0x02 sl@0: sl@0: /* sl@0: * The following structure represents the Notifier functions that sl@0: * you can override with the Tcl_SetNotifier call. sl@0: */ sl@0: typedef struct Tcl_NotifierProcs { sl@0: Tcl_SetTimerProc *setTimerProc; sl@0: Tcl_WaitForEventProc *waitForEventProc; sl@0: Tcl_CreateFileHandlerProc *createFileHandlerProc; sl@0: Tcl_DeleteFileHandlerProc *deleteFileHandlerProc; sl@0: Tcl_InitNotifierProc *initNotifierProc; sl@0: Tcl_FinalizeNotifierProc *finalizeNotifierProc; sl@0: Tcl_AlertNotifierProc *alertNotifierProc; sl@0: Tcl_ServiceModeHookProc *serviceModeHookProc; sl@0: } Tcl_NotifierProcs; sl@0: sl@0: sl@0: /* sl@0: * The following structure represents a user-defined encoding. It collects sl@0: * together all the functions that are used by the specific encoding. sl@0: */ sl@0: typedef struct Tcl_EncodingType { sl@0: CONST char *encodingName; /* The name of the encoding, e.g. "euc-jp". sl@0: * This name is the unique key for this sl@0: * encoding type. */ sl@0: Tcl_EncodingConvertProc *toUtfProc; sl@0: /* Procedure to convert from external sl@0: * encoding into UTF-8. */ sl@0: Tcl_EncodingConvertProc *fromUtfProc; sl@0: /* Procedure to convert from UTF-8 into sl@0: * external encoding. */ sl@0: Tcl_EncodingFreeProc *freeProc; sl@0: /* If non-NULL, procedure to call when this sl@0: * encoding is deleted. */ sl@0: ClientData clientData; /* Arbitrary value associated with encoding sl@0: * type. Passed to conversion procedures. */ sl@0: int nullSize; /* Number of zero bytes that signify sl@0: * end-of-string in this encoding. This sl@0: * number is used to determine the source sl@0: * string length when the srcLen argument is sl@0: * negative. Must be 1 or 2. */ sl@0: } Tcl_EncodingType; sl@0: sl@0: /* sl@0: * The following definitions are used as values for the conversion control sl@0: * flags argument when converting text from one character set to another: sl@0: * sl@0: * TCL_ENCODING_START: Signifies that the source buffer is the first sl@0: * block in a (potentially multi-block) input sl@0: * stream. Tells the conversion procedure to sl@0: * reset to an initial state and perform any sl@0: * initialization that needs to occur before the sl@0: * first byte is converted. If the source sl@0: * buffer contains the entire input stream to be sl@0: * converted, this flag should be set. sl@0: * sl@0: * TCL_ENCODING_END: Signifies that the source buffer is the last sl@0: * block in a (potentially multi-block) input sl@0: * stream. Tells the conversion routine to sl@0: * perform any finalization that needs to occur sl@0: * after the last byte is converted and then to sl@0: * reset to an initial state. If the source sl@0: * buffer contains the entire input stream to be sl@0: * converted, this flag should be set. sl@0: * sl@0: * TCL_ENCODING_STOPONERROR: If set, then the converter will return sl@0: * immediately upon encountering an invalid sl@0: * byte sequence or a source character that has sl@0: * no mapping in the target encoding. If clear, sl@0: * then the converter will skip the problem, sl@0: * substituting one or more "close" characters sl@0: * in the destination buffer and then continue sl@0: * to sonvert the source. sl@0: */ sl@0: #define TCL_ENCODING_START 0x01 sl@0: #define TCL_ENCODING_END 0x02 sl@0: #define TCL_ENCODING_STOPONERROR 0x04 sl@0: sl@0: sl@0: /* sl@0: * The following data structures and declarations are for the new Tcl sl@0: * parser. sl@0: */ sl@0: sl@0: /* sl@0: * For each word of a command, and for each piece of a word such as a sl@0: * variable reference, one of the following structures is created to sl@0: * describe the token. sl@0: */ sl@0: typedef struct Tcl_Token { sl@0: int type; /* Type of token, such as TCL_TOKEN_WORD; sl@0: * see below for valid types. */ sl@0: CONST char *start; /* First character in token. */ sl@0: int size; /* Number of bytes in token. */ sl@0: int numComponents; /* If this token is composed of other sl@0: * tokens, this field tells how many of sl@0: * them there are (including components of sl@0: * components, etc.). The component tokens sl@0: * immediately follow this one. */ sl@0: } Tcl_Token; sl@0: sl@0: /* sl@0: * Type values defined for Tcl_Token structures. These values are sl@0: * defined as mask bits so that it's easy to check for collections of sl@0: * types. sl@0: * sl@0: * TCL_TOKEN_WORD - The token describes one word of a command, sl@0: * from the first non-blank character of sl@0: * the word (which may be " or {) up to but sl@0: * not including the space, semicolon, or sl@0: * bracket that terminates the word. sl@0: * NumComponents counts the total number of sl@0: * sub-tokens that make up the word. This sl@0: * includes, for example, sub-tokens of sl@0: * TCL_TOKEN_VARIABLE tokens. sl@0: * TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD sl@0: * except that the word is guaranteed to sl@0: * consist of a single TCL_TOKEN_TEXT sl@0: * sub-token. sl@0: * TCL_TOKEN_TEXT - The token describes a range of literal sl@0: * text that is part of a word. sl@0: * NumComponents is always 0. sl@0: * TCL_TOKEN_BS - The token describes a backslash sequence sl@0: * that must be collapsed. NumComponents sl@0: * is always 0. sl@0: * TCL_TOKEN_COMMAND - The token describes a command whose result sl@0: * must be substituted into the word. The sl@0: * token includes the enclosing brackets. sl@0: * NumComponents is always 0. sl@0: * TCL_TOKEN_VARIABLE - The token describes a variable sl@0: * substitution, including the dollar sign, sl@0: * variable name, and array index (if there sl@0: * is one) up through the right sl@0: * parentheses. NumComponents tells how sl@0: * many additional tokens follow to sl@0: * represent the variable name. The first sl@0: * token will be a TCL_TOKEN_TEXT token sl@0: * that describes the variable name. If sl@0: * the variable is an array reference then sl@0: * there will be one or more additional sl@0: * tokens, of type TCL_TOKEN_TEXT, sl@0: * TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and sl@0: * TCL_TOKEN_VARIABLE, that describe the sl@0: * array index; numComponents counts the sl@0: * total number of nested tokens that make sl@0: * up the variable reference, including sl@0: * sub-tokens of TCL_TOKEN_VARIABLE tokens. sl@0: * TCL_TOKEN_SUB_EXPR - The token describes one subexpression of a sl@0: * expression, from the first non-blank sl@0: * character of the subexpression up to but not sl@0: * including the space, brace, or bracket sl@0: * that terminates the subexpression. sl@0: * NumComponents counts the total number of sl@0: * following subtokens that make up the sl@0: * subexpression; this includes all subtokens sl@0: * for any nested TCL_TOKEN_SUB_EXPR tokens. sl@0: * For example, a numeric value used as a sl@0: * primitive operand is described by a sl@0: * TCL_TOKEN_SUB_EXPR token followed by a sl@0: * TCL_TOKEN_TEXT token. A binary subexpression sl@0: * is described by a TCL_TOKEN_SUB_EXPR token sl@0: * followed by the TCL_TOKEN_OPERATOR token sl@0: * for the operator, then TCL_TOKEN_SUB_EXPR sl@0: * tokens for the left then the right operands. sl@0: * TCL_TOKEN_OPERATOR - The token describes one expression operator. sl@0: * An operator might be the name of a math sl@0: * function such as "abs". A TCL_TOKEN_OPERATOR sl@0: * token is always preceeded by one sl@0: * TCL_TOKEN_SUB_EXPR token for the operator's sl@0: * subexpression, and is followed by zero or sl@0: * more TCL_TOKEN_SUB_EXPR tokens for the sl@0: * operator's operands. NumComponents is sl@0: * always 0. sl@0: */ sl@0: #define TCL_TOKEN_WORD 1 sl@0: #define TCL_TOKEN_SIMPLE_WORD 2 sl@0: #define TCL_TOKEN_TEXT 4 sl@0: #define TCL_TOKEN_BS 8 sl@0: #define TCL_TOKEN_COMMAND 16 sl@0: #define TCL_TOKEN_VARIABLE 32 sl@0: #define TCL_TOKEN_SUB_EXPR 64 sl@0: #define TCL_TOKEN_OPERATOR 128 sl@0: sl@0: /* sl@0: * Parsing error types. On any parsing error, one of these values sl@0: * will be stored in the error field of the Tcl_Parse structure sl@0: * defined below. sl@0: */ sl@0: #define TCL_PARSE_SUCCESS 0 sl@0: #define TCL_PARSE_QUOTE_EXTRA 1 sl@0: #define TCL_PARSE_BRACE_EXTRA 2 sl@0: #define TCL_PARSE_MISSING_BRACE 3 sl@0: #define TCL_PARSE_MISSING_BRACKET 4 sl@0: #define TCL_PARSE_MISSING_PAREN 5 sl@0: #define TCL_PARSE_MISSING_QUOTE 6 sl@0: #define TCL_PARSE_MISSING_VAR_BRACE 7 sl@0: #define TCL_PARSE_SYNTAX 8 sl@0: #define TCL_PARSE_BAD_NUMBER 9 sl@0: sl@0: /* sl@0: * A structure of the following type is filled in by Tcl_ParseCommand. sl@0: * It describes a single command parsed from an input string. sl@0: */ sl@0: #define NUM_STATIC_TOKENS 20 sl@0: sl@0: typedef struct Tcl_Parse { sl@0: CONST char *commentStart; /* Pointer to # that begins the first of sl@0: * one or more comments preceding the sl@0: * command. */ sl@0: int commentSize; /* Number of bytes in comments (up through sl@0: * newline character that terminates the sl@0: * last comment). If there were no sl@0: * comments, this field is 0. */ sl@0: CONST char *commandStart; /* First character in first word of command. */ sl@0: int commandSize; /* Number of bytes in command, including sl@0: * first character of first word, up sl@0: * through the terminating newline, sl@0: * close bracket, or semicolon. */ sl@0: int numWords; /* Total number of words in command. May sl@0: * be 0. */ sl@0: Tcl_Token *tokenPtr; /* Pointer to first token representing sl@0: * the words of the command. Initially sl@0: * points to staticTokens, but may change sl@0: * to point to malloc-ed space if command sl@0: * exceeds space in staticTokens. */ sl@0: int numTokens; /* Total number of tokens in command. */ sl@0: int tokensAvailable; /* Total number of tokens available at sl@0: * *tokenPtr. */ sl@0: int errorType; /* One of the parsing error types defined sl@0: * above. */ sl@0: sl@0: /* sl@0: * The fields below are intended only for the private use of the sl@0: * parser. They should not be used by procedures that invoke sl@0: * Tcl_ParseCommand. sl@0: */ sl@0: sl@0: CONST char *string; /* The original command string passed to sl@0: * Tcl_ParseCommand. */ sl@0: CONST char *end; /* Points to the character just after the sl@0: * last one in the command string. */ sl@0: Tcl_Interp *interp; /* Interpreter to use for error reporting, sl@0: * or NULL. */ sl@0: CONST char *term; /* Points to character in string that sl@0: * terminated most recent token. Filled in sl@0: * by ParseTokens. If an error occurs, sl@0: * points to beginning of region where the sl@0: * error occurred (e.g. the open brace if sl@0: * the close brace is missing). */ sl@0: int incomplete; /* This field is set to 1 by Tcl_ParseCommand sl@0: * if the command appears to be incomplete. sl@0: * This information is used by sl@0: * Tcl_CommandComplete. */ sl@0: Tcl_Token staticTokens[NUM_STATIC_TOKENS]; sl@0: /* Initial space for tokens for command. sl@0: * This space should be large enough to sl@0: * accommodate most commands; dynamic sl@0: * space is allocated for very large sl@0: * commands that don't fit here. */ sl@0: } Tcl_Parse; sl@0: sl@0: /* sl@0: * The following definitions are the error codes returned by the conversion sl@0: * routines: sl@0: * sl@0: * TCL_OK: All characters were converted. sl@0: * sl@0: * TCL_CONVERT_NOSPACE: The output buffer would not have been large sl@0: * enough for all of the converted data; as many sl@0: * characters as could fit were converted though. sl@0: * sl@0: * TCL_CONVERT_MULTIBYTE: The last few bytes in the source string were sl@0: * the beginning of a multibyte sequence, but sl@0: * more bytes were needed to complete this sl@0: * sequence. A subsequent call to the conversion sl@0: * routine should pass the beginning of this sl@0: * unconverted sequence plus additional bytes sl@0: * from the source stream to properly convert sl@0: * the formerly split-up multibyte sequence. sl@0: * sl@0: * TCL_CONVERT_SYNTAX: The source stream contained an invalid sl@0: * character sequence. This may occur if the sl@0: * input stream has been damaged or if the input sl@0: * encoding method was misidentified. This error sl@0: * is reported only if TCL_ENCODING_STOPONERROR sl@0: * was specified. sl@0: * sl@0: * TCL_CONVERT_UNKNOWN: The source string contained a character sl@0: * that could not be represented in the target sl@0: * encoding. This error is reported only if sl@0: * TCL_ENCODING_STOPONERROR was specified. sl@0: */ sl@0: #define TCL_CONVERT_MULTIBYTE -1 sl@0: #define TCL_CONVERT_SYNTAX -2 sl@0: #define TCL_CONVERT_UNKNOWN -3 sl@0: #define TCL_CONVERT_NOSPACE -4 sl@0: sl@0: /* sl@0: * The maximum number of bytes that are necessary to represent a single sl@0: * Unicode character in UTF-8. The valid values should be 3 or 6 (or sl@0: * perhaps 1 if we want to support a non-unicode enabled core). sl@0: * If 3, then Tcl_UniChar must be 2-bytes in size (UCS-2). (default) sl@0: * If 6, then Tcl_UniChar must be 4-bytes in size (UCS-4). sl@0: * At this time UCS-2 mode is the default and recommended mode. sl@0: * UCS-4 is experimental and not recommended. It works for the core, sl@0: * but most extensions expect UCS-2. sl@0: */ sl@0: #ifndef TCL_UTF_MAX sl@0: #define TCL_UTF_MAX 3 sl@0: #endif sl@0: sl@0: /* sl@0: * This represents a Unicode character. Any changes to this should sl@0: * also be reflected in regcustom.h. sl@0: */ sl@0: #if TCL_UTF_MAX > 3 sl@0: /* sl@0: * unsigned int isn't 100% accurate as it should be a strict 4-byte sl@0: * value (perhaps wchar_t). 64-bit systems may have troubles. The sl@0: * size of this value must be reflected correctly in regcustom.h and sl@0: * in tclEncoding.c. sl@0: * XXX: Tcl is currently UCS-2 and planning UTF-16 for the Unicode sl@0: * XXX: string rep that Tcl_UniChar represents. Changing the size sl@0: * XXX: of Tcl_UniChar is /not/ supported. sl@0: */ sl@0: typedef unsigned int Tcl_UniChar; sl@0: #else sl@0: typedef unsigned short Tcl_UniChar; sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Deprecated Tcl procedures: sl@0: */ sl@0: #ifndef TCL_NO_DEPRECATED sl@0: # define Tcl_EvalObj(interp,objPtr) \ sl@0: Tcl_EvalObjEx((interp),(objPtr),0) sl@0: # define Tcl_GlobalEvalObj(interp,objPtr) \ sl@0: Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL) sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * These function have been renamed. The old names are deprecated, but we sl@0: * define these macros for backwards compatibilty. sl@0: */ sl@0: #define Tcl_Ckalloc Tcl_Alloc sl@0: #define Tcl_Ckfree Tcl_Free sl@0: #define Tcl_Ckrealloc Tcl_Realloc sl@0: #define Tcl_Return Tcl_SetResult sl@0: #define Tcl_TildeSubst Tcl_TranslateFileName sl@0: #define panic Tcl_Panic sl@0: #define panicVA Tcl_PanicVA sl@0: sl@0: sl@0: /* sl@0: * The following constant is used to test for older versions of Tcl sl@0: * in the stubs tables. sl@0: * sl@0: * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different sl@0: * value since the stubs tables don't match. sl@0: */ sl@0: sl@0: #define TCL_STUB_MAGIC ((int)0xFCA3BACF) sl@0: sl@0: /* sl@0: * The following function is required to be defined in all stubs aware sl@0: * extensions. The function is actually implemented in the stub sl@0: * library, not the main Tcl library, although there is a trivial sl@0: * implementation in the main library in case an extension is statically sl@0: * linked into an application. sl@0: */ sl@0: sl@0: EXTERN CONST char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, sl@0: CONST char *version, int exact)); sl@0: sl@0: #ifndef USE_TCL_STUBS sl@0: sl@0: /* sl@0: * When not using stubs, make it a macro. sl@0: */ sl@0: sl@0: #define Tcl_InitStubs(interp, version, exact) \ sl@0: Tcl_PkgRequire(interp, "Tcl", version, exact) sl@0: sl@0: #endif sl@0: sl@0: sl@0: /* sl@0: * Include the public function declarations that are accessible via sl@0: * the stubs table. sl@0: */ sl@0: sl@0: #include "tclDecls.h" sl@0: sl@0: /* sl@0: * Include platform specific public function declarations that are sl@0: * accessible via the stubs table. sl@0: */ sl@0: sl@0: /* sl@0: * tclPlatDecls.h can't be included here on the Mac, as we need sl@0: * Mac specific headers to define the Mac types used in this file, sl@0: * but these Mac haders conflict with a number of tk types sl@0: * and thus can't be included in the globally read tcl.h sl@0: * This header was originally added here as a fix for bug 5241 sl@0: * (stub link error for symbols in TclPlatStubs table), as a work- sl@0: * around for the bug on the mac, tclMac.h is included immediately sl@0: * after tcl.h in the tcl precompiled header (with DLLEXPORT set). sl@0: */ sl@0: sl@0: #if !defined(MAC_TCL) sl@0: #include "tclPlatDecls.h" sl@0: #endif sl@0: sl@0: /* sl@0: * Public functions that are not accessible via the stubs table. sl@0: */ sl@0: sl@0: EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv, sl@0: Tcl_AppInitProc *appInitProc)); sl@0: sl@0: /* sl@0: * Convenience declaration of Tcl_AppInit for backwards compatibility. sl@0: * This function is not *implemented* by the tcl library, so the storage sl@0: * class is neither DLLEXPORT nor DLLIMPORT sl@0: */ sl@0: #undef TCL_STORAGE_CLASS sl@0: #define TCL_STORAGE_CLASS sl@0: sl@0: EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp)); sl@0: sl@0: #undef TCL_STORAGE_CLASS sl@0: #define TCL_STORAGE_CLASS DLLIMPORT sl@0: sl@0: #endif /* RC_INVOKED */ sl@0: sl@0: /* sl@0: * end block for C++ sl@0: */ sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: #endif /* _TCL */