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