OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / tcl.h
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  * Copyright (c) 2002 by Kevin B. Kenny.  All rights reserved.
12  *
13  * See the file "license.terms" for information on usage and redistribution
14  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15  *
16  * RCS: @(#) $Id: tcl.h,v 1.153.2.8 2003/10/22 22:35:46 andreas_kupries Exp $
17  */
18
19 #ifndef _TCL
20 #define _TCL
21
22 /*
23  * For C++ compilers, use extern "C"
24  */
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29     
30 /*
31  * The following defines are used to indicate the various release levels.
32  */
33
34 #define TCL_ALPHA_RELEASE       0
35 #define TCL_BETA_RELEASE        1
36 #define TCL_FINAL_RELEASE       2
37
38 /*
39  * When version numbers change here, must also go into the following files
40  * and update the version numbers:
41  *
42  * library/init.tcl     (only if Major.minor changes, not patchlevel) 1 LOC
43  * unix/configure.in    (2 LOC Major, 2 LOC minor, 1 LOC patch)
44  * win/configure.in     (as above)
45  * win/tcl.m4           (not patchlevel)
46  * win/makefile.vc      (not patchlevel) 2 LOC
47  * README               (sections 0 and 2)
48  * mac/README           (2 LOC, not patchlevel)
49  * macosx/Tcl.pbproj/project.pbxproj (not patchlevel) 2 LOC
50  * win/README.binary    (sections 0-4)
51  * win/README           (not patchlevel) (sections 0 and 2)
52  * unix/tcl.spec        (2 LOC Major/Minor, 1 LOC patch)
53  * tests/basic.test     (1 LOC M/M, not patchlevel)
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 #define TCL_MAJOR_VERSION   8
59 #define TCL_MINOR_VERSION   4
60 #define TCL_RELEASE_LEVEL   TCL_FINAL_RELEASE
61 #define TCL_RELEASE_SERIAL  5
62
63 #define TCL_VERSION         "8.4"
64 #define TCL_PATCH_LEVEL     "8.4.5"
65
66 /*
67  * The following definitions set up the proper options for Windows
68  * compilers.  We use this method because there is no autoconf equivalent.
69  */
70
71 #ifndef __WIN32__
72 #   if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) || defined(__BORLANDC__)
73 #       define __WIN32__
74 #       ifndef WIN32
75 #           define WIN32
76 #       endif
77 #   endif
78 #endif
79
80 /*
81  * STRICT: See MSDN Article Q83456
82  */
83 #ifdef __WIN32__
84 #   ifndef STRICT
85 #       define STRICT
86 #   endif
87 #endif /* __WIN32__ */
88
89 /*
90  * The following definitions set up the proper options for Macintosh
91  * compilers.  We use this method because there is no autoconf equivalent.
92  */
93
94 #ifdef MAC_TCL
95 #include <ConditionalMacros.h>
96 #   ifndef USE_TCLALLOC
97 #       define USE_TCLALLOC 1
98 #   endif
99 #   ifndef NO_STRERROR
100 #       define NO_STRERROR 1
101 #   endif
102 #   define INLINE 
103 #endif
104
105
106 /*
107  * Utility macros: STRINGIFY takes an argument and wraps it in "" (double
108  * quotation marks), JOIN joins two arguments.
109  */
110 #ifndef STRINGIFY
111 #  define STRINGIFY(x) STRINGIFY1(x)
112 #  define STRINGIFY1(x) #x
113 #endif
114 #ifndef JOIN
115 #  define JOIN(a,b) JOIN1(a,b)
116 #  define JOIN1(a,b) a##b
117 #endif
118
119 /* 
120  * A special definition used to allow this header file to be included
121  * from windows or mac resource files so that they can obtain version
122  * information.  RC_INVOKED is defined by default by the windows RC tool
123  * and manually set for macintosh.
124  *
125  * Resource compilers don't like all the C stuff, like typedefs and
126  * procedure declarations, that occur below, so block them out.
127  */
128
129 #ifndef RC_INVOKED
130
131 /*
132  * Special macro to define mutexes, that doesn't do anything
133  * if we are not using threads.
134  */
135
136 #ifdef TCL_THREADS
137 #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name;
138 #else
139 #define TCL_DECLARE_MUTEX(name)
140 #endif
141
142 /*
143  * Macros that eliminate the overhead of the thread synchronization
144  * functions when compiling without thread support.
145  */
146
147 #ifndef TCL_THREADS
148 #define Tcl_MutexLock(mutexPtr)
149 #define Tcl_MutexUnlock(mutexPtr)
150 #define Tcl_MutexFinalize(mutexPtr)
151 #define Tcl_ConditionNotify(condPtr)
152 #define Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
153 #define Tcl_ConditionFinalize(condPtr)
154 #endif /* TCL_THREADS */
155
156
157 #ifndef BUFSIZ
158 #   include <stdio.h>
159 #endif
160
161
162 /*
163  * Definitions that allow Tcl functions with variable numbers of
164  * arguments to be used with either varargs.h or stdarg.h.  TCL_VARARGS
165  * is used in procedure prototypes.  TCL_VARARGS_DEF is used to declare
166  * the arguments in a function definiton: it takes the type and name of
167  * the first argument and supplies the appropriate argument declaration
168  * string for use in the function definition.  TCL_VARARGS_START
169  * initializes the va_list data structure and returns the first argument.
170  */
171 #if !defined(NO_STDARG)
172 #   include <stdarg.h>
173 #   define TCL_VARARGS(type, name) (type name, ...)
174 #   define TCL_VARARGS_DEF(type, name) (type name, ...)
175 #   define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
176 #else
177 #   include <varargs.h>
178 #      define TCL_VARARGS(type, name) ()
179 #      define TCL_VARARGS_DEF(type, name) (va_alist)
180 #   define TCL_VARARGS_START(type, name, list) \
181         (va_start(list), va_arg(list, type))
182 #endif
183
184 /*
185  * Macros used to declare a function to be exported by a DLL.
186  * Used by Windows, maps to no-op declarations on non-Windows systems.
187  * The default build on windows is for a DLL, which causes the DLLIMPORT
188  * and DLLEXPORT macros to be nonempty. To build a static library, the
189  * macro STATIC_BUILD should be defined.
190  */
191
192 #ifdef STATIC_BUILD
193 #   define DLLIMPORT
194 #   define DLLEXPORT
195 #else
196 #   if (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || (defined(__GNUC__) && defined(__declspec)))) || (defined(MAC_TCL) && FUNCTION_DECLSPEC)
197 #       define DLLIMPORT __declspec(dllimport)
198 #       define DLLEXPORT __declspec(dllexport)
199 #   else
200 #       define DLLIMPORT
201 #       define DLLEXPORT
202 #   endif
203 #endif
204
205 /*
206  * These macros are used to control whether functions are being declared for
207  * import or export.  If a function is being declared while it is being built
208  * to be included in a shared library, then it should have the DLLEXPORT
209  * storage class.  If is being declared for use by a module that is going to
210  * link against the shared library, then it should have the DLLIMPORT storage
211  * class.  If the symbol is beind declared for a static build or for use from a
212  * stub library, then the storage class should be empty.
213  *
214  * The convention is that a macro called BUILD_xxxx, where xxxx is the
215  * name of a library we are building, is set on the compile line for sources
216  * that are to be placed in the library.  When this macro is set, the
217  * storage class will be set to DLLEXPORT.  At the end of the header file, the
218  * storage class will be reset to DLLIMPORT.
219  */
220 #undef TCL_STORAGE_CLASS
221 #ifdef BUILD_tcl
222 #   define TCL_STORAGE_CLASS DLLEXPORT
223 #else
224 #   ifdef USE_TCL_STUBS
225 #      define TCL_STORAGE_CLASS
226 #   else
227 #      define TCL_STORAGE_CLASS DLLIMPORT
228 #   endif
229 #endif
230
231
232 /*
233  * Definitions that allow this header file to be used either with or
234  * without ANSI C features like function prototypes.
235  */
236 #undef _ANSI_ARGS_
237 #undef CONST
238 #ifndef INLINE
239 #   define INLINE
240 #endif
241
242 #ifndef NO_CONST
243 #   define CONST const
244 #else
245 #   define CONST
246 #endif
247
248 #ifndef NO_PROTOTYPES
249 #   define _ANSI_ARGS_(x)       x
250 #else
251 #   define _ANSI_ARGS_(x)       ()
252 #endif
253
254 #ifdef USE_NON_CONST
255 #   ifdef USE_COMPAT_CONST
256 #      error define at most one of USE_NON_CONST and USE_COMPAT_CONST
257 #   endif
258 #   define CONST84
259 #   define CONST84_RETURN
260 #else
261 #   ifdef USE_COMPAT_CONST
262 #      define CONST84 
263 #      define CONST84_RETURN CONST
264 #   else
265 #      define CONST84 CONST
266 #      define CONST84_RETURN CONST
267 #   endif
268 #endif
269
270
271 /*
272  * Make sure EXTERN isn't defined elsewhere
273  */
274 #ifdef EXTERN
275 #   undef EXTERN
276 #endif /* EXTERN */
277
278 #ifdef __cplusplus
279 #   define EXTERN extern "C" TCL_STORAGE_CLASS
280 #else
281 #   define EXTERN extern TCL_STORAGE_CLASS
282 #endif
283
284
285 /*
286  * The following code is copied from winnt.h.
287  * If we don't replicate it here, then <windows.h> can't be included 
288  * after tcl.h, since tcl.h also defines VOID.
289  * This block is skipped under Cygwin and Mingw.
290  * 
291  * 
292  */
293 #if defined(__WIN32__) && !defined(HAVE_WINNT_IGNORE_VOID)
294 #ifndef VOID
295 #define VOID void
296 typedef char CHAR;
297 typedef short SHORT;
298 typedef long LONG;
299 #endif
300 #endif /* __WIN32__ && !HAVE_WINNT_IGNORE_VOID */
301
302 /*
303  * Macro to use instead of "void" for arguments that must have
304  * type "void *" in ANSI C;  maps them to type "char *" in
305  * non-ANSI systems.
306  */
307
308 #ifndef NO_VOID
309 #         define VOID void
310 #else
311 #         define VOID char
312 #endif
313
314 /*
315  * Miscellaneous declarations.
316  */
317 #ifndef NULL
318 #   define NULL 0
319 #endif
320
321 #ifndef _CLIENTDATA
322 #   ifndef NO_VOID
323         typedef void *ClientData;
324 #   else
325         typedef int *ClientData;
326 #   endif
327 #   define _CLIENTDATA
328 #endif
329
330 /*
331  * Define Tcl_WideInt to be a type that is (at least) 64-bits wide,
332  * and define Tcl_WideUInt to be the unsigned variant of that type
333  * (assuming that where we have one, we can have the other.)
334  *
335  * Also defines the following macros:
336  * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on
337  *      a real 64-bit system.)
338  * Tcl_WideAsLong - forgetful converter from wideInt to long.
339  * Tcl_LongAsWide - sign-extending converter from long to wideInt.
340  * Tcl_WideAsDouble - converter from wideInt to double.
341  * Tcl_DoubleAsWide - converter from double to wideInt.
342  *
343  * The following invariant should hold for any long value 'longVal':
344  *      longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal))
345  *
346  * Note on converting between Tcl_WideInt and strings.  This
347  * implementation (in tclObj.c) depends on the functions strtoull()
348  * and sprintf(...,"%" TCL_LL_MODIFIER "d",...).  TCL_LL_MODIFIER_SIZE
349  * is the length of the modifier string, which is "ll" on most 32-bit
350  * Unix systems.  It has to be split up like this to allow for the more
351  * complex formats sometimes needed (e.g. in the format(n) command.)
352  */
353
354 #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG)
355 #   if defined(__CYGWIN__)
356 #      define TCL_WIDE_INT_TYPE long long
357 #      define TCL_LL_MODIFIER   "L"
358 typedef struct stat     Tcl_StatBuf;
359 #      define TCL_LL_MODIFIER_SIZE      1
360 #   elif defined(__WIN32__)
361 #      define TCL_WIDE_INT_TYPE __int64
362 #      ifdef __BORLANDC__
363 typedef struct stati64 Tcl_StatBuf;
364 #         define TCL_LL_MODIFIER        "L"
365 #         define TCL_LL_MODIFIER_SIZE   1
366 #      else /* __BORLANDC__ */
367 typedef struct _stati64 Tcl_StatBuf;
368 #         define TCL_LL_MODIFIER        "I64"
369 #         define TCL_LL_MODIFIER_SIZE   3
370 #      endif /* __BORLANDC__ */
371 #   else /* __WIN32__ */
372 /*
373  * Don't know what platform it is and configure hasn't discovered what
374  * is going on for us.  Try to guess...
375  */
376 #      ifdef NO_LIMITS_H
377 #         error please define either TCL_WIDE_INT_TYPE or TCL_WIDE_INT_IS_LONG
378 #      else /* !NO_LIMITS_H */
379 #         include <limits.h>
380 #         if (INT_MAX < LONG_MAX)
381 #            define TCL_WIDE_INT_IS_LONG        1
382 #         else
383 #            define TCL_WIDE_INT_TYPE long long
384 #         endif
385 #      endif /* NO_LIMITS_H */
386 #   endif /* __WIN32__ */
387 #endif /* !TCL_WIDE_INT_TYPE & !TCL_WIDE_INT_IS_LONG */
388 #ifdef TCL_WIDE_INT_IS_LONG
389 #   undef TCL_WIDE_INT_TYPE
390 #   define TCL_WIDE_INT_TYPE    long
391 #endif /* TCL_WIDE_INT_IS_LONG */
392
393 typedef TCL_WIDE_INT_TYPE               Tcl_WideInt;
394 typedef unsigned TCL_WIDE_INT_TYPE      Tcl_WideUInt;
395
396 #ifdef TCL_WIDE_INT_IS_LONG
397 typedef struct stat     Tcl_StatBuf;
398 #   define Tcl_WideAsLong(val)          ((long)(val))
399 #   define Tcl_LongAsWide(val)          ((long)(val))
400 #   define Tcl_WideAsDouble(val)        ((double)((long)(val)))
401 #   define Tcl_DoubleAsWide(val)        ((long)((double)(val)))
402 #   ifndef TCL_LL_MODIFIER
403 #      define TCL_LL_MODIFIER           "l"
404 #      define TCL_LL_MODIFIER_SIZE      1
405 #   endif /* !TCL_LL_MODIFIER */
406 #else /* TCL_WIDE_INT_IS_LONG */
407 /*
408  * The next short section of defines are only done when not running on
409  * Windows or some other strange platform.
410  */
411 #   ifndef TCL_LL_MODIFIER
412 #      ifdef HAVE_STRUCT_STAT64
413 typedef struct stat64   Tcl_StatBuf;
414 #      else
415 typedef struct stat     Tcl_StatBuf;
416 #      endif /* HAVE_STRUCT_STAT64 */
417 #      define TCL_LL_MODIFIER           "ll"
418 #      define TCL_LL_MODIFIER_SIZE      2
419 #   endif /* !TCL_LL_MODIFIER */
420 #   define Tcl_WideAsLong(val)          ((long)((Tcl_WideInt)(val)))
421 #   define Tcl_LongAsWide(val)          ((Tcl_WideInt)((long)(val)))
422 #   define Tcl_WideAsDouble(val)        ((double)((Tcl_WideInt)(val)))
423 #   define Tcl_DoubleAsWide(val)        ((Tcl_WideInt)((double)(val)))
424 #endif /* TCL_WIDE_INT_IS_LONG */
425
426
427 /*
428  * This flag controls whether binary compatability is maintained with
429  * extensions built against a previous version of Tcl. This is true
430  * by default.
431  */
432 #ifndef TCL_PRESERVE_BINARY_COMPATABILITY
433 #   define TCL_PRESERVE_BINARY_COMPATABILITY 1
434 #endif
435
436
437 /*
438  * Data structures defined opaquely in this module. The definitions below
439  * just provide dummy types. A few fields are made visible in Tcl_Interp
440  * structures, namely those used for returning a string result from
441  * commands. Direct access to the result field is discouraged in Tcl 8.0.
442  * The interpreter result is either an object or a string, and the two
443  * values are kept consistent unless some C code sets interp->result
444  * directly. Programmers should use either the procedure Tcl_GetObjResult()
445  * or Tcl_GetStringResult() to read the interpreter's result. See the
446  * SetResult man page for details.
447  * 
448  * Note: any change to the Tcl_Interp definition below must be mirrored
449  * in the "real" definition in tclInt.h.
450  *
451  * Note: Tcl_ObjCmdProc procedures do not directly set result and freeProc.
452  * Instead, they set a Tcl_Obj member in the "real" structure that can be
453  * accessed with Tcl_GetObjResult() and Tcl_SetObjResult().
454  */
455
456 typedef struct Tcl_Interp {
457     char *result;               /* If the last command returned a string
458                                  * result, this points to it. */
459     void (*freeProc) _ANSI_ARGS_((char *blockPtr));
460                                 /* Zero means the string result is
461                                  * statically allocated. TCL_DYNAMIC means
462                                  * it was allocated with ckalloc and should
463                                  * be freed with ckfree. Other values give
464                                  * the address of procedure to invoke to
465                                  * free the result. Tcl_Eval must free it
466                                  * before executing next command. */
467     int errorLine;              /* When TCL_ERROR is returned, this gives
468                                  * the line number within the command where
469                                  * the error occurred (1 if first line). */
470 } Tcl_Interp;
471
472 typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler;
473 typedef struct Tcl_Channel_ *Tcl_Channel;
474 typedef struct Tcl_Command_ *Tcl_Command;
475 typedef struct Tcl_Condition_ *Tcl_Condition;
476 typedef struct Tcl_EncodingState_ *Tcl_EncodingState;
477 typedef struct Tcl_Encoding_ *Tcl_Encoding;
478 typedef struct Tcl_Event Tcl_Event;
479 typedef struct Tcl_Mutex_ *Tcl_Mutex;
480 typedef struct Tcl_Pid_ *Tcl_Pid;
481 typedef struct Tcl_RegExp_ *Tcl_RegExp;
482 typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey;
483 typedef struct Tcl_ThreadId_ *Tcl_ThreadId;
484 typedef struct Tcl_TimerToken_ *Tcl_TimerToken;
485 typedef struct Tcl_Trace_ *Tcl_Trace;
486 typedef struct Tcl_Var_ *Tcl_Var;
487 typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion;
488 typedef struct Tcl_LoadHandle_ *Tcl_LoadHandle;
489
490 /*
491  * Definition of the interface to procedures implementing threads.
492  * A procedure following this definition is given to each call of
493  * 'Tcl_CreateThread' and will be called as the main fuction of
494  * the new thread created by that call.
495  */
496 #ifdef MAC_TCL
497 typedef pascal void *(Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
498 #elif defined __WIN32__
499 typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
500 #else
501 typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
502 #endif
503
504
505 /*
506  * Threading function return types used for abstracting away platform
507  * differences when writing a Tcl_ThreadCreateProc.  See the NewThread
508  * function in generic/tclThreadTest.c for it's usage.
509  */
510 #ifdef MAC_TCL
511 #   define Tcl_ThreadCreateType         pascal void *
512 #   define TCL_THREAD_CREATE_RETURN     return NULL
513 #elif defined __WIN32__
514 #   define Tcl_ThreadCreateType         unsigned __stdcall
515 #   define TCL_THREAD_CREATE_RETURN     return 0
516 #else
517 #   define Tcl_ThreadCreateType         void
518 #   define TCL_THREAD_CREATE_RETURN     
519 #endif
520
521
522 /*
523  * Definition of values for default stacksize and the possible flags to be
524  * given to Tcl_CreateThread.
525  */
526 #define TCL_THREAD_STACK_DEFAULT (0)    /* Use default size for stack */
527 #define TCL_THREAD_NOFLAGS       (0000) /* Standard flags, default behaviour */
528 #define TCL_THREAD_JOINABLE      (0001) /* Mark the thread as joinable */
529
530 /*
531  * Flag values passed to Tcl_GetRegExpFromObj.
532  */
533 #define TCL_REG_BASIC           000000  /* BREs (convenience) */
534 #define TCL_REG_EXTENDED        000001  /* EREs */
535 #define TCL_REG_ADVF            000002  /* advanced features in EREs */
536 #define TCL_REG_ADVANCED        000003  /* AREs (which are also EREs) */
537 #define TCL_REG_QUOTE           000004  /* no special characters, none */
538 #define TCL_REG_NOCASE          000010  /* ignore case */
539 #define TCL_REG_NOSUB           000020  /* don't care about subexpressions */
540 #define TCL_REG_EXPANDED        000040  /* expanded format, white space &
541                                          * comments */
542 #define TCL_REG_NLSTOP          000100  /* \n doesn't match . or [^ ] */
543 #define TCL_REG_NLANCH          000200  /* ^ matches after \n, $ before */
544 #define TCL_REG_NEWLINE         000300  /* newlines are line terminators */
545 #define TCL_REG_CANMATCH        001000  /* report details on partial/limited
546                                          * matches */
547
548 /*
549  * The following flag is experimental and only intended for use by Expect.  It
550  * will probably go away in a later release.
551  */
552 #define TCL_REG_BOSONLY         002000  /* prepend \A to pattern so it only
553                                          * matches at the beginning of the
554                                          * string. */
555
556 /*
557  * Flags values passed to Tcl_RegExpExecObj.
558  */
559 #define TCL_REG_NOTBOL  0001    /* Beginning of string does not match ^.  */
560 #define TCL_REG_NOTEOL  0002    /* End of string does not match $. */
561
562 /*
563  * Structures filled in by Tcl_RegExpInfo.  Note that all offset values are
564  * relative to the start of the match string, not the beginning of the
565  * entire string.
566  */
567 typedef struct Tcl_RegExpIndices {
568     long start;         /* character offset of first character in match */
569     long end;           /* character offset of first character after the
570                          * match. */
571 } Tcl_RegExpIndices;
572
573 typedef struct Tcl_RegExpInfo {
574     int nsubs;                  /* number of subexpressions in the
575                                  * compiled expression */
576     Tcl_RegExpIndices *matches; /* array of nsubs match offset
577                                  * pairs */
578     long extendStart;           /* The offset at which a subsequent
579                                  * match might begin. */
580     long reserved;              /* Reserved for later use. */
581 } Tcl_RegExpInfo;
582
583 /*
584  * Picky compilers complain if this typdef doesn't appear before the
585  * struct's reference in tclDecls.h.
586  */
587 typedef Tcl_StatBuf *Tcl_Stat_;
588 typedef struct stat *Tcl_OldStat_;
589
590 /*
591  * When a TCL command returns, the interpreter contains a result from the
592  * command. Programmers are strongly encouraged to use one of the
593  * procedures Tcl_GetObjResult() or Tcl_GetStringResult() to read the
594  * interpreter's result. See the SetResult man page for details. Besides
595  * this result, the command procedure returns an integer code, which is 
596  * one of the following:
597  *
598  * TCL_OK               Command completed normally; the interpreter's
599  *                      result contains the command's result.
600  * TCL_ERROR            The command couldn't be completed successfully;
601  *                      the interpreter's result describes what went wrong.
602  * TCL_RETURN           The command requests that the current procedure
603  *                      return; the interpreter's result contains the
604  *                      procedure's return value.
605  * TCL_BREAK            The command requests that the innermost loop
606  *                      be exited; the interpreter's result is meaningless.
607  * TCL_CONTINUE         Go on to the next iteration of the current loop;
608  *                      the interpreter's result is meaningless.
609  */
610 #define TCL_OK          0
611 #define TCL_ERROR       1
612 #define TCL_RETURN      2
613 #define TCL_BREAK       3
614 #define TCL_CONTINUE    4
615
616 #define TCL_RESULT_SIZE 200
617
618 /*
619  * Flags to control what substitutions are performed by Tcl_SubstObj():
620  */
621 #define TCL_SUBST_COMMANDS      001
622 #define TCL_SUBST_VARIABLES     002
623 #define TCL_SUBST_BACKSLASHES   004
624 #define TCL_SUBST_ALL           007
625
626
627 /*
628  * Argument descriptors for math function callbacks in expressions:
629  */
630 typedef enum {
631     TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT
632 } Tcl_ValueType;
633 typedef struct Tcl_Value {
634     Tcl_ValueType type;         /* Indicates intValue or doubleValue is
635                                  * valid, or both. */
636     long intValue;              /* Integer value. */
637     double doubleValue;         /* Double-precision floating value. */
638     Tcl_WideInt wideValue;      /* Wide (min. 64-bit) integer value. */
639 } Tcl_Value;
640
641 /*
642  * Forward declaration of Tcl_Obj to prevent an error when the forward
643  * reference to Tcl_Obj is encountered in the procedure types declared 
644  * below.
645  */
646 struct Tcl_Obj;
647
648
649 /*
650  * Procedure types defined by Tcl:
651  */
652
653 typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
654 typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData,
655         Tcl_Interp *interp, int code));
656 typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask));
657 typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data));
658 typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData));
659 typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData,
660         Tcl_Interp *interp, int argc, CONST84 char *argv[]));
661 typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData,
662         Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc,
663         ClientData cmdClientData, int argc, CONST84 char *argv[]));
664 typedef int (Tcl_CmdObjTraceProc) _ANSI_ARGS_((ClientData clientData,
665         Tcl_Interp *interp, int level, CONST char *command,
666         Tcl_Command commandInfo, int objc, struct Tcl_Obj * CONST * objv));
667 typedef void (Tcl_CmdObjTraceDeleteProc) _ANSI_ARGS_((ClientData clientData));
668 typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, 
669         struct Tcl_Obj *dupPtr));
670 typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData,
671         CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr,
672         char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr,
673         int *dstCharsPtr));
674 typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData));
675 typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags));
676 typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData,
677         int flags));
678 typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr,
679         ClientData clientData));
680 typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData,
681         int flags));
682 typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData));
683 typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask));
684 typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData));
685 typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
686 typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr));
687 typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData));
688 typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData,
689         Tcl_Interp *interp));
690 typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData,
691         Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr));
692 typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData));
693 typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData,
694         Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv));
695 typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
696 typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(CONST char *, format));
697 typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData,
698         Tcl_Channel chan, char *address, int port));
699 typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData));
700 typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp,
701         struct Tcl_Obj *objPtr));
702 typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
703 typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData,
704         Tcl_Interp *interp, CONST84 char *part1, CONST84 char *part2, int flags));
705 typedef void (Tcl_CommandTraceProc) _ANSI_ARGS_((ClientData clientData,
706         Tcl_Interp *interp, CONST char *oldName, CONST char *newName,
707         int flags));
708 typedef void (Tcl_CreateFileHandlerProc) _ANSI_ARGS_((int fd, int mask,
709         Tcl_FileProc *proc, ClientData clientData));
710 typedef void (Tcl_DeleteFileHandlerProc) _ANSI_ARGS_((int fd));
711 typedef void (Tcl_AlertNotifierProc) _ANSI_ARGS_((ClientData clientData));
712 typedef void (Tcl_ServiceModeHookProc) _ANSI_ARGS_((int mode));
713 typedef ClientData (Tcl_InitNotifierProc) _ANSI_ARGS_((VOID));
714 typedef void (Tcl_FinalizeNotifierProc) _ANSI_ARGS_((ClientData clientData));
715 typedef void (Tcl_MainLoopProc) _ANSI_ARGS_((void));
716
717
718 /*
719  * The following structure represents a type of object, which is a
720  * particular internal representation for an object plus a set of
721  * procedures that provide standard operations on objects of that type.
722  */
723
724 typedef struct Tcl_ObjType {
725     char *name;                 /* Name of the type, e.g. "int". */
726     Tcl_FreeInternalRepProc *freeIntRepProc;
727                                 /* Called to free any storage for the type's
728                                  * internal rep. NULL if the internal rep
729                                  * does not need freeing. */
730     Tcl_DupInternalRepProc *dupIntRepProc;
731                                 /* Called to create a new object as a copy
732                                  * of an existing object. */
733     Tcl_UpdateStringProc *updateStringProc;
734                                 /* Called to update the string rep from the
735                                  * type's internal representation. */
736     Tcl_SetFromAnyProc *setFromAnyProc;
737                                 /* Called to convert the object's internal
738                                  * rep to this type. Frees the internal rep
739                                  * of the old type. Returns TCL_ERROR on
740                                  * failure. */
741 } Tcl_ObjType;
742
743
744 /*
745  * One of the following structures exists for each object in the Tcl
746  * system. An object stores a value as either a string, some internal
747  * representation, or both.
748  */
749
750 typedef struct Tcl_Obj {
751     int refCount;               /* When 0 the object will be freed. */
752     char *bytes;                /* This points to the first byte of the
753                                  * object's string representation. The array
754                                  * must be followed by a null byte (i.e., at
755                                  * offset length) but may also contain
756                                  * embedded null characters. The array's
757                                  * storage is allocated by ckalloc. NULL
758                                  * means the string rep is invalid and must
759                                  * be regenerated from the internal rep.
760                                  * Clients should use Tcl_GetStringFromObj
761                                  * or Tcl_GetString to get a pointer to the
762                                  * byte array as a readonly value. */
763     int length;                 /* The number of bytes at *bytes, not
764                                  * including the terminating null. */
765     Tcl_ObjType *typePtr;       /* Denotes the object's type. Always
766                                  * corresponds to the type of the object's
767                                  * internal rep. NULL indicates the object
768                                  * has no internal rep (has no type). */
769     union {                     /* The internal representation: */
770         long longValue;         /*   - an long integer value */
771         double doubleValue;     /*   - a double-precision floating value */
772         VOID *otherValuePtr;    /*   - another, type-specific value */
773         Tcl_WideInt wideValue;  /*   - a long long value */
774         struct {                /*   - internal rep as two pointers */
775             VOID *ptr1;
776             VOID *ptr2;
777         } twoPtrValue;
778     } internalRep;
779 } Tcl_Obj;
780
781
782 /*
783  * Macros to increment and decrement a Tcl_Obj's reference count, and to
784  * test whether an object is shared (i.e. has reference count > 1).
785  * Note: clients should use Tcl_DecrRefCount() when they are finished using
786  * an object, and should never call TclFreeObj() directly. TclFreeObj() is
787  * only defined and made public in tcl.h to support Tcl_DecrRefCount's macro
788  * definition. Note also that Tcl_DecrRefCount() refers to the parameter
789  * "obj" twice. This means that you should avoid calling it with an
790  * expression that is expensive to compute or has side effects.
791  */
792 void            Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
793 void            Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
794 int             Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr));
795
796 #ifdef TCL_MEM_DEBUG
797 #   define Tcl_IncrRefCount(objPtr) \
798         Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__)
799 #   define Tcl_DecrRefCount(objPtr) \
800         Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
801 #   define Tcl_IsShared(objPtr) \
802         Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
803 #else
804 #   define Tcl_IncrRefCount(objPtr) \
805         ++(objPtr)->refCount
806 #   define Tcl_DecrRefCount(objPtr) \
807         if (--(objPtr)->refCount <= 0) TclFreeObj(objPtr)
808 #   define Tcl_IsShared(objPtr) \
809         ((objPtr)->refCount > 1)
810 #endif
811
812 /*
813  * Macros and definitions that help to debug the use of Tcl objects.
814  * When TCL_MEM_DEBUG is defined, the Tcl_New declarations are 
815  * overridden to call debugging versions of the object creation procedures.
816  */
817
818 #ifdef TCL_MEM_DEBUG
819 #  define Tcl_NewBooleanObj(val) \
820      Tcl_DbNewBooleanObj(val, __FILE__, __LINE__)
821 #  define Tcl_NewByteArrayObj(bytes, len) \
822      Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__)
823 #  define Tcl_NewDoubleObj(val) \
824      Tcl_DbNewDoubleObj(val, __FILE__, __LINE__)
825 #  define Tcl_NewIntObj(val) \
826      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
827 #  define Tcl_NewListObj(objc, objv) \
828      Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__)
829 #  define Tcl_NewLongObj(val) \
830      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
831 #  define Tcl_NewObj() \
832      Tcl_DbNewObj(__FILE__, __LINE__)
833 #  define Tcl_NewStringObj(bytes, len) \
834      Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__)
835 #  define Tcl_NewWideIntObj(val) \
836      Tcl_DbNewWideIntObj(val, __FILE__, __LINE__)
837 #endif /* TCL_MEM_DEBUG */
838
839
840 /*
841  * The following structure contains the state needed by
842  * Tcl_SaveResult.  No-one outside of Tcl should access any of these
843  * fields.  This structure is typically allocated on the stack.
844  */
845 typedef struct Tcl_SavedResult {
846     char *result;
847     Tcl_FreeProc *freeProc;
848     Tcl_Obj *objResultPtr;
849     char *appendResult;
850     int appendAvl;
851     int appendUsed;
852     char resultSpace[TCL_RESULT_SIZE+1];
853 } Tcl_SavedResult;
854
855
856 /*
857  * The following definitions support Tcl's namespace facility.
858  * Note: the first five fields must match exactly the fields in a
859  * Namespace structure (see tclInt.h). 
860  */
861
862 typedef struct Tcl_Namespace {
863     char *name;                 /* The namespace's name within its parent
864                                  * namespace. This contains no ::'s. The
865                                  * name of the global namespace is ""
866                                  * although "::" is an synonym. */
867     char *fullName;             /* The namespace's fully qualified name.
868                                  * This starts with ::. */
869     ClientData clientData;      /* Arbitrary value associated with this
870                                  * namespace. */
871     Tcl_NamespaceDeleteProc* deleteProc;
872                                 /* Procedure invoked when deleting the
873                                  * namespace to, e.g., free clientData. */
874     struct Tcl_Namespace* parentPtr;
875                                 /* Points to the namespace that contains
876                                  * this one. NULL if this is the global
877                                  * namespace. */
878 } Tcl_Namespace;
879
880
881 /*
882  * The following structure represents a call frame, or activation record.
883  * A call frame defines a naming context for a procedure call: its local
884  * scope (for local variables) and its namespace scope (used for non-local
885  * variables; often the global :: namespace). A call frame can also define
886  * the naming context for a namespace eval or namespace inscope command:
887  * the namespace in which the command's code should execute. The
888  * Tcl_CallFrame structures exist only while procedures or namespace
889  * eval/inscope's are being executed, and provide a Tcl call stack.
890  * 
891  * A call frame is initialized and pushed using Tcl_PushCallFrame and
892  * popped using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be
893  * provided by the Tcl_PushCallFrame caller, and callers typically allocate
894  * them on the C call stack for efficiency. For this reason, Tcl_CallFrame
895  * is defined as a structure and not as an opaque token. However, most
896  * Tcl_CallFrame fields are hidden since applications should not access
897  * them directly; others are declared as "dummyX".
898  *
899  * WARNING!! The structure definition must be kept consistent with the
900  * CallFrame structure in tclInt.h. If you change one, change the other.
901  */
902
903 typedef struct Tcl_CallFrame {
904     Tcl_Namespace *nsPtr;
905     int dummy1;
906     int dummy2;
907     char *dummy3;
908     char *dummy4;
909     char *dummy5;
910     int dummy6;
911     char *dummy7;
912     char *dummy8;
913     int dummy9;
914     char* dummy10;
915 } Tcl_CallFrame;
916
917
918 /*
919  * Information about commands that is returned by Tcl_GetCommandInfo and
920  * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based
921  * command procedure while proc is a traditional Tcl argc/argv
922  * string-based procedure. Tcl_CreateObjCommand and Tcl_CreateCommand
923  * ensure that both objProc and proc are non-NULL and can be called to
924  * execute the command. However, it may be faster to call one instead of
925  * the other. The member isNativeObjectProc is set to 1 if an
926  * object-based procedure was registered by Tcl_CreateObjCommand, and to
927  * 0 if a string-based procedure was registered by Tcl_CreateCommand.
928  * The other procedure is typically set to a compatibility wrapper that
929  * does string-to-object or object-to-string argument conversions then
930  * calls the other procedure.
931  */
932
933 typedef struct Tcl_CmdInfo {
934     int isNativeObjectProc;      /* 1 if objProc was registered by a call to
935                                   * Tcl_CreateObjCommand; 0 otherwise.
936                                   * Tcl_SetCmdInfo does not modify this
937                                   * field. */
938     Tcl_ObjCmdProc *objProc;     /* Command's object-based procedure. */
939     ClientData objClientData;    /* ClientData for object proc. */
940     Tcl_CmdProc *proc;           /* Command's string-based procedure. */
941     ClientData clientData;       /* ClientData for string proc. */
942     Tcl_CmdDeleteProc *deleteProc;
943                                  /* Procedure to call when command is
944                                   * deleted. */
945     ClientData deleteData;       /* Value to pass to deleteProc (usually
946                                   * the same as clientData). */
947     Tcl_Namespace *namespacePtr; /* Points to the namespace that contains
948                                   * this command. Note that Tcl_SetCmdInfo
949                                   * will not change a command's namespace;
950                                   * use Tcl_RenameCommand to do that. */
951
952 } Tcl_CmdInfo;
953
954 /*
955  * The structure defined below is used to hold dynamic strings.  The only
956  * field that clients should use is the string field, accessible via the
957  * macro Tcl_DStringValue.  
958  */
959 #define TCL_DSTRING_STATIC_SIZE 200
960 typedef struct Tcl_DString {
961     char *string;               /* Points to beginning of string:  either
962                                  * staticSpace below or a malloced array. */
963     int length;                 /* Number of non-NULL characters in the
964                                  * string. */
965     int spaceAvl;               /* Total number of bytes available for the
966                                  * string and its terminating NULL char. */
967     char staticSpace[TCL_DSTRING_STATIC_SIZE];
968                                 /* Space to use in common case where string
969                                  * is small. */
970 } Tcl_DString;
971
972 #define Tcl_DStringLength(dsPtr) ((dsPtr)->length)
973 #define Tcl_DStringValue(dsPtr) ((dsPtr)->string)
974 #define Tcl_DStringTrunc Tcl_DStringSetLength
975
976 /*
977  * Definitions for the maximum number of digits of precision that may
978  * be specified in the "tcl_precision" variable, and the number of
979  * bytes of buffer space required by Tcl_PrintDouble.
980  */
981 #define TCL_MAX_PREC 17
982 #define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10)
983
984 /*
985  * Definition for a number of bytes of buffer space sufficient to hold the
986  * string representation of an integer in base 10 (assuming the existence
987  * of 64-bit integers).
988  */
989 #define TCL_INTEGER_SPACE       24
990
991 /*
992  * Flag that may be passed to Tcl_ConvertElement to force it not to
993  * output braces (careful!  if you change this flag be sure to change
994  * the definitions at the front of tclUtil.c).
995  */
996 #define TCL_DONT_USE_BRACES     1
997
998 /*
999  * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow
1000  * abbreviated strings.
1001  */
1002 #define TCL_EXACT       1
1003
1004 /*
1005  * Flag values passed to Tcl_RecordAndEval and/or Tcl_EvalObj.
1006  * WARNING: these bit choices must not conflict with the bit choices
1007  * for evalFlag bits in tclInt.h!!
1008  */
1009 #define TCL_NO_EVAL             0x10000
1010 #define TCL_EVAL_GLOBAL         0x20000
1011 #define TCL_EVAL_DIRECT         0x40000
1012 #define TCL_EVAL_INVOKE         0x80000
1013
1014 /*
1015  * Special freeProc values that may be passed to Tcl_SetResult (see
1016  * the man page for details):
1017  */
1018 #define TCL_VOLATILE    ((Tcl_FreeProc *) 1)
1019 #define TCL_STATIC      ((Tcl_FreeProc *) 0)
1020 #define TCL_DYNAMIC     ((Tcl_FreeProc *) 3)
1021
1022 /*
1023  * Flag values passed to variable-related procedures.
1024  */
1025 #define TCL_GLOBAL_ONLY          1
1026 #define TCL_NAMESPACE_ONLY       2
1027 #define TCL_APPEND_VALUE         4
1028 #define TCL_LIST_ELEMENT         8
1029 #define TCL_TRACE_READS          0x10
1030 #define TCL_TRACE_WRITES         0x20
1031 #define TCL_TRACE_UNSETS         0x40
1032 #define TCL_TRACE_DESTROYED      0x80
1033 #define TCL_INTERP_DESTROYED     0x100
1034 #define TCL_LEAVE_ERR_MSG        0x200
1035 #define TCL_TRACE_ARRAY          0x800
1036 #ifndef TCL_REMOVE_OBSOLETE_TRACES
1037 /* Required to support old variable/vdelete/vinfo traces */
1038 #define TCL_TRACE_OLD_STYLE      0x1000
1039 #endif
1040 /* Indicate the semantics of the result of a trace */
1041 #define TCL_TRACE_RESULT_DYNAMIC 0x8000
1042 #define TCL_TRACE_RESULT_OBJECT  0x10000
1043
1044 /*
1045  * Flag values passed to command-related procedures.
1046  */
1047
1048 #define TCL_TRACE_RENAME 0x2000
1049 #define TCL_TRACE_DELETE 0x4000
1050
1051 #define TCL_ALLOW_INLINE_COMPILATION 0x20000
1052
1053 /*
1054  * Flag values passed to Tcl_CreateObjTrace, and used internally
1055  * by command execution traces.  Slots 4,8,16 and 32 are
1056  * used internally by execution traces (see tclCmdMZ.c)
1057  */
1058 #define TCL_TRACE_ENTER_EXEC            1
1059 #define TCL_TRACE_LEAVE_EXEC            2
1060
1061 /*
1062  * The TCL_PARSE_PART1 flag is deprecated and has no effect. 
1063  * The part1 is now always parsed whenever the part2 is NULL.
1064  * (This is to avoid a common error when converting code to
1065  *  use the new object based APIs and forgetting to give the
1066  *  flag)
1067  */
1068 #ifndef TCL_NO_DEPRECATED
1069 #   define TCL_PARSE_PART1      0x400
1070 #endif
1071
1072
1073 /*
1074  * Types for linked variables:
1075  */
1076 #define TCL_LINK_INT            1
1077 #define TCL_LINK_DOUBLE         2
1078 #define TCL_LINK_BOOLEAN        3
1079 #define TCL_LINK_STRING         4
1080 #define TCL_LINK_WIDE_INT       5
1081 #define TCL_LINK_READ_ONLY      0x80
1082
1083
1084 /*
1085  * Forward declarations of Tcl_HashTable and related types.
1086  */
1087 typedef struct Tcl_HashKeyType Tcl_HashKeyType;
1088 typedef struct Tcl_HashTable Tcl_HashTable;
1089 typedef struct Tcl_HashEntry Tcl_HashEntry;
1090
1091 typedef unsigned int (Tcl_HashKeyProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr,
1092         VOID *keyPtr));
1093 typedef int (Tcl_CompareHashKeysProc) _ANSI_ARGS_((VOID *keyPtr,
1094         Tcl_HashEntry *hPtr));
1095 typedef Tcl_HashEntry *(Tcl_AllocHashEntryProc) _ANSI_ARGS_((
1096         Tcl_HashTable *tablePtr, VOID *keyPtr));
1097 typedef void (Tcl_FreeHashEntryProc) _ANSI_ARGS_((Tcl_HashEntry *hPtr));
1098
1099 /*
1100  * This flag controls whether the hash table stores the hash of a key, or
1101  * recalculates it. There should be no reason for turning this flag off
1102  * as it is completely binary and source compatible unless you directly
1103  * access the bucketPtr member of the Tcl_HashTableEntry structure. This
1104  * member has been removed and the space used to store the hash value.
1105  */
1106 #ifndef TCL_HASH_KEY_STORE_HASH
1107 #   define TCL_HASH_KEY_STORE_HASH 1
1108 #endif
1109
1110 /*
1111  * Structure definition for an entry in a hash table.  No-one outside
1112  * Tcl should access any of these fields directly;  use the macros
1113  * defined below.
1114  */
1115
1116 struct Tcl_HashEntry {
1117     Tcl_HashEntry *nextPtr;             /* Pointer to next entry in this
1118                                          * hash bucket, or NULL for end of
1119                                          * chain. */
1120     Tcl_HashTable *tablePtr;            /* Pointer to table containing entry. */
1121 #if TCL_HASH_KEY_STORE_HASH
1122 #   if TCL_PRESERVE_BINARY_COMPATABILITY
1123     VOID *hash;                         /* Hash value, stored as pointer to
1124                                          * ensure that the offsets of the
1125                                          * fields in this structure are not
1126                                          * changed. */
1127 #   else
1128     unsigned int hash;                  /* Hash value. */
1129 #   endif
1130 #else
1131     Tcl_HashEntry **bucketPtr;          /* Pointer to bucket that points to
1132                                          * first entry in this entry's chain:
1133                                          * used for deleting the entry. */
1134 #endif
1135     ClientData clientData;              /* Application stores something here
1136                                          * with Tcl_SetHashValue. */
1137     union {                             /* Key has one of these forms: */
1138         char *oneWordValue;             /* One-word value for key. */
1139         Tcl_Obj *objPtr;                /* Tcl_Obj * key value. */
1140         int words[1];                   /* Multiple integer words for key.
1141                                          * The actual size will be as large
1142                                          * as necessary for this table's
1143                                          * keys. */
1144         char string[4];                 /* String for key.  The actual size
1145                                          * will be as large as needed to hold
1146                                          * the key. */
1147     } key;                              /* MUST BE LAST FIELD IN RECORD!! */
1148 };
1149
1150 /*
1151  * Flags used in Tcl_HashKeyType.
1152  *
1153  * TCL_HASH_KEY_RANDOMIZE_HASH:
1154  *                              There are some things, pointers for example
1155  *                              which don't hash well because they do not use
1156  *                              the lower bits. If this flag is set then the
1157  *                              hash table will attempt to rectify this by
1158  *                              randomising the bits and then using the upper
1159  *                              N bits as the index into the table.
1160  */
1161 #define TCL_HASH_KEY_RANDOMIZE_HASH 0x1
1162
1163 /*
1164  * Structure definition for the methods associated with a hash table
1165  * key type.
1166  */
1167 #define TCL_HASH_KEY_TYPE_VERSION 1
1168 struct Tcl_HashKeyType {
1169     int version;                /* Version of the table. If this structure is
1170                                  * extended in future then the version can be
1171                                  * used to distinguish between different
1172                                  * structures. 
1173                                  */
1174
1175     int flags;                  /* Flags, see above for details. */
1176
1177     /* Calculates a hash value for the key. If this is NULL then the pointer
1178      * itself is used as a hash value.
1179      */
1180     Tcl_HashKeyProc *hashKeyProc;
1181
1182     /* Compares two keys and returns zero if they do not match, and non-zero
1183      * if they do. If this is NULL then the pointers are compared.
1184      */
1185     Tcl_CompareHashKeysProc *compareKeysProc;
1186
1187     /* Called to allocate memory for a new entry, i.e. if the key is a
1188      * string then this could allocate a single block which contains enough
1189      * space for both the entry and the string. Only the key field of the
1190      * allocated Tcl_HashEntry structure needs to be filled in. If something
1191      * else needs to be done to the key, i.e. incrementing a reference count
1192      * then that should be done by this function. If this is NULL then Tcl_Alloc
1193      * is used to allocate enough space for a Tcl_HashEntry and the key pointer
1194      * is assigned to key.oneWordValue.
1195      */
1196     Tcl_AllocHashEntryProc *allocEntryProc;
1197
1198     /* Called to free memory associated with an entry. If something else needs
1199      * to be done to the key, i.e. decrementing a reference count then that
1200      * should be done by this function. If this is NULL then Tcl_Free is used
1201      * to free the Tcl_HashEntry.
1202      */
1203     Tcl_FreeHashEntryProc *freeEntryProc;
1204 };
1205
1206 /*
1207  * Structure definition for a hash table.  Must be in tcl.h so clients
1208  * can allocate space for these structures, but clients should never
1209  * access any fields in this structure.
1210  */
1211
1212 #define TCL_SMALL_HASH_TABLE 4
1213 struct Tcl_HashTable {
1214     Tcl_HashEntry **buckets;            /* Pointer to bucket array.  Each
1215                                          * element points to first entry in
1216                                          * bucket's hash chain, or NULL. */
1217     Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
1218                                         /* Bucket array used for small tables
1219                                          * (to avoid mallocs and frees). */
1220     int numBuckets;                     /* Total number of buckets allocated
1221                                          * at **bucketPtr. */
1222     int numEntries;                     /* Total number of entries present
1223                                          * in table. */
1224     int rebuildSize;                    /* Enlarge table when numEntries gets
1225                                          * to be this large. */
1226     int downShift;                      /* Shift count used in hashing
1227                                          * function.  Designed to use high-
1228                                          * order bits of randomized keys. */
1229     int mask;                           /* Mask value used in hashing
1230                                          * function. */
1231     int keyType;                        /* Type of keys used in this table. 
1232                                          * It's either TCL_CUSTOM_KEYS,
1233                                          * TCL_STRING_KEYS, TCL_ONE_WORD_KEYS,
1234                                          * or an integer giving the number of
1235                                          * ints that is the size of the key.
1236                                          */
1237 #if TCL_PRESERVE_BINARY_COMPATABILITY
1238     Tcl_HashEntry *(*findProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr,
1239             CONST char *key));
1240     Tcl_HashEntry *(*createProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr,
1241             CONST char *key, int *newPtr));
1242 #endif
1243     Tcl_HashKeyType *typePtr;           /* Type of the keys used in the
1244                                          * Tcl_HashTable. */
1245 };
1246
1247 /*
1248  * Structure definition for information used to keep track of searches
1249  * through hash tables:
1250  */
1251
1252 typedef struct Tcl_HashSearch {
1253     Tcl_HashTable *tablePtr;            /* Table being searched. */
1254     int nextIndex;                      /* Index of next bucket to be
1255                                          * enumerated after present one. */
1256     Tcl_HashEntry *nextEntryPtr;        /* Next entry to be enumerated in the
1257                                          * the current bucket. */
1258 } Tcl_HashSearch;
1259
1260 /*
1261  * Acceptable key types for hash tables:
1262  *
1263  * TCL_STRING_KEYS:             The keys are strings, they are copied into
1264  *                              the entry.
1265  * TCL_ONE_WORD_KEYS:           The keys are pointers, the pointer is stored
1266  *                              in the entry.
1267  * TCL_CUSTOM_TYPE_KEYS:        The keys are arbitrary types which are copied
1268  *                              into the entry.
1269  * TCL_CUSTOM_PTR_KEYS:         The keys are pointers to arbitrary types, the
1270  *                              pointer is stored in the entry.
1271  *
1272  * While maintaining binary compatability the above have to be distinct
1273  * values as they are used to differentiate between old versions of the
1274  * hash table which don't have a typePtr and new ones which do. Once binary
1275  * compatability is discarded in favour of making more wide spread changes
1276  * TCL_STRING_KEYS can be the same as TCL_CUSTOM_TYPE_KEYS, and
1277  * TCL_ONE_WORD_KEYS can be the same as TCL_CUSTOM_PTR_KEYS because they
1278  * simply determine how the key is accessed from the entry and not the
1279  * behaviour.
1280  */
1281
1282 #define TCL_STRING_KEYS         0
1283 #define TCL_ONE_WORD_KEYS       1
1284
1285 #if TCL_PRESERVE_BINARY_COMPATABILITY
1286 #   define TCL_CUSTOM_TYPE_KEYS         -2
1287 #   define TCL_CUSTOM_PTR_KEYS          -1
1288 #else
1289 #   define TCL_CUSTOM_TYPE_KEYS         TCL_STRING_KEYS
1290 #   define TCL_CUSTOM_PTR_KEYS          TCL_ONE_WORD_KEYS
1291 #endif
1292
1293 /*
1294  * Macros for clients to use to access fields of hash entries:
1295  */
1296
1297 #define Tcl_GetHashValue(h) ((h)->clientData)
1298 #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))
1299 #if TCL_PRESERVE_BINARY_COMPATABILITY
1300 #   define Tcl_GetHashKey(tablePtr, h) \
1301         ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \
1302                     (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \
1303                    ? (h)->key.oneWordValue \
1304                    : (h)->key.string))
1305 #else
1306 #   define Tcl_GetHashKey(tablePtr, h) \
1307         ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) \
1308                    ? (h)->key.oneWordValue \
1309                    : (h)->key.string))
1310 #endif
1311
1312 /*
1313  * Macros to use for clients to use to invoke find and create procedures
1314  * for hash tables:
1315  */
1316
1317 #if TCL_PRESERVE_BINARY_COMPATABILITY
1318 #   define Tcl_FindHashEntry(tablePtr, key) \
1319         (*((tablePtr)->findProc))(tablePtr, key)
1320 #   define Tcl_CreateHashEntry(tablePtr, key, newPtr) \
1321         (*((tablePtr)->createProc))(tablePtr, key, newPtr)
1322 #else /* !TCL_PRESERVE_BINARY_COMPATABILITY */
1323 /*
1324  * Macro to use new extended version of Tcl_InitHashTable.
1325  */
1326 #   define Tcl_InitHashTable(tablePtr, keyType) \
1327         Tcl_InitHashTableEx(tablePtr, keyType, NULL)
1328 #endif /* TCL_PRESERVE_BINARY_COMPATABILITY */
1329
1330
1331 /*
1332  * Flag values to pass to Tcl_DoOneEvent to disable searches
1333  * for some kinds of events:
1334  */
1335 #define TCL_DONT_WAIT           (1<<1)
1336 #define TCL_WINDOW_EVENTS       (1<<2)
1337 #define TCL_FILE_EVENTS         (1<<3)
1338 #define TCL_TIMER_EVENTS        (1<<4)
1339 #define TCL_IDLE_EVENTS         (1<<5)  /* WAS 0x10 ???? */
1340 #define TCL_ALL_EVENTS          (~TCL_DONT_WAIT)
1341
1342 /*
1343  * The following structure defines a generic event for the Tcl event
1344  * system.  These are the things that are queued in calls to Tcl_QueueEvent
1345  * and serviced later by Tcl_DoOneEvent.  There can be many different
1346  * kinds of events with different fields, corresponding to window events,
1347  * timer events, etc.  The structure for a particular event consists of
1348  * a Tcl_Event header followed by additional information specific to that
1349  * event.
1350  */
1351 struct Tcl_Event {
1352     Tcl_EventProc *proc;        /* Procedure to call to service this event. */
1353     struct Tcl_Event *nextPtr;  /* Next in list of pending events, or NULL. */
1354 };
1355
1356 /*
1357  * Positions to pass to Tcl_QueueEvent:
1358  */
1359 typedef enum {
1360     TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK
1361 } Tcl_QueuePosition;
1362
1363 /*
1364  * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier
1365  * event routines.
1366  */
1367 #define TCL_SERVICE_NONE 0
1368 #define TCL_SERVICE_ALL 1
1369
1370
1371 /*
1372  * The following structure keeps is used to hold a time value, either as
1373  * an absolute time (the number of seconds from the epoch) or as an
1374  * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT.
1375  * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT.
1376  */
1377 typedef struct Tcl_Time {
1378     long sec;                   /* Seconds. */
1379     long usec;                  /* Microseconds. */
1380 } Tcl_Time;
1381
1382 typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr));
1383 typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr));
1384
1385
1386 /*
1387  * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler
1388  * to indicate what sorts of events are of interest:
1389  */
1390 #define TCL_READABLE    (1<<1)
1391 #define TCL_WRITABLE    (1<<2)
1392 #define TCL_EXCEPTION   (1<<3)
1393
1394 /*
1395  * Flag values to pass to Tcl_OpenCommandChannel to indicate the
1396  * disposition of the stdio handles.  TCL_STDIN, TCL_STDOUT, TCL_STDERR,
1397  * are also used in Tcl_GetStdChannel.
1398  */
1399 #define TCL_STDIN               (1<<1)  
1400 #define TCL_STDOUT              (1<<2)
1401 #define TCL_STDERR              (1<<3)
1402 #define TCL_ENFORCE_MODE        (1<<4)
1403
1404 /*
1405  * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel
1406  * should be closed.
1407  */
1408 #define TCL_CLOSE_READ          (1<<1)
1409 #define TCL_CLOSE_WRITE (1<<2)
1410
1411 /*
1412  * Value to use as the closeProc for a channel that supports the
1413  * close2Proc interface.
1414  */
1415 #define TCL_CLOSE2PROC  ((Tcl_DriverCloseProc *)1)
1416
1417 /*
1418  * Channel version tag.  This was introduced in 8.3.2/8.4.
1419  */
1420 #define TCL_CHANNEL_VERSION_1   ((Tcl_ChannelTypeVersion) 0x1)
1421 #define TCL_CHANNEL_VERSION_2   ((Tcl_ChannelTypeVersion) 0x2)
1422 #define TCL_CHANNEL_VERSION_3   ((Tcl_ChannelTypeVersion) 0x3)
1423
1424 /*
1425  * Typedefs for the various operations in a channel type:
1426  */
1427 typedef int     (Tcl_DriverBlockModeProc) _ANSI_ARGS_((
1428                     ClientData instanceData, int mode));
1429 typedef int     (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData,
1430                     Tcl_Interp *interp));
1431 typedef int     (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData,
1432                     Tcl_Interp *interp, int flags));
1433 typedef int     (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData,
1434                     char *buf, int toRead, int *errorCodePtr));
1435 typedef int     (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData,
1436                     CONST84 char *buf, int toWrite, int *errorCodePtr));
1437 typedef int     (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData,
1438                     long offset, int mode, int *errorCodePtr));
1439 typedef int     (Tcl_DriverSetOptionProc) _ANSI_ARGS_((
1440                     ClientData instanceData, Tcl_Interp *interp,
1441                     CONST char *optionName, CONST char *value));
1442 typedef int     (Tcl_DriverGetOptionProc) _ANSI_ARGS_((
1443                     ClientData instanceData, Tcl_Interp *interp,
1444                     CONST84 char *optionName, Tcl_DString *dsPtr));
1445 typedef void    (Tcl_DriverWatchProc) _ANSI_ARGS_((
1446                     ClientData instanceData, int mask));
1447 typedef int     (Tcl_DriverGetHandleProc) _ANSI_ARGS_((
1448                     ClientData instanceData, int direction,
1449                     ClientData *handlePtr));
1450 typedef int     (Tcl_DriverFlushProc) _ANSI_ARGS_((
1451                     ClientData instanceData));
1452 typedef int     (Tcl_DriverHandlerProc) _ANSI_ARGS_((
1453                     ClientData instanceData, int interestMask));
1454 typedef Tcl_WideInt (Tcl_DriverWideSeekProc) _ANSI_ARGS_((
1455                     ClientData instanceData, Tcl_WideInt offset,
1456                     int mode, int *errorCodePtr));
1457
1458
1459 /*
1460  * The following declarations either map ckalloc and ckfree to
1461  * malloc and free, or they map them to procedures with all sorts
1462  * of debugging hooks defined in tclCkalloc.c.
1463  */
1464 #ifdef TCL_MEM_DEBUG
1465
1466 #   define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
1467 #   define ckfree(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
1468 #   define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
1469 #   define attemptckalloc(x) Tcl_AttemptDbCkalloc(x, __FILE__, __LINE__)
1470 #   define attemptckrealloc(x,y) Tcl_AttemptDbCkrealloc((x), (y), __FILE__, __LINE__)
1471 #else /* !TCL_MEM_DEBUG */
1472
1473 /*
1474  * If we are not using the debugging allocator, we should call the 
1475  * Tcl_Alloc, et al. routines in order to guarantee that every module
1476  * is using the same memory allocator both inside and outside of the
1477  * Tcl library.
1478  */
1479 #   define ckalloc(x) Tcl_Alloc(x)
1480 #   define ckfree(x) Tcl_Free(x)
1481 #   define ckrealloc(x,y) Tcl_Realloc(x,y)
1482 #   define attemptckalloc(x) Tcl_AttemptAlloc(x)
1483 #   define attemptckrealloc(x,y) Tcl_AttemptRealloc(x,y)
1484 #   define Tcl_InitMemory(x)
1485 #   define Tcl_DumpActiveMemory(x)
1486 #   define Tcl_ValidateAllMemory(x,y)
1487
1488 #endif /* !TCL_MEM_DEBUG */
1489
1490 /*
1491  * struct Tcl_ChannelType:
1492  *
1493  * One such structure exists for each type (kind) of channel.
1494  * It collects together in one place all the functions that are
1495  * part of the specific channel type.
1496  *
1497  * It is recommend that the Tcl_Channel* functions are used to access
1498  * elements of this structure, instead of direct accessing.
1499  */
1500 typedef struct Tcl_ChannelType {
1501     char *typeName;                     /* The name of the channel type in Tcl
1502                                          * commands. This storage is owned by
1503                                          * channel type. */
1504     Tcl_ChannelTypeVersion version;     /* Version of the channel type. */
1505     Tcl_DriverCloseProc *closeProc;     /* Procedure to call to close the
1506                                          * channel, or TCL_CLOSE2PROC if the
1507                                          * close2Proc should be used
1508                                          * instead. */
1509     Tcl_DriverInputProc *inputProc;     /* Procedure to call for input
1510                                          * on channel. */
1511     Tcl_DriverOutputProc *outputProc;   /* Procedure to call for output
1512                                          * on channel. */
1513     Tcl_DriverSeekProc *seekProc;       /* Procedure to call to seek
1514                                          * on the channel. May be NULL. */
1515     Tcl_DriverSetOptionProc *setOptionProc;
1516                                         /* Set an option on a channel. */
1517     Tcl_DriverGetOptionProc *getOptionProc;
1518                                         /* Get an option from a channel. */
1519     Tcl_DriverWatchProc *watchProc;     /* Set up the notifier to watch
1520                                          * for events on this channel. */
1521     Tcl_DriverGetHandleProc *getHandleProc;
1522                                         /* Get an OS handle from the channel
1523                                          * or NULL if not supported. */
1524     Tcl_DriverClose2Proc *close2Proc;   /* Procedure to call to close the
1525                                          * channel if the device supports
1526                                          * closing the read & write sides
1527                                          * independently. */
1528     Tcl_DriverBlockModeProc *blockModeProc;
1529                                         /* Set blocking mode for the
1530                                          * raw channel. May be NULL. */
1531     /*
1532      * Only valid in TCL_CHANNEL_VERSION_2 channels or later
1533      */
1534     Tcl_DriverFlushProc *flushProc;     /* Procedure to call to flush a
1535                                          * channel. May be NULL. */
1536     Tcl_DriverHandlerProc *handlerProc; /* Procedure to call to handle a
1537                                          * channel event.  This will be passed
1538                                          * up the stacked channel chain. */
1539     /*
1540      * Only valid in TCL_CHANNEL_VERSION_3 channels or later
1541      */
1542     Tcl_DriverWideSeekProc *wideSeekProc;
1543                                         /* Procedure to call to seek
1544                                          * on the channel which can
1545                                          * handle 64-bit offsets. May be
1546                                          * NULL, and must be NULL if
1547                                          * seekProc is NULL. */
1548 } Tcl_ChannelType;
1549
1550 /*
1551  * The following flags determine whether the blockModeProc above should
1552  * set the channel into blocking or nonblocking mode. They are passed
1553  * as arguments to the blockModeProc procedure in the above structure.
1554  */
1555 #define TCL_MODE_BLOCKING 0             /* Put channel into blocking mode. */
1556 #define TCL_MODE_NONBLOCKING 1          /* Put channel into nonblocking
1557                                          * mode. */
1558
1559 /*
1560  * Enum for different types of file paths.
1561  */
1562 typedef enum Tcl_PathType {
1563     TCL_PATH_ABSOLUTE,
1564     TCL_PATH_RELATIVE,
1565     TCL_PATH_VOLUME_RELATIVE
1566 } Tcl_PathType;
1567
1568
1569 /* 
1570  * The following structure is used to pass glob type data amongst
1571  * the various glob routines and Tcl_FSMatchInDirectory.
1572  */
1573 typedef struct Tcl_GlobTypeData {
1574     /* Corresponds to bcdpfls as in 'find -t' */
1575     int type;
1576     /* Corresponds to file permissions */
1577     int perm;
1578     /* Acceptable mac type */
1579     Tcl_Obj* macType;
1580     /* Acceptable mac creator */
1581     Tcl_Obj* macCreator;
1582 } Tcl_GlobTypeData;
1583
1584 /*
1585  * type and permission definitions for glob command
1586  */
1587 #define TCL_GLOB_TYPE_BLOCK             (1<<0)
1588 #define TCL_GLOB_TYPE_CHAR              (1<<1)
1589 #define TCL_GLOB_TYPE_DIR               (1<<2)
1590 #define TCL_GLOB_TYPE_PIPE              (1<<3)
1591 #define TCL_GLOB_TYPE_FILE              (1<<4)
1592 #define TCL_GLOB_TYPE_LINK              (1<<5)
1593 #define TCL_GLOB_TYPE_SOCK              (1<<6)
1594 #define TCL_GLOB_TYPE_MOUNT             (1<<7)
1595
1596 #define TCL_GLOB_PERM_RONLY             (1<<0)
1597 #define TCL_GLOB_PERM_HIDDEN            (1<<1)
1598 #define TCL_GLOB_PERM_R                 (1<<2)
1599 #define TCL_GLOB_PERM_W                 (1<<3)
1600 #define TCL_GLOB_PERM_X                 (1<<4)
1601
1602
1603 /*
1604  * Typedefs for the various filesystem operations:
1605  */
1606 typedef int (Tcl_FSStatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf));
1607 typedef int (Tcl_FSAccessProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, int mode));
1608 typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) 
1609         _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *pathPtr, 
1610         int mode, int permissions));
1611 typedef int (Tcl_FSMatchInDirectoryProc) _ANSI_ARGS_((Tcl_Interp* interp, 
1612         Tcl_Obj *result, Tcl_Obj *pathPtr, CONST char *pattern, 
1613         Tcl_GlobTypeData * types));
1614 typedef Tcl_Obj* (Tcl_FSGetCwdProc) _ANSI_ARGS_((Tcl_Interp *interp));
1615 typedef int (Tcl_FSChdirProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1616 typedef int (Tcl_FSLstatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 
1617                                            Tcl_StatBuf *buf));
1618 typedef int (Tcl_FSCreateDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1619 typedef int (Tcl_FSDeleteFileProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1620 typedef int (Tcl_FSCopyDirectoryProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr,
1621            Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr));
1622 typedef int (Tcl_FSCopyFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr,
1623                             Tcl_Obj *destPathPtr));
1624 typedef int (Tcl_FSRemoveDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
1625                             int recursive, Tcl_Obj **errorPtr));
1626 typedef int (Tcl_FSRenameFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr,
1627                             Tcl_Obj *destPathPtr));
1628 typedef void (Tcl_FSUnloadFileProc) _ANSI_ARGS_((Tcl_LoadHandle loadHandle));
1629 typedef Tcl_Obj* (Tcl_FSListVolumesProc) _ANSI_ARGS_((void));
1630 /* We have to declare the utime structure here. */
1631 struct utimbuf;
1632 typedef int (Tcl_FSUtimeProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 
1633                                            struct utimbuf *tval));
1634 typedef int (Tcl_FSNormalizePathProc) _ANSI_ARGS_((Tcl_Interp *interp, 
1635                          Tcl_Obj *pathPtr, int nextCheckpoint));
1636 typedef int (Tcl_FSFileAttrsGetProc) _ANSI_ARGS_((Tcl_Interp *interp,
1637                             int index, Tcl_Obj *pathPtr,
1638                             Tcl_Obj **objPtrRef));
1639 typedef CONST char** (Tcl_FSFileAttrStringsProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 
1640                             Tcl_Obj** objPtrRef));
1641 typedef int (Tcl_FSFileAttrsSetProc) _ANSI_ARGS_((Tcl_Interp *interp,
1642                             int index, Tcl_Obj *pathPtr,
1643                             Tcl_Obj *objPtr));
1644 typedef Tcl_Obj* (Tcl_FSLinkProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 
1645                                                Tcl_Obj *toPtr, int linkType));
1646 typedef int (Tcl_FSLoadFileProc) _ANSI_ARGS_((Tcl_Interp * interp, 
1647                             Tcl_Obj *pathPtr,
1648                             Tcl_LoadHandle *handlePtr,
1649                             Tcl_FSUnloadFileProc **unloadProcPtr));
1650 typedef int (Tcl_FSPathInFilesystemProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 
1651                             ClientData *clientDataPtr));
1652 typedef Tcl_Obj* (Tcl_FSFilesystemPathTypeProc) 
1653                             _ANSI_ARGS_((Tcl_Obj *pathPtr));
1654 typedef Tcl_Obj* (Tcl_FSFilesystemSeparatorProc) 
1655                             _ANSI_ARGS_((Tcl_Obj *pathPtr));
1656 typedef void (Tcl_FSFreeInternalRepProc) _ANSI_ARGS_((ClientData clientData));
1657 typedef ClientData (Tcl_FSDupInternalRepProc) 
1658                             _ANSI_ARGS_((ClientData clientData));
1659 typedef Tcl_Obj* (Tcl_FSInternalToNormalizedProc) 
1660                             _ANSI_ARGS_((ClientData clientData));
1661 typedef ClientData (Tcl_FSCreateInternalRepProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1662
1663 typedef struct Tcl_FSVersion_ *Tcl_FSVersion;
1664
1665 /*
1666  *----------------------------------------------------------------
1667  * Data structures related to hooking into the filesystem
1668  *----------------------------------------------------------------
1669  */
1670
1671 /*
1672  * Filesystem version tag.  This was introduced in 8.4.
1673  */
1674 #define TCL_FILESYSTEM_VERSION_1        ((Tcl_FSVersion) 0x1)
1675
1676 /*
1677  * struct Tcl_Filesystem:
1678  *
1679  * One such structure exists for each type (kind) of filesystem.
1680  * It collects together in one place all the functions that are
1681  * part of the specific filesystem.  Tcl always accesses the
1682  * filesystem through one of these structures.
1683  * 
1684  * Not all entries need be non-NULL; any which are NULL are simply
1685  * ignored.  However, a complete filesystem should provide all of
1686  * these functions.  The explanations in the structure show
1687  * the importance of each function.
1688  */
1689
1690 typedef struct Tcl_Filesystem {
1691     CONST char *typeName;   /* The name of the filesystem. */
1692     int structureLength;    /* Length of this structure, so future
1693                              * binary compatibility can be assured. */
1694     Tcl_FSVersion version;  
1695                             /* Version of the filesystem type. */
1696     Tcl_FSPathInFilesystemProc *pathInFilesystemProc;
1697                             /* Function to check whether a path is in 
1698                              * this filesystem.  This is the most
1699                              * important filesystem procedure. */
1700     Tcl_FSDupInternalRepProc *dupInternalRepProc;
1701                             /* Function to duplicate internal fs rep.  May
1702                              * be NULL (but then fs is less efficient). */ 
1703     Tcl_FSFreeInternalRepProc *freeInternalRepProc;
1704                             /* Function to free internal fs rep.  Must
1705                              * be implemented, if internal representations
1706                              * need freeing, otherwise it can be NULL. */ 
1707     Tcl_FSInternalToNormalizedProc *internalToNormalizedProc;
1708                             /* Function to convert internal representation
1709                              * to a normalized path.  Only required if
1710                              * the fs creates pure path objects with no
1711                              * string/path representation. */
1712     Tcl_FSCreateInternalRepProc *createInternalRepProc;
1713                             /* Function to create a filesystem-specific
1714                              * internal representation.  May be NULL
1715                              * if paths have no internal representation, 
1716                              * or if the Tcl_FSPathInFilesystemProc
1717                              * for this filesystem always immediately 
1718                              * creates an internal representation for 
1719                              * paths it accepts. */
1720     Tcl_FSNormalizePathProc *normalizePathProc;       
1721                             /* Function to normalize a path.  Should
1722                              * be implemented for all filesystems
1723                              * which can have multiple string 
1724                              * representations for the same path 
1725                              * object. */
1726     Tcl_FSFilesystemPathTypeProc *filesystemPathTypeProc;
1727                             /* Function to determine the type of a 
1728                              * path in this filesystem.  May be NULL. */
1729     Tcl_FSFilesystemSeparatorProc *filesystemSeparatorProc;
1730                             /* Function to return the separator 
1731                              * character(s) for this filesystem.  Must
1732                              * be implemented. */
1733     Tcl_FSStatProc *statProc; 
1734                             /* 
1735                              * Function to process a 'Tcl_FSStat()'
1736                              * call.  Must be implemented for any
1737                              * reasonable filesystem.
1738                              */
1739     Tcl_FSAccessProc *accessProc;           
1740                             /* 
1741                              * Function to process a 'Tcl_FSAccess()'
1742                              * call.  Must be implemented for any
1743                              * reasonable filesystem.
1744                              */
1745     Tcl_FSOpenFileChannelProc *openFileChannelProc; 
1746                             /* 
1747                              * Function to process a
1748                              * 'Tcl_FSOpenFileChannel()' call.  Must be
1749                              * implemented for any reasonable
1750                              * filesystem.
1751                              */
1752     Tcl_FSMatchInDirectoryProc *matchInDirectoryProc;  
1753                             /* Function to process a 
1754                              * 'Tcl_FSMatchInDirectory()'.  If not
1755                              * implemented, then glob and recursive
1756                              * copy functionality will be lacking in
1757                              * the filesystem. */
1758     Tcl_FSUtimeProc *utimeProc;       
1759                             /* Function to process a 
1760                              * 'Tcl_FSUtime()' call.  Required to
1761                              * allow setting (not reading) of times 
1762                              * with 'file mtime', 'file atime' and
1763                              * the open-r/open-w/fcopy implementation
1764                              * of 'file copy'. */
1765     Tcl_FSLinkProc *linkProc; 
1766                             /* Function to process a 
1767                              * 'Tcl_FSLink()' call.  Should be
1768                              * implemented only if the filesystem supports
1769                              * links (reading or creating). */
1770     Tcl_FSListVolumesProc *listVolumesProc;         
1771                             /* Function to list any filesystem volumes 
1772                              * added by this filesystem.  Should be
1773                              * implemented only if the filesystem adds
1774                              * volumes at the head of the filesystem. */
1775     Tcl_FSFileAttrStringsProc *fileAttrStringsProc;
1776                             /* Function to list all attributes strings 
1777                              * which are valid for this filesystem.  
1778                              * If not implemented the filesystem will
1779                              * not support the 'file attributes' command.
1780                              * This allows arbitrary additional information
1781                              * to be attached to files in the filesystem. */
1782     Tcl_FSFileAttrsGetProc *fileAttrsGetProc;
1783                             /* Function to process a 
1784                              * 'Tcl_FSFileAttrsGet()' call, used by
1785                              * 'file attributes'. */
1786     Tcl_FSFileAttrsSetProc *fileAttrsSetProc;
1787                             /* Function to process a 
1788                              * 'Tcl_FSFileAttrsSet()' call, used by
1789                              * 'file attributes'.  */
1790     Tcl_FSCreateDirectoryProc *createDirectoryProc;         
1791                             /* Function to process a 
1792                              * 'Tcl_FSCreateDirectory()' call. Should
1793                              * be implemented unless the FS is
1794                              * read-only. */
1795     Tcl_FSRemoveDirectoryProc *removeDirectoryProc;         
1796                             /* Function to process a 
1797                              * 'Tcl_FSRemoveDirectory()' call. Should
1798                              * be implemented unless the FS is
1799                              * read-only. */
1800     Tcl_FSDeleteFileProc *deleteFileProc;           
1801                             /* Function to process a 
1802                              * 'Tcl_FSDeleteFile()' call.  Should
1803                              * be implemented unless the FS is
1804                              * read-only. */
1805     Tcl_FSCopyFileProc *copyFileProc; 
1806                             /* Function to process a 
1807                              * 'Tcl_FSCopyFile()' call.  If not
1808                              * implemented Tcl will fall back
1809                              * on open-r, open-w and fcopy as
1810                              * a copying mechanism, for copying
1811                              * actions initiated in Tcl (not C). */
1812     Tcl_FSRenameFileProc *renameFileProc;           
1813                             /* Function to process a 
1814                              * 'Tcl_FSRenameFile()' call.  If not
1815                              * implemented, Tcl will fall back on
1816                              * a copy and delete mechanism, for 
1817                              * rename actions initiated in Tcl (not C). */
1818     Tcl_FSCopyDirectoryProc *copyDirectoryProc;     
1819                             /* Function to process a 
1820                              * 'Tcl_FSCopyDirectory()' call.  If
1821                              * not implemented, Tcl will fall back
1822                              * on a recursive create-dir, file copy
1823                              * mechanism, for copying actions
1824                              * initiated in Tcl (not C). */
1825     Tcl_FSLstatProc *lstatProc;     
1826                             /* Function to process a 
1827                              * 'Tcl_FSLstat()' call.  If not implemented,
1828                              * Tcl will attempt to use the 'statProc'
1829                              * defined above instead. */
1830     Tcl_FSLoadFileProc *loadFileProc; 
1831                             /* Function to process a 
1832                              * 'Tcl_FSLoadFile()' call.  If not
1833                              * implemented, Tcl will fall back on
1834                              * a copy to native-temp followed by a 
1835                              * Tcl_FSLoadFile on that temporary copy. */
1836     Tcl_FSGetCwdProc *getCwdProc;     
1837                             /* 
1838                              * Function to process a 'Tcl_FSGetCwd()'
1839                              * call.  Most filesystems need not
1840                              * implement this.  It will usually only be
1841                              * called once, if 'getcwd' is called
1842                              * before 'chdir'.  May be NULL.
1843                              */
1844     Tcl_FSChdirProc *chdirProc;     
1845                             /* 
1846                              * Function to process a 'Tcl_FSChdir()'
1847                              * call.  If filesystems do not implement
1848                              * this, it will be emulated by a series of
1849                              * directory access checks.  Otherwise,
1850                              * virtual filesystems which do implement
1851                              * it need only respond with a positive
1852                              * return result if the dirName is a valid
1853                              * directory in their filesystem.  They
1854                              * need not remember the result, since that
1855                              * will be automatically remembered for use
1856                              * by GetCwd.  Real filesystems should
1857                              * carry out the correct action (i.e. call
1858                              * the correct system 'chdir' api).  If not
1859                              * implemented, then 'cd' and 'pwd' will
1860                              * fail inside the filesystem.
1861                              */
1862 } Tcl_Filesystem;
1863
1864 /*
1865  * The following definitions are used as values for the 'linkAction' flag
1866  * to Tcl_FSLink, or the linkProc of any filesystem.  Any combination
1867  * of flags can be given.  For link creation, the linkProc should create
1868  * a link which matches any of the types given.
1869  * 
1870  * TCL_CREATE_SYMBOLIC_LINK:  Create a symbolic or soft link.
1871  * TCL_CREATE_HARD_LINK:      Create a hard link.
1872  */
1873 #define TCL_CREATE_SYMBOLIC_LINK   0x01
1874 #define TCL_CREATE_HARD_LINK       0x02
1875
1876 /*
1877  * The following structure represents the Notifier functions that
1878  * you can override with the Tcl_SetNotifier call.
1879  */
1880 typedef struct Tcl_NotifierProcs {
1881     Tcl_SetTimerProc *setTimerProc;
1882     Tcl_WaitForEventProc *waitForEventProc;
1883     Tcl_CreateFileHandlerProc *createFileHandlerProc;
1884     Tcl_DeleteFileHandlerProc *deleteFileHandlerProc;
1885     Tcl_InitNotifierProc *initNotifierProc;
1886     Tcl_FinalizeNotifierProc *finalizeNotifierProc;
1887     Tcl_AlertNotifierProc *alertNotifierProc;
1888     Tcl_ServiceModeHookProc *serviceModeHookProc;
1889 } Tcl_NotifierProcs;
1890
1891
1892 /*
1893  * The following structure represents a user-defined encoding.  It collects
1894  * together all the functions that are used by the specific encoding.
1895  */
1896 typedef struct Tcl_EncodingType {
1897     CONST char *encodingName;   /* The name of the encoding, e.g.  "euc-jp".
1898                                  * This name is the unique key for this
1899                                  * encoding type. */
1900     Tcl_EncodingConvertProc *toUtfProc;
1901                                 /* Procedure to convert from external
1902                                  * encoding into UTF-8. */
1903     Tcl_EncodingConvertProc *fromUtfProc;
1904                                 /* Procedure to convert from UTF-8 into
1905                                  * external encoding. */
1906     Tcl_EncodingFreeProc *freeProc;
1907                                 /* If non-NULL, procedure to call when this
1908                                  * encoding is deleted. */
1909     ClientData clientData;      /* Arbitrary value associated with encoding
1910                                  * type.  Passed to conversion procedures. */
1911     int nullSize;               /* Number of zero bytes that signify
1912                                  * end-of-string in this encoding.  This
1913                                  * number is used to determine the source
1914                                  * string length when the srcLen argument is
1915                                  * negative.  Must be 1 or 2. */
1916 } Tcl_EncodingType;    
1917
1918 /*
1919  * The following definitions are used as values for the conversion control
1920  * flags argument when converting text from one character set to another:
1921  *
1922  * TCL_ENCODING_START:          Signifies that the source buffer is the first
1923  *                              block in a (potentially multi-block) input
1924  *                              stream.  Tells the conversion procedure to
1925  *                              reset to an initial state and perform any
1926  *                              initialization that needs to occur before the
1927  *                              first byte is converted.  If the source
1928  *                              buffer contains the entire input stream to be
1929  *                              converted, this flag should be set.
1930  *
1931  * TCL_ENCODING_END:            Signifies that the source buffer is the last
1932  *                              block in a (potentially multi-block) input
1933  *                              stream.  Tells the conversion routine to
1934  *                              perform any finalization that needs to occur
1935  *                              after the last byte is converted and then to
1936  *                              reset to an initial state.  If the source
1937  *                              buffer contains the entire input stream to be
1938  *                              converted, this flag should be set.
1939  *                              
1940  * TCL_ENCODING_STOPONERROR:    If set, then the converter will return
1941  *                              immediately upon encountering an invalid
1942  *                              byte sequence or a source character that has
1943  *                              no mapping in the target encoding.  If clear,
1944  *                              then the converter will skip the problem,
1945  *                              substituting one or more "close" characters
1946  *                              in the destination buffer and then continue
1947  *                              to sonvert the source.
1948  */
1949 #define TCL_ENCODING_START              0x01
1950 #define TCL_ENCODING_END                0x02
1951 #define TCL_ENCODING_STOPONERROR        0x04
1952
1953
1954 /*
1955  * The following data structures and declarations are for the new Tcl
1956  * parser.
1957  */
1958
1959 /*
1960  * For each word of a command, and for each piece of a word such as a
1961  * variable reference, one of the following structures is created to
1962  * describe the token.
1963  */
1964 typedef struct Tcl_Token {
1965     int type;                   /* Type of token, such as TCL_TOKEN_WORD;
1966                                  * see below for valid types. */
1967     CONST char *start;          /* First character in token. */
1968     int size;                   /* Number of bytes in token. */
1969     int numComponents;          /* If this token is composed of other
1970                                  * tokens, this field tells how many of
1971                                  * them there are (including components of
1972                                  * components, etc.).  The component tokens
1973                                  * immediately follow this one. */
1974 } Tcl_Token;
1975
1976 /*
1977  * Type values defined for Tcl_Token structures.  These values are
1978  * defined as mask bits so that it's easy to check for collections of
1979  * types.
1980  *
1981  * TCL_TOKEN_WORD -             The token describes one word of a command,
1982  *                              from the first non-blank character of
1983  *                              the word (which may be " or {) up to but
1984  *                              not including the space, semicolon, or
1985  *                              bracket that terminates the word. 
1986  *                              NumComponents counts the total number of
1987  *                              sub-tokens that make up the word.  This
1988  *                              includes, for example, sub-tokens of
1989  *                              TCL_TOKEN_VARIABLE tokens.
1990  * TCL_TOKEN_SIMPLE_WORD -      This token is just like TCL_TOKEN_WORD
1991  *                              except that the word is guaranteed to
1992  *                              consist of a single TCL_TOKEN_TEXT
1993  *                              sub-token.
1994  * TCL_TOKEN_TEXT -             The token describes a range of literal
1995  *                              text that is part of a word. 
1996  *                              NumComponents is always 0.
1997  * TCL_TOKEN_BS -               The token describes a backslash sequence
1998  *                              that must be collapsed.  NumComponents
1999  *                              is always 0.
2000  * TCL_TOKEN_COMMAND -          The token describes a command whose result
2001  *                              must be substituted into the word.  The
2002  *                              token includes the enclosing brackets. 
2003  *                              NumComponents is always 0.
2004  * TCL_TOKEN_VARIABLE -         The token describes a variable
2005  *                              substitution, including the dollar sign,
2006  *                              variable name, and array index (if there
2007  *                              is one) up through the right
2008  *                              parentheses.  NumComponents tells how
2009  *                              many additional tokens follow to
2010  *                              represent the variable name.  The first
2011  *                              token will be a TCL_TOKEN_TEXT token
2012  *                              that describes the variable name.  If
2013  *                              the variable is an array reference then
2014  *                              there will be one or more additional
2015  *                              tokens, of type TCL_TOKEN_TEXT,
2016  *                              TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and
2017  *                              TCL_TOKEN_VARIABLE, that describe the
2018  *                              array index; numComponents counts the
2019  *                              total number of nested tokens that make
2020  *                              up the variable reference, including
2021  *                              sub-tokens of TCL_TOKEN_VARIABLE tokens.
2022  * TCL_TOKEN_SUB_EXPR -         The token describes one subexpression of a
2023  *                              expression, from the first non-blank
2024  *                              character of the subexpression up to but not
2025  *                              including the space, brace, or bracket
2026  *                              that terminates the subexpression. 
2027  *                              NumComponents counts the total number of
2028  *                              following subtokens that make up the
2029  *                              subexpression; this includes all subtokens
2030  *                              for any nested TCL_TOKEN_SUB_EXPR tokens.
2031  *                              For example, a numeric value used as a
2032  *                              primitive operand is described by a
2033  *                              TCL_TOKEN_SUB_EXPR token followed by a
2034  *                              TCL_TOKEN_TEXT token. A binary subexpression
2035  *                              is described by a TCL_TOKEN_SUB_EXPR token
2036  *                              followed by the TCL_TOKEN_OPERATOR token
2037  *                              for the operator, then TCL_TOKEN_SUB_EXPR
2038  *                              tokens for the left then the right operands.
2039  * TCL_TOKEN_OPERATOR -         The token describes one expression operator.
2040  *                              An operator might be the name of a math
2041  *                              function such as "abs". A TCL_TOKEN_OPERATOR
2042  *                              token is always preceeded by one
2043  *                              TCL_TOKEN_SUB_EXPR token for the operator's
2044  *                              subexpression, and is followed by zero or
2045  *                              more TCL_TOKEN_SUB_EXPR tokens for the
2046  *                              operator's operands. NumComponents is
2047  *                              always 0.
2048  */
2049 #define TCL_TOKEN_WORD          1
2050 #define TCL_TOKEN_SIMPLE_WORD   2
2051 #define TCL_TOKEN_TEXT          4
2052 #define TCL_TOKEN_BS            8
2053 #define TCL_TOKEN_COMMAND       16
2054 #define TCL_TOKEN_VARIABLE      32
2055 #define TCL_TOKEN_SUB_EXPR      64
2056 #define TCL_TOKEN_OPERATOR      128
2057
2058 /*
2059  * Parsing error types.  On any parsing error, one of these values
2060  * will be stored in the error field of the Tcl_Parse structure
2061  * defined below.
2062  */
2063 #define TCL_PARSE_SUCCESS               0
2064 #define TCL_PARSE_QUOTE_EXTRA           1
2065 #define TCL_PARSE_BRACE_EXTRA           2
2066 #define TCL_PARSE_MISSING_BRACE         3
2067 #define TCL_PARSE_MISSING_BRACKET       4
2068 #define TCL_PARSE_MISSING_PAREN         5
2069 #define TCL_PARSE_MISSING_QUOTE         6
2070 #define TCL_PARSE_MISSING_VAR_BRACE     7
2071 #define TCL_PARSE_SYNTAX                8
2072 #define TCL_PARSE_BAD_NUMBER            9
2073
2074 /*
2075  * A structure of the following type is filled in by Tcl_ParseCommand.
2076  * It describes a single command parsed from an input string.
2077  */
2078 #define NUM_STATIC_TOKENS 20
2079
2080 typedef struct Tcl_Parse {
2081     CONST char *commentStart;   /* Pointer to # that begins the first of
2082                                  * one or more comments preceding the
2083                                  * command. */
2084     int commentSize;            /* Number of bytes in comments (up through
2085                                  * newline character that terminates the
2086                                  * last comment).  If there were no
2087                                  * comments, this field is 0. */
2088     CONST char *commandStart;   /* First character in first word of command. */
2089     int commandSize;            /* Number of bytes in command, including
2090                                  * first character of first word, up
2091                                  * through the terminating newline,
2092                                  * close bracket, or semicolon. */
2093     int numWords;               /* Total number of words in command.  May
2094                                  * be 0. */
2095     Tcl_Token *tokenPtr;        /* Pointer to first token representing
2096                                  * the words of the command.  Initially
2097                                  * points to staticTokens, but may change
2098                                  * to point to malloc-ed space if command
2099                                  * exceeds space in staticTokens. */
2100     int numTokens;              /* Total number of tokens in command. */
2101     int tokensAvailable;        /* Total number of tokens available at
2102                                  * *tokenPtr. */
2103     int errorType;              /* One of the parsing error types defined
2104                                  * above. */
2105
2106     /*
2107      * The fields below are intended only for the private use of the
2108      * parser.  They should not be used by procedures that invoke
2109      * Tcl_ParseCommand.
2110      */
2111
2112     CONST char *string;         /* The original command string passed to
2113                                  * Tcl_ParseCommand. */
2114     CONST char *end;            /* Points to the character just after the
2115                                  * last one in the command string. */
2116     Tcl_Interp *interp;         /* Interpreter to use for error reporting,
2117                                  * or NULL. */
2118     CONST char *term;           /* Points to character in string that
2119                                  * terminated most recent token.  Filled in
2120                                  * by ParseTokens.  If an error occurs,
2121                                  * points to beginning of region where the
2122                                  * error occurred (e.g. the open brace if
2123                                  * the close brace is missing). */
2124     int incomplete;             /* This field is set to 1 by Tcl_ParseCommand
2125                                  * if the command appears to be incomplete.
2126                                  * This information is used by
2127                                  * Tcl_CommandComplete. */
2128     Tcl_Token staticTokens[NUM_STATIC_TOKENS];
2129                                 /* Initial space for tokens for command.
2130                                  * This space should be large enough to
2131                                  * accommodate most commands; dynamic
2132                                  * space is allocated for very large
2133                                  * commands that don't fit here. */
2134 } Tcl_Parse;
2135
2136 /*
2137  * The following definitions are the error codes returned by the conversion
2138  * routines:
2139  *
2140  * TCL_OK:                      All characters were converted.
2141  *
2142  * TCL_CONVERT_NOSPACE:         The output buffer would not have been large
2143  *                              enough for all of the converted data; as many
2144  *                              characters as could fit were converted though.
2145  *
2146  * TCL_CONVERT_MULTIBYTE:       The last few bytes in the source string were
2147  *                              the beginning of a multibyte sequence, but
2148  *                              more bytes were needed to complete this
2149  *                              sequence.  A subsequent call to the conversion
2150  *                              routine should pass the beginning of this
2151  *                              unconverted sequence plus additional bytes
2152  *                              from the source stream to properly convert
2153  *                              the formerly split-up multibyte sequence.
2154  *
2155  * TCL_CONVERT_SYNTAX:          The source stream contained an invalid
2156  *                              character sequence.  This may occur if the
2157  *                              input stream has been damaged or if the input
2158  *                              encoding method was misidentified.  This error
2159  *                              is reported only if TCL_ENCODING_STOPONERROR
2160  *                              was specified.
2161  * 
2162  * TCL_CONVERT_UNKNOWN:         The source string contained a character
2163  *                              that could not be represented in the target
2164  *                              encoding.  This error is reported only if
2165  *                              TCL_ENCODING_STOPONERROR was specified.
2166  */
2167 #define TCL_CONVERT_MULTIBYTE           -1
2168 #define TCL_CONVERT_SYNTAX              -2
2169 #define TCL_CONVERT_UNKNOWN             -3
2170 #define TCL_CONVERT_NOSPACE             -4
2171
2172 /*
2173  * The maximum number of bytes that are necessary to represent a single
2174  * Unicode character in UTF-8.  The valid values should be 3 or 6 (or
2175  * perhaps 1 if we want to support a non-unicode enabled core).
2176  * If 3, then Tcl_UniChar must be 2-bytes in size (UCS-2). (default)
2177  * If 6, then Tcl_UniChar must be 4-bytes in size (UCS-4).
2178  * At this time UCS-2 mode is the default and recommended mode.
2179  * UCS-4 is experimental and not recommended.  It works for the core,
2180  * but most extensions expect UCS-2.
2181  */
2182 #ifndef TCL_UTF_MAX
2183 #define TCL_UTF_MAX             3
2184 #endif
2185
2186 /*
2187  * This represents a Unicode character.  Any changes to this should
2188  * also be reflected in regcustom.h.
2189  */
2190 #if TCL_UTF_MAX > 3
2191     /*
2192      * unsigned int isn't 100% accurate as it should be a strict 4-byte
2193      * value (perhaps wchar_t).  64-bit systems may have troubles.  The
2194      * size of this value must be reflected correctly in regcustom.h.
2195      */
2196 typedef unsigned int Tcl_UniChar;
2197 #else
2198 typedef unsigned short Tcl_UniChar;
2199 #endif
2200
2201
2202 /*
2203  * Deprecated Tcl procedures:
2204  */
2205 #ifndef TCL_NO_DEPRECATED
2206 #   define Tcl_EvalObj(interp,objPtr) \
2207         Tcl_EvalObjEx((interp),(objPtr),0)
2208 #   define Tcl_GlobalEvalObj(interp,objPtr) \
2209         Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL)
2210 #endif
2211
2212
2213 /*
2214  * These function have been renamed. The old names are deprecated, but we
2215  * define these macros for backwards compatibilty.
2216  */
2217 #define Tcl_Ckalloc Tcl_Alloc
2218 #define Tcl_Ckfree Tcl_Free
2219 #define Tcl_Ckrealloc Tcl_Realloc
2220 #define Tcl_Return Tcl_SetResult
2221 #define Tcl_TildeSubst Tcl_TranslateFileName
2222 #define panic Tcl_Panic
2223 #define panicVA Tcl_PanicVA
2224
2225
2226 /*
2227  * The following constant is used to test for older versions of Tcl
2228  * in the stubs tables.
2229  *
2230  * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different
2231  * value since the stubs tables don't match.
2232  */
2233
2234 #define TCL_STUB_MAGIC ((int)0xFCA3BACF)
2235
2236 /*
2237  * The following function is required to be defined in all stubs aware
2238  * extensions.  The function is actually implemented in the stub
2239  * library, not the main Tcl library, although there is a trivial
2240  * implementation in the main library in case an extension is statically
2241  * linked into an application.
2242  */
2243
2244 EXTERN CONST char *     Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
2245                             CONST char *version, int exact));
2246
2247 #ifndef USE_TCL_STUBS
2248
2249 /*
2250  * When not using stubs, make it a macro.
2251  */
2252
2253 #define Tcl_InitStubs(interp, version, exact) \
2254     Tcl_PkgRequire(interp, "Tcl", version, exact)
2255
2256 #endif
2257
2258
2259 /*
2260  * Include the public function declarations that are accessible via
2261  * the stubs table.
2262  */
2263
2264 #include "tclDecls.h"
2265
2266 /*
2267  * Include platform specific public function declarations that are
2268  * accessible via the stubs table.
2269  */
2270
2271 /*
2272  * tclPlatDecls.h can't be included here on the Mac, as we need
2273  * Mac specific headers to define the Mac types used in this file,
2274  * but these Mac haders conflict with a number of tk types
2275  * and thus can't be included in the globally read tcl.h
2276  * This header was originally added here as a fix for bug 5241
2277  * (stub link error for symbols in TclPlatStubs table), as a work-
2278  * around for the bug on the mac, tclMac.h is included immediately 
2279  * after tcl.h in the tcl precompiled header (with DLLEXPORT set).
2280  */
2281
2282 #if !defined(MAC_TCL)
2283 #include "tclPlatDecls.h"
2284 #endif
2285
2286 /*
2287  * Public functions that are not accessible via the stubs table.
2288  */
2289
2290 EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv,
2291         Tcl_AppInitProc *appInitProc));
2292
2293 /*
2294  * Convenience declaration of Tcl_AppInit for backwards compatibility.
2295  * This function is not *implemented* by the tcl library, so the storage
2296  * class is neither DLLEXPORT nor DLLIMPORT
2297  */
2298 #undef TCL_STORAGE_CLASS
2299 #define TCL_STORAGE_CLASS
2300
2301 EXTERN int              Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp));
2302
2303 #undef TCL_STORAGE_CLASS
2304 #define TCL_STORAGE_CLASS DLLIMPORT
2305
2306 #endif /* RC_INVOKED */
2307
2308 /*
2309  * end block for C++
2310  */
2311 #ifdef __cplusplus
2312 }
2313 #endif
2314
2315 #endif /* _TCL */