home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / include / tcl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-22  |  56.5 KB  |  1,710 lines

  1. /*
  2.  * tcl.h --
  3.  *
  4.  *    This header file describes the externally-visible facilities
  5.  *    of the Tcl interpreter.
  6.  *
  7.  * Copyright (c) 1987-1994 The Regents of the University of California.
  8.  * Copyright (c) 1993-1996 Lucent Technologies.
  9.  * Copyright (c) 1994-1998 Sun Microsystems, Inc.
  10.  * Copyright (c) 1998-2000 by Scriptics Corporation.
  11.  *
  12.  * See the file "license.terms" for information on usage and redistribution
  13.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  14.  *
  15.  * RCS: @(#) $Id: tcl.h,v 1.70.2.9 2001/10/17 19:29:24 das Exp $
  16.  */
  17.  
  18. #ifndef _TCL
  19. #define _TCL
  20.  
  21. /*
  22.  * For C++ compilers, use extern "C"
  23.  */
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.     
  29. /*
  30.  * The following defines are used to indicate the various release levels.
  31.  */
  32.  
  33. #define TCL_ALPHA_RELEASE    0
  34. #define TCL_BETA_RELEASE    1
  35. #define TCL_FINAL_RELEASE    2
  36.  
  37. /*
  38.  * When version numbers change here, must also go into the following files
  39.  * and update the version numbers:
  40.  *
  41.  * library/init.tcl    (only if Major.minor changes, not patchlevel) 1 LOC
  42.  * unix/configure.in    (2 LOC Major, 2 LOC minor, 1 LOC patch)
  43.  * win/configure.in    (as above)
  44.  * win/tcl.m4        (not patchlevel)
  45.  * win/makefile.vc    (not patchlevel) 2 LOC
  46.  * win/pkgIndex.tcl    (not patchlevel, for tclregNN.dll)
  47.  * README        (sections 0 and 2)
  48.  * mac/README        (2 LOC, not patchlevel)
  49.  * win/README.binary    (sections 0-4)
  50.  * win/README        (not patchlevel) (sections 0 and 2)
  51.  * unix/README        (not patchlevel) (part (h))
  52.  * unix/tcl.spec    (2 LOC Major/Minor, 1 LOC patch)
  53.  * tests/basic.test    (not patchlevel) (version checks)
  54.  * tools/tcl.hpj.in    (not patchlevel, for windows installer)
  55.  * tools/tcl.wse.in    (for windows installer)
  56.  * tools/tclSplash.bmp    (not patchlevel)
  57.  */
  58.  
  59. #define TCL_MAJOR_VERSION   8
  60. #define TCL_MINOR_VERSION   3
  61. #define TCL_RELEASE_LEVEL   TCL_FINAL_RELEASE
  62. #define TCL_RELEASE_SERIAL  4
  63.  
  64. #define TCL_VERSION        "8.3"
  65. #define TCL_PATCH_LEVEL        "8.3.4"
  66.  
  67. /*
  68.  * The following definitions set up the proper options for Windows
  69.  * compilers.  We use this method because there is no autoconf equivalent.
  70.  */
  71.  
  72. #ifndef __WIN32__
  73. #   if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
  74. #    define __WIN32__
  75. #    ifndef WIN32
  76. #        define WIN32
  77. #    endif
  78. #   endif
  79. #endif
  80.  
  81. #ifdef __WIN32__
  82. #   ifndef STRICT
  83. #    define STRICT
  84. #   endif
  85. #   ifndef USE_PROTOTYPE
  86. #    define USE_PROTOTYPE 1
  87. #   endif
  88. #   ifndef HAS_STDARG
  89. #    define HAS_STDARG 1
  90. #   endif
  91. #   ifndef USE_PROTOTYPE
  92. #    define USE_PROTOTYPE 1
  93. #   endif
  94.  
  95. #endif /* __WIN32__ */
  96.  
  97. /*
  98.  * The following definitions set up the proper options for Macintosh
  99.  * compilers.  We use this method because there is no autoconf equivalent.
  100.  */
  101.  
  102. #ifdef MAC_TCL
  103. #include <ConditionalMacros.h>
  104. #   ifndef HAS_STDARG
  105. #    define HAS_STDARG 1
  106. #   endif
  107. #   ifndef USE_TCLALLOC
  108. #    define USE_TCLALLOC 1
  109. #   endif
  110. #   ifndef NO_STRERROR
  111. #    define NO_STRERROR 1
  112. #   endif
  113. #   define INLINE 
  114. #endif
  115.  
  116. /*
  117.  * Utility macros: STRINGIFY takes an argument and wraps it in "" (double
  118.  * quotation marks), JOIN joins two arguments.
  119.  */
  120.  
  121. #define VERBATIM(x) x
  122. #ifdef _MSC_VER
  123. # define STRINGIFY(x) STRINGIFY1(x)
  124. # define STRINGIFY1(x) #x
  125. # define JOIN(a,b) JOIN1(a,b)
  126. # define JOIN1(a,b) a##b
  127. #else
  128. # ifdef RESOURCE_INCLUDED
  129. #  define STRINGIFY(x) STRINGIFY1(x)
  130. #  define STRINGIFY1(x) #x
  131. #  define JOIN(a,b) JOIN1(a,b)
  132. #  define JOIN1(a,b) a##b
  133. # else
  134. #  ifdef __STDC__
  135. #   define STRINGIFY(x) #x
  136. #   define JOIN(a,b) a##b
  137. #  else
  138. #   define STRINGIFY(x) "x"
  139. #   define JOIN(a,b) VERBATIM(a)VERBATIM(b)
  140. #  endif
  141. # endif
  142. #endif
  143.  
  144. /*
  145.  * Special macro to define mutexes, that doesn't do anything
  146.  * if we are not using threads.
  147.  */
  148.  
  149. #ifdef TCL_THREADS
  150. #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name;
  151. #else
  152. #define TCL_DECLARE_MUTEX(name)
  153. #endif
  154.  
  155. /*
  156.  * Macros that eliminate the overhead of the thread synchronization
  157.  * functions when compiling without thread support.
  158.  */
  159.  
  160. #ifndef TCL_THREADS
  161. #define Tcl_MutexLock(mutexPtr)
  162. #define Tcl_MutexUnlock(mutexPtr)
  163. #define Tcl_MutexFinalize(mutexPtr)
  164. #define Tcl_ConditionNotify(condPtr)
  165. #define Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
  166. #define Tcl_ConditionFinalize(condPtr)
  167. #endif /* TCL_THREADS */
  168.  
  169. /* 
  170.  * A special definition used to allow this header file to be included 
  171.  * in resource files so that they can get obtain version information from
  172.  * this file.  Resource compilers don't like all the C stuff, like typedefs
  173.  * and procedure declarations, that occur below.
  174.  */
  175.  
  176. #ifndef RESOURCE_INCLUDED
  177.  
  178. #ifndef BUFSIZ
  179. #include <stdio.h>
  180. #endif
  181.  
  182. /*
  183.  * Definitions that allow Tcl functions with variable numbers of
  184.  * arguments to be used with either varargs.h or stdarg.h.  TCL_VARARGS
  185.  * is used in procedure prototypes.  TCL_VARARGS_DEF is used to declare
  186.  * the arguments in a function definiton: it takes the type and name of
  187.  * the first argument and supplies the appropriate argument declaration
  188.  * string for use in the function definition.  TCL_VARARGS_START
  189.  * initializes the va_list data structure and returns the first argument.
  190.  */
  191.  
  192. #if defined(__STDC__) || defined(HAS_STDARG)
  193. #   include <stdarg.h>
  194.  
  195. #   define TCL_VARARGS(type, name) (type name, ...)
  196. #   define TCL_VARARGS_DEF(type, name) (type name, ...)
  197. #   define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
  198. #else
  199. #   include <varargs.h>
  200.  
  201. #   ifdef __cplusplus
  202. #    define TCL_VARARGS(type, name) (type name, ...)
  203. #    define TCL_VARARGS_DEF(type, name) (type va_alist, ...)
  204. #   else
  205. #    define TCL_VARARGS(type, name) ()
  206. #    define TCL_VARARGS_DEF(type, name) (va_alist)
  207. #   endif
  208. #   define TCL_VARARGS_START(type, name, list) \
  209.     (va_start(list), va_arg(list, type))
  210. #endif
  211.  
  212. /*
  213.  * Macros used to declare a function to be exported by a DLL.
  214.  * Used by Windows, maps to no-op declarations on non-Windows systems.
  215.  * The default build on windows is for a DLL, which causes the DLLIMPORT
  216.  * and DLLEXPORT macros to be nonempty. To build a static library, the
  217.  * macro STATIC_BUILD should be defined.
  218.  */
  219.  
  220. #ifdef STATIC_BUILD
  221. # define DLLIMPORT
  222. # define DLLEXPORT
  223. #else
  224. # if (defined(__WIN32__) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__declspec)))) || (defined(MAC_TCL) && FUNCTION_DECLSPEC)
  225. #   define DLLIMPORT __declspec(dllimport)
  226. #   define DLLEXPORT __declspec(dllexport)
  227. # else
  228. #  define DLLIMPORT
  229. #  define DLLEXPORT
  230. # endif
  231. #endif
  232.  
  233. /*
  234.  * These macros are used to control whether functions are being declared for
  235.  * import or export.  If a function is being declared while it is being built
  236.  * to be included in a shared library, then it should have the DLLEXPORT
  237.  * storage class.  If is being declared for use by a module that is going to
  238.  * link against the shared library, then it should have the DLLIMPORT storage
  239.  * class.  If the symbol is beind declared for a static build or for use from a
  240.  * stub library, then the storage class should be empty.
  241.  *
  242.  * The convention is that a macro called BUILD_xxxx, where xxxx is the
  243.  * name of a library we are building, is set on the compile line for sources
  244.  * that are to be placed in the library.  When this macro is set, the
  245.  * storage class will be set to DLLEXPORT.  At the end of the header file, the
  246.  * storage class will be reset to DLLIMPORT.
  247.  */
  248.  
  249. #undef TCL_STORAGE_CLASS
  250. #ifdef BUILD_tcl
  251. # define TCL_STORAGE_CLASS DLLEXPORT
  252. #else
  253. # ifdef USE_TCL_STUBS
  254. #  define TCL_STORAGE_CLASS
  255. # else
  256. #  define TCL_STORAGE_CLASS DLLIMPORT
  257. # endif
  258. #endif
  259.  
  260. /*
  261.  * Definitions that allow this header file to be used either with or
  262.  * without ANSI C features like function prototypes.
  263.  */
  264.  
  265. #undef _ANSI_ARGS_
  266. #undef CONST
  267. #ifndef INLINE
  268. #   define INLINE
  269. #endif
  270.  
  271. #if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE)
  272. #   define _USING_PROTOTYPES_ 1
  273. #   define _ANSI_ARGS_(x)    x
  274. #   define CONST const
  275. #else
  276. #   define _ANSI_ARGS_(x)    ()
  277. #   define CONST
  278. #endif
  279.  
  280. /*
  281.  * Make sure EXTERN isn't defined elsewhere
  282.  */
  283. #ifdef EXTERN
  284. #undef EXTERN
  285. #endif /* EXTERN */
  286.  
  287. #ifdef __cplusplus
  288. #   define EXTERN extern "C" TCL_STORAGE_CLASS
  289. #else
  290. #   define EXTERN extern TCL_STORAGE_CLASS
  291. #endif
  292.  
  293. /*
  294.  * Macro to use instead of "void" for arguments that must have
  295.  * type "void *" in ANSI C;  maps them to type "char *" in
  296.  * non-ANSI systems.
  297.  */
  298. #ifndef __WIN32__
  299. #ifndef VOID
  300. #   ifdef __STDC__
  301. #       define VOID void
  302. #   else
  303. #       define VOID char
  304. #   endif
  305. #endif
  306. #else /* __WIN32__ */
  307. /*
  308.  * The following code is copied from winnt.h
  309.  */
  310. #ifndef VOID
  311. #define VOID void
  312. typedef char CHAR;
  313. typedef short SHORT;
  314. typedef long LONG;
  315. #endif
  316. #endif /* __WIN32__ */
  317.  
  318. /*
  319.  * Miscellaneous declarations.
  320.  */
  321.  
  322. #ifndef NULL
  323. #define NULL 0
  324. #endif
  325.  
  326. #ifndef _CLIENTDATA
  327. #   if defined(__STDC__) || defined(__cplusplus)
  328.     typedef void *ClientData;
  329. #   else
  330.     typedef int *ClientData;
  331. #   endif /* __STDC__ */
  332. #define _CLIENTDATA
  333. #endif
  334.  
  335. /*
  336.  * Data structures defined opaquely in this module. The definitions below
  337.  * just provide dummy types. A few fields are made visible in Tcl_Interp
  338.  * structures, namely those used for returning a string result from
  339.  * commands. Direct access to the result field is discouraged in Tcl 8.0.
  340.  * The interpreter result is either an object or a string, and the two
  341.  * values are kept consistent unless some C code sets interp->result
  342.  * directly. Programmers should use either the procedure Tcl_GetObjResult()
  343.  * or Tcl_GetStringResult() to read the interpreter's result. See the
  344.  * SetResult man page for details.
  345.  * 
  346.  * Note: any change to the Tcl_Interp definition below must be mirrored
  347.  * in the "real" definition in tclInt.h.
  348.  *
  349.  * Note: Tcl_ObjCmdProc procedures do not directly set result and freeProc.
  350.  * Instead, they set a Tcl_Obj member in the "real" structure that can be
  351.  * accessed with Tcl_GetObjResult() and Tcl_SetObjResult().
  352.  */
  353.  
  354. typedef struct Tcl_Interp {
  355.     char *result;        /* If the last command returned a string
  356.                  * result, this points to it. */
  357.     void (*freeProc) _ANSI_ARGS_((char *blockPtr));
  358.                 /* Zero means the string result is
  359.                  * statically allocated. TCL_DYNAMIC means
  360.                  * it was allocated with ckalloc and should
  361.                  * be freed with ckfree. Other values give
  362.                  * the address of procedure to invoke to
  363.                  * free the result. Tcl_Eval must free it
  364.                  * before executing next command. */
  365.     int errorLine;              /* When TCL_ERROR is returned, this gives
  366.                                  * the line number within the command where
  367.                                  * the error occurred (1 if first line). */
  368. } Tcl_Interp;
  369.  
  370. typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler;
  371. typedef struct Tcl_Channel_ *Tcl_Channel;
  372. typedef struct Tcl_Command_ *Tcl_Command;
  373. typedef struct Tcl_Condition_ *Tcl_Condition;
  374. typedef struct Tcl_EncodingState_ *Tcl_EncodingState;
  375. typedef struct Tcl_Encoding_ *Tcl_Encoding;
  376. typedef struct Tcl_Event Tcl_Event;
  377. typedef struct Tcl_Mutex_ *Tcl_Mutex;
  378. typedef struct Tcl_Pid_ *Tcl_Pid;
  379. typedef struct Tcl_RegExp_ *Tcl_RegExp;
  380. typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey;
  381. typedef struct Tcl_ThreadId_ *Tcl_ThreadId;
  382. typedef struct Tcl_TimerToken_ *Tcl_TimerToken;
  383. typedef struct Tcl_Trace_ *Tcl_Trace;
  384. typedef struct Tcl_Var_ *Tcl_Var;
  385. typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion;
  386.  
  387. /*
  388.  * Definition of the interface to procedures implementing threads.
  389.  * A procedure following this definition is given to each call of
  390.  * 'Tcl_CreateThread' and will be called as the main fuction of
  391.  * the new thread created by that call.
  392.  */
  393.  
  394. #ifdef MAC_TCL
  395. typedef pascal void *(Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
  396. #elif defined __WIN32__
  397. typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
  398. #else
  399. typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
  400. #endif
  401.  
  402.  
  403. /*
  404.  * Threading function return types used for abstracting away platform
  405.  * differences when writing a Tcl_ThreadCreateProc.  See the NewThread
  406.  * function in generic/tclThreadTest.c for it's usage.
  407.  */
  408. #ifdef MAC_TCL
  409. #   define Tcl_ThreadCreateType        pascal void *
  410. #   define TCL_THREAD_CREATE_RETURN    return NULL
  411. #elif defined __WIN32__
  412. #   define Tcl_ThreadCreateType        unsigned __stdcall
  413. #   define TCL_THREAD_CREATE_RETURN    return 0
  414. #else
  415. #   define Tcl_ThreadCreateType        void
  416. #   define TCL_THREAD_CREATE_RETURN    
  417. #endif
  418.  
  419.  
  420.  
  421. /*
  422.  * Definition of values for default stacksize and the possible flags to be
  423.  * given to Tcl_CreateThread.
  424.  */
  425.  
  426. #define TCL_THREAD_STACK_DEFAULT (0)    /* Use default size for stack */
  427. #define TCL_THREAD_NOFLAGS       (0000) /* Standard flags, default behaviour */
  428. #define TCL_THREAD_JOINABLE      (0001) /* Mark the thread as joinable */
  429.  
  430. /*
  431.  * Flag values passed to Tcl_GetRegExpFromObj.
  432.  */
  433.  
  434. #define    TCL_REG_BASIC        000000    /* BREs (convenience) */
  435. #define    TCL_REG_EXTENDED    000001    /* EREs */
  436. #define    TCL_REG_ADVF        000002    /* advanced features in EREs */
  437. #define    TCL_REG_ADVANCED    000003    /* AREs (which are also EREs) */
  438. #define    TCL_REG_QUOTE        000004    /* no special characters, none */
  439. #define    TCL_REG_NOCASE        000010    /* ignore case */
  440. #define    TCL_REG_NOSUB        000020    /* don't care about subexpressions */
  441. #define    TCL_REG_EXPANDED    000040    /* expanded format, white space &
  442.                      * comments */
  443. #define    TCL_REG_NLSTOP        000100  /* \n doesn't match . or [^ ] */
  444. #define    TCL_REG_NLANCH        000200  /* ^ matches after \n, $ before */
  445. #define    TCL_REG_NEWLINE        000300  /* newlines are line terminators */
  446. #define    TCL_REG_CANMATCH    001000  /* report details on partial/limited
  447.                      * matches */
  448.  
  449. /*
  450.  * The following flag is experimental and only intended for use by Expect.  It
  451.  * will probably go away in a later release.
  452.  */
  453.  
  454. #define TCL_REG_BOSONLY        002000    /* prepend \A to pattern so it only
  455.                      * matches at the beginning of the
  456.                      * string. */
  457.  
  458. /*
  459.  * Flags values passed to Tcl_RegExpExecObj.
  460.  */
  461.  
  462. #define    TCL_REG_NOTBOL    0001    /* Beginning of string does not match ^.  */
  463. #define    TCL_REG_NOTEOL    0002    /* End of string does not match $. */
  464.  
  465. /*
  466.  * Structures filled in by Tcl_RegExpInfo.  Note that all offset values are
  467.  * relative to the start of the match string, not the beginning of the
  468.  * entire string.
  469.  */
  470.  
  471. typedef struct Tcl_RegExpIndices {
  472.     long start;        /* character offset of first character in match */
  473.     long end;        /* character offset of first character after the
  474.              * match. */
  475. } Tcl_RegExpIndices;
  476.  
  477. typedef struct Tcl_RegExpInfo {
  478.     int nsubs;            /* number of subexpressions in the
  479.                  * compiled expression */
  480.     Tcl_RegExpIndices *matches;    /* array of nsubs match offset
  481.                  * pairs */
  482.     long extendStart;        /* The offset at which a subsequent
  483.                  * match might begin. */
  484.     long reserved;        /* Reserved for later use. */
  485. } Tcl_RegExpInfo;
  486.  
  487. /*
  488.  * Picky compilers complain if this typdef doesn't appear before the
  489.  * struct's reference in tclDecls.h.
  490.  */
  491.  
  492. typedef struct stat *Tcl_Stat_;
  493.  
  494. /*
  495.  * When a TCL command returns, the interpreter contains a result from the
  496.  * command. Programmers are strongly encouraged to use one of the
  497.  * procedures Tcl_GetObjResult() or Tcl_GetStringResult() to read the
  498.  * interpreter's result. See the SetResult man page for details. Besides
  499.  * this result, the command procedure returns an integer code, which is 
  500.  * one of the following:
  501.  *
  502.  * TCL_OK        Command completed normally; the interpreter's
  503.  *            result contains    the command's result.
  504.  * TCL_ERROR        The command couldn't be completed successfully;
  505.  *            the interpreter's result describes what went wrong.
  506.  * TCL_RETURN        The command requests that the current procedure
  507.  *            return; the interpreter's result contains the
  508.  *            procedure's return value.
  509.  * TCL_BREAK        The command requests that the innermost loop
  510.  *            be exited; the interpreter's result is meaningless.
  511.  * TCL_CONTINUE        Go on to the next iteration of the current loop;
  512.  *            the interpreter's result is meaningless.
  513.  */
  514.  
  515. #define TCL_OK        0
  516. #define TCL_ERROR    1
  517. #define TCL_RETURN    2
  518. #define TCL_BREAK    3
  519. #define TCL_CONTINUE    4
  520.  
  521. #define TCL_RESULT_SIZE 200
  522.  
  523. /*
  524.  * Argument descriptors for math function callbacks in expressions:
  525.  */
  526.  
  527. typedef enum {TCL_INT, TCL_DOUBLE, TCL_EITHER} Tcl_ValueType;
  528. typedef struct Tcl_Value {
  529.     Tcl_ValueType type;        /* Indicates intValue or doubleValue is
  530.                  * valid, or both. */
  531.     long intValue;        /* Integer value. */
  532.     double doubleValue;        /* Double-precision floating value. */
  533. } Tcl_Value;
  534.  
  535. /*
  536.  * Forward declaration of Tcl_Obj to prevent an error when the forward
  537.  * reference to Tcl_Obj is encountered in the procedure types declared 
  538.  * below.
  539.  */
  540.  
  541. struct Tcl_Obj;
  542.  
  543. /*
  544.  * Procedure types defined by Tcl:
  545.  */
  546.  
  547. typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
  548. typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData,
  549.     Tcl_Interp *interp, int code));
  550. typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask));
  551. typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data));
  552. typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData));
  553. typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData,
  554.     Tcl_Interp *interp, int argc, char *argv[]));
  555. typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData,
  556.     Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc,
  557.     ClientData cmdClientData, int argc, char *argv[]));
  558. typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, 
  559.         struct Tcl_Obj *dupPtr));
  560. typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData,
  561.     CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr,
  562.     char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr,
  563.     int *dstCharsPtr));
  564. typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData));
  565. typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags));
  566. typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData,
  567.     int flags));
  568. typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr,
  569.         ClientData clientData));
  570. typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData,
  571.     int flags));
  572. typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData));
  573. typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask));
  574. typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData));
  575. typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
  576. typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr));
  577. typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData));
  578. typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData,
  579.     Tcl_Interp *interp));
  580. typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData,
  581.     Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr));
  582. typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData));
  583. typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData,
  584.     Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv));
  585. typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
  586. typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(char *, format));
  587. typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData,
  588.         Tcl_Channel chan, char *address, int port));
  589. typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData));
  590. typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp,
  591.     struct Tcl_Obj *objPtr));
  592. typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
  593. typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData,
  594.     Tcl_Interp *interp, char *part1, char *part2, int flags));
  595. typedef void (Tcl_CreateFileHandlerProc) _ANSI_ARGS_((int fd, int mask,
  596.     Tcl_FileProc *proc, ClientData clientData));
  597. typedef void (Tcl_DeleteFileHandlerProc) _ANSI_ARGS_((int fd));
  598. typedef void (Tcl_MainLoopProc) _ANSI_ARGS_((void));
  599.  
  600. /*
  601.  * The following structure represents a type of object, which is a
  602.  * particular internal representation for an object plus a set of
  603.  * procedures that provide standard operations on objects of that type.
  604.  */
  605.  
  606. typedef struct Tcl_ObjType {
  607.     char *name;            /* Name of the type, e.g. "int". */
  608.     Tcl_FreeInternalRepProc *freeIntRepProc;
  609.                 /* Called to free any storage for the type's
  610.                  * internal rep. NULL if the internal rep
  611.                  * does not need freeing. */
  612.     Tcl_DupInternalRepProc *dupIntRepProc;
  613.                     /* Called to create a new object as a copy
  614.                  * of an existing object. */
  615.     Tcl_UpdateStringProc *updateStringProc;
  616.                     /* Called to update the string rep from the
  617.                  * type's internal representation. */
  618.     Tcl_SetFromAnyProc *setFromAnyProc;
  619.                     /* Called to convert the object's internal
  620.                  * rep to this type. Frees the internal rep
  621.                  * of the old type. Returns TCL_ERROR on
  622.                  * failure. */
  623. } Tcl_ObjType;
  624.  
  625. /*
  626.  * One of the following structures exists for each object in the Tcl
  627.  * system. An object stores a value as either a string, some internal
  628.  * representation, or both.
  629.  */
  630.  
  631. typedef struct Tcl_Obj {
  632.     int refCount;        /* When 0 the object will be freed. */
  633.     char *bytes;        /* This points to the first byte of the
  634.                  * object's string representation. The array
  635.                  * must be followed by a null byte (i.e., at
  636.                  * offset length) but may also contain
  637.                  * embedded null characters. The array's
  638.                  * storage is allocated by ckalloc. NULL
  639.                  * means the string rep is invalid and must
  640.                  * be regenerated from the internal rep.
  641.                  * Clients should use Tcl_GetStringFromObj
  642.                  * or Tcl_GetString to get a pointer to the
  643.                  * byte array as a readonly value. */
  644.     int length;            /* The number of bytes at *bytes, not
  645.                  * including the terminating null. */
  646.     Tcl_ObjType *typePtr;    /* Denotes the object's type. Always
  647.                  * corresponds to the type of the object's
  648.                  * internal rep. NULL indicates the object
  649.                  * has no internal rep (has no type). */
  650.     union {            /* The internal representation: */
  651.     long longValue;        /*   - an long integer value */
  652.     double doubleValue;    /*   - a double-precision floating value */
  653.     VOID *otherValuePtr;    /*   - another, type-specific value */
  654.     struct {        /*   - internal rep as two pointers */
  655.         VOID *ptr1;
  656.         VOID *ptr2;
  657.     } twoPtrValue;
  658.     } internalRep;
  659. } Tcl_Obj;
  660.  
  661. /*
  662.  * Macros to increment and decrement a Tcl_Obj's reference count, and to
  663.  * test whether an object is shared (i.e. has reference count > 1).
  664.  * Note: clients should use Tcl_DecrRefCount() when they are finished using
  665.  * an object, and should never call TclFreeObj() directly. TclFreeObj() is
  666.  * only defined and made public in tcl.h to support Tcl_DecrRefCount's macro
  667.  * definition. Note also that Tcl_DecrRefCount() refers to the parameter
  668.  * "obj" twice. This means that you should avoid calling it with an
  669.  * expression that is expensive to compute or has side effects.
  670.  */
  671.  
  672. void        Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
  673. void        Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
  674. int        Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr));
  675.  
  676. #ifdef TCL_MEM_DEBUG
  677. #   define Tcl_IncrRefCount(objPtr) \
  678.     Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__)
  679. #   define Tcl_DecrRefCount(objPtr) \
  680.     Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
  681. #   define Tcl_IsShared(objPtr) \
  682.     Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
  683. #else
  684. #   define Tcl_IncrRefCount(objPtr) \
  685.     ++(objPtr)->refCount
  686. #   define Tcl_DecrRefCount(objPtr) \
  687.     if (--(objPtr)->refCount <= 0) TclFreeObj(objPtr)
  688. #   define Tcl_IsShared(objPtr) \
  689.     ((objPtr)->refCount > 1)
  690. #endif
  691.  
  692. /*
  693.  * Macros and definitions that help to debug the use of Tcl objects.
  694.  * When TCL_MEM_DEBUG is defined, the Tcl_New declarations are 
  695.  * overridden to call debugging versions of the object creation procedures.
  696.  */
  697.  
  698. #ifdef TCL_MEM_DEBUG
  699. #  define Tcl_NewBooleanObj(val) \
  700.      Tcl_DbNewBooleanObj(val, __FILE__, __LINE__)
  701. #  define Tcl_NewByteArrayObj(bytes, len) \
  702.      Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__)
  703. #  define Tcl_NewDoubleObj(val) \
  704.      Tcl_DbNewDoubleObj(val, __FILE__, __LINE__)
  705. #  define Tcl_NewIntObj(val) \
  706.      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
  707. #  define Tcl_NewListObj(objc, objv) \
  708.      Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__)
  709. #  define Tcl_NewLongObj(val) \
  710.      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
  711. #  define Tcl_NewObj() \
  712.      Tcl_DbNewObj(__FILE__, __LINE__)
  713. #  define Tcl_NewStringObj(bytes, len) \
  714.      Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__)
  715. #endif /* TCL_MEM_DEBUG */
  716.  
  717. /*
  718.  * The following structure contains the state needed by
  719.  * Tcl_SaveResult.  No-one outside of Tcl should access any of these
  720.  * fields.  This structure is typically allocated on the stack.
  721.  */
  722.  
  723. typedef struct Tcl_SavedResult {
  724.     char *result;
  725.     Tcl_FreeProc *freeProc;
  726.     Tcl_Obj *objResultPtr;
  727.     char *appendResult;
  728.     int appendAvl;
  729.     int appendUsed;
  730.     char resultSpace[TCL_RESULT_SIZE+1];
  731. } Tcl_SavedResult;
  732.  
  733.  
  734. /*
  735.  * The following definitions support Tcl's namespace facility.
  736.  * Note: the first five fields must match exactly the fields in a
  737.  * Namespace structure (see tclInt.h). 
  738.  */
  739.  
  740. typedef struct Tcl_Namespace {
  741.     char *name;                 /* The namespace's name within its parent
  742.                  * namespace. This contains no ::'s. The
  743.                  * name of the global namespace is ""
  744.                  * although "::" is an synonym. */
  745.     char *fullName;             /* The namespace's fully qualified name.
  746.                  * This starts with ::. */
  747.     ClientData clientData;      /* Arbitrary value associated with this
  748.                  * namespace. */
  749.     Tcl_NamespaceDeleteProc* deleteProc;
  750.                                 /* Procedure invoked when deleting the
  751.                  * namespace to, e.g., free clientData. */
  752.     struct Tcl_Namespace* parentPtr;
  753.                                 /* Points to the namespace that contains
  754.                  * this one. NULL if this is the global
  755.                  * namespace. */
  756. } Tcl_Namespace;
  757.  
  758. /*
  759.  * The following structure represents a call frame, or activation record.
  760.  * A call frame defines a naming context for a procedure call: its local
  761.  * scope (for local variables) and its namespace scope (used for non-local
  762.  * variables; often the global :: namespace). A call frame can also define
  763.  * the naming context for a namespace eval or namespace inscope command:
  764.  * the namespace in which the command's code should execute. The
  765.  * Tcl_CallFrame structures exist only while procedures or namespace
  766.  * eval/inscope's are being executed, and provide a Tcl call stack.
  767.  * 
  768.  * A call frame is initialized and pushed using Tcl_PushCallFrame and
  769.  * popped using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be
  770.  * provided by the Tcl_PushCallFrame caller, and callers typically allocate
  771.  * them on the C call stack for efficiency. For this reason, Tcl_CallFrame
  772.  * is defined as a structure and not as an opaque token. However, most
  773.  * Tcl_CallFrame fields are hidden since applications should not access
  774.  * them directly; others are declared as "dummyX".
  775.  *
  776.  * WARNING!! The structure definition must be kept consistent with the
  777.  * CallFrame structure in tclInt.h. If you change one, change the other.
  778.  */
  779.  
  780. typedef struct Tcl_CallFrame {
  781.     Tcl_Namespace *nsPtr;
  782.     int dummy1;
  783.     int dummy2;
  784.     char *dummy3;
  785.     char *dummy4;
  786.     char *dummy5;
  787.     int dummy6;
  788.     char *dummy7;
  789.     char *dummy8;
  790.     int dummy9;
  791.     char* dummy10;
  792. } Tcl_CallFrame;
  793.  
  794. /*
  795.  * Information about commands that is returned by Tcl_GetCommandInfo and
  796.  * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based
  797.  * command procedure while proc is a traditional Tcl argc/argv
  798.  * string-based procedure. Tcl_CreateObjCommand and Tcl_CreateCommand
  799.  * ensure that both objProc and proc are non-NULL and can be called to
  800.  * execute the command. However, it may be faster to call one instead of
  801.  * the other. The member isNativeObjectProc is set to 1 if an
  802.  * object-based procedure was registered by Tcl_CreateObjCommand, and to
  803.  * 0 if a string-based procedure was registered by Tcl_CreateCommand.
  804.  * The other procedure is typically set to a compatibility wrapper that
  805.  * does string-to-object or object-to-string argument conversions then
  806.  * calls the other procedure.
  807.  */
  808.      
  809. typedef struct Tcl_CmdInfo {
  810.     int isNativeObjectProc;     /* 1 if objProc was registered by a call to
  811.                   * Tcl_CreateObjCommand; 0 otherwise.
  812.                   * Tcl_SetCmdInfo does not modify this
  813.                   * field. */
  814.     Tcl_ObjCmdProc *objProc;     /* Command's object-based procedure. */
  815.     ClientData objClientData;     /* ClientData for object proc. */
  816.     Tcl_CmdProc *proc;         /* Command's string-based procedure. */
  817.     ClientData clientData;     /* ClientData for string proc. */
  818.     Tcl_CmdDeleteProc *deleteProc;
  819.                                  /* Procedure to call when command is
  820.                                   * deleted. */
  821.     ClientData deleteData;     /* Value to pass to deleteProc (usually
  822.                   * the same as clientData). */
  823.     Tcl_Namespace *namespacePtr; /* Points to the namespace that contains
  824.                   * this command. Note that Tcl_SetCmdInfo
  825.                   * will not change a command's namespace;
  826.                   * use Tcl_RenameCommand to do that. */
  827.  
  828. } Tcl_CmdInfo;
  829.  
  830. /*
  831.  * The structure defined below is used to hold dynamic strings.  The only
  832.  * field that clients should use is the string field, and they should
  833.  * never modify it.
  834.  */
  835.  
  836. #define TCL_DSTRING_STATIC_SIZE 200
  837. typedef struct Tcl_DString {
  838.     char *string;        /* Points to beginning of string:  either
  839.                  * staticSpace below or a malloced array. */
  840.     int length;            /* Number of non-NULL characters in the
  841.                  * string. */
  842.     int spaceAvl;        /* Total number of bytes available for the
  843.                  * string and its terminating NULL char. */
  844.     char staticSpace[TCL_DSTRING_STATIC_SIZE];
  845.                 /* Space to use in common case where string
  846.                  * is small. */
  847. } Tcl_DString;
  848.  
  849. #define Tcl_DStringLength(dsPtr) ((dsPtr)->length)
  850. #define Tcl_DStringValue(dsPtr) ((dsPtr)->string)
  851. #define Tcl_DStringTrunc Tcl_DStringSetLength
  852.  
  853. /*
  854.  * Definitions for the maximum number of digits of precision that may
  855.  * be specified in the "tcl_precision" variable, and the number of
  856.  * bytes of buffer space required by Tcl_PrintDouble.
  857.  */
  858.  
  859. #define TCL_MAX_PREC 17
  860. #define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10)
  861.  
  862. /*
  863.  * Definition for a number of bytes of buffer space sufficient to hold the
  864.  * string representation of an integer in base 10 (assuming the existence
  865.  * of 64-bit integers).
  866.  */
  867.  
  868. #define TCL_INTEGER_SPACE    24
  869.  
  870. /*
  871.  * Flag that may be passed to Tcl_ConvertElement to force it not to
  872.  * output braces (careful!  if you change this flag be sure to change
  873.  * the definitions at the front of tclUtil.c).
  874.  */
  875.  
  876. #define TCL_DONT_USE_BRACES    1
  877.  
  878. /*
  879.  * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow
  880.  * abbreviated strings.
  881.  */
  882.  
  883. #define TCL_EXACT    1
  884.  
  885. /*
  886.  * Flag values passed to Tcl_RecordAndEval and/or Tcl_EvalObj.
  887.  * WARNING: these bit choices must not conflict with the bit choices
  888.  * for evalFlag bits in tclInt.h!!
  889.  */
  890.  
  891. #define TCL_NO_EVAL        0x10000
  892. #define TCL_EVAL_GLOBAL        0x20000
  893. #define TCL_EVAL_DIRECT        0x40000
  894.  
  895. /*
  896.  * Special freeProc values that may be passed to Tcl_SetResult (see
  897.  * the man page for details):
  898.  */
  899.  
  900. #define TCL_VOLATILE    ((Tcl_FreeProc *) 1)
  901. #define TCL_STATIC    ((Tcl_FreeProc *) 0)
  902. #define TCL_DYNAMIC    ((Tcl_FreeProc *) 3)
  903.  
  904. /*
  905.  * Flag values passed to variable-related procedures.
  906.  */
  907.  
  908. #define TCL_GLOBAL_ONLY         1
  909. #define TCL_NAMESPACE_ONLY     2
  910. #define TCL_APPEND_VALUE     4
  911. #define TCL_LIST_ELEMENT     8
  912. #define TCL_TRACE_READS         0x10
  913. #define TCL_TRACE_WRITES     0x20
  914. #define TCL_TRACE_UNSETS     0x40
  915. #define TCL_TRACE_DESTROYED     0x80
  916. #define TCL_INTERP_DESTROYED     0x100
  917. #define TCL_LEAVE_ERR_MSG     0x200
  918. #define TCL_TRACE_ARRAY         0x800
  919.  
  920. /*
  921.  * The TCL_PARSE_PART1 flag is deprecated and has no effect. 
  922.  * The part1 is now always parsed whenever the part2 is NULL.
  923.  * (This is to avoid a common error when converting code to
  924.  *  use the new object based APIs and forgetting to give the
  925.  *  flag)
  926.  */
  927. #ifndef TCL_NO_DEPRECATED
  928. #define TCL_PARSE_PART1          0x400
  929. #endif
  930.  
  931.  
  932. /*
  933.  * Types for linked variables:
  934.  */
  935.  
  936. #define TCL_LINK_INT        1
  937. #define TCL_LINK_DOUBLE        2
  938. #define TCL_LINK_BOOLEAN    3
  939. #define TCL_LINK_STRING        4
  940. #define TCL_LINK_READ_ONLY    0x80
  941.  
  942. /*
  943.  * Forward declaration of Tcl_HashTable.  Needed by some C++ compilers
  944.  * to prevent errors when the forward reference to Tcl_HashTable is
  945.  * encountered in the Tcl_HashEntry structure.
  946.  */
  947.  
  948. #ifdef __cplusplus
  949. struct Tcl_HashTable;
  950. #endif
  951.  
  952. /*
  953.  * Structure definition for an entry in a hash table.  No-one outside
  954.  * Tcl should access any of these fields directly;  use the macros
  955.  * defined below.
  956.  */
  957.  
  958. typedef struct Tcl_HashEntry {
  959.     struct Tcl_HashEntry *nextPtr;    /* Pointer to next entry in this
  960.                      * hash bucket, or NULL for end of
  961.                      * chain. */
  962.     struct Tcl_HashTable *tablePtr;    /* Pointer to table containing entry. */
  963.     struct Tcl_HashEntry **bucketPtr;    /* Pointer to bucket that points to
  964.                      * first entry in this entry's chain:
  965.                      * used for deleting the entry. */
  966.     ClientData clientData;        /* Application stores something here
  967.                      * with Tcl_SetHashValue. */
  968.     union {                /* Key has one of these forms: */
  969.     char *oneWordValue;        /* One-word value for key. */
  970.     int words[1];            /* Multiple integer words for key.
  971.                      * The actual size will be as large
  972.                      * as necessary for this table's
  973.                      * keys. */
  974.     char string[4];            /* String for key.  The actual size
  975.                      * will be as large as needed to hold
  976.                      * the key. */
  977.     } key;                /* MUST BE LAST FIELD IN RECORD!! */
  978. } Tcl_HashEntry;
  979.  
  980. /*
  981.  * Structure definition for a hash table.  Must be in tcl.h so clients
  982.  * can allocate space for these structures, but clients should never
  983.  * access any fields in this structure.
  984.  */
  985.  
  986. #define TCL_SMALL_HASH_TABLE 4
  987. typedef struct Tcl_HashTable {
  988.     Tcl_HashEntry **buckets;        /* Pointer to bucket array.  Each
  989.                      * element points to first entry in
  990.                      * bucket's hash chain, or NULL. */
  991.     Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
  992.                     /* Bucket array used for small tables
  993.                      * (to avoid mallocs and frees). */
  994.     int numBuckets;            /* Total number of buckets allocated
  995.                      * at **bucketPtr. */
  996.     int numEntries;            /* Total number of entries present
  997.                      * in table. */
  998.     int rebuildSize;            /* Enlarge table when numEntries gets
  999.                      * to be this large. */
  1000.     int downShift;            /* Shift count used in hashing
  1001.                      * function.  Designed to use high-
  1002.                      * order bits of randomized keys. */
  1003.     int mask;                /* Mask value used in hashing
  1004.                      * function. */
  1005.     int keyType;            /* Type of keys used in this table. 
  1006.                      * It's either TCL_STRING_KEYS,
  1007.                      * TCL_ONE_WORD_KEYS, or an integer
  1008.                      * giving the number of ints that
  1009.                                          * is the size of the key.
  1010.                      */
  1011.     Tcl_HashEntry *(*findProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr,
  1012.         CONST char *key));
  1013.     Tcl_HashEntry *(*createProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr,
  1014.         CONST char *key, int *newPtr));
  1015. } Tcl_HashTable;
  1016.  
  1017. /*
  1018.  * Structure definition for information used to keep track of searches
  1019.  * through hash tables:
  1020.  */
  1021.  
  1022. typedef struct Tcl_HashSearch {
  1023.     Tcl_HashTable *tablePtr;        /* Table being searched. */
  1024.     int nextIndex;            /* Index of next bucket to be
  1025.                      * enumerated after present one. */
  1026.     Tcl_HashEntry *nextEntryPtr;    /* Next entry to be enumerated in the
  1027.                      * the current bucket. */
  1028. } Tcl_HashSearch;
  1029.  
  1030. /*
  1031.  * Acceptable key types for hash tables:
  1032.  */
  1033.  
  1034. #define TCL_STRING_KEYS        0
  1035. #define TCL_ONE_WORD_KEYS    1
  1036.  
  1037. /*
  1038.  * Macros for clients to use to access fields of hash entries:
  1039.  */
  1040.  
  1041. #define Tcl_GetHashValue(h) ((h)->clientData)
  1042. #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))
  1043. #define Tcl_GetHashKey(tablePtr, h) \
  1044.     ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) ? (h)->key.oneWordValue \
  1045.                         : (h)->key.string))
  1046.  
  1047. /*
  1048.  * Macros to use for clients to use to invoke find and create procedures
  1049.  * for hash tables:
  1050.  */
  1051.  
  1052. #define Tcl_FindHashEntry(tablePtr, key) \
  1053.     (*((tablePtr)->findProc))(tablePtr, key)
  1054. #define Tcl_CreateHashEntry(tablePtr, key, newPtr) \
  1055.     (*((tablePtr)->createProc))(tablePtr, key, newPtr)
  1056.  
  1057. /*
  1058.  * Flag values to pass to Tcl_DoOneEvent to disable searches
  1059.  * for some kinds of events:
  1060.  */
  1061.  
  1062. #define TCL_DONT_WAIT        (1<<1)
  1063. #define TCL_WINDOW_EVENTS    (1<<2)
  1064. #define TCL_FILE_EVENTS        (1<<3)
  1065. #define TCL_TIMER_EVENTS    (1<<4)
  1066. #define TCL_IDLE_EVENTS        (1<<5)    /* WAS 0x10 ???? */
  1067. #define TCL_ALL_EVENTS        (~TCL_DONT_WAIT)
  1068.  
  1069. /*
  1070.  * The following structure defines a generic event for the Tcl event
  1071.  * system.  These are the things that are queued in calls to Tcl_QueueEvent
  1072.  * and serviced later by Tcl_DoOneEvent.  There can be many different
  1073.  * kinds of events with different fields, corresponding to window events,
  1074.  * timer events, etc.  The structure for a particular event consists of
  1075.  * a Tcl_Event header followed by additional information specific to that
  1076.  * event.
  1077.  */
  1078.  
  1079. struct Tcl_Event {
  1080.     Tcl_EventProc *proc;    /* Procedure to call to service this event. */
  1081.     struct Tcl_Event *nextPtr;    /* Next in list of pending events, or NULL. */
  1082. };
  1083.  
  1084. /*
  1085.  * Positions to pass to Tcl_QueueEvent:
  1086.  */
  1087.  
  1088. typedef enum {
  1089.     TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK
  1090. } Tcl_QueuePosition;
  1091.  
  1092. /*
  1093.  * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier
  1094.  * event routines.
  1095.  */
  1096.  
  1097. #define TCL_SERVICE_NONE 0
  1098. #define TCL_SERVICE_ALL 1
  1099.  
  1100. /*
  1101.  * The following structure keeps is used to hold a time value, either as
  1102.  * an absolute time (the number of seconds from the epoch) or as an
  1103.  * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT.
  1104.  * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT.
  1105.  */
  1106.  
  1107. typedef struct Tcl_Time {
  1108.     long sec;            /* Seconds. */
  1109.     long usec;            /* Microseconds. */
  1110. } Tcl_Time;
  1111.  
  1112. typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr));
  1113. typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr));
  1114.  
  1115. /*
  1116.  * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler
  1117.  * to indicate what sorts of events are of interest:
  1118.  */
  1119.  
  1120. #define TCL_READABLE    (1<<1)
  1121. #define TCL_WRITABLE    (1<<2)
  1122. #define TCL_EXCEPTION    (1<<3)
  1123.  
  1124. /*
  1125.  * Flag values to pass to Tcl_OpenCommandChannel to indicate the
  1126.  * disposition of the stdio handles.  TCL_STDIN, TCL_STDOUT, TCL_STDERR,
  1127.  * are also used in Tcl_GetStdChannel.
  1128.  */
  1129.  
  1130. #define TCL_STDIN        (1<<1)    
  1131. #define TCL_STDOUT        (1<<2)
  1132. #define TCL_STDERR        (1<<3)
  1133. #define TCL_ENFORCE_MODE    (1<<4)
  1134.  
  1135. /*
  1136.  * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel
  1137.  * should be closed.
  1138.  */
  1139.  
  1140. #define TCL_CLOSE_READ        (1<<1)
  1141. #define TCL_CLOSE_WRITE        (1<<2)
  1142.  
  1143. /*
  1144.  * Value to use as the closeProc for a channel that supports the
  1145.  * close2Proc interface.
  1146.  */
  1147.  
  1148. #define TCL_CLOSE2PROC    ((Tcl_DriverCloseProc *)1)
  1149.  
  1150. /*
  1151.  * Channel version tag.  This was introduced in 8.3.2/8.4.
  1152.  */
  1153.  
  1154. #define TCL_CHANNEL_VERSION_1    ((Tcl_ChannelTypeVersion) 0x1)
  1155. #define TCL_CHANNEL_VERSION_2    ((Tcl_ChannelTypeVersion) 0x2)
  1156.  
  1157. /*
  1158.  * Typedefs for the various operations in a channel type:
  1159.  */
  1160.  
  1161. typedef int    (Tcl_DriverBlockModeProc) _ANSI_ARGS_((
  1162.             ClientData instanceData, int mode));
  1163. typedef int    (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData,
  1164.             Tcl_Interp *interp));
  1165. typedef int    (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData,
  1166.             Tcl_Interp *interp, int flags));
  1167. typedef int    (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData,
  1168.             char *buf, int toRead, int *errorCodePtr));
  1169. typedef int    (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData,
  1170.             char *buf, int toWrite, int *errorCodePtr));
  1171. typedef int    (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData,
  1172.             long offset, int mode, int *errorCodePtr));
  1173. typedef int    (Tcl_DriverSetOptionProc) _ANSI_ARGS_((
  1174.             ClientData instanceData, Tcl_Interp *interp,
  1175.                 char *optionName, char *value));
  1176. typedef int    (Tcl_DriverGetOptionProc) _ANSI_ARGS_((
  1177.             ClientData instanceData, Tcl_Interp *interp,
  1178.             char *optionName, Tcl_DString *dsPtr));
  1179. typedef void    (Tcl_DriverWatchProc) _ANSI_ARGS_((
  1180.             ClientData instanceData, int mask));
  1181. typedef int    (Tcl_DriverGetHandleProc) _ANSI_ARGS_((
  1182.             ClientData instanceData, int direction,
  1183.             ClientData *handlePtr));
  1184. typedef int    (Tcl_DriverFlushProc) _ANSI_ARGS_((
  1185.             ClientData instanceData));
  1186. typedef int    (Tcl_DriverHandlerProc) _ANSI_ARGS_((
  1187.             ClientData instanceData, int interestMask));
  1188.  
  1189. /*
  1190.  * The following declarations either map ckalloc and ckfree to
  1191.  * malloc and free, or they map them to procedures with all sorts
  1192.  * of debugging hooks defined in tclCkalloc.c.
  1193.  */
  1194.  
  1195. #ifdef TCL_MEM_DEBUG
  1196.  
  1197. #   define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
  1198. #   define ckfree(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
  1199. #   define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
  1200.  
  1201. #else /* !TCL_MEM_DEBUG */
  1202.  
  1203. /*
  1204.  * If we are not using the debugging allocator, we should call the 
  1205.  * Tcl_Alloc, et al. routines in order to guarantee that every module
  1206.  * is using the same memory allocator both inside and outside of the
  1207.  * Tcl library.
  1208.  */
  1209.  
  1210. #   define ckalloc(x) Tcl_Alloc(x)
  1211. #   define ckfree(x) Tcl_Free(x)
  1212. #   define ckrealloc(x,y) Tcl_Realloc(x,y)
  1213. #   define Tcl_InitMemory(x)
  1214. #   define Tcl_DumpActiveMemory(x)
  1215. #   define Tcl_ValidateAllMemory(x,y)
  1216.  
  1217. #endif /* !TCL_MEM_DEBUG */
  1218.  
  1219. /*
  1220.  * Enum for different end of line translation and recognition modes.
  1221.  */
  1222.  
  1223. typedef enum Tcl_EolTranslation {
  1224.     TCL_TRANSLATE_AUTO,            /* Eol == \r, \n and \r\n. */
  1225.     TCL_TRANSLATE_CR,            /* Eol == \r. */
  1226.     TCL_TRANSLATE_LF,            /* Eol == \n. */
  1227.     TCL_TRANSLATE_CRLF            /* Eol == \r\n. */
  1228. } Tcl_EolTranslation;
  1229.  
  1230. /*
  1231.  * struct Tcl_ChannelType:
  1232.  *
  1233.  * One such structure exists for each type (kind) of channel.
  1234.  * It collects together in one place all the functions that are
  1235.  * part of the specific channel type.
  1236.  *
  1237.  * It is recommend that the Tcl_Channel* functions are used to access
  1238.  * elements of this structure, instead of direct accessing.
  1239.  */
  1240.  
  1241. typedef struct Tcl_ChannelType {
  1242.     char *typeName;            /* The name of the channel type in Tcl
  1243.                      * commands. This storage is owned by
  1244.                      * channel type. */
  1245.     Tcl_ChannelTypeVersion version;    /* Version of the channel type. */
  1246.     Tcl_DriverCloseProc *closeProc;    /* Procedure to call to close the
  1247.                      * channel, or TCL_CLOSE2PROC if the
  1248.                      * close2Proc should be used
  1249.                      * instead. */
  1250.     Tcl_DriverInputProc *inputProc;    /* Procedure to call for input
  1251.                      * on channel. */
  1252.     Tcl_DriverOutputProc *outputProc;    /* Procedure to call for output
  1253.                      * on channel. */
  1254.     Tcl_DriverSeekProc *seekProc;    /* Procedure to call to seek
  1255.                      * on the channel. May be NULL. */
  1256.     Tcl_DriverSetOptionProc *setOptionProc;
  1257.                     /* Set an option on a channel. */
  1258.     Tcl_DriverGetOptionProc *getOptionProc;
  1259.                     /* Get an option from a channel. */
  1260.     Tcl_DriverWatchProc *watchProc;    /* Set up the notifier to watch
  1261.                      * for events on this channel. */
  1262.     Tcl_DriverGetHandleProc *getHandleProc;
  1263.                     /* Get an OS handle from the channel
  1264.                      * or NULL if not supported. */
  1265.     Tcl_DriverClose2Proc *close2Proc;    /* Procedure to call to close the
  1266.                      * channel if the device supports
  1267.                      * closing the read & write sides
  1268.                      * independently. */
  1269.     Tcl_DriverBlockModeProc *blockModeProc;
  1270.                     /* Set blocking mode for the
  1271.                      * raw channel. May be NULL. */
  1272.     /*
  1273.      * Only valid in TCL_CHANNEL_VERSION_2 channels
  1274.      */
  1275.     Tcl_DriverFlushProc *flushProc;    /* Procedure to call to flush a
  1276.                      * channel. May be NULL. */
  1277.     Tcl_DriverHandlerProc *handlerProc;    /* Procedure to call to handle a
  1278.                      * channel event.  This will be passed
  1279.                      * up the stacked channel chain. */
  1280. } Tcl_ChannelType;
  1281.  
  1282. /*
  1283.  * The following flags determine whether the blockModeProc above should
  1284.  * set the channel into blocking or nonblocking mode. They are passed
  1285.  * as arguments to the blockModeProc procedure in the above structure.
  1286.  */
  1287.  
  1288. #define TCL_MODE_BLOCKING    0    /* Put channel into blocking mode. */
  1289. #define TCL_MODE_NONBLOCKING    1    /* Put channel into nonblocking
  1290.                      * mode. */
  1291.  
  1292. /*
  1293.  * Enum for different types of file paths.
  1294.  */
  1295.  
  1296. typedef enum Tcl_PathType {
  1297.     TCL_PATH_ABSOLUTE,
  1298.     TCL_PATH_RELATIVE,
  1299.     TCL_PATH_VOLUME_RELATIVE
  1300. } Tcl_PathType;
  1301.  
  1302. /*
  1303.  * The following structure represents the Notifier functions that
  1304.  * you can override with the Tcl_SetNotifier call.
  1305.  */
  1306.  
  1307. typedef struct Tcl_NotifierProcs {
  1308.     Tcl_SetTimerProc *setTimerProc;
  1309.     Tcl_WaitForEventProc *waitForEventProc;
  1310.     Tcl_CreateFileHandlerProc *createFileHandlerProc;
  1311.     Tcl_DeleteFileHandlerProc *deleteFileHandlerProc;
  1312. } Tcl_NotifierProcs;
  1313.  
  1314. /*
  1315.  * The following structure represents a user-defined encoding.  It collects
  1316.  * together all the functions that are used by the specific encoding.
  1317.  */
  1318.  
  1319. typedef struct Tcl_EncodingType {
  1320.     CONST char *encodingName;    /* The name of the encoding, e.g.  "euc-jp".
  1321.                  * This name is the unique key for this
  1322.                  * encoding type. */
  1323.     Tcl_EncodingConvertProc *toUtfProc;
  1324.                 /* Procedure to convert from external
  1325.                  * encoding into UTF-8. */
  1326.     Tcl_EncodingConvertProc *fromUtfProc;
  1327.                 /* Procedure to convert from UTF-8 into
  1328.                  * external encoding. */
  1329.     Tcl_EncodingFreeProc *freeProc;
  1330.                 /* If non-NULL, procedure to call when this
  1331.                  * encoding is deleted. */
  1332.     ClientData clientData;    /* Arbitrary value associated with encoding
  1333.                  * type.  Passed to conversion procedures. */
  1334.     int nullSize;        /* Number of zero bytes that signify
  1335.                  * end-of-string in this encoding.  This
  1336.                  * number is used to determine the source
  1337.                  * string length when the srcLen argument is
  1338.                  * negative.  Must be 1 or 2. */
  1339. } Tcl_EncodingType;    
  1340.  
  1341. /*
  1342.  * The following definitions are used as values for the conversion control
  1343.  * flags argument when converting text from one character set to another:
  1344.  *
  1345.  * TCL_ENCODING_START:             Signifies that the source buffer is the first
  1346.  *                block in a (potentially multi-block) input
  1347.  *                stream.  Tells the conversion procedure to
  1348.  *                reset to an initial state and perform any
  1349.  *                initialization that needs to occur before the
  1350.  *                first byte is converted.  If the source
  1351.  *                buffer contains the entire input stream to be
  1352.  *                converted, this flag should be set.
  1353.  *
  1354.  * TCL_ENCODING_END:        Signifies that the source buffer is the last
  1355.  *                block in a (potentially multi-block) input
  1356.  *                stream.  Tells the conversion routine to
  1357.  *                perform any finalization that needs to occur
  1358.  *                after the last byte is converted and then to
  1359.  *                reset to an initial state.  If the source
  1360.  *                buffer contains the entire input stream to be
  1361.  *                converted, this flag should be set.
  1362.  *                
  1363.  * TCL_ENCODING_STOPONERROR:    If set, then the converter will return
  1364.  *                immediately upon encountering an invalid
  1365.  *                byte sequence or a source character that has
  1366.  *                no mapping in the target encoding.  If clear,
  1367.  *                then the converter will skip the problem,
  1368.  *                substituting one or more "close" characters
  1369.  *                in the destination buffer and then continue
  1370.  *                to sonvert the source.
  1371.  */
  1372.  
  1373. #define TCL_ENCODING_START        0x01
  1374. #define TCL_ENCODING_END        0x02
  1375. #define TCL_ENCODING_STOPONERROR    0x04
  1376.  
  1377. /*
  1378.  *----------------------------------------------------------------
  1379.  * The following data structures and declarations are for the new
  1380.  * Tcl parser.    This stuff should all move to tcl.h eventually.
  1381.  *----------------------------------------------------------------
  1382.  */
  1383.  
  1384. /*
  1385.  * For each word of a command, and for each piece of a word such as a
  1386.  * variable reference, one of the following structures is created to
  1387.  * describe the token.
  1388.  */
  1389.  
  1390. typedef struct Tcl_Token {
  1391.     int type;            /* Type of token, such as TCL_TOKEN_WORD;
  1392.                  * see below for valid types. */
  1393.     char *start;        /* First character in token. */
  1394.     int size;            /* Number of bytes in token. */
  1395.     int numComponents;        /* If this token is composed of other
  1396.                  * tokens, this field tells how many of
  1397.                  * them there are (including components of
  1398.                  * components, etc.).  The component tokens
  1399.                  * immediately follow this one. */
  1400. } Tcl_Token;
  1401.  
  1402. /*
  1403.  * Type values defined for Tcl_Token structures.  These values are
  1404.  * defined as mask bits so that it's easy to check for collections of
  1405.  * types.
  1406.  *
  1407.  * TCL_TOKEN_WORD -        The token describes one word of a command,
  1408.  *                from the first non-blank character of
  1409.  *                the word (which may be " or {) up to but
  1410.  *                not including the space, semicolon, or
  1411.  *                bracket that terminates the word. 
  1412.  *                NumComponents counts the total number of
  1413.  *                sub-tokens that make up the word.  This
  1414.  *                includes, for example, sub-tokens of
  1415.  *                TCL_TOKEN_VARIABLE tokens.
  1416.  * TCL_TOKEN_SIMPLE_WORD -    This token is just like TCL_TOKEN_WORD
  1417.  *                except that the word is guaranteed to
  1418.  *                consist of a single TCL_TOKEN_TEXT
  1419.  *                sub-token.
  1420.  * TCL_TOKEN_TEXT -        The token describes a range of literal
  1421.  *                text that is part of a word. 
  1422.  *                NumComponents is always 0.
  1423.  * TCL_TOKEN_BS -        The token describes a backslash sequence
  1424.  *                that must be collapsed.     NumComponents
  1425.  *                is always 0.
  1426.  * TCL_TOKEN_COMMAND -        The token describes a command whose result
  1427.  *                must be substituted into the word.  The
  1428.  *                token includes the enclosing brackets. 
  1429.  *                NumComponents is always 0.
  1430.  * TCL_TOKEN_VARIABLE -        The token describes a variable
  1431.  *                substitution, including the dollar sign,
  1432.  *                variable name, and array index (if there
  1433.  *                is one) up through the right
  1434.  *                parentheses.  NumComponents tells how
  1435.  *                many additional tokens follow to
  1436.  *                represent the variable name.  The first
  1437.  *                token will be a TCL_TOKEN_TEXT token
  1438.  *                that describes the variable name.  If
  1439.  *                the variable is an array reference then
  1440.  *                there will be one or more additional
  1441.  *                tokens, of type TCL_TOKEN_TEXT,
  1442.  *                TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and
  1443.  *                TCL_TOKEN_VARIABLE, that describe the
  1444.  *                array index; numComponents counts the
  1445.  *                total number of nested tokens that make
  1446.  *                up the variable reference, including
  1447.  *                sub-tokens of TCL_TOKEN_VARIABLE tokens.
  1448.  * TCL_TOKEN_SUB_EXPR -        The token describes one subexpression of a
  1449.  *                expression, from the first non-blank
  1450.  *                character of the subexpression up to but not
  1451.  *                including the space, brace, or bracket
  1452.  *                that terminates the subexpression. 
  1453.  *                NumComponents counts the total number of
  1454.  *                following subtokens that make up the
  1455.  *                subexpression; this includes all subtokens
  1456.  *                for any nested TCL_TOKEN_SUB_EXPR tokens.
  1457.  *                For example, a numeric value used as a
  1458.  *                primitive operand is described by a
  1459.  *                TCL_TOKEN_SUB_EXPR token followed by a
  1460.  *                TCL_TOKEN_TEXT token. A binary subexpression
  1461.  *                is described by a TCL_TOKEN_SUB_EXPR token
  1462.  *                followed by the    TCL_TOKEN_OPERATOR token
  1463.  *                for the operator, then TCL_TOKEN_SUB_EXPR
  1464.  *                tokens for the left then the right operands.
  1465.  * TCL_TOKEN_OPERATOR -        The token describes one expression operator.
  1466.  *                An operator might be the name of a math
  1467.  *                function such as "abs". A TCL_TOKEN_OPERATOR
  1468.  *                token is always preceeded by one
  1469.  *                TCL_TOKEN_SUB_EXPR token for the operator's
  1470.  *                subexpression, and is followed by zero or
  1471.  *                more TCL_TOKEN_SUB_EXPR tokens for the
  1472.  *                operator's operands. NumComponents is
  1473.  *                always 0.
  1474.  */
  1475.  
  1476. #define TCL_TOKEN_WORD        1
  1477. #define TCL_TOKEN_SIMPLE_WORD    2
  1478. #define TCL_TOKEN_TEXT        4
  1479. #define TCL_TOKEN_BS        8
  1480. #define TCL_TOKEN_COMMAND    16
  1481. #define TCL_TOKEN_VARIABLE    32
  1482. #define TCL_TOKEN_SUB_EXPR    64
  1483. #define TCL_TOKEN_OPERATOR    128
  1484.  
  1485. /*
  1486.  * Parsing error types.  On any parsing error, one of these values
  1487.  * will be stored in the error field of the Tcl_Parse structure
  1488.  * defined below.
  1489.  */
  1490.  
  1491. #define TCL_PARSE_SUCCESS        0
  1492. #define TCL_PARSE_QUOTE_EXTRA        1
  1493. #define TCL_PARSE_BRACE_EXTRA        2
  1494. #define TCL_PARSE_MISSING_BRACE        3
  1495. #define TCL_PARSE_MISSING_BRACKET    4
  1496. #define TCL_PARSE_MISSING_PAREN        5
  1497. #define TCL_PARSE_MISSING_QUOTE        6
  1498. #define TCL_PARSE_MISSING_VAR_BRACE    7
  1499. #define TCL_PARSE_SYNTAX        8
  1500. #define TCL_PARSE_BAD_NUMBER        9
  1501.  
  1502. /*
  1503.  * A structure of the following type is filled in by Tcl_ParseCommand.
  1504.  * It describes a single command parsed from an input string.
  1505.  */
  1506.  
  1507. #define NUM_STATIC_TOKENS 20
  1508.  
  1509. typedef struct Tcl_Parse {
  1510.     char *commentStart;        /* Pointer to # that begins the first of
  1511.                  * one or more comments preceding the
  1512.                  * command. */
  1513.     int commentSize;        /* Number of bytes in comments (up through
  1514.                  * newline character that terminates the
  1515.                  * last comment).  If there were no
  1516.                  * comments, this field is 0. */
  1517.     char *commandStart;        /* First character in first word of command. */
  1518.     int commandSize;        /* Number of bytes in command, including
  1519.                  * first character of first word, up
  1520.                  * through the terminating newline,
  1521.                  * close bracket, or semicolon. */
  1522.     int numWords;        /* Total number of words in command.  May
  1523.                  * be 0. */
  1524.     Tcl_Token *tokenPtr;    /* Pointer to first token representing
  1525.                  * the words of the command.  Initially
  1526.                  * points to staticTokens, but may change
  1527.                  * to point to malloc-ed space if command
  1528.                  * exceeds space in staticTokens. */
  1529.     int numTokens;        /* Total number of tokens in command. */
  1530.     int tokensAvailable;    /* Total number of tokens available at
  1531.                  * *tokenPtr. */
  1532.     int errorType;        /* One of the parsing error types defined
  1533.                  * above. */
  1534.  
  1535.     /*
  1536.      * The fields below are intended only for the private use of the
  1537.      * parser.    They should not be used by procedures that invoke
  1538.      * Tcl_ParseCommand.
  1539.      */
  1540.  
  1541.     char *string;        /* The original command string passed to
  1542.                  * Tcl_ParseCommand. */
  1543.     char *end;            /* Points to the character just after the
  1544.                  * last one in the command string. */
  1545.     Tcl_Interp *interp;        /* Interpreter to use for error reporting,
  1546.                  * or NULL. */
  1547.     char *term;            /* Points to character in string that
  1548.                  * terminated most recent token.  Filled in
  1549.                  * by ParseTokens.  If an error occurs,
  1550.                  * points to beginning of region where the
  1551.                  * error occurred (e.g. the open brace if
  1552.                  * the close brace is missing). */
  1553.     int incomplete;        /* This field is set to 1 by Tcl_ParseCommand
  1554.                  * if the command appears to be incomplete.
  1555.                  * This information is used by
  1556.                  * Tcl_CommandComplete. */
  1557.     Tcl_Token staticTokens[NUM_STATIC_TOKENS];
  1558.                 /* Initial space for tokens for command.
  1559.                  * This space should be large enough to
  1560.                  * accommodate most commands; dynamic
  1561.                  * space is allocated for very large
  1562.                  * commands that don't fit here. */
  1563. } Tcl_Parse;
  1564.  
  1565. /*
  1566.  * The following definitions are the error codes returned by the conversion
  1567.  * routines:
  1568.  *
  1569.  * TCL_OK:            All characters were converted.
  1570.  *
  1571.  * TCL_CONVERT_NOSPACE:        The output buffer would not have been large
  1572.  *                enough for all of the converted data; as many
  1573.  *                characters as could fit were converted though.
  1574.  *
  1575.  * TCL_CONVERT_MULTIBYTE:    The last few bytes in the source string were
  1576.  *                the beginning of a multibyte sequence, but
  1577.  *                more bytes were needed to complete this
  1578.  *                sequence.  A subsequent call to the conversion
  1579.  *                routine should pass the beginning of this
  1580.  *                unconverted sequence plus additional bytes
  1581.  *                from the source stream to properly convert
  1582.  *                the formerly split-up multibyte sequence.
  1583.  *
  1584.  * TCL_CONVERT_SYNTAX:        The source stream contained an invalid
  1585.  *                character sequence.  This may occur if the
  1586.  *                input stream has been damaged or if the input
  1587.  *                encoding method was misidentified.  This error
  1588.  *                is reported only if TCL_ENCODING_STOPONERROR
  1589.  *                was specified.
  1590.  * 
  1591.  * TCL_CONVERT_UNKNOWN:        The source string contained a character
  1592.  *                that could not be represented in the target
  1593.  *                encoding.  This error is reported only if
  1594.  *                TCL_ENCODING_STOPONERROR was specified.
  1595.  */
  1596.  
  1597. #define TCL_CONVERT_MULTIBYTE        -1
  1598. #define TCL_CONVERT_SYNTAX        -2
  1599. #define TCL_CONVERT_UNKNOWN        -3
  1600. #define TCL_CONVERT_NOSPACE        -4
  1601.  
  1602. /*
  1603.  * The maximum number of bytes that are necessary to represent a single
  1604.  * Unicode character in UTF-8.
  1605.  */
  1606.  
  1607. #define TCL_UTF_MAX        3
  1608.  
  1609. /*
  1610.  * This represents a Unicode character.  
  1611.  */
  1612.  
  1613. typedef unsigned short Tcl_UniChar;
  1614.  
  1615. /*
  1616.  * Deprecated Tcl procedures:
  1617.  */
  1618.  
  1619. #ifndef TCL_NO_DEPRECATED
  1620. #define Tcl_EvalObj(interp,objPtr) Tcl_EvalObjEx((interp),(objPtr),0)
  1621. #define Tcl_GlobalEvalObj(interp,objPtr) \
  1622.     Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL)
  1623. #endif
  1624.  
  1625. /*
  1626.  * These function have been renamed. The old names are deprecated, but we
  1627.  * define these macros for backwards compatibilty.
  1628.  */
  1629.  
  1630. #define Tcl_Ckalloc Tcl_Alloc
  1631. #define Tcl_Ckfree Tcl_Free
  1632. #define Tcl_Ckrealloc Tcl_Realloc
  1633. #define Tcl_Return Tcl_SetResult
  1634. #define Tcl_TildeSubst Tcl_TranslateFileName
  1635. #define panic Tcl_Panic
  1636. #define panicVA Tcl_PanicVA
  1637.  
  1638. /*
  1639.  * The following constant is used to test for older versions of Tcl
  1640.  * in the stubs tables.
  1641.  *
  1642.  * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different
  1643.  * value since the stubs tables don't match.
  1644.  */
  1645.  
  1646. #define TCL_STUB_MAGIC 0xFCA3BACF
  1647.  
  1648. /*
  1649.  * The following function is required to be defined in all stubs aware
  1650.  * extensions.  The function is actually implemented in the stub
  1651.  * library, not the main Tcl library, although there is a trivial
  1652.  * implementation in the main library in case an extension is statically
  1653.  * linked into an application.
  1654.  */
  1655.  
  1656. EXTERN char *        Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
  1657.                 char *version, int exact));
  1658.  
  1659. #ifndef USE_TCL_STUBS
  1660.  
  1661. /*
  1662.  * When not using stubs, make it a macro.
  1663.  */
  1664.  
  1665. #define Tcl_InitStubs(interp, version, exact) \
  1666.     Tcl_PkgRequire(interp, "Tcl", version, exact)
  1667.  
  1668. #endif
  1669.  
  1670.  
  1671. /*
  1672.  * Include the public function declarations that are accessible via
  1673.  * the stubs table.
  1674.  */
  1675.  
  1676. #include "tclDecls.h"
  1677.  
  1678. /*
  1679.  * Public functions that are not accessible via the stubs table.
  1680.  */
  1681.  
  1682. EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv,
  1683.     Tcl_AppInitProc *appInitProc));
  1684.  
  1685. /*
  1686.  * Convenience declaration of Tcl_AppInit for backwards compatibility.
  1687.  * This function is not *implemented* by the tcl library, so the storage
  1688.  * class is neither DLLEXPORT nor DLLIMPORT
  1689.  */
  1690.  
  1691. #undef TCL_STORAGE_CLASS
  1692. #define TCL_STORAGE_CLASS
  1693.  
  1694. EXTERN int        Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp));
  1695.  
  1696. #endif /* RESOURCE_INCLUDED */
  1697.  
  1698. #undef TCL_STORAGE_CLASS
  1699. #define TCL_STORAGE_CLASS DLLIMPORT
  1700.  
  1701. /*
  1702.  * end block for C++
  1703.  */
  1704.     
  1705. #ifdef __cplusplus
  1706. }
  1707. #endif
  1708.     
  1709. #endif /* _TCL */
  1710.