Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:30:17

0001 /*
0002  * tcl.h --
0003  *
0004  *  This header file describes the externally-visible facilities of the
0005  *  Tcl interpreter.
0006  *
0007  * Copyright (c) 1987-1994 The Regents of the University of California.
0008  * Copyright (c) 1993-1996 Lucent Technologies.
0009  * Copyright (c) 1994-1998 Sun Microsystems, Inc.
0010  * Copyright (c) 1998-2000 by Scriptics Corporation.
0011  * Copyright (c) 2002 by Kevin B. Kenny.  All rights reserved.
0012  *
0013  * See the file "license.terms" for information on usage and redistribution of
0014  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
0015  */
0016 
0017 #ifndef _TCL
0018 #define _TCL
0019 
0020 /*
0021  * For C++ compilers, use extern "C"
0022  */
0023 
0024 #ifdef __cplusplus
0025 extern "C" {
0026 #endif
0027 
0028 /*
0029  * The following defines are used to indicate the various release levels.
0030  */
0031 
0032 #define TCL_ALPHA_RELEASE   0
0033 #define TCL_BETA_RELEASE    1
0034 #define TCL_FINAL_RELEASE   2
0035 
0036 /*
0037  * When version numbers change here, must also go into the following files and
0038  * update the version numbers:
0039  *
0040  * library/init.tcl (1 LOC patch)
0041  * unix/configure.in    (2 LOC Major, 2 LOC minor, 1 LOC patch)
0042  * win/configure.in (as above)
0043  * win/tcl.m4       (not patchlevel)
0044  * README       (sections 0 and 2, with and without separator)
0045  * macosx/Tcl-Common.xcconfig (not patchlevel) 1 LOC
0046  * win/README       (not patchlevel) (sections 0 and 2)
0047  * unix/tcl.spec    (1 LOC patch)
0048  * tools/tcl.hpj.in (not patchlevel, for windows installer)
0049  */
0050 
0051 #define TCL_MAJOR_VERSION   8
0052 #define TCL_MINOR_VERSION   6
0053 #define TCL_RELEASE_LEVEL   TCL_FINAL_RELEASE
0054 #define TCL_RELEASE_SERIAL  12
0055 
0056 #define TCL_VERSION     "8.6"
0057 #define TCL_PATCH_LEVEL     "8.6.12"
0058 
0059 /*
0060  *----------------------------------------------------------------------------
0061  * The following definitions set up the proper options for Windows compilers.
0062  * We use this method because there is no autoconf equivalent.
0063  */
0064 
0065 #ifdef _WIN32
0066 #   ifndef __WIN32__
0067 #   define __WIN32__
0068 #   endif
0069 #   ifndef WIN32
0070 #   define WIN32
0071 #   endif
0072 #endif
0073 
0074 /*
0075  * Utility macros: STRINGIFY takes an argument and wraps it in "" (double
0076  * quotation marks), JOIN joins two arguments.
0077  */
0078 
0079 #ifndef STRINGIFY
0080 #  define STRINGIFY(x) STRINGIFY1(x)
0081 #  define STRINGIFY1(x) #x
0082 #endif
0083 #ifndef JOIN
0084 #  define JOIN(a,b) JOIN1(a,b)
0085 #  define JOIN1(a,b) a##b
0086 #endif
0087 
0088 /*
0089  * A special definition used to allow this header file to be included from
0090  * windows resource files so that they can obtain version information.
0091  * RC_INVOKED is defined by default by the windows RC tool.
0092  *
0093  * Resource compilers don't like all the C stuff, like typedefs and function
0094  * declarations, that occur below, so block them out.
0095  */
0096 
0097 #ifndef RC_INVOKED
0098 
0099 /*
0100  * Special macro to define mutexes, that doesn't do anything if we are not
0101  * using threads.
0102  */
0103 
0104 #ifdef TCL_THREADS
0105 #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name;
0106 #else
0107 #define TCL_DECLARE_MUTEX(name)
0108 #endif
0109 
0110 /*
0111  * Tcl's public routine Tcl_FSSeek() uses the values SEEK_SET, SEEK_CUR, and
0112  * SEEK_END, all #define'd by stdio.h .
0113  *
0114  * Also, many extensions need stdio.h, and they've grown accustomed to tcl.h
0115  * providing it for them rather than #include-ing it themselves as they
0116  * should, so also for their sake, we keep the #include to be consistent with
0117  * prior Tcl releases.
0118  */
0119 
0120 #include <stdio.h>
0121 
0122 /*
0123  *----------------------------------------------------------------------------
0124  * Support for functions with a variable number of arguments.
0125  *
0126  * The following TCL_VARARGS* macros are to support old extensions
0127  * written for older versions of Tcl where the macros permitted
0128  * support for the varargs.h system as well as stdarg.h .
0129  *
0130  * New code should just directly be written to use stdarg.h conventions.
0131  */
0132 
0133 #include <stdarg.h>
0134 #if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
0135 #    define TCL_VARARGS(type, name) (type name, ...)
0136 #    define TCL_VARARGS_DEF(type, name) (type name, ...)
0137 #    define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
0138 #endif /* !TCL_NO_DEPRECATED */
0139 #if defined(__GNUC__) && (__GNUC__ > 2)
0140 #   if defined(_WIN32) && defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO
0141 #   define TCL_FORMAT_PRINTF(a,b) __attribute__ ((__format__ (__MINGW_PRINTF_FORMAT, a, b)))
0142 #   else
0143 #   define TCL_FORMAT_PRINTF(a,b) __attribute__ ((__format__ (__printf__, a, b)))
0144 #   endif
0145 #   define TCL_NORETURN __attribute__ ((noreturn))
0146 #   if defined(BUILD_tcl) || defined(BUILD_tk)
0147 #   define TCL_NORETURN1 __attribute__ ((noreturn))
0148 #   else
0149 #   define TCL_NORETURN1 /* nothing */
0150 #   endif
0151 #else
0152 #   define TCL_FORMAT_PRINTF(a,b)
0153 #   if defined(_MSC_VER) && (_MSC_VER >= 1310)
0154 #   define TCL_NORETURN _declspec(noreturn)
0155 #   else
0156 #   define TCL_NORETURN /* nothing */
0157 #   endif
0158 #   define TCL_NORETURN1 /* nothing */
0159 #endif
0160 
0161 /*
0162  * Allow a part of Tcl's API to be explicitly marked as deprecated.
0163  *
0164  * Used to make TIP 330/336 generate moans even if people use the
0165  * compatibility macros. Change your code, guys! We won't support you forever.
0166  */
0167 
0168 #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
0169 #   if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
0170 #   define TCL_DEPRECATED_API(msg)  __attribute__ ((__deprecated__ (msg)))
0171 #   else
0172 #   define TCL_DEPRECATED_API(msg)  __attribute__ ((__deprecated__))
0173 #   endif
0174 #else
0175 #   define TCL_DEPRECATED_API(msg)  /* nothing portable */
0176 #endif
0177 
0178 /*
0179  *----------------------------------------------------------------------------
0180  * Macros used to declare a function to be exported by a DLL. Used by Windows,
0181  * maps to no-op declarations on non-Windows systems. The default build on
0182  * windows is for a DLL, which causes the DLLIMPORT and DLLEXPORT macros to be
0183  * nonempty. To build a static library, the macro STATIC_BUILD should be
0184  * defined.
0185  *
0186  * Note: when building static but linking dynamically to MSVCRT we must still
0187  *       correctly decorate the C library imported function.  Use CRTIMPORT
0188  *       for this purpose.  _DLL is defined by the compiler when linking to
0189  *       MSVCRT.
0190  */
0191 
0192 #if (defined(_WIN32) && (defined(_MSC_VER) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0550)) || defined(__LCC__) || defined(__WATCOMC__) || (defined(__GNUC__) && defined(__declspec))))
0193 #   define HAVE_DECLSPEC 1
0194 #   ifdef STATIC_BUILD
0195 #       define DLLIMPORT
0196 #       define DLLEXPORT
0197 #       ifdef _DLL
0198 #           define CRTIMPORT __declspec(dllimport)
0199 #       else
0200 #           define CRTIMPORT
0201 #       endif
0202 #   else
0203 #       define DLLIMPORT __declspec(dllimport)
0204 #       define DLLEXPORT __declspec(dllexport)
0205 #       define CRTIMPORT __declspec(dllimport)
0206 #   endif
0207 #else
0208 #   define DLLIMPORT
0209 #   if defined(__GNUC__) && __GNUC__ > 3
0210 #       define DLLEXPORT __attribute__ ((visibility("default")))
0211 #   else
0212 #       define DLLEXPORT
0213 #   endif
0214 #   define CRTIMPORT
0215 #endif
0216 
0217 /*
0218  * These macros are used to control whether functions are being declared for
0219  * import or export. If a function is being declared while it is being built
0220  * to be included in a shared library, then it should have the DLLEXPORT
0221  * storage class. If is being declared for use by a module that is going to
0222  * link against the shared library, then it should have the DLLIMPORT storage
0223  * class. If the symbol is being declared for a static build or for use from a
0224  * stub library, then the storage class should be empty.
0225  *
0226  * The convention is that a macro called BUILD_xxxx, where xxxx is the name of
0227  * a library we are building, is set on the compile line for sources that are
0228  * to be placed in the library. When this macro is set, the storage class will
0229  * be set to DLLEXPORT. At the end of the header file, the storage class will
0230  * be reset to DLLIMPORT.
0231  */
0232 
0233 #undef TCL_STORAGE_CLASS
0234 #ifdef BUILD_tcl
0235 #   define TCL_STORAGE_CLASS DLLEXPORT
0236 #else
0237 #   ifdef USE_TCL_STUBS
0238 #      define TCL_STORAGE_CLASS
0239 #   else
0240 #      define TCL_STORAGE_CLASS DLLIMPORT
0241 #   endif
0242 #endif
0243 
0244 /*
0245  * The following _ANSI_ARGS_ macro is to support old extensions
0246  * written for older versions of Tcl where it permitted support
0247  * for compilers written in the pre-prototype era of C.
0248  *
0249  * New code should use prototypes.
0250  */
0251 
0252 #ifndef TCL_NO_DEPRECATED
0253 #   undef _ANSI_ARGS_
0254 #   define _ANSI_ARGS_(x)   x
0255 #endif
0256 
0257 /*
0258  * Definitions that allow this header file to be used either with or without
0259  * ANSI C features.
0260  */
0261 
0262 #ifndef INLINE
0263 #   define INLINE
0264 #endif
0265 
0266 #ifdef NO_CONST
0267 #   ifndef const
0268 #      define const
0269 #   endif
0270 #endif
0271 #ifndef CONST
0272 #   define CONST const
0273 #endif
0274 
0275 #ifdef USE_NON_CONST
0276 #   ifdef USE_COMPAT_CONST
0277 #      error define at most one of USE_NON_CONST and USE_COMPAT_CONST
0278 #   endif
0279 #   define CONST84
0280 #   define CONST84_RETURN
0281 #else
0282 #   ifdef USE_COMPAT_CONST
0283 #      define CONST84
0284 #      define CONST84_RETURN const
0285 #   else
0286 #      define CONST84 const
0287 #      define CONST84_RETURN const
0288 #   endif
0289 #endif
0290 
0291 #ifndef CONST86
0292 #      define CONST86 CONST84
0293 #endif
0294 
0295 /*
0296  * Make sure EXTERN isn't defined elsewhere.
0297  */
0298 
0299 #ifdef EXTERN
0300 #   undef EXTERN
0301 #endif /* EXTERN */
0302 
0303 #ifdef __cplusplus
0304 #   define EXTERN extern "C" TCL_STORAGE_CLASS
0305 #else
0306 #   define EXTERN extern TCL_STORAGE_CLASS
0307 #endif
0308 
0309 /*
0310  *----------------------------------------------------------------------------
0311  * The following code is copied from winnt.h. If we don't replicate it here,
0312  * then <windows.h> can't be included after tcl.h, since tcl.h also defines
0313  * VOID. This block is skipped under Cygwin and Mingw.
0314  */
0315 
0316 #if defined(_WIN32) && !defined(HAVE_WINNT_IGNORE_VOID)
0317 #ifndef VOID
0318 #define VOID void
0319 typedef char CHAR;
0320 typedef short SHORT;
0321 typedef long LONG;
0322 #endif
0323 #endif /* _WIN32 && !HAVE_WINNT_IGNORE_VOID */
0324 
0325 /*
0326  * Macro to use instead of "void" for arguments that must have type "void *"
0327  * in ANSI C; maps them to type "char *" in non-ANSI systems.
0328  */
0329 
0330 #ifndef __VXWORKS__
0331 #   ifndef NO_VOID
0332 #   define VOID void
0333 #   else
0334 #   define VOID char
0335 #   endif
0336 #endif
0337 
0338 /*
0339  * Miscellaneous declarations.
0340  */
0341 
0342 #ifndef _CLIENTDATA
0343 #   ifndef NO_VOID
0344     typedef void *ClientData;
0345 #   else
0346     typedef int *ClientData;
0347 #   endif
0348 #   define _CLIENTDATA
0349 #endif
0350 
0351 /*
0352  * Darwin specific configure overrides (to support fat compiles, where
0353  * configure runs only once for multiple architectures):
0354  */
0355 
0356 #ifdef __APPLE__
0357 #   ifdef __LP64__
0358 #   undef TCL_WIDE_INT_TYPE
0359 #   define TCL_WIDE_INT_IS_LONG 1
0360 #   define TCL_CFG_DO64BIT 1
0361 #    else /* !__LP64__ */
0362 #   define TCL_WIDE_INT_TYPE long long
0363 #   undef TCL_WIDE_INT_IS_LONG
0364 #   undef TCL_CFG_DO64BIT
0365 #    endif /* __LP64__ */
0366 #    undef HAVE_STRUCT_STAT64
0367 #endif /* __APPLE__ */
0368 
0369 /* Cross-compiling 32-bit on a 64-bit platform? Then our
0370  * configure script does the wrong thing. Correct that here.
0371  */
0372 #if defined(__GNUC__) && !defined(_WIN32) && !defined(__LP64__)
0373 #   undef TCL_WIDE_INT_IS_LONG
0374 #   undef TCL_WIDE_INT_TYPE
0375 #   define TCL_WIDE_INT_TYPE long long
0376 #endif
0377 
0378 /*
0379  * Define Tcl_WideInt to be a type that is (at least) 64-bits wide, and define
0380  * Tcl_WideUInt to be the unsigned variant of that type (assuming that where
0381  * we have one, we can have the other.)
0382  *
0383  * Also defines the following macros:
0384  * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on a
0385  *  LP64 system such as modern Solaris or Linux ... not including Win64)
0386  * Tcl_WideAsLong - forgetful converter from wideInt to long.
0387  * Tcl_LongAsWide - sign-extending converter from long to wideInt.
0388  * Tcl_WideAsDouble - converter from wideInt to double.
0389  * Tcl_DoubleAsWide - converter from double to wideInt.
0390  *
0391  * The following invariant should hold for any long value 'longVal':
0392  *  longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal))
0393  *
0394  * Note on converting between Tcl_WideInt and strings. This implementation (in
0395  * tclObj.c) depends on the function
0396  * sprintf(...,"%" TCL_LL_MODIFIER "d",...).
0397  */
0398 
0399 #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG)
0400 #   ifdef _WIN32
0401 #   define TCL_WIDE_INT_TYPE __int64
0402 #   ifdef __BORLANDC__
0403 #       define TCL_LL_MODIFIER  "L"
0404 #   elif defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO)
0405 #       define TCL_LL_MODIFIER  "I64"
0406 #   else
0407 #       define TCL_LL_MODIFIER  "ll"
0408 #   endif
0409 #   elif defined(__GNUC__)
0410 #      define TCL_WIDE_INT_TYPE long long
0411 #      define TCL_LL_MODIFIER   "ll"
0412 #   else /* ! _WIN32 && ! __GNUC__ */
0413 /*
0414  * Don't know what platform it is and configure hasn't discovered what is
0415  * going on for us. Try to guess...
0416  */
0417 #      include <limits.h>
0418 #      if (INT_MAX < LONG_MAX)
0419 #         define TCL_WIDE_INT_IS_LONG   1
0420 #      else
0421 #         define TCL_WIDE_INT_TYPE long long
0422 #      endif
0423 #   endif /* _WIN32 */
0424 #endif /* !TCL_WIDE_INT_TYPE & !TCL_WIDE_INT_IS_LONG */
0425 #ifdef TCL_WIDE_INT_IS_LONG
0426 #   undef TCL_WIDE_INT_TYPE
0427 #   define TCL_WIDE_INT_TYPE    long
0428 #endif /* TCL_WIDE_INT_IS_LONG */
0429 
0430 typedef TCL_WIDE_INT_TYPE       Tcl_WideInt;
0431 typedef unsigned TCL_WIDE_INT_TYPE  Tcl_WideUInt;
0432 
0433 #ifdef TCL_WIDE_INT_IS_LONG
0434 #   define Tcl_WideAsLong(val)      ((long)(val))
0435 #   define Tcl_LongAsWide(val)      ((long)(val))
0436 #   define Tcl_WideAsDouble(val)    ((double)((long)(val)))
0437 #   define Tcl_DoubleAsWide(val)    ((long)((double)(val)))
0438 #   ifndef TCL_LL_MODIFIER
0439 #      define TCL_LL_MODIFIER       "l"
0440 #   endif /* !TCL_LL_MODIFIER */
0441 #else /* TCL_WIDE_INT_IS_LONG */
0442 /*
0443  * The next short section of defines are only done when not running on Windows
0444  * or some other strange platform.
0445  */
0446 #   ifndef TCL_LL_MODIFIER
0447 #      define TCL_LL_MODIFIER       "ll"
0448 #   endif /* !TCL_LL_MODIFIER */
0449 #   define Tcl_WideAsLong(val)      ((long)((Tcl_WideInt)(val)))
0450 #   define Tcl_LongAsWide(val)      ((Tcl_WideInt)((long)(val)))
0451 #   define Tcl_WideAsDouble(val)    ((double)((Tcl_WideInt)(val)))
0452 #   define Tcl_DoubleAsWide(val)    ((Tcl_WideInt)((double)(val)))
0453 #endif /* TCL_WIDE_INT_IS_LONG */
0454 
0455 #ifdef _WIN32
0456 #   ifdef __BORLANDC__
0457     typedef struct stati64 Tcl_StatBuf;
0458 #   elif defined(_WIN64) || defined(_USE_64BIT_TIME_T)
0459     typedef struct __stat64 Tcl_StatBuf;
0460 #   elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T)
0461     typedef struct _stati64 Tcl_StatBuf;
0462 #   else
0463     typedef struct _stat32i64 Tcl_StatBuf;
0464 #   endif /* _MSC_VER < 1400 */
0465 #elif defined(__CYGWIN__)
0466     typedef struct {
0467     dev_t st_dev;
0468     unsigned short st_ino;
0469     unsigned short st_mode;
0470     short st_nlink;
0471     short st_uid;
0472     short st_gid;
0473     /* Here is a 2-byte gap */
0474     dev_t st_rdev;
0475     /* Here is a 4-byte gap */
0476     long long st_size;
0477     struct {long tv_sec;} st_atim;
0478     struct {long tv_sec;} st_mtim;
0479     struct {long tv_sec;} st_ctim;
0480     /* Here is a 4-byte gap */
0481     } Tcl_StatBuf;
0482 #elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__)
0483     typedef struct stat64 Tcl_StatBuf;
0484 #else
0485     typedef struct stat Tcl_StatBuf;
0486 #endif
0487 
0488 /*
0489  *----------------------------------------------------------------------------
0490  * Data structures defined opaquely in this module. The definitions below just
0491  * provide dummy types. A few fields are made visible in Tcl_Interp
0492  * structures, namely those used for returning a string result from commands.
0493  * Direct access to the result field is discouraged in Tcl 8.0. The
0494  * interpreter result is either an object or a string, and the two values are
0495  * kept consistent unless some C code sets interp->result directly.
0496  * Programmers should use either the function Tcl_GetObjResult() or
0497  * Tcl_GetStringResult() to read the interpreter's result. See the SetResult
0498  * man page for details.
0499  *
0500  * Note: any change to the Tcl_Interp definition below must be mirrored in the
0501  * "real" definition in tclInt.h.
0502  *
0503  * Note: Tcl_ObjCmdProc functions do not directly set result and freeProc.
0504  * Instead, they set a Tcl_Obj member in the "real" structure that can be
0505  * accessed with Tcl_GetObjResult() and Tcl_SetObjResult().
0506  */
0507 
0508 typedef struct Tcl_Interp
0509 #if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
0510 {
0511     /* TIP #330: Strongly discourage extensions from using the string
0512      * result. */
0513 #ifdef USE_INTERP_RESULT
0514     char *result TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult");
0515                 /* If the last command returned a string
0516                  * result, this points to it. */
0517     void (*freeProc) (char *blockPtr)
0518         TCL_DEPRECATED_API("use Tcl_GetStringResult/Tcl_SetResult");
0519                 /* Zero means the string result is statically
0520                  * allocated. TCL_DYNAMIC means it was
0521                  * allocated with ckalloc and should be freed
0522                  * with ckfree. Other values give the address
0523                  * of function to invoke to free the result.
0524                  * Tcl_Eval must free it before executing next
0525                  * command. */
0526 #else
0527     char *resultDontUse; /* Don't use in extensions! */
0528     void (*freeProcDontUse) (char *); /* Don't use in extensions! */
0529 #endif
0530 #ifdef USE_INTERP_ERRORLINE
0531     int errorLine TCL_DEPRECATED_API("use Tcl_GetErrorLine/Tcl_SetErrorLine");
0532                 /* When TCL_ERROR is returned, this gives the
0533                  * line number within the command where the
0534                  * error occurred (1 if first line). */
0535 #else
0536     int errorLineDontUse; /* Don't use in extensions! */
0537 #endif
0538 }
0539 #endif /* !TCL_NO_DEPRECATED */
0540 Tcl_Interp;
0541 
0542 typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler;
0543 typedef struct Tcl_Channel_ *Tcl_Channel;
0544 typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion;
0545 typedef struct Tcl_Command_ *Tcl_Command;
0546 typedef struct Tcl_Condition_ *Tcl_Condition;
0547 typedef struct Tcl_Dict_ *Tcl_Dict;
0548 typedef struct Tcl_EncodingState_ *Tcl_EncodingState;
0549 typedef struct Tcl_Encoding_ *Tcl_Encoding;
0550 typedef struct Tcl_Event Tcl_Event;
0551 typedef struct Tcl_InterpState_ *Tcl_InterpState;
0552 typedef struct Tcl_LoadHandle_ *Tcl_LoadHandle;
0553 typedef struct Tcl_Mutex_ *Tcl_Mutex;
0554 typedef struct Tcl_Pid_ *Tcl_Pid;
0555 typedef struct Tcl_RegExp_ *Tcl_RegExp;
0556 typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey;
0557 typedef struct Tcl_ThreadId_ *Tcl_ThreadId;
0558 typedef struct Tcl_TimerToken_ *Tcl_TimerToken;
0559 typedef struct Tcl_Trace_ *Tcl_Trace;
0560 typedef struct Tcl_Var_ *Tcl_Var;
0561 typedef struct Tcl_ZLibStream_ *Tcl_ZlibStream;
0562 
0563 /*
0564  *----------------------------------------------------------------------------
0565  * Definition of the interface to functions implementing threads. A function
0566  * following this definition is given to each call of 'Tcl_CreateThread' and
0567  * will be called as the main fuction of the new thread created by that call.
0568  */
0569 
0570 #if defined _WIN32
0571 typedef unsigned (__stdcall Tcl_ThreadCreateProc) (ClientData clientData);
0572 #else
0573 typedef void (Tcl_ThreadCreateProc) (ClientData clientData);
0574 #endif
0575 
0576 /*
0577  * Threading function return types used for abstracting away platform
0578  * differences when writing a Tcl_ThreadCreateProc. See the NewThread function
0579  * in generic/tclThreadTest.c for it's usage.
0580  */
0581 
0582 #if defined _WIN32
0583 #   define Tcl_ThreadCreateType     unsigned __stdcall
0584 #   define TCL_THREAD_CREATE_RETURN return 0
0585 #else
0586 #   define Tcl_ThreadCreateType     void
0587 #   define TCL_THREAD_CREATE_RETURN
0588 #endif
0589 
0590 /*
0591  * Definition of values for default stacksize and the possible flags to be
0592  * given to Tcl_CreateThread.
0593  */
0594 
0595 #define TCL_THREAD_STACK_DEFAULT (0)    /* Use default size for stack. */
0596 #define TCL_THREAD_NOFLAGS   (0000) /* Standard flags, default
0597                      * behaviour. */
0598 #define TCL_THREAD_JOINABLE  (0001) /* Mark the thread as joinable. */
0599 
0600 /*
0601  * Flag values passed to Tcl_StringCaseMatch.
0602  */
0603 
0604 #define TCL_MATCH_NOCASE    (1<<0)
0605 
0606 /*
0607  * Flag values passed to Tcl_GetRegExpFromObj.
0608  */
0609 
0610 #define TCL_REG_BASIC       000000  /* BREs (convenience). */
0611 #define TCL_REG_EXTENDED    000001  /* EREs. */
0612 #define TCL_REG_ADVF        000002  /* Advanced features in EREs. */
0613 #define TCL_REG_ADVANCED    000003  /* AREs (which are also EREs). */
0614 #define TCL_REG_QUOTE       000004  /* No special characters, none. */
0615 #define TCL_REG_NOCASE      000010  /* Ignore case. */
0616 #define TCL_REG_NOSUB       000020  /* Don't care about subexpressions. */
0617 #define TCL_REG_EXPANDED    000040  /* Expanded format, white space &
0618                      * comments. */
0619 #define TCL_REG_NLSTOP      000100  /* \n doesn't match . or [^ ] */
0620 #define TCL_REG_NLANCH      000200  /* ^ matches after \n, $ before. */
0621 #define TCL_REG_NEWLINE     000300  /* Newlines are line terminators. */
0622 #define TCL_REG_CANMATCH    001000  /* Report details on partial/limited
0623                      * matches. */
0624 
0625 /*
0626  * Flags values passed to Tcl_RegExpExecObj.
0627  */
0628 
0629 #define TCL_REG_NOTBOL  0001    /* Beginning of string does not match ^.  */
0630 #define TCL_REG_NOTEOL  0002    /* End of string does not match $. */
0631 
0632 /*
0633  * Structures filled in by Tcl_RegExpInfo. Note that all offset values are
0634  * relative to the start of the match string, not the beginning of the entire
0635  * string.
0636  */
0637 
0638 typedef struct Tcl_RegExpIndices {
0639     long start;         /* Character offset of first character in
0640                  * match. */
0641     long end;           /* Character offset of first character after
0642                  * the match. */
0643 } Tcl_RegExpIndices;
0644 
0645 typedef struct Tcl_RegExpInfo {
0646     int nsubs;          /* Number of subexpressions in the compiled
0647                  * expression. */
0648     Tcl_RegExpIndices *matches; /* Array of nsubs match offset pairs. */
0649     long extendStart;       /* The offset at which a subsequent match
0650                  * might begin. */
0651     long reserved;      /* Reserved for later use. */
0652 } Tcl_RegExpInfo;
0653 
0654 /*
0655  * Picky compilers complain if this typdef doesn't appear before the struct's
0656  * reference in tclDecls.h.
0657  */
0658 
0659 typedef Tcl_StatBuf *Tcl_Stat_;
0660 typedef struct stat *Tcl_OldStat_;
0661 
0662 /*
0663  *----------------------------------------------------------------------------
0664  * When a TCL command returns, the interpreter contains a result from the
0665  * command. Programmers are strongly encouraged to use one of the functions
0666  * Tcl_GetObjResult() or Tcl_GetStringResult() to read the interpreter's
0667  * result. See the SetResult man page for details. Besides this result, the
0668  * command function returns an integer code, which is one of the following:
0669  *
0670  * TCL_OK       Command completed normally; the interpreter's result
0671  *          contains the command's result.
0672  * TCL_ERROR        The command couldn't be completed successfully; the
0673  *          interpreter's result describes what went wrong.
0674  * TCL_RETURN       The command requests that the current function return;
0675  *          the interpreter's result contains the function's
0676  *          return value.
0677  * TCL_BREAK        The command requests that the innermost loop be
0678  *          exited; the interpreter's result is meaningless.
0679  * TCL_CONTINUE     Go on to the next iteration of the current loop; the
0680  *          interpreter's result is meaningless.
0681  */
0682 
0683 #define TCL_OK          0
0684 #define TCL_ERROR       1
0685 #define TCL_RETURN      2
0686 #define TCL_BREAK       3
0687 #define TCL_CONTINUE        4
0688 
0689 #define TCL_RESULT_SIZE     200
0690 
0691 /*
0692  *----------------------------------------------------------------------------
0693  * Flags to control what substitutions are performed by Tcl_SubstObj():
0694  */
0695 
0696 #define TCL_SUBST_COMMANDS  001
0697 #define TCL_SUBST_VARIABLES 002
0698 #define TCL_SUBST_BACKSLASHES   004
0699 #define TCL_SUBST_ALL       007
0700 
0701 /*
0702  * Argument descriptors for math function callbacks in expressions:
0703  */
0704 
0705 typedef enum {
0706     TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT
0707 } Tcl_ValueType;
0708 
0709 typedef struct Tcl_Value {
0710     Tcl_ValueType type;     /* Indicates intValue or doubleValue is valid,
0711                  * or both. */
0712     long intValue;      /* Integer value. */
0713     double doubleValue;     /* Double-precision floating value. */
0714     Tcl_WideInt wideValue;  /* Wide (min. 64-bit) integer value. */
0715 } Tcl_Value;
0716 
0717 /*
0718  * Forward declaration of Tcl_Obj to prevent an error when the forward
0719  * reference to Tcl_Obj is encountered in the function types declared below.
0720  */
0721 
0722 struct Tcl_Obj;
0723 
0724 /*
0725  *----------------------------------------------------------------------------
0726  * Function types defined by Tcl:
0727  */
0728 
0729 typedef int (Tcl_AppInitProc) (Tcl_Interp *interp);
0730 typedef int (Tcl_AsyncProc) (ClientData clientData, Tcl_Interp *interp,
0731     int code);
0732 typedef void (Tcl_ChannelProc) (ClientData clientData, int mask);
0733 typedef void (Tcl_CloseProc) (ClientData data);
0734 typedef void (Tcl_CmdDeleteProc) (ClientData clientData);
0735 typedef int (Tcl_CmdProc) (ClientData clientData, Tcl_Interp *interp,
0736     int argc, CONST84 char *argv[]);
0737 typedef void (Tcl_CmdTraceProc) (ClientData clientData, Tcl_Interp *interp,
0738     int level, char *command, Tcl_CmdProc *proc,
0739     ClientData cmdClientData, int argc, CONST84 char *argv[]);
0740 typedef int (Tcl_CmdObjTraceProc) (ClientData clientData, Tcl_Interp *interp,
0741     int level, const char *command, Tcl_Command commandInfo, int objc,
0742     struct Tcl_Obj *const *objv);
0743 typedef void (Tcl_CmdObjTraceDeleteProc) (ClientData clientData);
0744 typedef void (Tcl_DupInternalRepProc) (struct Tcl_Obj *srcPtr,
0745     struct Tcl_Obj *dupPtr);
0746 typedef int (Tcl_EncodingConvertProc) (ClientData clientData, const char *src,
0747     int srcLen, int flags, Tcl_EncodingState *statePtr, char *dst,
0748     int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr);
0749 typedef void (Tcl_EncodingFreeProc) (ClientData clientData);
0750 typedef int (Tcl_EventProc) (Tcl_Event *evPtr, int flags);
0751 typedef void (Tcl_EventCheckProc) (ClientData clientData, int flags);
0752 typedef int (Tcl_EventDeleteProc) (Tcl_Event *evPtr, ClientData clientData);
0753 typedef void (Tcl_EventSetupProc) (ClientData clientData, int flags);
0754 typedef void (Tcl_ExitProc) (ClientData clientData);
0755 typedef void (Tcl_FileProc) (ClientData clientData, int mask);
0756 typedef void (Tcl_FileFreeProc) (ClientData clientData);
0757 typedef void (Tcl_FreeInternalRepProc) (struct Tcl_Obj *objPtr);
0758 typedef void (Tcl_FreeProc) (char *blockPtr);
0759 typedef void (Tcl_IdleProc) (ClientData clientData);
0760 typedef void (Tcl_InterpDeleteProc) (ClientData clientData,
0761     Tcl_Interp *interp);
0762 typedef int (Tcl_MathProc) (ClientData clientData, Tcl_Interp *interp,
0763     Tcl_Value *args, Tcl_Value *resultPtr);
0764 typedef void (Tcl_NamespaceDeleteProc) (ClientData clientData);
0765 typedef int (Tcl_ObjCmdProc) (ClientData clientData, Tcl_Interp *interp,
0766     int objc, struct Tcl_Obj *const *objv);
0767 typedef int (Tcl_PackageInitProc) (Tcl_Interp *interp);
0768 typedef int (Tcl_PackageUnloadProc) (Tcl_Interp *interp, int flags);
0769 typedef void (Tcl_PanicProc) (const char *format, ...);
0770 typedef void (Tcl_TcpAcceptProc) (ClientData callbackData, Tcl_Channel chan,
0771     char *address, int port);
0772 typedef void (Tcl_TimerProc) (ClientData clientData);
0773 typedef int (Tcl_SetFromAnyProc) (Tcl_Interp *interp, struct Tcl_Obj *objPtr);
0774 typedef void (Tcl_UpdateStringProc) (struct Tcl_Obj *objPtr);
0775 typedef char * (Tcl_VarTraceProc) (ClientData clientData, Tcl_Interp *interp,
0776     CONST84 char *part1, CONST84 char *part2, int flags);
0777 typedef void (Tcl_CommandTraceProc) (ClientData clientData, Tcl_Interp *interp,
0778     const char *oldName, const char *newName, int flags);
0779 typedef void (Tcl_CreateFileHandlerProc) (int fd, int mask, Tcl_FileProc *proc,
0780     ClientData clientData);
0781 typedef void (Tcl_DeleteFileHandlerProc) (int fd);
0782 typedef void (Tcl_AlertNotifierProc) (ClientData clientData);
0783 typedef void (Tcl_ServiceModeHookProc) (int mode);
0784 typedef ClientData (Tcl_InitNotifierProc) (void);
0785 typedef void (Tcl_FinalizeNotifierProc) (ClientData clientData);
0786 typedef void (Tcl_MainLoopProc) (void);
0787 
0788 /*
0789  *----------------------------------------------------------------------------
0790  * The following structure represents a type of object, which is a particular
0791  * internal representation for an object plus a set of functions that provide
0792  * standard operations on objects of that type.
0793  */
0794 
0795 typedef struct Tcl_ObjType {
0796     const char *name;       /* Name of the type, e.g. "int". */
0797     Tcl_FreeInternalRepProc *freeIntRepProc;
0798                 /* Called to free any storage for the type's
0799                  * internal rep. NULL if the internal rep does
0800                  * not need freeing. */
0801     Tcl_DupInternalRepProc *dupIntRepProc;
0802                 /* Called to create a new object as a copy of
0803                  * an existing object. */
0804     Tcl_UpdateStringProc *updateStringProc;
0805                 /* Called to update the string rep from the
0806                  * type's internal representation. */
0807     Tcl_SetFromAnyProc *setFromAnyProc;
0808                 /* Called to convert the object's internal rep
0809                  * to this type. Frees the internal rep of the
0810                  * old type. Returns TCL_ERROR on failure. */
0811 } Tcl_ObjType;
0812 
0813 /*
0814  * One of the following structures exists for each object in the Tcl system.
0815  * An object stores a value as either a string, some internal representation,
0816  * or both.
0817  */
0818 
0819 typedef struct Tcl_Obj {
0820     int refCount;       /* When 0 the object will be freed. */
0821     char *bytes;        /* This points to the first byte of the
0822                  * object's string representation. The array
0823                  * must be followed by a null byte (i.e., at
0824                  * offset length) but may also contain
0825                  * embedded null characters. The array's
0826                  * storage is allocated by ckalloc. NULL means
0827                  * the string rep is invalid and must be
0828                  * regenerated from the internal rep.  Clients
0829                  * should use Tcl_GetStringFromObj or
0830                  * Tcl_GetString to get a pointer to the byte
0831                  * array as a readonly value. */
0832     int length;         /* The number of bytes at *bytes, not
0833                  * including the terminating null. */
0834     const Tcl_ObjType *typePtr; /* Denotes the object's type. Always
0835                  * corresponds to the type of the object's
0836                  * internal rep. NULL indicates the object has
0837                  * no internal rep (has no type). */
0838     union {         /* The internal representation: */
0839     long longValue;     /*   - an long integer value. */
0840     double doubleValue; /*   - a double-precision floating value. */
0841     void *otherValuePtr;    /*   - another, type-specific value,
0842                            not used internally any more. */
0843     Tcl_WideInt wideValue;  /*   - a long long value. */
0844     struct {        /*   - internal rep as two pointers.
0845                  *     the main use of which is a bignum's
0846                  *     tightly packed fields, where the alloc,
0847                  *     used and signum flags are packed into
0848                  *     ptr2 with everything else hung off ptr1. */
0849         void *ptr1;
0850         void *ptr2;
0851     } twoPtrValue;
0852     struct {        /*   - internal rep as a pointer and a long,
0853                            not used internally any more. */
0854         void *ptr;
0855         unsigned long value;
0856     } ptrAndLongRep;
0857     } internalRep;
0858 } Tcl_Obj;
0859 
0860 /*
0861  * Macros to increment and decrement a Tcl_Obj's reference count, and to test
0862  * whether an object is shared (i.e. has reference count > 1). Note: clients
0863  * should use Tcl_DecrRefCount() when they are finished using an object, and
0864  * should never call TclFreeObj() directly. TclFreeObj() is only defined and
0865  * made public in tcl.h to support Tcl_DecrRefCount's macro definition.
0866  */
0867 
0868 void        Tcl_IncrRefCount(Tcl_Obj *objPtr);
0869 void        Tcl_DecrRefCount(Tcl_Obj *objPtr);
0870 int     Tcl_IsShared(Tcl_Obj *objPtr);
0871 
0872 /*
0873  *----------------------------------------------------------------------------
0874  * The following structure contains the state needed by Tcl_SaveResult. No-one
0875  * outside of Tcl should access any of these fields. This structure is
0876  * typically allocated on the stack.
0877  */
0878 
0879 typedef struct Tcl_SavedResult {
0880     char *result;
0881     Tcl_FreeProc *freeProc;
0882     Tcl_Obj *objResultPtr;
0883     char *appendResult;
0884     int appendAvl;
0885     int appendUsed;
0886     char resultSpace[TCL_RESULT_SIZE+1];
0887 } Tcl_SavedResult;
0888 
0889 /*
0890  *----------------------------------------------------------------------------
0891  * The following definitions support Tcl's namespace facility. Note: the first
0892  * five fields must match exactly the fields in a Namespace structure (see
0893  * tclInt.h).
0894  */
0895 
0896 typedef struct Tcl_Namespace {
0897     char *name;         /* The namespace's name within its parent
0898                  * namespace. This contains no ::'s. The name
0899                  * of the global namespace is "" although "::"
0900                  * is an synonym. */
0901     char *fullName;     /* The namespace's fully qualified name. This
0902                  * starts with ::. */
0903     ClientData clientData;  /* Arbitrary value associated with this
0904                  * namespace. */
0905     Tcl_NamespaceDeleteProc *deleteProc;
0906                 /* Function invoked when deleting the
0907                  * namespace to, e.g., free clientData. */
0908     struct Tcl_Namespace *parentPtr;
0909                 /* Points to the namespace that contains this
0910                  * one. NULL if this is the global
0911                  * namespace. */
0912 } Tcl_Namespace;
0913 
0914 /*
0915  *----------------------------------------------------------------------------
0916  * The following structure represents a call frame, or activation record. A
0917  * call frame defines a naming context for a procedure call: its local scope
0918  * (for local variables) and its namespace scope (used for non-local
0919  * variables; often the global :: namespace). A call frame can also define the
0920  * naming context for a namespace eval or namespace inscope command: the
0921  * namespace in which the command's code should execute. The Tcl_CallFrame
0922  * structures exist only while procedures or namespace eval/inscope's are
0923  * being executed, and provide a Tcl call stack.
0924  *
0925  * A call frame is initialized and pushed using Tcl_PushCallFrame and popped
0926  * using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be provided by the
0927  * Tcl_PushCallFrame caller, and callers typically allocate them on the C call
0928  * stack for efficiency. For this reason, Tcl_CallFrame is defined as a
0929  * structure and not as an opaque token. However, most Tcl_CallFrame fields
0930  * are hidden since applications should not access them directly; others are
0931  * declared as "dummyX".
0932  *
0933  * WARNING!! The structure definition must be kept consistent with the
0934  * CallFrame structure in tclInt.h. If you change one, change the other.
0935  */
0936 
0937 typedef struct Tcl_CallFrame {
0938     Tcl_Namespace *nsPtr;
0939     int dummy1;
0940     int dummy2;
0941     void *dummy3;
0942     void *dummy4;
0943     void *dummy5;
0944     int dummy6;
0945     void *dummy7;
0946     void *dummy8;
0947     int dummy9;
0948     void *dummy10;
0949     void *dummy11;
0950     void *dummy12;
0951     void *dummy13;
0952 } Tcl_CallFrame;
0953 
0954 /*
0955  *----------------------------------------------------------------------------
0956  * Information about commands that is returned by Tcl_GetCommandInfo and
0957  * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based command
0958  * function while proc is a traditional Tcl argc/argv string-based function.
0959  * Tcl_CreateObjCommand and Tcl_CreateCommand ensure that both objProc and
0960  * proc are non-NULL and can be called to execute the command. However, it may
0961  * be faster to call one instead of the other. The member isNativeObjectProc
0962  * is set to 1 if an object-based function was registered by
0963  * Tcl_CreateObjCommand, and to 0 if a string-based function was registered by
0964  * Tcl_CreateCommand. The other function is typically set to a compatibility
0965  * wrapper that does string-to-object or object-to-string argument conversions
0966  * then calls the other function.
0967  */
0968 
0969 typedef struct Tcl_CmdInfo {
0970     int isNativeObjectProc; /* 1 if objProc was registered by a call to
0971                  * Tcl_CreateObjCommand; 0 otherwise.
0972                  * Tcl_SetCmdInfo does not modify this
0973                  * field. */
0974     Tcl_ObjCmdProc *objProc;    /* Command's object-based function. */
0975     ClientData objClientData;   /* ClientData for object proc. */
0976     Tcl_CmdProc *proc;      /* Command's string-based function. */
0977     ClientData clientData;  /* ClientData for string proc. */
0978     Tcl_CmdDeleteProc *deleteProc;
0979                 /* Function to call when command is
0980                  * deleted. */
0981     ClientData deleteData;  /* Value to pass to deleteProc (usually the
0982                  * same as clientData). */
0983     Tcl_Namespace *namespacePtr;/* Points to the namespace that contains this
0984                  * command. Note that Tcl_SetCmdInfo will not
0985                  * change a command's namespace; use
0986                  * TclRenameCommand or Tcl_Eval (of 'rename')
0987                  * to do that. */
0988 } Tcl_CmdInfo;
0989 
0990 /*
0991  *----------------------------------------------------------------------------
0992  * The structure defined below is used to hold dynamic strings. The only
0993  * fields that clients should use are string and length, accessible via the
0994  * macros Tcl_DStringValue and Tcl_DStringLength.
0995  */
0996 
0997 #define TCL_DSTRING_STATIC_SIZE 200
0998 typedef struct Tcl_DString {
0999     char *string;       /* Points to beginning of string: either
1000                  * staticSpace below or a malloced array. */
1001     int length;         /* Number of non-NULL characters in the
1002                  * string. */
1003     int spaceAvl;       /* Total number of bytes available for the
1004                  * string and its terminating NULL char. */
1005     char staticSpace[TCL_DSTRING_STATIC_SIZE];
1006                 /* Space to use in common case where string is
1007                  * small. */
1008 } Tcl_DString;
1009 
1010 #define Tcl_DStringLength(dsPtr) ((dsPtr)->length)
1011 #define Tcl_DStringValue(dsPtr) ((dsPtr)->string)
1012 #define Tcl_DStringTrunc Tcl_DStringSetLength
1013 
1014 /*
1015  * Definitions for the maximum number of digits of precision that may be
1016  * specified in the "tcl_precision" variable, and the number of bytes of
1017  * buffer space required by Tcl_PrintDouble.
1018  */
1019 
1020 #define TCL_MAX_PREC        17
1021 #define TCL_DOUBLE_SPACE    (TCL_MAX_PREC+10)
1022 
1023 /*
1024  * Definition for a number of bytes of buffer space sufficient to hold the
1025  * string representation of an integer in base 10 (assuming the existence of
1026  * 64-bit integers).
1027  */
1028 
1029 #define TCL_INTEGER_SPACE   24
1030 
1031 /*
1032  * Flag values passed to Tcl_ConvertElement.
1033  * TCL_DONT_USE_BRACES forces it not to enclose the element in braces, but to
1034  *  use backslash quoting instead.
1035  * TCL_DONT_QUOTE_HASH disables the default quoting of the '#' character. It
1036  *  is safe to leave the hash unquoted when the element is not the first
1037  *  element of a list, and this flag can be used by the caller to indicate
1038  *  that condition.
1039  */
1040 
1041 #define TCL_DONT_USE_BRACES 1
1042 #define TCL_DONT_QUOTE_HASH 8
1043 
1044 /*
1045  * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow
1046  * abbreviated strings.
1047  */
1048 
1049 #define TCL_EXACT   1
1050 
1051 /*
1052  *----------------------------------------------------------------------------
1053  * Flag values passed to Tcl_RecordAndEval, Tcl_EvalObj, Tcl_EvalObjv.
1054  * WARNING: these bit choices must not conflict with the bit choices for
1055  * evalFlag bits in tclInt.h!
1056  *
1057  * Meanings:
1058  *  TCL_NO_EVAL:        Just record this command
1059  *  TCL_EVAL_GLOBAL:    Execute script in global namespace
1060  *  TCL_EVAL_DIRECT:    Do not compile this script
1061  *  TCL_EVAL_INVOKE:    Magical Tcl_EvalObjv mode for aliases/ensembles
1062  *              o Run in iPtr->lookupNsPtr or global namespace
1063  *              o Cut out of error traces
1064  *              o Don't reset the flags controlling ensemble
1065  *                error message rewriting.
1066  *  TCL_CANCEL_UNWIND:  Magical Tcl_CancelEval mode that causes the
1067  *              stack for the script in progress to be
1068  *              completely unwound.
1069  *  TCL_EVAL_NOERR: Do no exception reporting at all, just return
1070  *              as the caller will report.
1071  */
1072 
1073 #define TCL_NO_EVAL     0x010000
1074 #define TCL_EVAL_GLOBAL     0x020000
1075 #define TCL_EVAL_DIRECT     0x040000
1076 #define TCL_EVAL_INVOKE     0x080000
1077 #define TCL_CANCEL_UNWIND   0x100000
1078 #define TCL_EVAL_NOERR          0x200000
1079 
1080 /*
1081  * Special freeProc values that may be passed to Tcl_SetResult (see the man
1082  * page for details):
1083  */
1084 
1085 #define TCL_VOLATILE        ((Tcl_FreeProc *) 1)
1086 #define TCL_STATIC      ((Tcl_FreeProc *) 0)
1087 #define TCL_DYNAMIC     ((Tcl_FreeProc *) 3)
1088 
1089 /*
1090  * Flag values passed to variable-related functions.
1091  * WARNING: these bit choices must not conflict with the bit choice for
1092  * TCL_CANCEL_UNWIND, above.
1093  */
1094 
1095 #define TCL_GLOBAL_ONLY      1
1096 #define TCL_NAMESPACE_ONLY   2
1097 #define TCL_APPEND_VALUE     4
1098 #define TCL_LIST_ELEMENT     8
1099 #define TCL_TRACE_READS      0x10
1100 #define TCL_TRACE_WRITES     0x20
1101 #define TCL_TRACE_UNSETS     0x40
1102 #define TCL_TRACE_DESTROYED  0x80
1103 #define TCL_INTERP_DESTROYED     0x100
1104 #define TCL_LEAVE_ERR_MSG    0x200
1105 #define TCL_TRACE_ARRAY      0x800
1106 #ifndef TCL_REMOVE_OBSOLETE_TRACES
1107 /* Required to support old variable/vdelete/vinfo traces. */
1108 #define TCL_TRACE_OLD_STYLE  0x1000
1109 #endif
1110 /* Indicate the semantics of the result of a trace. */
1111 #define TCL_TRACE_RESULT_DYNAMIC 0x8000
1112 #define TCL_TRACE_RESULT_OBJECT  0x10000
1113 
1114 /*
1115  * Flag values for ensemble commands.
1116  */
1117 
1118 #define TCL_ENSEMBLE_PREFIX 0x02/* Flag value to say whether to allow
1119                  * unambiguous prefixes of commands or to
1120                  * require exact matches for command names. */
1121 
1122 /*
1123  * Flag values passed to command-related functions.
1124  */
1125 
1126 #define TCL_TRACE_RENAME    0x2000
1127 #define TCL_TRACE_DELETE    0x4000
1128 
1129 #define TCL_ALLOW_INLINE_COMPILATION 0x20000
1130 
1131 /*
1132  * The TCL_PARSE_PART1 flag is deprecated and has no effect. The part1 is now
1133  * always parsed whenever the part2 is NULL. (This is to avoid a common error
1134  * when converting code to use the new object based APIs and forgetting to
1135  * give the flag)
1136  */
1137 
1138 #if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
1139 #   define TCL_PARSE_PART1  0x400
1140 #endif /* !TCL_NO_DEPRECATED */
1141 
1142 /*
1143  * Types for linked variables:
1144  */
1145 
1146 #define TCL_LINK_INT        1
1147 #define TCL_LINK_DOUBLE     2
1148 #define TCL_LINK_BOOLEAN    3
1149 #define TCL_LINK_STRING     4
1150 #define TCL_LINK_WIDE_INT   5
1151 #define TCL_LINK_CHAR       6
1152 #define TCL_LINK_UCHAR      7
1153 #define TCL_LINK_SHORT      8
1154 #define TCL_LINK_USHORT     9
1155 #define TCL_LINK_UINT       10
1156 #define TCL_LINK_LONG       11
1157 #define TCL_LINK_ULONG      12
1158 #define TCL_LINK_FLOAT      13
1159 #define TCL_LINK_WIDE_UINT  14
1160 #define TCL_LINK_READ_ONLY  0x80
1161 
1162 /*
1163  *----------------------------------------------------------------------------
1164  * Forward declarations of Tcl_HashTable and related types.
1165  */
1166 
1167 typedef struct Tcl_HashKeyType Tcl_HashKeyType;
1168 typedef struct Tcl_HashTable Tcl_HashTable;
1169 typedef struct Tcl_HashEntry Tcl_HashEntry;
1170 
1171 typedef unsigned (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr);
1172 typedef int (Tcl_CompareHashKeysProc) (void *keyPtr, Tcl_HashEntry *hPtr);
1173 typedef Tcl_HashEntry * (Tcl_AllocHashEntryProc) (Tcl_HashTable *tablePtr,
1174     void *keyPtr);
1175 typedef void (Tcl_FreeHashEntryProc) (Tcl_HashEntry *hPtr);
1176 
1177 /*
1178  * This flag controls whether the hash table stores the hash of a key, or
1179  * recalculates it. There should be no reason for turning this flag off as it
1180  * is completely binary and source compatible unless you directly access the
1181  * bucketPtr member of the Tcl_HashTableEntry structure. This member has been
1182  * removed and the space used to store the hash value.
1183  */
1184 
1185 #ifndef TCL_HASH_KEY_STORE_HASH
1186 #   define TCL_HASH_KEY_STORE_HASH 1
1187 #endif
1188 
1189 /*
1190  * Structure definition for an entry in a hash table. No-one outside Tcl
1191  * should access any of these fields directly; use the macros defined below.
1192  */
1193 
1194 struct Tcl_HashEntry {
1195     Tcl_HashEntry *nextPtr; /* Pointer to next entry in this hash bucket,
1196                  * or NULL for end of chain. */
1197     Tcl_HashTable *tablePtr;    /* Pointer to table containing entry. */
1198 #if TCL_HASH_KEY_STORE_HASH
1199     void *hash;         /* Hash value, stored as pointer to ensure
1200                  * that the offsets of the fields in this
1201                  * structure are not changed. */
1202 #else
1203     Tcl_HashEntry **bucketPtr;  /* Pointer to bucket that points to first
1204                  * entry in this entry's chain: used for
1205                  * deleting the entry. */
1206 #endif
1207     ClientData clientData;  /* Application stores something here with
1208                  * Tcl_SetHashValue. */
1209     union {         /* Key has one of these forms: */
1210     char *oneWordValue; /* One-word value for key. */
1211     Tcl_Obj *objPtr;    /* Tcl_Obj * key value. */
1212     int words[1];       /* Multiple integer words for key. The actual
1213                  * size will be as large as necessary for this
1214                  * table's keys. */
1215     char string[1];     /* String for key. The actual size will be as
1216                  * large as needed to hold the key. */
1217     } key;          /* MUST BE LAST FIELD IN RECORD!! */
1218 };
1219 
1220 /*
1221  * Flags used in Tcl_HashKeyType.
1222  *
1223  * TCL_HASH_KEY_RANDOMIZE_HASH -
1224  *              There are some things, pointers for example
1225  *              which don't hash well because they do not use
1226  *              the lower bits. If this flag is set then the
1227  *              hash table will attempt to rectify this by
1228  *              randomising the bits and then using the upper
1229  *              N bits as the index into the table.
1230  * TCL_HASH_KEY_SYSTEM_HASH -   If this flag is set then all memory internally
1231  *                              allocated for the hash table that is not for an
1232  *                              entry will use the system heap.
1233  */
1234 
1235 #define TCL_HASH_KEY_RANDOMIZE_HASH 0x1
1236 #define TCL_HASH_KEY_SYSTEM_HASH    0x2
1237 
1238 /*
1239  * Structure definition for the methods associated with a hash table key type.
1240  */
1241 
1242 #define TCL_HASH_KEY_TYPE_VERSION 1
1243 struct Tcl_HashKeyType {
1244     int version;        /* Version of the table. If this structure is
1245                  * extended in future then the version can be
1246                  * used to distinguish between different
1247                  * structures. */
1248     int flags;          /* Flags, see above for details. */
1249     Tcl_HashKeyProc *hashKeyProc;
1250                 /* Calculates a hash value for the key. If
1251                  * this is NULL then the pointer itself is
1252                  * used as a hash value. */
1253     Tcl_CompareHashKeysProc *compareKeysProc;
1254                 /* Compares two keys and returns zero if they
1255                  * do not match, and non-zero if they do. If
1256                  * this is NULL then the pointers are
1257                  * compared. */
1258     Tcl_AllocHashEntryProc *allocEntryProc;
1259                 /* Called to allocate memory for a new entry,
1260                  * i.e. if the key is a string then this could
1261                  * allocate a single block which contains
1262                  * enough space for both the entry and the
1263                  * string. Only the key field of the allocated
1264                  * Tcl_HashEntry structure needs to be filled
1265                  * in. If something else needs to be done to
1266                  * the key, i.e. incrementing a reference
1267                  * count then that should be done by this
1268                  * function. If this is NULL then Tcl_Alloc is
1269                  * used to allocate enough space for a
1270                  * Tcl_HashEntry and the key pointer is
1271                  * assigned to key.oneWordValue. */
1272     Tcl_FreeHashEntryProc *freeEntryProc;
1273                 /* Called to free memory associated with an
1274                  * entry. If something else needs to be done
1275                  * to the key, i.e. decrementing a reference
1276                  * count then that should be done by this
1277                  * function. If this is NULL then Tcl_Free is
1278                  * used to free the Tcl_HashEntry. */
1279 };
1280 
1281 /*
1282  * Structure definition for a hash table.  Must be in tcl.h so clients can
1283  * allocate space for these structures, but clients should never access any
1284  * fields in this structure.
1285  */
1286 
1287 #define TCL_SMALL_HASH_TABLE 4
1288 struct Tcl_HashTable {
1289     Tcl_HashEntry **buckets;    /* Pointer to bucket array. Each element
1290                  * points to first entry in bucket's hash
1291                  * chain, or NULL. */
1292     Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
1293                 /* Bucket array used for small tables (to
1294                  * avoid mallocs and frees). */
1295     int numBuckets;     /* Total number of buckets allocated at
1296                  * **bucketPtr. */
1297     int numEntries;     /* Total number of entries present in
1298                  * table. */
1299     int rebuildSize;        /* Enlarge table when numEntries gets to be
1300                  * this large. */
1301     int downShift;      /* Shift count used in hashing function.
1302                  * Designed to use high-order bits of
1303                  * randomized keys. */
1304     int mask;           /* Mask value used in hashing function. */
1305     int keyType;        /* Type of keys used in this table. It's
1306                  * either TCL_CUSTOM_KEYS, TCL_STRING_KEYS,
1307                  * TCL_ONE_WORD_KEYS, or an integer giving the
1308                  * number of ints that is the size of the
1309                  * key. */
1310     Tcl_HashEntry *(*findProc) (Tcl_HashTable *tablePtr, const char *key);
1311     Tcl_HashEntry *(*createProc) (Tcl_HashTable *tablePtr, const char *key,
1312         int *newPtr);
1313     const Tcl_HashKeyType *typePtr;
1314                 /* Type of the keys used in the
1315                  * Tcl_HashTable. */
1316 };
1317 
1318 /*
1319  * Structure definition for information used to keep track of searches through
1320  * hash tables:
1321  */
1322 
1323 typedef struct Tcl_HashSearch {
1324     Tcl_HashTable *tablePtr;    /* Table being searched. */
1325     int nextIndex;      /* Index of next bucket to be enumerated after
1326                  * present one. */
1327     Tcl_HashEntry *nextEntryPtr;/* Next entry to be enumerated in the current
1328                  * bucket. */
1329 } Tcl_HashSearch;
1330 
1331 /*
1332  * Acceptable key types for hash tables:
1333  *
1334  * TCL_STRING_KEYS:     The keys are strings, they are copied into the
1335  *              entry.
1336  * TCL_ONE_WORD_KEYS:       The keys are pointers, the pointer is stored
1337  *              in the entry.
1338  * TCL_CUSTOM_TYPE_KEYS:    The keys are arbitrary types which are copied
1339  *              into the entry.
1340  * TCL_CUSTOM_PTR_KEYS:     The keys are pointers to arbitrary types, the
1341  *              pointer is stored in the entry.
1342  *
1343  * While maintaining binary compatibility the above have to be distinct values
1344  * as they are used to differentiate between old versions of the hash table
1345  * which don't have a typePtr and new ones which do. Once binary compatibility
1346  * is discarded in favour of making more wide spread changes TCL_STRING_KEYS
1347  * can be the same as TCL_CUSTOM_TYPE_KEYS, and TCL_ONE_WORD_KEYS can be the
1348  * same as TCL_CUSTOM_PTR_KEYS because they simply determine how the key is
1349  * accessed from the entry and not the behaviour.
1350  */
1351 
1352 #define TCL_STRING_KEYS     (0)
1353 #define TCL_ONE_WORD_KEYS   (1)
1354 #define TCL_CUSTOM_TYPE_KEYS    (-2)
1355 #define TCL_CUSTOM_PTR_KEYS (-1)
1356 
1357 /*
1358  * Structure definition for information used to keep track of searches through
1359  * dictionaries. These fields should not be accessed by code outside
1360  * tclDictObj.c
1361  */
1362 
1363 typedef struct {
1364     void *next;         /* Search position for underlying hash
1365                  * table. */
1366     int epoch;          /* Epoch marker for dictionary being searched,
1367                  * or -1 if search has terminated. */
1368     Tcl_Dict dictionaryPtr; /* Reference to dictionary being searched. */
1369 } Tcl_DictSearch;
1370 
1371 /*
1372  *----------------------------------------------------------------------------
1373  * Flag values to pass to Tcl_DoOneEvent to disable searches for some kinds of
1374  * events:
1375  */
1376 
1377 #define TCL_DONT_WAIT       (1<<1)
1378 #define TCL_WINDOW_EVENTS   (1<<2)
1379 #define TCL_FILE_EVENTS     (1<<3)
1380 #define TCL_TIMER_EVENTS    (1<<4)
1381 #define TCL_IDLE_EVENTS     (1<<5)  /* WAS 0x10 ???? */
1382 #define TCL_ALL_EVENTS      (~TCL_DONT_WAIT)
1383 
1384 /*
1385  * The following structure defines a generic event for the Tcl event system.
1386  * These are the things that are queued in calls to Tcl_QueueEvent and
1387  * serviced later by Tcl_DoOneEvent. There can be many different kinds of
1388  * events with different fields, corresponding to window events, timer events,
1389  * etc. The structure for a particular event consists of a Tcl_Event header
1390  * followed by additional information specific to that event.
1391  */
1392 
1393 struct Tcl_Event {
1394     Tcl_EventProc *proc;    /* Function to call to service this event. */
1395     struct Tcl_Event *nextPtr;  /* Next in list of pending events, or NULL. */
1396 };
1397 
1398 /*
1399  * Positions to pass to Tcl_QueueEvent:
1400  */
1401 
1402 typedef enum {
1403     TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK
1404 } Tcl_QueuePosition;
1405 
1406 /*
1407  * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier
1408  * event routines.
1409  */
1410 
1411 #define TCL_SERVICE_NONE 0
1412 #define TCL_SERVICE_ALL 1
1413 
1414 /*
1415  * The following structure keeps is used to hold a time value, either as an
1416  * absolute time (the number of seconds from the epoch) or as an elapsed time.
1417  * On Unix systems the epoch is Midnight Jan 1, 1970 GMT.
1418  */
1419 
1420 typedef struct Tcl_Time {
1421     long sec;           /* Seconds. */
1422     long usec;          /* Microseconds. */
1423 } Tcl_Time;
1424 
1425 typedef void (Tcl_SetTimerProc) (CONST86 Tcl_Time *timePtr);
1426 typedef int (Tcl_WaitForEventProc) (CONST86 Tcl_Time *timePtr);
1427 
1428 /*
1429  * TIP #233 (Virtualized Time)
1430  */
1431 
1432 typedef void (Tcl_GetTimeProc)   (Tcl_Time *timebuf, ClientData clientData);
1433 typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, ClientData clientData);
1434 
1435 /*
1436  *----------------------------------------------------------------------------
1437  * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler to
1438  * indicate what sorts of events are of interest:
1439  */
1440 
1441 #define TCL_READABLE        (1<<1)
1442 #define TCL_WRITABLE        (1<<2)
1443 #define TCL_EXCEPTION       (1<<3)
1444 
1445 /*
1446  * Flag values to pass to Tcl_OpenCommandChannel to indicate the disposition
1447  * of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, are also used in
1448  * Tcl_GetStdChannel.
1449  */
1450 
1451 #define TCL_STDIN       (1<<1)
1452 #define TCL_STDOUT      (1<<2)
1453 #define TCL_STDERR      (1<<3)
1454 #define TCL_ENFORCE_MODE    (1<<4)
1455 
1456 /*
1457  * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel
1458  * should be closed.
1459  */
1460 
1461 #define TCL_CLOSE_READ      (1<<1)
1462 #define TCL_CLOSE_WRITE     (1<<2)
1463 
1464 /*
1465  * Value to use as the closeProc for a channel that supports the close2Proc
1466  * interface.
1467  */
1468 
1469 #define TCL_CLOSE2PROC      ((Tcl_DriverCloseProc *) 1)
1470 
1471 /*
1472  * Channel version tag. This was introduced in 8.3.2/8.4.
1473  */
1474 
1475 #define TCL_CHANNEL_VERSION_1   ((Tcl_ChannelTypeVersion) 0x1)
1476 #define TCL_CHANNEL_VERSION_2   ((Tcl_ChannelTypeVersion) 0x2)
1477 #define TCL_CHANNEL_VERSION_3   ((Tcl_ChannelTypeVersion) 0x3)
1478 #define TCL_CHANNEL_VERSION_4   ((Tcl_ChannelTypeVersion) 0x4)
1479 #define TCL_CHANNEL_VERSION_5   ((Tcl_ChannelTypeVersion) 0x5)
1480 
1481 /*
1482  * TIP #218: Channel Actions, Ids for Tcl_DriverThreadActionProc.
1483  */
1484 
1485 #define TCL_CHANNEL_THREAD_INSERT (0)
1486 #define TCL_CHANNEL_THREAD_REMOVE (1)
1487 
1488 /*
1489  * Typedefs for the various operations in a channel type:
1490  */
1491 
1492 typedef int (Tcl_DriverBlockModeProc) (ClientData instanceData, int mode);
1493 typedef int (Tcl_DriverCloseProc) (ClientData instanceData,
1494             Tcl_Interp *interp);
1495 typedef int (Tcl_DriverClose2Proc) (ClientData instanceData,
1496             Tcl_Interp *interp, int flags);
1497 typedef int (Tcl_DriverInputProc) (ClientData instanceData, char *buf,
1498             int toRead, int *errorCodePtr);
1499 typedef int (Tcl_DriverOutputProc) (ClientData instanceData,
1500             CONST84 char *buf, int toWrite, int *errorCodePtr);
1501 typedef int (Tcl_DriverSeekProc) (ClientData instanceData, long offset,
1502             int mode, int *errorCodePtr);
1503 typedef int (Tcl_DriverSetOptionProc) (ClientData instanceData,
1504             Tcl_Interp *interp, const char *optionName,
1505             const char *value);
1506 typedef int (Tcl_DriverGetOptionProc) (ClientData instanceData,
1507             Tcl_Interp *interp, CONST84 char *optionName,
1508             Tcl_DString *dsPtr);
1509 typedef void    (Tcl_DriverWatchProc) (ClientData instanceData, int mask);
1510 typedef int (Tcl_DriverGetHandleProc) (ClientData instanceData,
1511             int direction, ClientData *handlePtr);
1512 typedef int (Tcl_DriverFlushProc) (ClientData instanceData);
1513 typedef int (Tcl_DriverHandlerProc) (ClientData instanceData,
1514             int interestMask);
1515 typedef Tcl_WideInt (Tcl_DriverWideSeekProc) (ClientData instanceData,
1516             Tcl_WideInt offset, int mode, int *errorCodePtr);
1517 /*
1518  * TIP #218, Channel Thread Actions
1519  */
1520 typedef void    (Tcl_DriverThreadActionProc) (ClientData instanceData,
1521             int action);
1522 /*
1523  * TIP #208, File Truncation (etc.)
1524  */
1525 typedef int (Tcl_DriverTruncateProc) (ClientData instanceData,
1526             Tcl_WideInt length);
1527 
1528 /*
1529  * struct Tcl_ChannelType:
1530  *
1531  * One such structure exists for each type (kind) of channel. It collects
1532  * together in one place all the functions that are part of the specific
1533  * channel type.
1534  *
1535  * It is recommend that the Tcl_Channel* functions are used to access elements
1536  * of this structure, instead of direct accessing.
1537  */
1538 
1539 typedef struct Tcl_ChannelType {
1540     const char *typeName;   /* The name of the channel type in Tcl
1541                  * commands. This storage is owned by channel
1542                  * type. */
1543     Tcl_ChannelTypeVersion version;
1544                 /* Version of the channel type. */
1545     Tcl_DriverCloseProc *closeProc;
1546                 /* Function to call to close the channel, or
1547                  * TCL_CLOSE2PROC if the close2Proc should be
1548                  * used instead. */
1549     Tcl_DriverInputProc *inputProc;
1550                 /* Function to call for input on channel. */
1551     Tcl_DriverOutputProc *outputProc;
1552                 /* Function to call for output on channel. */
1553     Tcl_DriverSeekProc *seekProc;
1554                 /* Function to call to seek on the channel.
1555                  * May be NULL. */
1556     Tcl_DriverSetOptionProc *setOptionProc;
1557                 /* Set an option on a channel. */
1558     Tcl_DriverGetOptionProc *getOptionProc;
1559                 /* Get an option from a channel. */
1560     Tcl_DriverWatchProc *watchProc;
1561                 /* Set up the notifier to watch for events on
1562                  * this channel. */
1563     Tcl_DriverGetHandleProc *getHandleProc;
1564                 /* Get an OS handle from the channel or NULL
1565                  * if not supported. */
1566     Tcl_DriverClose2Proc *close2Proc;
1567                 /* Function to call to close the channel if
1568                  * the device supports closing the read &
1569                  * write sides independently. */
1570     Tcl_DriverBlockModeProc *blockModeProc;
1571                 /* Set blocking mode for the raw channel. May
1572                  * be NULL. */
1573     /*
1574      * Only valid in TCL_CHANNEL_VERSION_2 channels or later.
1575      */
1576     Tcl_DriverFlushProc *flushProc;
1577                 /* Function to call to flush a channel. May be
1578                  * NULL. */
1579     Tcl_DriverHandlerProc *handlerProc;
1580                 /* Function to call to handle a channel event.
1581                  * This will be passed up the stacked channel
1582                  * chain. */
1583     /*
1584      * Only valid in TCL_CHANNEL_VERSION_3 channels or later.
1585      */
1586     Tcl_DriverWideSeekProc *wideSeekProc;
1587                 /* Function to call to seek on the channel
1588                  * which can handle 64-bit offsets. May be
1589                  * NULL, and must be NULL if seekProc is
1590                  * NULL. */
1591     /*
1592      * Only valid in TCL_CHANNEL_VERSION_4 channels or later.
1593      * TIP #218, Channel Thread Actions.
1594      */
1595     Tcl_DriverThreadActionProc *threadActionProc;
1596                 /* Function to call to notify the driver of
1597                  * thread specific activity for a channel. May
1598                  * be NULL. */
1599     /*
1600      * Only valid in TCL_CHANNEL_VERSION_5 channels or later.
1601      * TIP #208, File Truncation.
1602      */
1603     Tcl_DriverTruncateProc *truncateProc;
1604                 /* Function to call to truncate the underlying
1605                  * file to a particular length. May be NULL if
1606                  * the channel does not support truncation. */
1607 } Tcl_ChannelType;
1608 
1609 /*
1610  * The following flags determine whether the blockModeProc above should set
1611  * the channel into blocking or nonblocking mode. They are passed as arguments
1612  * to the blockModeProc function in the above structure.
1613  */
1614 
1615 #define TCL_MODE_BLOCKING   0   /* Put channel into blocking mode. */
1616 #define TCL_MODE_NONBLOCKING    1   /* Put channel into nonblocking
1617                      * mode. */
1618 
1619 /*
1620  *----------------------------------------------------------------------------
1621  * Enum for different types of file paths.
1622  */
1623 
1624 typedef enum Tcl_PathType {
1625     TCL_PATH_ABSOLUTE,
1626     TCL_PATH_RELATIVE,
1627     TCL_PATH_VOLUME_RELATIVE
1628 } Tcl_PathType;
1629 
1630 /*
1631  * The following structure is used to pass glob type data amongst the various
1632  * glob routines and Tcl_FSMatchInDirectory.
1633  */
1634 
1635 typedef struct Tcl_GlobTypeData {
1636     int type;           /* Corresponds to bcdpfls as in 'find -t'. */
1637     int perm;           /* Corresponds to file permissions. */
1638     Tcl_Obj *macType;       /* Acceptable Mac type. */
1639     Tcl_Obj *macCreator;    /* Acceptable Mac creator. */
1640 } Tcl_GlobTypeData;
1641 
1642 /*
1643  * Type and permission definitions for glob command.
1644  */
1645 
1646 #define TCL_GLOB_TYPE_BLOCK     (1<<0)
1647 #define TCL_GLOB_TYPE_CHAR      (1<<1)
1648 #define TCL_GLOB_TYPE_DIR       (1<<2)
1649 #define TCL_GLOB_TYPE_PIPE      (1<<3)
1650 #define TCL_GLOB_TYPE_FILE      (1<<4)
1651 #define TCL_GLOB_TYPE_LINK      (1<<5)
1652 #define TCL_GLOB_TYPE_SOCK      (1<<6)
1653 #define TCL_GLOB_TYPE_MOUNT     (1<<7)
1654 
1655 #define TCL_GLOB_PERM_RONLY     (1<<0)
1656 #define TCL_GLOB_PERM_HIDDEN        (1<<1)
1657 #define TCL_GLOB_PERM_R         (1<<2)
1658 #define TCL_GLOB_PERM_W         (1<<3)
1659 #define TCL_GLOB_PERM_X         (1<<4)
1660 
1661 /*
1662  * Flags for the unload callback function.
1663  */
1664 
1665 #define TCL_UNLOAD_DETACH_FROM_INTERPRETER  (1<<0)
1666 #define TCL_UNLOAD_DETACH_FROM_PROCESS      (1<<1)
1667 
1668 /*
1669  * Typedefs for the various filesystem operations:
1670  */
1671 
1672 typedef int (Tcl_FSStatProc) (Tcl_Obj *pathPtr, Tcl_StatBuf *buf);
1673 typedef int (Tcl_FSAccessProc) (Tcl_Obj *pathPtr, int mode);
1674 typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) (Tcl_Interp *interp,
1675     Tcl_Obj *pathPtr, int mode, int permissions);
1676 typedef int (Tcl_FSMatchInDirectoryProc) (Tcl_Interp *interp, Tcl_Obj *result,
1677     Tcl_Obj *pathPtr, const char *pattern, Tcl_GlobTypeData *types);
1678 typedef Tcl_Obj * (Tcl_FSGetCwdProc) (Tcl_Interp *interp);
1679 typedef int (Tcl_FSChdirProc) (Tcl_Obj *pathPtr);
1680 typedef int (Tcl_FSLstatProc) (Tcl_Obj *pathPtr, Tcl_StatBuf *buf);
1681 typedef int (Tcl_FSCreateDirectoryProc) (Tcl_Obj *pathPtr);
1682 typedef int (Tcl_FSDeleteFileProc) (Tcl_Obj *pathPtr);
1683 typedef int (Tcl_FSCopyDirectoryProc) (Tcl_Obj *srcPathPtr,
1684     Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr);
1685 typedef int (Tcl_FSCopyFileProc) (Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr);
1686 typedef int (Tcl_FSRemoveDirectoryProc) (Tcl_Obj *pathPtr, int recursive,
1687     Tcl_Obj **errorPtr);
1688 typedef int (Tcl_FSRenameFileProc) (Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr);
1689 typedef void (Tcl_FSUnloadFileProc) (Tcl_LoadHandle loadHandle);
1690 typedef Tcl_Obj * (Tcl_FSListVolumesProc) (void);
1691 /* We have to declare the utime structure here. */
1692 struct utimbuf;
1693 typedef int (Tcl_FSUtimeProc) (Tcl_Obj *pathPtr, struct utimbuf *tval);
1694 typedef int (Tcl_FSNormalizePathProc) (Tcl_Interp *interp, Tcl_Obj *pathPtr,
1695     int nextCheckpoint);
1696 typedef int (Tcl_FSFileAttrsGetProc) (Tcl_Interp *interp, int index,
1697     Tcl_Obj *pathPtr, Tcl_Obj **objPtrRef);
1698 typedef const char *CONST86 * (Tcl_FSFileAttrStringsProc) (Tcl_Obj *pathPtr,
1699     Tcl_Obj **objPtrRef);
1700 typedef int (Tcl_FSFileAttrsSetProc) (Tcl_Interp *interp, int index,
1701     Tcl_Obj *pathPtr, Tcl_Obj *objPtr);
1702 typedef Tcl_Obj * (Tcl_FSLinkProc) (Tcl_Obj *pathPtr, Tcl_Obj *toPtr,
1703     int linkType);
1704 typedef int (Tcl_FSLoadFileProc) (Tcl_Interp *interp, Tcl_Obj *pathPtr,
1705     Tcl_LoadHandle *handlePtr, Tcl_FSUnloadFileProc **unloadProcPtr);
1706 typedef int (Tcl_FSPathInFilesystemProc) (Tcl_Obj *pathPtr,
1707     ClientData *clientDataPtr);
1708 typedef Tcl_Obj * (Tcl_FSFilesystemPathTypeProc) (Tcl_Obj *pathPtr);
1709 typedef Tcl_Obj * (Tcl_FSFilesystemSeparatorProc) (Tcl_Obj *pathPtr);
1710 typedef void (Tcl_FSFreeInternalRepProc) (ClientData clientData);
1711 typedef ClientData (Tcl_FSDupInternalRepProc) (ClientData clientData);
1712 typedef Tcl_Obj * (Tcl_FSInternalToNormalizedProc) (ClientData clientData);
1713 typedef ClientData (Tcl_FSCreateInternalRepProc) (Tcl_Obj *pathPtr);
1714 
1715 typedef struct Tcl_FSVersion_ *Tcl_FSVersion;
1716 
1717 /*
1718  *----------------------------------------------------------------------------
1719  * Data structures related to hooking into the filesystem
1720  */
1721 
1722 /*
1723  * Filesystem version tag.  This was introduced in 8.4.
1724  */
1725 
1726 #define TCL_FILESYSTEM_VERSION_1    ((Tcl_FSVersion) 0x1)
1727 
1728 /*
1729  * struct Tcl_Filesystem:
1730  *
1731  * One such structure exists for each type (kind) of filesystem. It collects
1732  * together the functions that form the interface for a particulr the
1733  * filesystem. Tcl always accesses the filesystem through one of these
1734  * structures.
1735  *
1736  * Not all entries need be non-NULL; any which are NULL are simply ignored.
1737  * However, a complete filesystem should provide all of these functions. The
1738  * explanations in the structure show the importance of each function.
1739  */
1740 
1741 typedef struct Tcl_Filesystem {
1742     const char *typeName;   /* The name of the filesystem. */
1743     int structureLength;    /* Length of this structure, so future binary
1744                  * compatibility can be assured. */
1745     Tcl_FSVersion version;  /* Version of the filesystem type. */
1746     Tcl_FSPathInFilesystemProc *pathInFilesystemProc;
1747                 /* Determines whether the pathname is in this
1748                  * filesystem. This is the most important
1749                  * filesystem function. */
1750     Tcl_FSDupInternalRepProc *dupInternalRepProc;
1751                 /* Duplicates the internal handle of the node.
1752                  * If it is NULL, the filesystem is less
1753                  * performant. */
1754     Tcl_FSFreeInternalRepProc *freeInternalRepProc;
1755                 /* Frees the internal handle of the node.  NULL
1756                  * only if there is no need to free resources
1757                  * used for the internal handle. */
1758     Tcl_FSInternalToNormalizedProc *internalToNormalizedProc;
1759                 /* Converts the internal handle to a normalized
1760                  * path.  NULL if the filesystem creates nodes
1761                  * having no pathname. */
1762     Tcl_FSCreateInternalRepProc *createInternalRepProc;
1763                 /* Creates an internal handle for a pathname.
1764                  * May be NULL if pathnames have no internal
1765                  * handle or if pathInFilesystemProc always
1766                  * immediately creates an internal
1767                  * representation for pathnames in the
1768                  * filesystem. */
1769     Tcl_FSNormalizePathProc *normalizePathProc;
1770                 /* Normalizes a path.  Should be implemented if
1771                  * the filesystems supports multiple paths to
1772                  * the same node. */
1773     Tcl_FSFilesystemPathTypeProc *filesystemPathTypeProc;
1774                 /* Determines the type of a path in this
1775                  * filesystem. May be NULL. */
1776     Tcl_FSFilesystemSeparatorProc *filesystemSeparatorProc;
1777                 /* Produces the separator character(s) for this
1778                  * filesystem. Must not be NULL. */
1779     Tcl_FSStatProc *statProc;   /* Called by 'Tcl_FSStat()'.  Provided by any
1780                  * reasonable filesystem. */
1781     Tcl_FSAccessProc *accessProc;
1782                 /* Called by 'Tcl_FSAccess()'.  Implemented by
1783                  * any reasonable filesystem. */
1784     Tcl_FSOpenFileChannelProc *openFileChannelProc;
1785                 /* Called by 'Tcl_FSOpenFileChannel()'.
1786                  * Provided by any reasonable filesystem. */
1787     Tcl_FSMatchInDirectoryProc *matchInDirectoryProc;
1788                 /* Called by 'Tcl_FSMatchInDirectory()'.  NULL
1789                  * if the filesystem does not support glob or
1790                  * recursive copy. */
1791     Tcl_FSUtimeProc *utimeProc; /* Called by 'Tcl_FSUtime()', by 'file
1792                  *  mtime' to set (not read) times, 'file
1793                  *  atime', and the open-r/open-w/fcopy variant
1794                  *  of 'file copy'. */
1795     Tcl_FSLinkProc *linkProc;   /* Called by 'Tcl_FSLink()'. NULL if reading or
1796                  *  creating links is not supported. */
1797     Tcl_FSListVolumesProc *listVolumesProc;
1798                 /* Lists filesystem volumes added by this
1799                  * filesystem. NULL if the filesystem does not
1800                  * use volumes. */
1801     Tcl_FSFileAttrStringsProc *fileAttrStringsProc;
1802                 /* List all valid attributes strings.  NULL if
1803                  * the filesystem does not support the 'file
1804                  * attributes' command.  Can be used to attach
1805                  * arbitrary additional data to files in a
1806                  * filesystem. */
1807     Tcl_FSFileAttrsGetProc *fileAttrsGetProc;
1808                 /* Called by 'Tcl_FSFileAttrsGet()' and by
1809                  * 'file attributes'. */
1810     Tcl_FSFileAttrsSetProc *fileAttrsSetProc;
1811                 /* Called by 'Tcl_FSFileAttrsSet()' and by
1812                  * 'file attributes'.  */
1813     Tcl_FSCreateDirectoryProc *createDirectoryProc;
1814                 /* Called by 'Tcl_FSCreateDirectory()'.  May be
1815                  * NULL if the filesystem is read-only. */
1816     Tcl_FSRemoveDirectoryProc *removeDirectoryProc;
1817                 /* Called by 'Tcl_FSRemoveDirectory()'.  May be
1818                  * NULL if the filesystem is read-only. */
1819     Tcl_FSDeleteFileProc *deleteFileProc;
1820                 /* Called by 'Tcl_FSDeleteFile()' May be NULL
1821                  * if the filesystem is is read-only. */
1822     Tcl_FSCopyFileProc *copyFileProc;
1823                 /* Called by 'Tcl_FSCopyFile()'.  If NULL, for
1824                  * a copy operation at the script level (not
1825                  * C) Tcl uses open-r, open-w and fcopy. */
1826     Tcl_FSRenameFileProc *renameFileProc;
1827                 /* Called by 'Tcl_FSRenameFile()'. If NULL, for
1828                  * a rename operation at the script level (not
1829                  * C) Tcl performs a copy operation followed
1830                  * by a delete operation. */
1831     Tcl_FSCopyDirectoryProc *copyDirectoryProc;
1832                 /* Called by 'Tcl_FSCopyDirectory()'. If NULL,
1833                  * for a copy operation at the script level
1834                  * (not C) Tcl recursively creates directories
1835                  * and copies files. */
1836     Tcl_FSLstatProc *lstatProc; /* Called by 'Tcl_FSLstat()'. If NULL, Tcl
1837                  * attempts to use 'statProc' instead. */
1838     Tcl_FSLoadFileProc *loadFileProc;
1839                 /* Called by 'Tcl_FSLoadFile()'. If NULL, Tcl
1840                  * performs a copy to a temporary file in the
1841                  * native filesystem and then calls
1842                  * Tcl_FSLoadFile() on that temporary copy. */
1843     Tcl_FSGetCwdProc *getCwdProc;
1844                 /* Called by 'Tcl_FSGetCwd()'.  Normally NULL.
1845                  * Usually only called once:  If 'getcwd' is
1846                  * called before 'chdir' is ever called. */
1847     Tcl_FSChdirProc *chdirProc; /* Called by 'Tcl_FSChdir()'.  For a virtual
1848                  * filesystem, chdirProc just returns zero
1849                  * (success) if the pathname is a valid
1850                  * directory, and some other value otherwise.
1851                  * For A real filesystem, chdirProc performs
1852                  * the correct action, e.g.  calls the system
1853                  * 'chdir' function. If not implemented, then
1854                  * 'cd' and 'pwd' fail for a pathname in this
1855                  * filesystem. On success Tcl stores the
1856                  * pathname for use by GetCwd.  If NULL, Tcl
1857                  * performs records the pathname as the new
1858                  * current directory if it passes a series of
1859                  * directory access checks. */
1860 } Tcl_Filesystem;
1861 
1862 /*
1863  * The following definitions are used as values for the 'linkAction' flag to
1864  * Tcl_FSLink, or the linkProc of any filesystem. Any combination of flags can
1865  * be given. For link creation, the linkProc should create a link which
1866  * matches any of the types given.
1867  *
1868  * TCL_CREATE_SYMBOLIC_LINK -   Create a symbolic or soft link.
1869  * TCL_CREATE_HARD_LINK -   Create a hard link.
1870  */
1871 
1872 #define TCL_CREATE_SYMBOLIC_LINK    0x01
1873 #define TCL_CREATE_HARD_LINK        0x02
1874 
1875 /*
1876  *----------------------------------------------------------------------------
1877  * The following structure represents the Notifier functions that you can
1878  * override with the Tcl_SetNotifier call.
1879  */
1880 
1881 typedef struct Tcl_NotifierProcs {
1882     Tcl_SetTimerProc *setTimerProc;
1883     Tcl_WaitForEventProc *waitForEventProc;
1884     Tcl_CreateFileHandlerProc *createFileHandlerProc;
1885     Tcl_DeleteFileHandlerProc *deleteFileHandlerProc;
1886     Tcl_InitNotifierProc *initNotifierProc;
1887     Tcl_FinalizeNotifierProc *finalizeNotifierProc;
1888     Tcl_AlertNotifierProc *alertNotifierProc;
1889     Tcl_ServiceModeHookProc *serviceModeHookProc;
1890 } Tcl_NotifierProcs;
1891 
1892 /*
1893  *----------------------------------------------------------------------------
1894  * The following data structures and declarations are for the new Tcl parser.
1895  *
1896  * For each word of a command, and for each piece of a word such as a variable
1897  * reference, one of the following structures is created to describe the
1898  * token.
1899  */
1900 
1901 typedef struct Tcl_Token {
1902     int type;           /* Type of token, such as TCL_TOKEN_WORD; see
1903                  * below for valid types. */
1904     const char *start;      /* First character in token. */
1905     int size;           /* Number of bytes in token. */
1906     int numComponents;      /* If this token is composed of other tokens,
1907                  * this field tells how many of them there are
1908                  * (including components of components, etc.).
1909                  * The component tokens immediately follow
1910                  * this one. */
1911 } Tcl_Token;
1912 
1913 /*
1914  * Type values defined for Tcl_Token structures. These values are defined as
1915  * mask bits so that it's easy to check for collections of types.
1916  *
1917  * TCL_TOKEN_WORD -     The token describes one word of a command,
1918  *              from the first non-blank character of the word
1919  *              (which may be " or {) up to but not including
1920  *              the space, semicolon, or bracket that
1921  *              terminates the word. NumComponents counts the
1922  *              total number of sub-tokens that make up the
1923  *              word. This includes, for example, sub-tokens
1924  *              of TCL_TOKEN_VARIABLE tokens.
1925  * TCL_TOKEN_SIMPLE_WORD -  This token is just like TCL_TOKEN_WORD except
1926  *              that the word is guaranteed to consist of a
1927  *              single TCL_TOKEN_TEXT sub-token.
1928  * TCL_TOKEN_TEXT -     The token describes a range of literal text
1929  *              that is part of a word. NumComponents is
1930  *              always 0.
1931  * TCL_TOKEN_BS -       The token describes a backslash sequence that
1932  *              must be collapsed. NumComponents is always 0.
1933  * TCL_TOKEN_COMMAND -      The token describes a command whose result
1934  *              must be substituted into the word. The token
1935  *              includes the enclosing brackets. NumComponents
1936  *              is always 0.
1937  * TCL_TOKEN_VARIABLE -     The token describes a variable substitution,
1938  *              including the dollar sign, variable name, and
1939  *              array index (if there is one) up through the
1940  *              right parentheses. NumComponents tells how
1941  *              many additional tokens follow to represent the
1942  *              variable name. The first token will be a
1943  *              TCL_TOKEN_TEXT token that describes the
1944  *              variable name. If the variable is an array
1945  *              reference then there will be one or more
1946  *              additional tokens, of type TCL_TOKEN_TEXT,
1947  *              TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and
1948  *              TCL_TOKEN_VARIABLE, that describe the array
1949  *              index; numComponents counts the total number
1950  *              of nested tokens that make up the variable
1951  *              reference, including sub-tokens of
1952  *              TCL_TOKEN_VARIABLE tokens.
1953  * TCL_TOKEN_SUB_EXPR -     The token describes one subexpression of an
1954  *              expression, from the first non-blank character
1955  *              of the subexpression up to but not including
1956  *              the space, brace, or bracket that terminates
1957  *              the subexpression. NumComponents counts the
1958  *              total number of following subtokens that make
1959  *              up the subexpression; this includes all
1960  *              subtokens for any nested TCL_TOKEN_SUB_EXPR
1961  *              tokens. For example, a numeric value used as a
1962  *              primitive operand is described by a
1963  *              TCL_TOKEN_SUB_EXPR token followed by a
1964  *              TCL_TOKEN_TEXT token. A binary subexpression
1965  *              is described by a TCL_TOKEN_SUB_EXPR token
1966  *              followed by the TCL_TOKEN_OPERATOR token for
1967  *              the operator, then TCL_TOKEN_SUB_EXPR tokens
1968  *              for the left then the right operands.
1969  * TCL_TOKEN_OPERATOR -     The token describes one expression operator.
1970  *              An operator might be the name of a math
1971  *              function such as "abs". A TCL_TOKEN_OPERATOR
1972  *              token is always preceded by one
1973  *              TCL_TOKEN_SUB_EXPR token for the operator's
1974  *              subexpression, and is followed by zero or more
1975  *              TCL_TOKEN_SUB_EXPR tokens for the operator's
1976  *              operands. NumComponents is always 0.
1977  * TCL_TOKEN_EXPAND_WORD -  This token is just like TCL_TOKEN_WORD except
1978  *              that it marks a word that began with the
1979  *              literal character prefix "{*}". This word is
1980  *              marked to be expanded - that is, broken into
1981  *              words after substitution is complete.
1982  */
1983 
1984 #define TCL_TOKEN_WORD      1
1985 #define TCL_TOKEN_SIMPLE_WORD   2
1986 #define TCL_TOKEN_TEXT      4
1987 #define TCL_TOKEN_BS        8
1988 #define TCL_TOKEN_COMMAND   16
1989 #define TCL_TOKEN_VARIABLE  32
1990 #define TCL_TOKEN_SUB_EXPR  64
1991 #define TCL_TOKEN_OPERATOR  128
1992 #define TCL_TOKEN_EXPAND_WORD   256
1993 
1994 /*
1995  * Parsing error types. On any parsing error, one of these values will be
1996  * stored in the error field of the Tcl_Parse structure defined below.
1997  */
1998 
1999 #define TCL_PARSE_SUCCESS       0
2000 #define TCL_PARSE_QUOTE_EXTRA       1
2001 #define TCL_PARSE_BRACE_EXTRA       2
2002 #define TCL_PARSE_MISSING_BRACE     3
2003 #define TCL_PARSE_MISSING_BRACKET   4
2004 #define TCL_PARSE_MISSING_PAREN     5
2005 #define TCL_PARSE_MISSING_QUOTE     6
2006 #define TCL_PARSE_MISSING_VAR_BRACE 7
2007 #define TCL_PARSE_SYNTAX        8
2008 #define TCL_PARSE_BAD_NUMBER        9
2009 
2010 /*
2011  * A structure of the following type is filled in by Tcl_ParseCommand. It
2012  * describes a single command parsed from an input string.
2013  */
2014 
2015 #define NUM_STATIC_TOKENS 20
2016 
2017 typedef struct Tcl_Parse {
2018     const char *commentStart;   /* Pointer to # that begins the first of one
2019                  * or more comments preceding the command. */
2020     int commentSize;        /* Number of bytes in comments (up through
2021                  * newline character that terminates the last
2022                  * comment). If there were no comments, this
2023                  * field is 0. */
2024     const char *commandStart;   /* First character in first word of
2025                  * command. */
2026     int commandSize;        /* Number of bytes in command, including first
2027                  * character of first word, up through the
2028                  * terminating newline, close bracket, or
2029                  * semicolon. */
2030     int numWords;       /* Total number of words in command. May be
2031                  * 0. */
2032     Tcl_Token *tokenPtr;    /* Pointer to first token representing the
2033                  * words of the command. Initially points to
2034                  * staticTokens, but may change to point to
2035                  * malloc-ed space if command exceeds space in
2036                  * staticTokens. */
2037     int numTokens;      /* Total number of tokens in command. */
2038     int tokensAvailable;    /* Total number of tokens available at
2039                  * *tokenPtr. */
2040     int errorType;      /* One of the parsing error types defined
2041                  * above. */
2042 
2043     /*
2044      * The fields below are intended only for the private use of the parser.
2045      * They should not be used by functions that invoke Tcl_ParseCommand.
2046      */
2047 
2048     const char *string;     /* The original command string passed to
2049                  * Tcl_ParseCommand. */
2050     const char *end;        /* Points to the character just after the last
2051                  * one in the command string. */
2052     Tcl_Interp *interp;     /* Interpreter to use for error reporting, or
2053                  * NULL. */
2054     const char *term;       /* Points to character in string that
2055                  * terminated most recent token. Filled in by
2056                  * ParseTokens. If an error occurs, points to
2057                  * beginning of region where the error
2058                  * occurred (e.g. the open brace if the close
2059                  * brace is missing). */
2060     int incomplete;     /* This field is set to 1 by Tcl_ParseCommand
2061                  * if the command appears to be incomplete.
2062                  * This information is used by
2063                  * Tcl_CommandComplete. */
2064     Tcl_Token staticTokens[NUM_STATIC_TOKENS];
2065                 /* Initial space for tokens for command. This
2066                  * space should be large enough to accommodate
2067                  * most commands; dynamic space is allocated
2068                  * for very large commands that don't fit
2069                  * here. */
2070 } Tcl_Parse;
2071 
2072 /*
2073  *----------------------------------------------------------------------------
2074  * The following structure represents a user-defined encoding. It collects
2075  * together all the functions that are used by the specific encoding.
2076  */
2077 
2078 typedef struct Tcl_EncodingType {
2079     const char *encodingName;   /* The name of the encoding, e.g. "euc-jp".
2080                  * This name is the unique key for this
2081                  * encoding type. */
2082     Tcl_EncodingConvertProc *toUtfProc;
2083                 /* Function to convert from external encoding
2084                  * into UTF-8. */
2085     Tcl_EncodingConvertProc *fromUtfProc;
2086                 /* Function to convert from UTF-8 into
2087                  * external encoding. */
2088     Tcl_EncodingFreeProc *freeProc;
2089                 /* If non-NULL, function to call when this
2090                  * encoding is deleted. */
2091     ClientData clientData;  /* Arbitrary value associated with encoding
2092                  * type. Passed to conversion functions. */
2093     int nullSize;       /* Number of zero bytes that signify
2094                  * end-of-string in this encoding. This number
2095                  * is used to determine the source string
2096                  * length when the srcLen argument is
2097                  * negative. Must be 1 or 2. */
2098 } Tcl_EncodingType;
2099 
2100 /*
2101  * The following definitions are used as values for the conversion control
2102  * flags argument when converting text from one character set to another:
2103  *
2104  * TCL_ENCODING_START -     Signifies that the source buffer is the first
2105  *              block in a (potentially multi-block) input
2106  *              stream. Tells the conversion function to reset
2107  *              to an initial state and perform any
2108  *              initialization that needs to occur before the
2109  *              first byte is converted. If the source buffer
2110  *              contains the entire input stream to be
2111  *              converted, this flag should be set.
2112  * TCL_ENCODING_END -       Signifies that the source buffer is the last
2113  *              block in a (potentially multi-block) input
2114  *              stream. Tells the conversion routine to
2115  *              perform any finalization that needs to occur
2116  *              after the last byte is converted and then to
2117  *              reset to an initial state. If the source
2118  *              buffer contains the entire input stream to be
2119  *              converted, this flag should be set.
2120  * TCL_ENCODING_STOPONERROR -   If set, the converter returns immediately upon
2121  *              encountering an invalid byte sequence or a
2122  *              source character that has no mapping in the
2123  *              target encoding. If clear, the converter
2124  *              substitues the problematic character(s) with
2125  *              one or more "close" characters in the
2126  *              destination buffer and then continues to
2127  *              convert the source.
2128  * TCL_ENCODING_NO_TERMINATE -  If set, Tcl_ExternalToUtf does not append a
2129  *              terminating NUL byte.  Since it does not need
2130  *              an extra byte for a terminating NUL, it fills
2131  *              all dstLen bytes with encoded UTF-8 content if
2132  *              needed.  If clear, a byte is reserved in the
2133  *              dst space for NUL termination, and a
2134  *              terminating NUL is appended.
2135  * TCL_ENCODING_CHAR_LIMIT -    If set and dstCharsPtr is not NULL, then
2136  *              Tcl_ExternalToUtf takes the initial value of
2137  *              *dstCharsPtr as a limit of the maximum number
2138  *              of chars to produce in the encoded UTF-8
2139  *              content.  Otherwise, the number of chars
2140  *              produced is controlled only by other limiting
2141  *              factors.
2142  */
2143 
2144 #define TCL_ENCODING_START      0x01
2145 #define TCL_ENCODING_END        0x02
2146 #define TCL_ENCODING_STOPONERROR    0x04
2147 #define TCL_ENCODING_NO_TERMINATE   0x08
2148 #define TCL_ENCODING_CHAR_LIMIT     0x10
2149 
2150 /*
2151  * The following definitions are the error codes returned by the conversion
2152  * routines:
2153  *
2154  * TCL_OK -         All characters were converted.
2155  * TCL_CONVERT_NOSPACE -    The output buffer would not have been large
2156  *              enough for all of the converted data; as many
2157  *              characters as could fit were converted though.
2158  * TCL_CONVERT_MULTIBYTE -  The last few bytes in the source string were
2159  *              the beginning of a multibyte sequence, but
2160  *              more bytes were needed to complete this
2161  *              sequence. A subsequent call to the conversion
2162  *              routine should pass the beginning of this
2163  *              unconverted sequence plus additional bytes
2164  *              from the source stream to properly convert the
2165  *              formerly split-up multibyte sequence.
2166  * TCL_CONVERT_SYNTAX -     The source stream contained an invalid
2167  *              character sequence. This may occur if the
2168  *              input stream has been damaged or if the input
2169  *              encoding method was misidentified. This error
2170  *              is reported only if TCL_ENCODING_STOPONERROR
2171  *              was specified.
2172  * TCL_CONVERT_UNKNOWN -    The source string contained a character that
2173  *              could not be represented in the target
2174  *              encoding. This error is reported only if
2175  *              TCL_ENCODING_STOPONERROR was specified.
2176  */
2177 
2178 #define TCL_CONVERT_MULTIBYTE   (-1)
2179 #define TCL_CONVERT_SYNTAX  (-2)
2180 #define TCL_CONVERT_UNKNOWN (-3)
2181 #define TCL_CONVERT_NOSPACE (-4)
2182 
2183 /*
2184  * The maximum number of bytes that are necessary to represent a single
2185  * Unicode character in UTF-8. The valid values should be 3, 4 or 6
2186  * (or perhaps 1 if we want to support a non-unicode enabled core). If 3 or
2187  * 4, then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If 6,
2188  * then Tcl_UniChar must be 4-bytes in size (UCS-4). At this time UCS-2 mode
2189  * is the default and recommended mode. UCS-4 is experimental and not
2190  * recommended. It works for the core, but most extensions expect UCS-2.
2191  */
2192 
2193 #ifndef TCL_UTF_MAX
2194 #define TCL_UTF_MAX     3
2195 #endif
2196 
2197 /*
2198  * This represents a Unicode character. Any changes to this should also be
2199  * reflected in regcustom.h.
2200  */
2201 
2202 #if TCL_UTF_MAX > 4
2203     /*
2204      * unsigned int isn't 100% accurate as it should be a strict 4-byte value.
2205      * The size of this value must be reflected correctly in regcustom.h.
2206      * XXX: Tcl is currently UCS-2 and planning UTF-16 for the Unicode
2207      * XXX: string rep that Tcl_UniChar represents.  Changing the size
2208      * XXX: of Tcl_UniChar is /not/ supported.
2209      */
2210 typedef unsigned int Tcl_UniChar;
2211 #else
2212 typedef unsigned short Tcl_UniChar;
2213 #endif
2214 
2215 /*
2216  *----------------------------------------------------------------------------
2217  * TIP #59: The following structure is used in calls 'Tcl_RegisterConfig' to
2218  * provide the system with the embedded configuration data.
2219  */
2220 
2221 typedef struct Tcl_Config {
2222     const char *key;        /* Configuration key to register. ASCII
2223                  * encoded, thus UTF-8. */
2224     const char *value;      /* The value associated with the key. System
2225                  * encoding. */
2226 } Tcl_Config;
2227 
2228 /*
2229  *----------------------------------------------------------------------------
2230  * Flags for TIP#143 limits, detailing which limits are active in an
2231  * interpreter. Used for Tcl_{Add,Remove}LimitHandler type argument.
2232  */
2233 
2234 #define TCL_LIMIT_COMMANDS  0x01
2235 #define TCL_LIMIT_TIME      0x02
2236 
2237 /*
2238  * Structure containing information about a limit handler to be called when a
2239  * command- or time-limit is exceeded by an interpreter.
2240  */
2241 
2242 typedef void (Tcl_LimitHandlerProc) (ClientData clientData, Tcl_Interp *interp);
2243 typedef void (Tcl_LimitHandlerDeleteProc) (ClientData clientData);
2244 
2245 /*
2246  *----------------------------------------------------------------------------
2247  * Override definitions for libtommath.
2248  */
2249 
2250 typedef struct mp_int mp_int;
2251 #define MP_INT_DECLARED
2252 typedef unsigned int mp_digit;
2253 #define MP_DIGIT_DECLARED
2254 
2255 /*
2256  *----------------------------------------------------------------------------
2257  * Definitions needed for Tcl_ParseArgvObj routines.
2258  * Based on tkArgv.c.
2259  * Modifications from the original are copyright (c) Sam Bromley 2006
2260  */
2261 
2262 typedef struct {
2263     int type;           /* Indicates the option type; see below. */
2264     const char *keyStr;     /* The key string that flags the option in the
2265                  * argv array. */
2266     void *srcPtr;       /* Value to be used in setting dst; usage
2267                  * depends on type.*/
2268     void *dstPtr;       /* Address of value to be modified; usage
2269                  * depends on type.*/
2270     const char *helpStr;    /* Documentation message describing this
2271                  * option. */
2272     ClientData clientData;  /* Word to pass to function callbacks. */
2273 } Tcl_ArgvInfo;
2274 
2275 /*
2276  * Legal values for the type field of a Tcl_ArgInfo: see the user
2277  * documentation for details.
2278  */
2279 
2280 #define TCL_ARGV_CONSTANT   15
2281 #define TCL_ARGV_INT        16
2282 #define TCL_ARGV_STRING     17
2283 #define TCL_ARGV_REST       18
2284 #define TCL_ARGV_FLOAT      19
2285 #define TCL_ARGV_FUNC       20
2286 #define TCL_ARGV_GENFUNC    21
2287 #define TCL_ARGV_HELP       22
2288 #define TCL_ARGV_END        23
2289 
2290 /*
2291  * Types of callback functions for the TCL_ARGV_FUNC and TCL_ARGV_GENFUNC
2292  * argument types:
2293  */
2294 
2295 typedef int (Tcl_ArgvFuncProc)(ClientData clientData, Tcl_Obj *objPtr,
2296     void *dstPtr);
2297 typedef int (Tcl_ArgvGenFuncProc)(ClientData clientData, Tcl_Interp *interp,
2298     int objc, Tcl_Obj *const *objv, void *dstPtr);
2299 
2300 /*
2301  * Shorthand for commonly used argTable entries.
2302  */
2303 
2304 #define TCL_ARGV_AUTO_HELP \
2305     {TCL_ARGV_HELP, "-help",    NULL,   NULL, \
2306         "Print summary of command-line options and abort", NULL}
2307 #define TCL_ARGV_AUTO_REST \
2308     {TCL_ARGV_REST, "--",       NULL,   NULL, \
2309         "Marks the end of the options", NULL}
2310 #define TCL_ARGV_TABLE_END \
2311     {TCL_ARGV_END, NULL, NULL, NULL, NULL, NULL}
2312 
2313 /*
2314  *----------------------------------------------------------------------------
2315  * Definitions needed for Tcl_Zlib routines. [TIP #234]
2316  *
2317  * Constants for the format flags describing what sort of data format is
2318  * desired/expected for the Tcl_ZlibDeflate, Tcl_ZlibInflate and
2319  * Tcl_ZlibStreamInit functions.
2320  */
2321 
2322 #define TCL_ZLIB_FORMAT_RAW 1
2323 #define TCL_ZLIB_FORMAT_ZLIB    2
2324 #define TCL_ZLIB_FORMAT_GZIP    4
2325 #define TCL_ZLIB_FORMAT_AUTO    8
2326 
2327 /*
2328  * Constants that describe whether the stream is to operate in compressing or
2329  * decompressing mode.
2330  */
2331 
2332 #define TCL_ZLIB_STREAM_DEFLATE 16
2333 #define TCL_ZLIB_STREAM_INFLATE 32
2334 
2335 /*
2336  * Constants giving compression levels. Use of TCL_ZLIB_COMPRESS_DEFAULT is
2337  * recommended.
2338  */
2339 
2340 #define TCL_ZLIB_COMPRESS_NONE  0
2341 #define TCL_ZLIB_COMPRESS_FAST  1
2342 #define TCL_ZLIB_COMPRESS_BEST  9
2343 #define TCL_ZLIB_COMPRESS_DEFAULT (-1)
2344 
2345 /*
2346  * Constants for types of flushing, used with Tcl_ZlibFlush.
2347  */
2348 
2349 #define TCL_ZLIB_NO_FLUSH   0
2350 #define TCL_ZLIB_FLUSH      2
2351 #define TCL_ZLIB_FULLFLUSH  3
2352 #define TCL_ZLIB_FINALIZE   4
2353 
2354 /*
2355  *----------------------------------------------------------------------------
2356  * Definitions needed for the Tcl_LoadFile function. [TIP #416]
2357  */
2358 
2359 #define TCL_LOAD_GLOBAL 1
2360 #define TCL_LOAD_LAZY 2
2361 
2362 /*
2363  *----------------------------------------------------------------------------
2364  * Single public declaration for NRE.
2365  */
2366 
2367 typedef int (Tcl_NRPostProc) (ClientData data[], Tcl_Interp *interp,
2368                 int result);
2369 
2370 /*
2371  *----------------------------------------------------------------------------
2372  * The following constant is used to test for older versions of Tcl in the
2373  * stubs tables.
2374  */
2375 
2376 #define TCL_STUB_MAGIC      ((int) 0xFCA3BACF)
2377 
2378 /*
2379  * The following function is required to be defined in all stubs aware
2380  * extensions. The function is actually implemented in the stub library, not
2381  * the main Tcl library, although there is a trivial implementation in the
2382  * main library in case an extension is statically linked into an application.
2383  */
2384 
2385 const char *        Tcl_InitStubs(Tcl_Interp *interp, const char *version,
2386                 int exact);
2387 const char *        TclTomMathInitializeStubs(Tcl_Interp *interp,
2388                 const char *version, int epoch, int revision);
2389 
2390 /*
2391  * When not using stubs, make it a macro.
2392  */
2393 
2394 #ifndef USE_TCL_STUBS
2395 #define Tcl_InitStubs(interp, version, exact) \
2396     Tcl_PkgInitStubsCheck(interp, version, exact)
2397 #endif
2398 
2399 /*
2400  * Public functions that are not accessible via the stubs table.
2401  * Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171]
2402  */
2403 
2404 #define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \
2405         ((Tcl_CreateInterp)()))
2406 EXTERN void     Tcl_MainEx(int argc, char **argv,
2407                 Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
2408 EXTERN const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp,
2409                 const char *version, int exact);
2410 EXTERN void     Tcl_GetMemoryInfo(Tcl_DString *dsPtr);
2411 
2412 /*
2413  *----------------------------------------------------------------------------
2414  * Include the public function declarations that are accessible via the stubs
2415  * table.
2416  */
2417 
2418 #include "tclDecls.h"
2419 
2420 /*
2421  * Include platform specific public function declarations that are accessible
2422  * via the stubs table. Make all TclOO symbols MODULE_SCOPE (which only
2423  * has effect on building it as a shared library). See ticket [3010352].
2424  */
2425 
2426 #if defined(BUILD_tcl)
2427 #   undef TCLAPI
2428 #   define TCLAPI MODULE_SCOPE
2429 #endif
2430 
2431 #include "tclPlatDecls.h"
2432 
2433 /*
2434  *----------------------------------------------------------------------------
2435  * The following declarations either map ckalloc and ckfree to malloc and
2436  * free, or they map them to functions with all sorts of debugging hooks
2437  * defined in tclCkalloc.c.
2438  */
2439 
2440 #ifdef TCL_MEM_DEBUG
2441 
2442 #   define ckalloc(x) \
2443     ((void *) Tcl_DbCkalloc((unsigned)(x), __FILE__, __LINE__))
2444 #   define ckfree(x) \
2445     Tcl_DbCkfree((char *)(x), __FILE__, __LINE__)
2446 #   define ckrealloc(x,y) \
2447     ((void *) Tcl_DbCkrealloc((char *)(x), (unsigned)(y), __FILE__, __LINE__))
2448 #   define attemptckalloc(x) \
2449     ((void *) Tcl_AttemptDbCkalloc((unsigned)(x), __FILE__, __LINE__))
2450 #   define attemptckrealloc(x,y) \
2451     ((void *) Tcl_AttemptDbCkrealloc((char *)(x), (unsigned)(y), __FILE__, __LINE__))
2452 
2453 #else /* !TCL_MEM_DEBUG */
2454 
2455 /*
2456  * If we are not using the debugging allocator, we should call the Tcl_Alloc,
2457  * et al. routines in order to guarantee that every module is using the same
2458  * memory allocator both inside and outside of the Tcl library.
2459  */
2460 
2461 #   define ckalloc(x) \
2462     ((void *) Tcl_Alloc((unsigned)(x)))
2463 #   define ckfree(x) \
2464     Tcl_Free((char *)(x))
2465 #   define ckrealloc(x,y) \
2466     ((void *) Tcl_Realloc((char *)(x), (unsigned)(y)))
2467 #   define attemptckalloc(x) \
2468     ((void *) Tcl_AttemptAlloc((unsigned)(x)))
2469 #   define attemptckrealloc(x,y) \
2470     ((void *) Tcl_AttemptRealloc((char *)(x), (unsigned)(y)))
2471 #   undef  Tcl_InitMemory
2472 #   define Tcl_InitMemory(x)
2473 #   undef  Tcl_DumpActiveMemory
2474 #   define Tcl_DumpActiveMemory(x)
2475 #   undef  Tcl_ValidateAllMemory
2476 #   define Tcl_ValidateAllMemory(x,y)
2477 
2478 #endif /* !TCL_MEM_DEBUG */
2479 
2480 #ifdef TCL_MEM_DEBUG
2481 #   define Tcl_IncrRefCount(objPtr) \
2482     Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__)
2483 #   define Tcl_DecrRefCount(objPtr) \
2484     Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
2485 #   define Tcl_IsShared(objPtr) \
2486     Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
2487 #else
2488 #   define Tcl_IncrRefCount(objPtr) \
2489     ++(objPtr)->refCount
2490     /*
2491      * Use do/while0 idiom for optimum correctness without compiler warnings.
2492      * https://wiki.c2.com/?TrivialDoWhileLoop
2493      */
2494 #   define Tcl_DecrRefCount(objPtr) \
2495     do { \
2496         Tcl_Obj *_objPtr = (objPtr); \
2497         if (_objPtr->refCount-- <= 1) { \
2498         TclFreeObj(_objPtr); \
2499         } \
2500     } while(0)
2501 #   define Tcl_IsShared(objPtr) \
2502     ((objPtr)->refCount > 1)
2503 #endif
2504 
2505 /*
2506  * Macros and definitions that help to debug the use of Tcl objects. When
2507  * TCL_MEM_DEBUG is defined, the Tcl_New declarations are overridden to call
2508  * debugging versions of the object creation functions.
2509  */
2510 
2511 #ifdef TCL_MEM_DEBUG
2512 #  undef  Tcl_NewBignumObj
2513 #  define Tcl_NewBignumObj(val) \
2514      Tcl_DbNewBignumObj(val, __FILE__, __LINE__)
2515 #  undef  Tcl_NewBooleanObj
2516 #  define Tcl_NewBooleanObj(val) \
2517      Tcl_DbNewBooleanObj(val, __FILE__, __LINE__)
2518 #  undef  Tcl_NewByteArrayObj
2519 #  define Tcl_NewByteArrayObj(bytes, len) \
2520      Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__)
2521 #  undef  Tcl_NewDoubleObj
2522 #  define Tcl_NewDoubleObj(val) \
2523      Tcl_DbNewDoubleObj(val, __FILE__, __LINE__)
2524 #  undef  Tcl_NewIntObj
2525 #  define Tcl_NewIntObj(val) \
2526      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
2527 #  undef  Tcl_NewListObj
2528 #  define Tcl_NewListObj(objc, objv) \
2529      Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__)
2530 #  undef  Tcl_NewLongObj
2531 #  define Tcl_NewLongObj(val) \
2532      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
2533 #  undef  Tcl_NewObj
2534 #  define Tcl_NewObj() \
2535      Tcl_DbNewObj(__FILE__, __LINE__)
2536 #  undef  Tcl_NewStringObj
2537 #  define Tcl_NewStringObj(bytes, len) \
2538      Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__)
2539 #  undef  Tcl_NewWideIntObj
2540 #  define Tcl_NewWideIntObj(val) \
2541      Tcl_DbNewWideIntObj(val, __FILE__, __LINE__)
2542 #endif /* TCL_MEM_DEBUG */
2543 
2544 /*
2545  *----------------------------------------------------------------------------
2546  * Macros for clients to use to access fields of hash entries:
2547  */
2548 
2549 #define Tcl_GetHashValue(h) ((h)->clientData)
2550 #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))
2551 #define Tcl_GetHashKey(tablePtr, h) \
2552     ((void *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \
2553             (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \
2554            ? (h)->key.oneWordValue \
2555            : (h)->key.string))
2556 
2557 /*
2558  * Macros to use for clients to use to invoke find and create functions for
2559  * hash tables:
2560  */
2561 
2562 #undef  Tcl_FindHashEntry
2563 #define Tcl_FindHashEntry(tablePtr, key) \
2564     (*((tablePtr)->findProc))(tablePtr, (const char *)(key))
2565 #undef  Tcl_CreateHashEntry
2566 #define Tcl_CreateHashEntry(tablePtr, key, newPtr) \
2567     (*((tablePtr)->createProc))(tablePtr, (const char *)(key), newPtr)
2568 
2569 /*
2570  *----------------------------------------------------------------------------
2571  * Macros that eliminate the overhead of the thread synchronization functions
2572  * when compiling without thread support.
2573  */
2574 
2575 #ifndef TCL_THREADS
2576 #undef  Tcl_MutexLock
2577 #define Tcl_MutexLock(mutexPtr)
2578 #undef  Tcl_MutexUnlock
2579 #define Tcl_MutexUnlock(mutexPtr)
2580 #undef  Tcl_MutexFinalize
2581 #define Tcl_MutexFinalize(mutexPtr)
2582 #undef  Tcl_ConditionNotify
2583 #define Tcl_ConditionNotify(condPtr)
2584 #undef  Tcl_ConditionWait
2585 #define Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
2586 #undef  Tcl_ConditionFinalize
2587 #define Tcl_ConditionFinalize(condPtr)
2588 #endif /* TCL_THREADS */
2589 
2590 /*
2591  *----------------------------------------------------------------------------
2592  * Deprecated Tcl functions:
2593  */
2594 
2595 #ifndef TCL_NO_DEPRECATED
2596 /*
2597  * These function have been renamed. The old names are deprecated, but we
2598  * define these macros for backwards compatibility.
2599  */
2600 
2601 #   define Tcl_Ckalloc      Tcl_Alloc
2602 #   define Tcl_Ckfree       Tcl_Free
2603 #   define Tcl_Ckrealloc    Tcl_Realloc
2604 #   define Tcl_Return       Tcl_SetResult
2605 #   define Tcl_TildeSubst   Tcl_TranslateFileName
2606 #if !defined(__APPLE__) /* On OSX, there is a conflict with "mach/mach.h" */
2607 #   define panic        Tcl_Panic
2608 #endif
2609 #   define panicVA      Tcl_PanicVA
2610 #endif /* !TCL_NO_DEPRECATED */
2611 
2612 /*
2613  *----------------------------------------------------------------------------
2614  * Convenience declaration of Tcl_AppInit for backwards compatibility. This
2615  * function is not *implemented* by the tcl library, so the storage class is
2616  * neither DLLEXPORT nor DLLIMPORT.
2617  */
2618 
2619 extern Tcl_AppInitProc Tcl_AppInit;
2620 
2621 #endif /* RC_INVOKED */
2622 
2623 /*
2624  * end block for C++
2625  */
2626 
2627 #ifdef __cplusplus
2628 }
2629 #endif
2630 
2631 #endif /* _TCL */
2632 
2633 /*
2634  * Local Variables:
2635  * mode: c
2636  * c-basic-offset: 4
2637  * fill-column: 78
2638  * End:
2639  */