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