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