os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/tcl.h
Update contrib.
4 * This header file describes the externally-visible facilities
5 * of the Tcl interpreter.
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 * Portions Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiaries. All rights reserved.
14 * See the file "license.terms" for information on usage and redistribution
15 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17 * RCS: @(#) $Id: tcl.h,v 1.153.2.30 2006/10/23 17:53:26 dgp Exp $
24 * For C++ compilers, use extern "C"
32 * The following defines are used to indicate the various release levels.
35 #define TCL_ALPHA_RELEASE 0
36 #define TCL_BETA_RELEASE 1
37 #define TCL_FINAL_RELEASE 2
40 * When version numbers change here, must also go into the following files
41 * and update the version numbers:
43 * library/init.tcl (only if Major.minor changes, not patchlevel) 1 LOC
44 * unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch)
45 * win/configure.in (as above)
46 * win/tcl.m4 (not patchlevel)
47 * win/makefile.vc (not patchlevel) 2 LOC
48 * README (sections 0 and 2)
49 * mac/README (2 LOC, not patchlevel)
50 * macosx/Tcl.pbproj/project.pbxproj (not patchlevel) 1 LOC
51 * macosx/Tcl.pbproj/default.pbxuser (not patchlevel) 1 LOC
52 * win/README.binary (sections 0-4)
53 * win/README (not patchlevel) (sections 0 and 2)
54 * unix/tcl.spec (2 LOC Major/Minor, 1 LOC patch)
55 * tests/basic.test (1 LOC M/M, not patchlevel)
56 * tools/tcl.hpj.in (not patchlevel, for windows installer)
57 * tools/tcl.wse.in (for windows installer)
58 * tools/tclSplash.bmp (not patchlevel)
60 #define TCL_MAJOR_VERSION 8
61 #define TCL_MINOR_VERSION 4
62 #define TCL_RELEASE_LEVEL TCL_FINAL_RELEASE
63 #define TCL_RELEASE_SERIAL 15
65 #define TCL_VERSION "8.4"
66 #define TCL_PATCH_LEVEL "8.4.15"
69 * The following definitions set up the proper options for Windows
70 * compilers. We use this method because there is no autoconf equivalent.
73 // Only if not compiling for Symbian on a PC with a Windows compiler
76 # if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) || defined(__BORLANDC__)
86 * STRICT: See MSDN Article Q83456
92 #endif /* __WIN32__ */
95 * The following definitions set up the proper options for Macintosh
96 * compilers. We use this method because there is no autoconf equivalent.
100 #include <ConditionalMacros.h>
101 # ifndef USE_TCLALLOC
102 # define USE_TCLALLOC 1
105 # define NO_STRERROR 1
112 * Utility macros: STRINGIFY takes an argument and wraps it in "" (double
113 * quotation marks), JOIN joins two arguments.
116 # define STRINGIFY(x) STRINGIFY1(x)
117 # define STRINGIFY1(x) #x
120 # define JOIN(a,b) JOIN1(a,b)
121 # define JOIN1(a,b) a##b
125 * A special definition used to allow this header file to be included
126 * from windows or mac resource files so that they can obtain version
127 * information. RC_INVOKED is defined by default by the windows RC tool
128 * and manually set for macintosh.
130 * Resource compilers don't like all the C stuff, like typedefs and
131 * procedure declarations, that occur below, so block them out.
137 * Special macro to define mutexes, that doesn't do anything
138 * if we are not using threads.
142 #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name;
144 #define TCL_DECLARE_MUTEX(name)
148 * Macros that eliminate the overhead of the thread synchronization
149 * functions when compiling without thread support.
153 #define Tcl_MutexLock(mutexPtr)
154 #define Tcl_MutexUnlock(mutexPtr)
155 #define Tcl_MutexFinalize(mutexPtr)
156 #define Tcl_ConditionNotify(condPtr)
157 #define Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
158 #define Tcl_ConditionFinalize(condPtr)
159 #endif /* TCL_THREADS */
168 * Definitions that allow Tcl functions with variable numbers of
169 * arguments to be used with either varargs.h or stdarg.h. TCL_VARARGS
170 * is used in procedure prototypes. TCL_VARARGS_DEF is used to declare
171 * the arguments in a function definiton: it takes the type and name of
172 * the first argument and supplies the appropriate argument declaration
173 * string for use in the function definition. TCL_VARARGS_START
174 * initializes the va_list data structure and returns the first argument.
176 #if !defined(NO_STDARG)
178 # define TCL_VARARGS(type, name) (type name, ...)
179 # define TCL_VARARGS_DEF(type, name) (type name, ...)
180 # define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
182 # include <varargs.h>
183 # define TCL_VARARGS(type, name) ()
184 # define TCL_VARARGS_DEF(type, name) (va_alist)
185 # define TCL_VARARGS_START(type, name, list) \
186 (va_start(list), va_arg(list, type))
190 * Macros used to declare a function to be exported by a DLL.
191 * Used by Windows, maps to no-op declarations on non-Windows systems.
192 * The default build on windows is for a DLL, which causes the DLLIMPORT
193 * and DLLEXPORT macros to be nonempty. To build a static library, the
194 * macro STATIC_BUILD should be defined.
201 # if (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || (defined(__GNUC__) && defined(__declspec)))) || (defined(MAC_TCL) && FUNCTION_DECLSPEC)
202 # define DLLIMPORT __declspec(dllimport)
203 # define DLLEXPORT __declspec(dllexport)
211 * These macros are used to control whether functions are being declared for
212 * import or export. If a function is being declared while it is being built
213 * to be included in a shared library, then it should have the DLLEXPORT
214 * storage class. If is being declared for use by a module that is going to
215 * link against the shared library, then it should have the DLLIMPORT storage
216 * class. If the symbol is beind declared for a static build or for use from a
217 * stub library, then the storage class should be empty.
219 * The convention is that a macro called BUILD_xxxx, where xxxx is the
220 * name of a library we are building, is set on the compile line for sources
221 * that are to be placed in the library. When this macro is set, the
222 * storage class will be set to DLLEXPORT. At the end of the header file, the
223 * storage class will be reset to DLLIMPORT.
225 #undef TCL_STORAGE_CLASS
227 # define TCL_STORAGE_CLASS DLLEXPORT
229 # ifdef USE_TCL_STUBS
230 # define TCL_STORAGE_CLASS
232 # define TCL_STORAGE_CLASS DLLIMPORT
238 * Definitions that allow this header file to be used either with or
239 * without ANSI C features like function prototypes.
253 #ifndef NO_PROTOTYPES
254 # define _ANSI_ARGS_(x) x
256 # define _ANSI_ARGS_(x) ()
260 # ifdef USE_COMPAT_CONST
261 # error define at most one of USE_NON_CONST and USE_COMPAT_CONST
264 # define CONST84_RETURN
266 # ifdef USE_COMPAT_CONST
268 # define CONST84_RETURN CONST
270 # define CONST84 CONST
271 # define CONST84_RETURN CONST
277 * Make sure EXTERN isn't defined elsewhere
284 # define EXTERN extern "C" TCL_STORAGE_CLASS
286 # define EXTERN extern TCL_STORAGE_CLASS
294 # define EXTERN extern "C"
296 # define EXTERN extern
301 * The following code is copied from winnt.h.
302 * If we don't replicate it here, then <windows.h> can't be included
303 * after tcl.h, since tcl.h also defines VOID.
304 * This block is skipped under Cygwin and Mingw.
308 #if defined(__WIN32__) && !defined(HAVE_WINNT_IGNORE_VOID)
315 #endif /* __WIN32__ && !HAVE_WINNT_IGNORE_VOID */
318 * Macro to use instead of "void" for arguments that must have
319 * type "void *" in ANSI C; maps them to type "char *" in
330 * Miscellaneous declarations.
335 typedef void *ClientData;
337 typedef int *ClientData;
343 * Darwin specifc configure overrides (to support fat compiles, where
344 * configure runs only once for multiple architectures):
349 # undef TCL_WIDE_INT_TYPE
350 # define TCL_WIDE_INT_IS_LONG 1
351 # else /* !__LP64__ */
352 # define TCL_WIDE_INT_TYPE long long
353 # undef TCL_WIDE_INT_IS_LONG
354 # endif /* __LP64__ */
355 # undef HAVE_STRUCT_STAT64
356 #endif /* __APPLE__ */
359 * Define Tcl_WideInt to be a type that is (at least) 64-bits wide,
360 * and define Tcl_WideUInt to be the unsigned variant of that type
361 * (assuming that where we have one, we can have the other.)
363 * Also defines the following macros:
364 * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on
365 * a real 64-bit system.)
366 * Tcl_WideAsLong - forgetful converter from wideInt to long.
367 * Tcl_LongAsWide - sign-extending converter from long to wideInt.
368 * Tcl_WideAsDouble - converter from wideInt to double.
369 * Tcl_DoubleAsWide - converter from double to wideInt.
371 * The following invariant should hold for any long value 'longVal':
372 * longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal))
374 * Note on converting between Tcl_WideInt and strings. This
375 * implementation (in tclObj.c) depends on the functions strtoull()
376 * and sprintf(...,"%" TCL_LL_MODIFIER "d",...). TCL_LL_MODIFIER_SIZE
377 * is the length of the modifier string, which is "ll" on most 32-bit
378 * Unix systems. It has to be split up like this to allow for the more
379 * complex formats sometimes needed (e.g. in the format(n) command.)
382 #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG)
383 # if defined(__GNUC__)
384 # define TCL_WIDE_INT_TYPE long long
385 # if defined(__WIN32__) && !defined(__CYGWIN__)
386 # define TCL_LL_MODIFIER "I64"
387 # define TCL_LL_MODIFIER_SIZE 3
389 # define TCL_LL_MODIFIER "L"
390 # define TCL_LL_MODIFIER_SIZE 1
392 typedef struct stat Tcl_StatBuf;
393 # elif defined(__WIN32__)
394 # define TCL_WIDE_INT_TYPE __int64
396 typedef struct stati64 Tcl_StatBuf;
397 # define TCL_LL_MODIFIER "L"
398 # define TCL_LL_MODIFIER_SIZE 1
399 # else /* __BORLANDC__ */
400 # if _MSC_VER < 1400 || !defined(_M_IX86)
401 typedef struct _stati64 Tcl_StatBuf;
403 typedef struct _stat64 Tcl_StatBuf;
404 # endif /* _MSC_VER < 1400 */
405 # define TCL_LL_MODIFIER "I64"
406 # define TCL_LL_MODIFIER_SIZE 3
407 # endif /* __BORLANDC__ */
408 # else /* __WIN32__ */
410 * Don't know what platform it is and configure hasn't discovered what
411 * is going on for us. Try to guess...
414 # error please define either TCL_WIDE_INT_TYPE or TCL_WIDE_INT_IS_LONG
415 # else /* !NO_LIMITS_H */
417 # if (INT_MAX < LONG_MAX)
418 # define TCL_WIDE_INT_IS_LONG 1
420 # define TCL_WIDE_INT_TYPE long long
422 # endif /* NO_LIMITS_H */
423 # endif /* __WIN32__ */
424 #endif /* !TCL_WIDE_INT_TYPE & !TCL_WIDE_INT_IS_LONG */
425 #ifdef TCL_WIDE_INT_IS_LONG
426 # undef TCL_WIDE_INT_TYPE
427 # define TCL_WIDE_INT_TYPE long
428 #endif /* TCL_WIDE_INT_IS_LONG */
430 typedef TCL_WIDE_INT_TYPE Tcl_WideInt;
431 typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
433 #ifdef TCL_WIDE_INT_IS_LONG
434 typedef struct stat Tcl_StatBuf;
435 # define Tcl_WideAsLong(val) ((long)(val))
436 # define Tcl_LongAsWide(val) ((long)(val))
437 # define Tcl_WideAsDouble(val) ((double)((long)(val)))
438 # define Tcl_DoubleAsWide(val) ((long)((double)(val)))
439 # ifndef TCL_LL_MODIFIER
440 # define TCL_LL_MODIFIER "l"
441 # define TCL_LL_MODIFIER_SIZE 1
442 # endif /* !TCL_LL_MODIFIER */
443 #else /* TCL_WIDE_INT_IS_LONG */
445 * The next short section of defines are only done when not running on
446 * Windows or some other strange platform.
448 # ifndef TCL_LL_MODIFIER
449 # ifdef HAVE_STRUCT_STAT64
450 typedef struct stat64 Tcl_StatBuf;
452 typedef struct stat Tcl_StatBuf;
453 # endif /* HAVE_STRUCT_STAT64 */
454 # define TCL_LL_MODIFIER "ll"
455 # define TCL_LL_MODIFIER_SIZE 2
456 # endif /* !TCL_LL_MODIFIER */
457 # define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val)))
458 # define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val)))
459 # define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val)))
460 # define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val)))
461 #endif /* TCL_WIDE_INT_IS_LONG */
465 * This flag controls whether binary compatability is maintained with
466 * extensions built against a previous version of Tcl. This is true
469 #ifndef TCL_PRESERVE_BINARY_COMPATABILITY
470 # define TCL_PRESERVE_BINARY_COMPATABILITY 1
475 * Data structures defined opaquely in this module. The definitions below
476 * just provide dummy types. A few fields are made visible in Tcl_Interp
477 * structures, namely those used for returning a string result from
478 * commands. Direct access to the result field is discouraged in Tcl 8.0.
479 * The interpreter result is either an object or a string, and the two
480 * values are kept consistent unless some C code sets interp->result
481 * directly. Programmers should use either the procedure Tcl_GetObjResult()
482 * or Tcl_GetStringResult() to read the interpreter's result. See the
483 * SetResult man page for details.
485 * Note: any change to the Tcl_Interp definition below must be mirrored
486 * in the "real" definition in tclInt.h.
488 * Note: Tcl_ObjCmdProc procedures 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().
493 typedef struct Tcl_Interp {
494 char *result; /* If the last command returned a string
495 * result, this points to it. */
496 void (*freeProc) _ANSI_ARGS_((char *blockPtr));
497 /* Zero means the string result is
498 * statically allocated. TCL_DYNAMIC means
499 * it was allocated with ckalloc and should
500 * be freed with ckfree. Other values give
501 * the address of procedure to invoke to
502 * free the result. Tcl_Eval must free it
503 * before executing next command. */
504 int errorLine; /* When TCL_ERROR is returned, this gives
505 * the line number within the command where
506 * the error occurred (1 if first line). */
509 typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler;
510 typedef struct Tcl_Channel_ *Tcl_Channel;
511 typedef struct Tcl_Command_ *Tcl_Command;
512 typedef struct Tcl_Condition_ *Tcl_Condition;
513 typedef struct Tcl_EncodingState_ *Tcl_EncodingState;
514 typedef struct Tcl_Encoding_ *Tcl_Encoding;
515 typedef struct Tcl_Event Tcl_Event;
516 typedef struct Tcl_Mutex_ *Tcl_Mutex;
517 typedef struct Tcl_Pid_ *Tcl_Pid;
518 typedef struct Tcl_RegExp_ *Tcl_RegExp;
519 typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey;
520 typedef struct Tcl_ThreadId_ *Tcl_ThreadId;
521 typedef struct Tcl_TimerToken_ *Tcl_TimerToken;
522 typedef struct Tcl_Trace_ *Tcl_Trace;
523 typedef struct Tcl_Var_ *Tcl_Var;
524 typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion;
525 typedef struct Tcl_LoadHandle_ *Tcl_LoadHandle;
528 * Definition of the interface to procedures implementing threads.
529 * A procedure following this definition is given to each call of
530 * 'Tcl_CreateThread' and will be called as the main fuction of
531 * the new thread created by that call.
534 typedef pascal void *(Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
535 #elif defined __WIN32__
536 typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
538 typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
543 * Threading function return types used for abstracting away platform
544 * differences when writing a Tcl_ThreadCreateProc. See the NewThread
545 * function in generic/tclThreadTest.c for it's usage.
548 # define Tcl_ThreadCreateType pascal void *
549 # define TCL_THREAD_CREATE_RETURN return NULL
550 #elif defined __WIN32__
551 # define Tcl_ThreadCreateType unsigned __stdcall
552 # define TCL_THREAD_CREATE_RETURN return 0
554 # define Tcl_ThreadCreateType void
555 # define TCL_THREAD_CREATE_RETURN
560 * Definition of values for default stacksize and the possible flags to be
561 * given to Tcl_CreateThread.
563 #define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack */
564 #define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default behaviour */
565 #define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable */
568 * Flag values passed to Tcl_GetRegExpFromObj.
570 #define TCL_REG_BASIC 000000 /* BREs (convenience) */
571 #define TCL_REG_EXTENDED 000001 /* EREs */
572 #define TCL_REG_ADVF 000002 /* advanced features in EREs */
573 #define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs) */
574 #define TCL_REG_QUOTE 000004 /* no special characters, none */
575 #define TCL_REG_NOCASE 000010 /* ignore case */
576 #define TCL_REG_NOSUB 000020 /* don't care about subexpressions */
577 #define TCL_REG_EXPANDED 000040 /* expanded format, white space &
579 #define TCL_REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */
580 #define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before */
581 #define TCL_REG_NEWLINE 000300 /* newlines are line terminators */
582 #define TCL_REG_CANMATCH 001000 /* report details on partial/limited
586 * The following flag is experimental and only intended for use by Expect. It
587 * will probably go away in a later release.
589 #define TCL_REG_BOSONLY 002000 /* prepend \A to pattern so it only
590 * matches at the beginning of the
594 * Flags values passed to Tcl_RegExpExecObj.
596 #define TCL_REG_NOTBOL 0001 /* Beginning of string does not match ^. */
597 #define TCL_REG_NOTEOL 0002 /* End of string does not match $. */
600 * Structures filled in by Tcl_RegExpInfo. Note that all offset values are
601 * relative to the start of the match string, not the beginning of the
604 typedef struct Tcl_RegExpIndices {
605 long start; /* character offset of first character in match */
606 long end; /* character offset of first character after the
610 typedef struct Tcl_RegExpInfo {
611 int nsubs; /* number of subexpressions in the
612 * compiled expression */
613 Tcl_RegExpIndices *matches; /* array of nsubs match offset
615 long extendStart; /* The offset at which a subsequent
616 * match might begin. */
617 long reserved; /* Reserved for later use. */
621 * Picky compilers complain if this typdef doesn't appear before the
622 * struct's reference in tclDecls.h.
624 typedef Tcl_StatBuf *Tcl_Stat_;
625 typedef struct stat *Tcl_OldStat_;
628 * When a TCL command returns, the interpreter contains a result from the
629 * command. Programmers are strongly encouraged to use one of the
630 * procedures Tcl_GetObjResult() or Tcl_GetStringResult() to read the
631 * interpreter's result. See the SetResult man page for details. Besides
632 * this result, the command procedure returns an integer code, which is
633 * one of the following:
635 * TCL_OK Command completed normally; the interpreter's
636 * result contains the command's result.
637 * TCL_ERROR The command couldn't be completed successfully;
638 * the interpreter's result describes what went wrong.
639 * TCL_RETURN The command requests that the current procedure
640 * return; the interpreter's result contains the
641 * procedure's return value.
642 * TCL_BREAK The command requests that the innermost loop
643 * be exited; the interpreter's result is meaningless.
644 * TCL_CONTINUE Go on to the next iteration of the current loop;
645 * the interpreter's result is meaningless.
651 #define TCL_CONTINUE 4
653 #define TCL_RESULT_SIZE 200
656 * Flags to control what substitutions are performed by Tcl_SubstObj():
658 #define TCL_SUBST_COMMANDS 001
659 #define TCL_SUBST_VARIABLES 002
660 #define TCL_SUBST_BACKSLASHES 004
661 #define TCL_SUBST_ALL 007
665 * Argument descriptors for math function callbacks in expressions:
668 TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT
670 typedef struct Tcl_Value {
671 Tcl_ValueType type; /* Indicates intValue or doubleValue is
673 long intValue; /* Integer value. */
674 double doubleValue; /* Double-precision floating value. */
675 Tcl_WideInt wideValue; /* Wide (min. 64-bit) integer value. */
679 * Forward declaration of Tcl_Obj to prevent an error when the forward
680 * reference to Tcl_Obj is encountered in the procedure types declared
687 * Procedure types defined by Tcl:
690 typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
691 typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData,
692 Tcl_Interp *interp, int code));
693 typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask));
694 typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data));
695 typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData));
696 typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData,
697 Tcl_Interp *interp, int argc, CONST84 char *argv[]));
698 typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData,
699 Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc,
700 ClientData cmdClientData, int argc, CONST84 char *argv[]));
701 typedef int (Tcl_CmdObjTraceProc) _ANSI_ARGS_((ClientData clientData,
702 Tcl_Interp *interp, int level, CONST char *command,
703 Tcl_Command commandInfo, int objc, struct Tcl_Obj * CONST * objv));
704 typedef void (Tcl_CmdObjTraceDeleteProc) _ANSI_ARGS_((ClientData clientData));
705 typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr,
706 struct Tcl_Obj *dupPtr));
707 typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData,
708 CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr,
709 char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr,
711 typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData));
712 typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags));
713 typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData,
715 typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr,
716 ClientData clientData));
717 typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData,
719 typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData));
720 typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask));
721 typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData));
722 typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
723 typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr));
724 typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData));
725 typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData,
726 Tcl_Interp *interp));
727 typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData,
728 Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr));
729 typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData));
730 typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData,
731 Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv));
732 typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp));
733 typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(CONST char *, format));
734 typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData,
735 Tcl_Channel chan, char *address, int port));
736 typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData));
737 typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp,
738 struct Tcl_Obj *objPtr));
739 typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr));
740 typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData,
741 Tcl_Interp *interp, CONST84 char *part1, CONST84 char *part2, int flags));
742 typedef void (Tcl_CommandTraceProc) _ANSI_ARGS_((ClientData clientData,
743 Tcl_Interp *interp, CONST char *oldName, CONST char *newName,
745 typedef void (Tcl_CreateFileHandlerProc) _ANSI_ARGS_((int fd, int mask,
746 Tcl_FileProc *proc, ClientData clientData));
747 typedef void (Tcl_DeleteFileHandlerProc) _ANSI_ARGS_((int fd));
748 typedef void (Tcl_AlertNotifierProc) _ANSI_ARGS_((ClientData clientData));
749 typedef void (Tcl_ServiceModeHookProc) _ANSI_ARGS_((int mode));
750 typedef ClientData (Tcl_InitNotifierProc) _ANSI_ARGS_((VOID));
751 typedef void (Tcl_FinalizeNotifierProc) _ANSI_ARGS_((ClientData clientData));
752 typedef void (Tcl_MainLoopProc) _ANSI_ARGS_((void));
756 * The following structure represents a type of object, which is a
757 * particular internal representation for an object plus a set of
758 * procedures that provide standard operations on objects of that type.
761 typedef struct Tcl_ObjType {
762 char *name; /* Name of the type, e.g. "int". */
763 Tcl_FreeInternalRepProc *freeIntRepProc;
764 /* Called to free any storage for the type's
765 * internal rep. NULL if the internal rep
766 * does not need freeing. */
767 Tcl_DupInternalRepProc *dupIntRepProc;
768 /* Called to create a new object as a copy
769 * of an existing object. */
770 Tcl_UpdateStringProc *updateStringProc;
771 /* Called to update the string rep from the
772 * type's internal representation. */
773 Tcl_SetFromAnyProc *setFromAnyProc;
774 /* Called to convert the object's internal
775 * rep to this type. Frees the internal rep
776 * of the old type. Returns TCL_ERROR on
782 * One of the following structures exists for each object in the Tcl
783 * system. An object stores a value as either a string, some internal
784 * representation, or both.
787 typedef struct Tcl_Obj {
788 int refCount; /* When 0 the object will be freed. */
789 char *bytes; /* This points to the first byte of the
790 * object's string representation. The array
791 * must be followed by a null byte (i.e., at
792 * offset length) but may also contain
793 * embedded null characters. The array's
794 * storage is allocated by ckalloc. NULL
795 * means the string rep is invalid and must
796 * be regenerated from the internal rep.
797 * Clients should use Tcl_GetStringFromObj
798 * or Tcl_GetString to get a pointer to the
799 * byte array as a readonly value. */
800 int length; /* The number of bytes at *bytes, not
801 * including the terminating null. */
802 Tcl_ObjType *typePtr; /* Denotes the object's type. Always
803 * corresponds to the type of the object's
804 * internal rep. NULL indicates the object
805 * has no internal rep (has no type). */
806 union { /* The internal representation: */
807 long longValue; /* - an long integer value */
808 double doubleValue; /* - a double-precision floating value */
809 VOID *otherValuePtr; /* - another, type-specific value */
810 Tcl_WideInt wideValue; /* - a long long value */
811 struct { /* - internal rep as two pointers */
820 * Macros to increment and decrement a Tcl_Obj's reference count, and to
821 * test whether an object is shared (i.e. has reference count > 1).
822 * Note: clients should use Tcl_DecrRefCount() when they are finished using
823 * an object, and should never call TclFreeObj() directly. TclFreeObj() is
824 * only defined and made public in tcl.h to support Tcl_DecrRefCount's macro
825 * definition. Note also that Tcl_DecrRefCount() refers to the parameter
826 * "obj" twice. This means that you should avoid calling it with an
827 * expression that is expensive to compute or has side effects.
829 void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
830 void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
831 int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr));
834 # define Tcl_IncrRefCount(objPtr) \
835 Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__)
836 # define Tcl_DecrRefCount(objPtr) \
837 Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
838 # define Tcl_IsShared(objPtr) \
839 Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
841 # define Tcl_IncrRefCount(objPtr) \
844 * Use empty if ; else to handle use in unbraced outer if/else conditions
846 # define Tcl_DecrRefCount(objPtr) \
847 if (--(objPtr)->refCount > 0) ; else TclFreeObj(objPtr)
848 # define Tcl_IsShared(objPtr) \
849 ((objPtr)->refCount > 1)
853 * Macros and definitions that help to debug the use of Tcl objects.
854 * When TCL_MEM_DEBUG is defined, the Tcl_New declarations are
855 * overridden to call debugging versions of the object creation procedures.
859 # define Tcl_NewBooleanObj(val) \
860 Tcl_DbNewBooleanObj(val, __FILE__, __LINE__)
861 # define Tcl_NewByteArrayObj(bytes, len) \
862 Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__)
863 # define Tcl_NewDoubleObj(val) \
864 Tcl_DbNewDoubleObj(val, __FILE__, __LINE__)
865 # define Tcl_NewIntObj(val) \
866 Tcl_DbNewLongObj(val, __FILE__, __LINE__)
867 # define Tcl_NewListObj(objc, objv) \
868 Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__)
869 # define Tcl_NewLongObj(val) \
870 Tcl_DbNewLongObj(val, __FILE__, __LINE__)
871 # define Tcl_NewObj() \
872 Tcl_DbNewObj(__FILE__, __LINE__)
873 # define Tcl_NewStringObj(bytes, len) \
874 Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__)
875 # define Tcl_NewWideIntObj(val) \
876 Tcl_DbNewWideIntObj(val, __FILE__, __LINE__)
877 #endif /* TCL_MEM_DEBUG */
881 * The following structure contains the state needed by
882 * Tcl_SaveResult. No-one outside of Tcl should access any of these
883 * fields. This structure is typically allocated on the stack.
885 typedef struct Tcl_SavedResult {
887 Tcl_FreeProc *freeProc;
888 Tcl_Obj *objResultPtr;
892 char resultSpace[TCL_RESULT_SIZE+1];
897 * The following definitions support Tcl's namespace facility.
898 * Note: the first five fields must match exactly the fields in a
899 * Namespace structure (see tclInt.h).
902 typedef struct Tcl_Namespace {
903 char *name; /* The namespace's name within its parent
904 * namespace. This contains no ::'s. The
905 * name of the global namespace is ""
906 * although "::" is an synonym. */
907 char *fullName; /* The namespace's fully qualified name.
908 * This starts with ::. */
909 ClientData clientData; /* Arbitrary value associated with this
911 Tcl_NamespaceDeleteProc* deleteProc;
912 /* Procedure invoked when deleting the
913 * namespace to, e.g., free clientData. */
914 struct Tcl_Namespace* parentPtr;
915 /* Points to the namespace that contains
916 * this one. NULL if this is the global
922 * The following structure represents a call frame, or activation record.
923 * A call frame defines a naming context for a procedure call: its local
924 * scope (for local variables) and its namespace scope (used for non-local
925 * variables; often the global :: namespace). A call frame can also define
926 * the naming context for a namespace eval or namespace inscope command:
927 * the namespace in which the command's code should execute. The
928 * Tcl_CallFrame structures exist only while procedures or namespace
929 * eval/inscope's are being executed, and provide a Tcl call stack.
931 * A call frame is initialized and pushed using Tcl_PushCallFrame and
932 * popped using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be
933 * provided by the Tcl_PushCallFrame caller, and callers typically allocate
934 * them on the C call stack for efficiency. For this reason, Tcl_CallFrame
935 * is defined as a structure and not as an opaque token. However, most
936 * Tcl_CallFrame fields are hidden since applications should not access
937 * them directly; others are declared as "dummyX".
939 * WARNING!! The structure definition must be kept consistent with the
940 * CallFrame structure in tclInt.h. If you change one, change the other.
943 typedef struct Tcl_CallFrame {
944 Tcl_Namespace *nsPtr;
959 * Information about commands that is returned by Tcl_GetCommandInfo and
960 * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based
961 * command procedure while proc is a traditional Tcl argc/argv
962 * string-based procedure. Tcl_CreateObjCommand and Tcl_CreateCommand
963 * ensure that both objProc and proc are non-NULL and can be called to
964 * execute the command. However, it may be faster to call one instead of
965 * the other. The member isNativeObjectProc is set to 1 if an
966 * object-based procedure was registered by Tcl_CreateObjCommand, and to
967 * 0 if a string-based procedure was registered by Tcl_CreateCommand.
968 * The other procedure is typically set to a compatibility wrapper that
969 * does string-to-object or object-to-string argument conversions then
970 * calls the other procedure.
973 typedef struct Tcl_CmdInfo {
974 int isNativeObjectProc; /* 1 if objProc was registered by a call to
975 * Tcl_CreateObjCommand; 0 otherwise.
976 * Tcl_SetCmdInfo does not modify this
978 Tcl_ObjCmdProc *objProc; /* Command's object-based procedure. */
979 ClientData objClientData; /* ClientData for object proc. */
980 Tcl_CmdProc *proc; /* Command's string-based procedure. */
981 ClientData clientData; /* ClientData for string proc. */
982 Tcl_CmdDeleteProc *deleteProc;
983 /* Procedure to call when command is
985 ClientData deleteData; /* Value to pass to deleteProc (usually
986 * the same as clientData). */
987 Tcl_Namespace *namespacePtr; /* Points to the namespace that contains
988 * this command. Note that Tcl_SetCmdInfo
989 * will not change a command's namespace;
990 * use Tcl_RenameCommand to do that. */
995 * The structure defined below is used to hold dynamic strings. The only
996 * field that clients should use is the string field, accessible via the
997 * macro Tcl_DStringValue.
999 #define TCL_DSTRING_STATIC_SIZE 200
1000 typedef struct Tcl_DString {
1001 char *string; /* Points to beginning of string: either
1002 * staticSpace below or a malloced array. */
1003 int length; /* Number of non-NULL characters in the
1005 int spaceAvl; /* Total number of bytes available for the
1006 * string and its terminating NULL char. */
1007 char staticSpace[TCL_DSTRING_STATIC_SIZE];
1008 /* Space to use in common case where string
1012 #define Tcl_DStringLength(dsPtr) ((dsPtr)->length)
1013 #define Tcl_DStringValue(dsPtr) ((dsPtr)->string)
1014 #define Tcl_DStringTrunc Tcl_DStringSetLength
1017 * Definitions for the maximum number of digits of precision that may
1018 * be specified in the "tcl_precision" variable, and the number of
1019 * bytes of buffer space required by Tcl_PrintDouble.
1021 #define TCL_MAX_PREC 17
1022 #define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10)
1025 * Definition for a number of bytes of buffer space sufficient to hold the
1026 * string representation of an integer in base 10 (assuming the existence
1027 * of 64-bit integers).
1029 #define TCL_INTEGER_SPACE 24
1032 * Flag that may be passed to Tcl_ConvertElement to force it not to
1033 * output braces (careful! if you change this flag be sure to change
1034 * the definitions at the front of tclUtil.c).
1036 #define TCL_DONT_USE_BRACES 1
1039 * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow
1040 * abbreviated strings.
1045 * Flag values passed to Tcl_RecordAndEval and/or Tcl_EvalObj.
1046 * WARNING: these bit choices must not conflict with the bit choices
1047 * for evalFlag bits in tclInt.h!!
1049 #define TCL_NO_EVAL 0x10000
1050 #define TCL_EVAL_GLOBAL 0x20000
1051 #define TCL_EVAL_DIRECT 0x40000
1052 #define TCL_EVAL_INVOKE 0x80000
1055 * Special freeProc values that may be passed to Tcl_SetResult (see
1056 * the man page for details):
1058 #define TCL_VOLATILE ((Tcl_FreeProc *) 1)
1059 #define TCL_STATIC ((Tcl_FreeProc *) 0)
1060 #define TCL_DYNAMIC ((Tcl_FreeProc *) 3)
1063 * Flag values passed to variable-related procedures.
1065 #define TCL_GLOBAL_ONLY 1
1066 #define TCL_NAMESPACE_ONLY 2
1067 #define TCL_APPEND_VALUE 4
1068 #define TCL_LIST_ELEMENT 8
1069 #define TCL_TRACE_READS 0x10
1070 #define TCL_TRACE_WRITES 0x20
1071 #define TCL_TRACE_UNSETS 0x40
1072 #define TCL_TRACE_DESTROYED 0x80
1073 #define TCL_INTERP_DESTROYED 0x100
1074 #define TCL_LEAVE_ERR_MSG 0x200
1075 #define TCL_TRACE_ARRAY 0x800
1076 #ifndef TCL_REMOVE_OBSOLETE_TRACES
1077 /* Required to support old variable/vdelete/vinfo traces */
1078 #define TCL_TRACE_OLD_STYLE 0x1000
1080 /* Indicate the semantics of the result of a trace */
1081 #define TCL_TRACE_RESULT_DYNAMIC 0x8000
1082 #define TCL_TRACE_RESULT_OBJECT 0x10000
1085 * Flag values passed to command-related procedures.
1088 #define TCL_TRACE_RENAME 0x2000
1089 #define TCL_TRACE_DELETE 0x4000
1091 #define TCL_ALLOW_INLINE_COMPILATION 0x20000
1094 * Flag values passed to Tcl_CreateObjTrace, and used internally
1095 * by command execution traces. Slots 4,8,16 and 32 are
1096 * used internally by execution traces (see tclCmdMZ.c)
1098 #define TCL_TRACE_ENTER_EXEC 1
1099 #define TCL_TRACE_LEAVE_EXEC 2
1102 * The TCL_PARSE_PART1 flag is deprecated and has no effect.
1103 * The part1 is now always parsed whenever the part2 is NULL.
1104 * (This is to avoid a common error when converting code to
1105 * use the new object based APIs and forgetting to give the
1108 #ifndef TCL_NO_DEPRECATED
1109 # define TCL_PARSE_PART1 0x400
1114 * Types for linked variables:
1116 #define TCL_LINK_INT 1
1117 #define TCL_LINK_DOUBLE 2
1118 #define TCL_LINK_BOOLEAN 3
1119 #define TCL_LINK_STRING 4
1120 #define TCL_LINK_WIDE_INT 5
1121 #define TCL_LINK_READ_ONLY 0x80
1125 * Forward declarations of Tcl_HashTable and related types.
1127 typedef struct Tcl_HashKeyType Tcl_HashKeyType;
1128 typedef struct Tcl_HashTable Tcl_HashTable;
1129 typedef struct Tcl_HashEntry Tcl_HashEntry;
1131 typedef unsigned int (Tcl_HashKeyProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr,
1133 typedef int (Tcl_CompareHashKeysProc) _ANSI_ARGS_((VOID *keyPtr,
1134 Tcl_HashEntry *hPtr));
1135 typedef Tcl_HashEntry *(Tcl_AllocHashEntryProc) _ANSI_ARGS_((
1136 Tcl_HashTable *tablePtr, VOID *keyPtr));
1137 typedef void (Tcl_FreeHashEntryProc) _ANSI_ARGS_((Tcl_HashEntry *hPtr));
1140 * This flag controls whether the hash table stores the hash of a key, or
1141 * recalculates it. There should be no reason for turning this flag off
1142 * as it is completely binary and source compatible unless you directly
1143 * access the bucketPtr member of the Tcl_HashTableEntry structure. This
1144 * member has been removed and the space used to store the hash value.
1146 #ifndef TCL_HASH_KEY_STORE_HASH
1147 # define TCL_HASH_KEY_STORE_HASH 1
1151 * Structure definition for an entry in a hash table. No-one outside
1152 * Tcl should access any of these fields directly; use the macros
1156 struct Tcl_HashEntry {
1157 Tcl_HashEntry *nextPtr; /* Pointer to next entry in this
1158 * hash bucket, or NULL for end of
1160 Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */
1161 #if TCL_HASH_KEY_STORE_HASH
1162 # if TCL_PRESERVE_BINARY_COMPATABILITY
1163 VOID *hash; /* Hash value, stored as pointer to
1164 * ensure that the offsets of the
1165 * fields in this structure are not
1168 unsigned int hash; /* Hash value. */
1171 Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to
1172 * first entry in this entry's chain:
1173 * used for deleting the entry. */
1175 ClientData clientData; /* Application stores something here
1176 * with Tcl_SetHashValue. */
1177 union { /* Key has one of these forms: */
1178 char *oneWordValue; /* One-word value for key. */
1179 Tcl_Obj *objPtr; /* Tcl_Obj * key value. */
1180 int words[1]; /* Multiple integer words for key.
1181 * The actual size will be as large
1182 * as necessary for this table's
1184 char string[4]; /* String for key. The actual size
1185 * will be as large as needed to hold
1187 } key; /* MUST BE LAST FIELD IN RECORD!! */
1191 * Flags used in Tcl_HashKeyType.
1193 * TCL_HASH_KEY_RANDOMIZE_HASH:
1194 * There are some things, pointers for example
1195 * which don't hash well because they do not use
1196 * the lower bits. If this flag is set then the
1197 * hash table will attempt to rectify this by
1198 * randomising the bits and then using the upper
1199 * N bits as the index into the table.
1201 #define TCL_HASH_KEY_RANDOMIZE_HASH 0x1
1204 * Structure definition for the methods associated with a hash table
1207 #define TCL_HASH_KEY_TYPE_VERSION 1
1208 struct Tcl_HashKeyType {
1209 int version; /* Version of the table. If this structure is
1210 * extended in future then the version can be
1211 * used to distinguish between different
1215 int flags; /* Flags, see above for details. */
1217 /* Calculates a hash value for the key. If this is NULL then the pointer
1218 * itself is used as a hash value.
1220 Tcl_HashKeyProc *hashKeyProc;
1222 /* Compares two keys and returns zero if they do not match, and non-zero
1223 * if they do. If this is NULL then the pointers are compared.
1225 Tcl_CompareHashKeysProc *compareKeysProc;
1227 /* Called to allocate memory for a new entry, i.e. if the key is a
1228 * string then this could allocate a single block which contains enough
1229 * space for both the entry and the string. Only the key field of the
1230 * allocated Tcl_HashEntry structure needs to be filled in. If something
1231 * else needs to be done to the key, i.e. incrementing a reference count
1232 * then that should be done by this function. If this is NULL then Tcl_Alloc
1233 * is used to allocate enough space for a Tcl_HashEntry and the key pointer
1234 * is assigned to key.oneWordValue.
1236 Tcl_AllocHashEntryProc *allocEntryProc;
1238 /* Called to free memory associated with an entry. If something else needs
1239 * to be done to the key, i.e. decrementing a reference count then that
1240 * should be done by this function. If this is NULL then Tcl_Free is used
1241 * to free the Tcl_HashEntry.
1243 Tcl_FreeHashEntryProc *freeEntryProc;
1247 * Structure definition for a hash table. Must be in tcl.h so clients
1248 * can allocate space for these structures, but clients should never
1249 * access any fields in this structure.
1252 #define TCL_SMALL_HASH_TABLE 4
1253 struct Tcl_HashTable {
1254 Tcl_HashEntry **buckets; /* Pointer to bucket array. Each
1255 * element points to first entry in
1256 * bucket's hash chain, or NULL. */
1257 Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
1258 /* Bucket array used for small tables
1259 * (to avoid mallocs and frees). */
1260 int numBuckets; /* Total number of buckets allocated
1261 * at **bucketPtr. */
1262 int numEntries; /* Total number of entries present
1264 int rebuildSize; /* Enlarge table when numEntries gets
1265 * to be this large. */
1266 int downShift; /* Shift count used in hashing
1267 * function. Designed to use high-
1268 * order bits of randomized keys. */
1269 int mask; /* Mask value used in hashing
1271 int keyType; /* Type of keys used in this table.
1272 * It's either TCL_CUSTOM_KEYS,
1273 * TCL_STRING_KEYS, TCL_ONE_WORD_KEYS,
1274 * or an integer giving the number of
1275 * ints that is the size of the key.
1277 #if TCL_PRESERVE_BINARY_COMPATABILITY
1278 Tcl_HashEntry *(*findProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr,
1280 Tcl_HashEntry *(*createProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr,
1281 CONST char *key, int *newPtr));
1283 Tcl_HashKeyType *typePtr; /* Type of the keys used in the
1288 * Structure definition for information used to keep track of searches
1289 * through hash tables:
1292 typedef struct Tcl_HashSearch {
1293 Tcl_HashTable *tablePtr; /* Table being searched. */
1294 int nextIndex; /* Index of next bucket to be
1295 * enumerated after present one. */
1296 Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the
1297 * the current bucket. */
1301 * Acceptable key types for hash tables:
1303 * TCL_STRING_KEYS: The keys are strings, they are copied into
1305 * TCL_ONE_WORD_KEYS: The keys are pointers, the pointer is stored
1307 * TCL_CUSTOM_TYPE_KEYS: The keys are arbitrary types which are copied
1309 * TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the
1310 * pointer is stored in the entry.
1312 * While maintaining binary compatability the above have to be distinct
1313 * values as they are used to differentiate between old versions of the
1314 * hash table which don't have a typePtr and new ones which do. Once binary
1315 * compatability is discarded in favour of making more wide spread changes
1316 * TCL_STRING_KEYS can be the same as TCL_CUSTOM_TYPE_KEYS, and
1317 * TCL_ONE_WORD_KEYS can be the same as TCL_CUSTOM_PTR_KEYS because they
1318 * simply determine how the key is accessed from the entry and not the
1322 #define TCL_STRING_KEYS 0
1323 #define TCL_ONE_WORD_KEYS 1
1325 #if TCL_PRESERVE_BINARY_COMPATABILITY
1326 # define TCL_CUSTOM_TYPE_KEYS -2
1327 # define TCL_CUSTOM_PTR_KEYS -1
1329 # define TCL_CUSTOM_TYPE_KEYS TCL_STRING_KEYS
1330 # define TCL_CUSTOM_PTR_KEYS TCL_ONE_WORD_KEYS
1334 * Macros for clients to use to access fields of hash entries:
1337 #define Tcl_GetHashValue(h) ((h)->clientData)
1338 #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))
1339 #if TCL_PRESERVE_BINARY_COMPATABILITY
1340 # define Tcl_GetHashKey(tablePtr, h) \
1341 ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \
1342 (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \
1343 ? (h)->key.oneWordValue \
1346 # define Tcl_GetHashKey(tablePtr, h) \
1347 ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) \
1348 ? (h)->key.oneWordValue \
1353 * Macros to use for clients to use to invoke find and create procedures
1357 #if TCL_PRESERVE_BINARY_COMPATABILITY
1358 # define Tcl_FindHashEntry(tablePtr, key) \
1359 (*((tablePtr)->findProc))(tablePtr, key)
1360 # define Tcl_CreateHashEntry(tablePtr, key, newPtr) \
1361 (*((tablePtr)->createProc))(tablePtr, key, newPtr)
1362 #else /* !TCL_PRESERVE_BINARY_COMPATABILITY */
1364 * Macro to use new extended version of Tcl_InitHashTable.
1366 # define Tcl_InitHashTable(tablePtr, keyType) \
1367 Tcl_InitHashTableEx(tablePtr, keyType, NULL)
1368 #endif /* TCL_PRESERVE_BINARY_COMPATABILITY */
1372 * Flag values to pass to Tcl_DoOneEvent to disable searches
1373 * for some kinds of events:
1375 #define TCL_DONT_WAIT (1<<1)
1376 #define TCL_WINDOW_EVENTS (1<<2)
1377 #define TCL_FILE_EVENTS (1<<3)
1378 #define TCL_TIMER_EVENTS (1<<4)
1379 #define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */
1380 #define TCL_ALL_EVENTS (~TCL_DONT_WAIT)
1383 * The following structure defines a generic event for the Tcl event
1384 * system. These are the things that are queued in calls to Tcl_QueueEvent
1385 * and serviced later by Tcl_DoOneEvent. There can be many different
1386 * kinds of events with different fields, corresponding to window events,
1387 * timer events, etc. The structure for a particular event consists of
1388 * a Tcl_Event header followed by additional information specific to that
1392 Tcl_EventProc *proc; /* Procedure to call to service this event. */
1393 struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */
1397 * Positions to pass to Tcl_QueueEvent:
1400 TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK
1401 } Tcl_QueuePosition;
1404 * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier
1407 #define TCL_SERVICE_NONE 0
1408 #define TCL_SERVICE_ALL 1
1412 * The following structure keeps is used to hold a time value, either as
1413 * an absolute time (the number of seconds from the epoch) or as an
1414 * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT.
1415 * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT.
1417 typedef struct Tcl_Time {
1418 long sec; /* Seconds. */
1419 long usec; /* Microseconds. */
1422 typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr));
1423 typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr));
1427 * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler
1428 * to indicate what sorts of events are of interest:
1430 #define TCL_READABLE (1<<1)
1431 #define TCL_WRITABLE (1<<2)
1432 #define TCL_EXCEPTION (1<<3)
1435 * Flag values to pass to Tcl_OpenCommandChannel to indicate the
1436 * disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR,
1437 * are also used in Tcl_GetStdChannel.
1439 #define TCL_STDIN (1<<1)
1440 #define TCL_STDOUT (1<<2)
1441 #define TCL_STDERR (1<<3)
1442 #define TCL_ENFORCE_MODE (1<<4)
1445 * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel
1448 #define TCL_CLOSE_READ (1<<1)
1449 #define TCL_CLOSE_WRITE (1<<2)
1452 * Value to use as the closeProc for a channel that supports the
1453 * close2Proc interface.
1455 #define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1)
1458 * Channel version tag. This was introduced in 8.3.2/8.4.
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)
1466 * TIP #218: Channel Actions, Ids for Tcl_DriverThreadActionProc
1469 #define TCL_CHANNEL_THREAD_INSERT (0)
1470 #define TCL_CHANNEL_THREAD_REMOVE (1)
1473 * Typedefs for the various operations in a channel type:
1475 typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_((
1476 ClientData instanceData, int mode));
1477 typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData,
1478 Tcl_Interp *interp));
1479 typedef int (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData,
1480 Tcl_Interp *interp, int flags));
1481 typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData,
1482 char *buf, int toRead, int *errorCodePtr));
1483 typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData,
1484 CONST84 char *buf, int toWrite, int *errorCodePtr));
1485 typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData,
1486 long offset, int mode, int *errorCodePtr));
1487 typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_((
1488 ClientData instanceData, Tcl_Interp *interp,
1489 CONST char *optionName, CONST char *value));
1490 typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_((
1491 ClientData instanceData, Tcl_Interp *interp,
1492 CONST84 char *optionName, Tcl_DString *dsPtr));
1493 typedef void (Tcl_DriverWatchProc) _ANSI_ARGS_((
1494 ClientData instanceData, int mask));
1495 typedef int (Tcl_DriverGetHandleProc) _ANSI_ARGS_((
1496 ClientData instanceData, int direction,
1497 ClientData *handlePtr));
1498 typedef int (Tcl_DriverFlushProc) _ANSI_ARGS_((
1499 ClientData instanceData));
1500 typedef int (Tcl_DriverHandlerProc) _ANSI_ARGS_((
1501 ClientData instanceData, int interestMask));
1502 typedef Tcl_WideInt (Tcl_DriverWideSeekProc) _ANSI_ARGS_((
1503 ClientData instanceData, Tcl_WideInt offset,
1504 int mode, int *errorCodePtr));
1506 /* TIP #218, Channel Thread Actions */
1507 typedef void (Tcl_DriverThreadActionProc) _ANSI_ARGS_ ((
1508 ClientData instanceData, int action));
1511 * The following declarations either map ckalloc and ckfree to
1512 * malloc and free, or they map them to procedures with all sorts
1513 * of debugging hooks defined in tclCkalloc.c.
1515 #ifdef TCL_MEM_DEBUG
1517 # define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
1518 # define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__)
1519 # define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
1520 # define attemptckalloc(x) Tcl_AttemptDbCkalloc(x, __FILE__, __LINE__)
1521 # define attemptckrealloc(x,y) Tcl_AttemptDbCkrealloc((x), (y), __FILE__, __LINE__)
1522 #else /* !TCL_MEM_DEBUG */
1525 * If we are not using the debugging allocator, we should call the
1526 * Tcl_Alloc, et al. routines in order to guarantee that every module
1527 * is using the same memory allocator both inside and outside of the
1530 # define ckalloc(x) Tcl_Alloc(x)
1531 # define ckfree(x) Tcl_Free(x)
1532 # define ckrealloc(x,y) Tcl_Realloc(x,y)
1533 # define attemptckalloc(x) Tcl_AttemptAlloc(x)
1534 # define attemptckrealloc(x,y) Tcl_AttemptRealloc(x,y)
1535 # define Tcl_InitMemory(x)
1536 # define Tcl_DumpActiveMemory(x)
1537 # define Tcl_ValidateAllMemory(x,y)
1539 #endif /* !TCL_MEM_DEBUG */
1542 * struct Tcl_ChannelType:
1544 * One such structure exists for each type (kind) of channel.
1545 * It collects together in one place all the functions that are
1546 * part of the specific channel type.
1548 * It is recommend that the Tcl_Channel* functions are used to access
1549 * elements of this structure, instead of direct accessing.
1551 typedef struct Tcl_ChannelType {
1552 char *typeName; /* The name of the channel type in Tcl
1553 * commands. This storage is owned by
1555 Tcl_ChannelTypeVersion version; /* Version of the channel type. */
1556 Tcl_DriverCloseProc *closeProc; /* Procedure to call to close the
1557 * channel, or TCL_CLOSE2PROC if the
1558 * close2Proc should be used
1560 Tcl_DriverInputProc *inputProc; /* Procedure to call for input
1562 Tcl_DriverOutputProc *outputProc; /* Procedure to call for output
1564 Tcl_DriverSeekProc *seekProc; /* Procedure to call to seek
1565 * on the channel. May be NULL. */
1566 Tcl_DriverSetOptionProc *setOptionProc;
1567 /* Set an option on a channel. */
1568 Tcl_DriverGetOptionProc *getOptionProc;
1569 /* Get an option from a channel. */
1570 Tcl_DriverWatchProc *watchProc; /* Set up the notifier to watch
1571 * for events on this channel. */
1572 Tcl_DriverGetHandleProc *getHandleProc;
1573 /* Get an OS handle from the channel
1574 * or NULL if not supported. */
1575 Tcl_DriverClose2Proc *close2Proc; /* Procedure to call to close the
1576 * channel if the device supports
1577 * closing the read & write sides
1579 Tcl_DriverBlockModeProc *blockModeProc;
1580 /* Set blocking mode for the
1581 * raw channel. May be NULL. */
1583 * Only valid in TCL_CHANNEL_VERSION_2 channels or later
1585 Tcl_DriverFlushProc *flushProc; /* Procedure to call to flush a
1586 * channel. May be NULL. */
1587 Tcl_DriverHandlerProc *handlerProc; /* Procedure to call to handle a
1588 * channel event. This will be passed
1589 * up the stacked channel chain. */
1591 * Only valid in TCL_CHANNEL_VERSION_3 channels or later
1593 Tcl_DriverWideSeekProc *wideSeekProc;
1594 /* Procedure to call to seek
1595 * on the channel which can
1596 * handle 64-bit offsets. May be
1597 * NULL, and must be NULL if
1598 * seekProc is NULL. */
1601 * Only valid in TCL_CHANNEL_VERSION_4 channels or later
1602 * TIP #218, Channel Thread Actions
1604 Tcl_DriverThreadActionProc *threadActionProc;
1605 /* Procedure to call to notify
1606 * the driver of thread specific
1607 * activity for a channel.
1612 * The following flags determine whether the blockModeProc above should
1613 * set the channel into blocking or nonblocking mode. They are passed
1614 * as arguments to the blockModeProc procedure in the above structure.
1616 #define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */
1617 #define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking
1621 * Enum for different types of file paths.
1623 typedef enum Tcl_PathType {
1626 TCL_PATH_VOLUME_RELATIVE
1631 * The following structure is used to pass glob type data amongst
1632 * the various glob routines and Tcl_FSMatchInDirectory.
1634 typedef struct Tcl_GlobTypeData {
1635 /* Corresponds to bcdpfls as in 'find -t' */
1637 /* Corresponds to file permissions */
1639 /* Acceptable mac type */
1641 /* Acceptable mac creator */
1642 Tcl_Obj* macCreator;
1646 * type and permission definitions for glob command
1648 #define TCL_GLOB_TYPE_BLOCK (1<<0)
1649 #define TCL_GLOB_TYPE_CHAR (1<<1)
1650 #define TCL_GLOB_TYPE_DIR (1<<2)
1651 #define TCL_GLOB_TYPE_PIPE (1<<3)
1652 #define TCL_GLOB_TYPE_FILE (1<<4)
1653 #define TCL_GLOB_TYPE_LINK (1<<5)
1654 #define TCL_GLOB_TYPE_SOCK (1<<6)
1655 #define TCL_GLOB_TYPE_MOUNT (1<<7)
1657 #define TCL_GLOB_PERM_RONLY (1<<0)
1658 #define TCL_GLOB_PERM_HIDDEN (1<<1)
1659 #define TCL_GLOB_PERM_R (1<<2)
1660 #define TCL_GLOB_PERM_W (1<<3)
1661 #define TCL_GLOB_PERM_X (1<<4)
1665 * Typedefs for the various filesystem operations:
1667 typedef int (Tcl_FSStatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf));
1668 typedef int (Tcl_FSAccessProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, int mode));
1669 typedef Tcl_Channel (Tcl_FSOpenFileChannelProc)
1670 _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *pathPtr,
1671 int mode, int permissions));
1672 typedef int (Tcl_FSMatchInDirectoryProc) _ANSI_ARGS_((Tcl_Interp* interp,
1673 Tcl_Obj *result, Tcl_Obj *pathPtr, CONST char *pattern,
1674 Tcl_GlobTypeData * types));
1675 typedef Tcl_Obj* (Tcl_FSGetCwdProc) _ANSI_ARGS_((Tcl_Interp *interp));
1676 typedef int (Tcl_FSChdirProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1677 typedef int (Tcl_FSLstatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
1679 typedef int (Tcl_FSCreateDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1680 typedef int (Tcl_FSDeleteFileProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1681 typedef int (Tcl_FSCopyDirectoryProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr,
1682 Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr));
1683 typedef int (Tcl_FSCopyFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr,
1684 Tcl_Obj *destPathPtr));
1685 typedef int (Tcl_FSRemoveDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
1686 int recursive, Tcl_Obj **errorPtr));
1687 typedef int (Tcl_FSRenameFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr,
1688 Tcl_Obj *destPathPtr));
1689 typedef void (Tcl_FSUnloadFileProc) _ANSI_ARGS_((Tcl_LoadHandle loadHandle));
1690 typedef Tcl_Obj* (Tcl_FSListVolumesProc) _ANSI_ARGS_((void));
1691 /* We have to declare the utime structure here. */
1693 typedef int (Tcl_FSUtimeProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
1694 struct utimbuf *tval));
1695 typedef int (Tcl_FSNormalizePathProc) _ANSI_ARGS_((Tcl_Interp *interp,
1696 Tcl_Obj *pathPtr, int nextCheckpoint));
1697 typedef int (Tcl_FSFileAttrsGetProc) _ANSI_ARGS_((Tcl_Interp *interp,
1698 int index, Tcl_Obj *pathPtr,
1699 Tcl_Obj **objPtrRef));
1700 typedef CONST char** (Tcl_FSFileAttrStringsProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
1701 Tcl_Obj** objPtrRef));
1702 typedef int (Tcl_FSFileAttrsSetProc) _ANSI_ARGS_((Tcl_Interp *interp,
1703 int index, Tcl_Obj *pathPtr,
1705 typedef Tcl_Obj* (Tcl_FSLinkProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
1706 Tcl_Obj *toPtr, int linkType));
1707 typedef int (Tcl_FSLoadFileProc) _ANSI_ARGS_((Tcl_Interp * interp,
1709 Tcl_LoadHandle *handlePtr,
1710 Tcl_FSUnloadFileProc **unloadProcPtr));
1711 typedef int (Tcl_FSPathInFilesystemProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
1712 ClientData *clientDataPtr));
1713 typedef Tcl_Obj* (Tcl_FSFilesystemPathTypeProc)
1714 _ANSI_ARGS_((Tcl_Obj *pathPtr));
1715 typedef Tcl_Obj* (Tcl_FSFilesystemSeparatorProc)
1716 _ANSI_ARGS_((Tcl_Obj *pathPtr));
1717 typedef void (Tcl_FSFreeInternalRepProc) _ANSI_ARGS_((ClientData clientData));
1718 typedef ClientData (Tcl_FSDupInternalRepProc)
1719 _ANSI_ARGS_((ClientData clientData));
1720 typedef Tcl_Obj* (Tcl_FSInternalToNormalizedProc)
1721 _ANSI_ARGS_((ClientData clientData));
1722 typedef ClientData (Tcl_FSCreateInternalRepProc) _ANSI_ARGS_((Tcl_Obj *pathPtr));
1724 typedef struct Tcl_FSVersion_ *Tcl_FSVersion;
1727 *----------------------------------------------------------------
1728 * Data structures related to hooking into the filesystem
1729 *----------------------------------------------------------------
1733 * Filesystem version tag. This was introduced in 8.4.
1735 #define TCL_FILESYSTEM_VERSION_1 ((Tcl_FSVersion) 0x1)
1738 * struct Tcl_Filesystem:
1740 * One such structure exists for each type (kind) of filesystem.
1741 * It collects together in one place all the functions that are
1742 * part of the specific filesystem. Tcl always accesses the
1743 * filesystem through one of these structures.
1745 * Not all entries need be non-NULL; any which are NULL are simply
1746 * ignored. However, a complete filesystem should provide all of
1747 * these functions. The explanations in the structure show
1748 * the importance of each function.
1751 typedef struct Tcl_Filesystem {
1752 CONST char *typeName; /* The name of the filesystem. */
1753 int structureLength; /* Length of this structure, so future
1754 * binary compatibility can be assured. */
1755 Tcl_FSVersion version;
1756 /* Version of the filesystem type. */
1757 Tcl_FSPathInFilesystemProc *pathInFilesystemProc;
1758 /* Function to check whether a path is in
1759 * this filesystem. This is the most
1760 * important filesystem procedure. */
1761 Tcl_FSDupInternalRepProc *dupInternalRepProc;
1762 /* Function to duplicate internal fs rep. May
1763 * be NULL (but then fs is less efficient). */
1764 Tcl_FSFreeInternalRepProc *freeInternalRepProc;
1765 /* Function to free internal fs rep. Must
1766 * be implemented, if internal representations
1767 * need freeing, otherwise it can be NULL. */
1768 Tcl_FSInternalToNormalizedProc *internalToNormalizedProc;
1769 /* Function to convert internal representation
1770 * to a normalized path. Only required if
1771 * the fs creates pure path objects with no
1772 * string/path representation. */
1773 Tcl_FSCreateInternalRepProc *createInternalRepProc;
1774 /* Function to create a filesystem-specific
1775 * internal representation. May be NULL
1776 * if paths have no internal representation,
1777 * or if the Tcl_FSPathInFilesystemProc
1778 * for this filesystem always immediately
1779 * creates an internal representation for
1780 * paths it accepts. */
1781 Tcl_FSNormalizePathProc *normalizePathProc;
1782 /* Function to normalize a path. Should
1783 * be implemented for all filesystems
1784 * which can have multiple string
1785 * representations for the same path
1787 Tcl_FSFilesystemPathTypeProc *filesystemPathTypeProc;
1788 /* Function to determine the type of a
1789 * path in this filesystem. May be NULL. */
1790 Tcl_FSFilesystemSeparatorProc *filesystemSeparatorProc;
1791 /* Function to return the separator
1792 * character(s) for this filesystem. Must
1793 * be implemented. */
1794 Tcl_FSStatProc *statProc;
1796 * Function to process a 'Tcl_FSStat()'
1797 * call. Must be implemented for any
1798 * reasonable filesystem.
1800 Tcl_FSAccessProc *accessProc;
1802 * Function to process a 'Tcl_FSAccess()'
1803 * call. Must be implemented for any
1804 * reasonable filesystem.
1806 Tcl_FSOpenFileChannelProc *openFileChannelProc;
1808 * Function to process a
1809 * 'Tcl_FSOpenFileChannel()' call. Must be
1810 * implemented for any reasonable
1813 Tcl_FSMatchInDirectoryProc *matchInDirectoryProc;
1814 /* Function to process a
1815 * 'Tcl_FSMatchInDirectory()'. If not
1816 * implemented, then glob and recursive
1817 * copy functionality will be lacking in
1818 * the filesystem. */
1819 Tcl_FSUtimeProc *utimeProc;
1820 /* Function to process a
1821 * 'Tcl_FSUtime()' call. Required to
1822 * allow setting (not reading) of times
1823 * with 'file mtime', 'file atime' and
1824 * the open-r/open-w/fcopy implementation
1825 * of 'file copy'. */
1826 Tcl_FSLinkProc *linkProc;
1827 /* Function to process a
1828 * 'Tcl_FSLink()' call. Should be
1829 * implemented only if the filesystem supports
1830 * links (reading or creating). */
1831 Tcl_FSListVolumesProc *listVolumesProc;
1832 /* Function to list any filesystem volumes
1833 * added by this filesystem. Should be
1834 * implemented only if the filesystem adds
1835 * volumes at the head of the filesystem. */
1836 Tcl_FSFileAttrStringsProc *fileAttrStringsProc;
1837 /* Function to list all attributes strings
1838 * which are valid for this filesystem.
1839 * If not implemented the filesystem will
1840 * not support the 'file attributes' command.
1841 * This allows arbitrary additional information
1842 * to be attached to files in the filesystem. */
1843 Tcl_FSFileAttrsGetProc *fileAttrsGetProc;
1844 /* Function to process a
1845 * 'Tcl_FSFileAttrsGet()' call, used by
1846 * 'file attributes'. */
1847 Tcl_FSFileAttrsSetProc *fileAttrsSetProc;
1848 /* Function to process a
1849 * 'Tcl_FSFileAttrsSet()' call, used by
1850 * 'file attributes'. */
1851 Tcl_FSCreateDirectoryProc *createDirectoryProc;
1852 /* Function to process a
1853 * 'Tcl_FSCreateDirectory()' call. Should
1854 * be implemented unless the FS is
1856 Tcl_FSRemoveDirectoryProc *removeDirectoryProc;
1857 /* Function to process a
1858 * 'Tcl_FSRemoveDirectory()' call. Should
1859 * be implemented unless the FS is
1861 Tcl_FSDeleteFileProc *deleteFileProc;
1862 /* Function to process a
1863 * 'Tcl_FSDeleteFile()' call. Should
1864 * be implemented unless the FS is
1866 Tcl_FSCopyFileProc *copyFileProc;
1867 /* Function to process a
1868 * 'Tcl_FSCopyFile()' call. If not
1869 * implemented Tcl will fall back
1870 * on open-r, open-w and fcopy as
1871 * a copying mechanism, for copying
1872 * actions initiated in Tcl (not C). */
1873 Tcl_FSRenameFileProc *renameFileProc;
1874 /* Function to process a
1875 * 'Tcl_FSRenameFile()' call. If not
1876 * implemented, Tcl will fall back on
1877 * a copy and delete mechanism, for
1878 * rename actions initiated in Tcl (not C). */
1879 Tcl_FSCopyDirectoryProc *copyDirectoryProc;
1880 /* Function to process a
1881 * 'Tcl_FSCopyDirectory()' call. If
1882 * not implemented, Tcl will fall back
1883 * on a recursive create-dir, file copy
1884 * mechanism, for copying actions
1885 * initiated in Tcl (not C). */
1886 Tcl_FSLstatProc *lstatProc;
1887 /* Function to process a
1888 * 'Tcl_FSLstat()' call. If not implemented,
1889 * Tcl will attempt to use the 'statProc'
1890 * defined above instead. */
1891 Tcl_FSLoadFileProc *loadFileProc;
1892 /* Function to process a
1893 * 'Tcl_FSLoadFile()' call. If not
1894 * implemented, Tcl will fall back on
1895 * a copy to native-temp followed by a
1896 * Tcl_FSLoadFile on that temporary copy. */
1897 Tcl_FSGetCwdProc *getCwdProc;
1899 * Function to process a 'Tcl_FSGetCwd()'
1900 * call. Most filesystems need not
1901 * implement this. It will usually only be
1902 * called once, if 'getcwd' is called
1903 * before 'chdir'. May be NULL.
1905 Tcl_FSChdirProc *chdirProc;
1907 * Function to process a 'Tcl_FSChdir()'
1908 * call. If filesystems do not implement
1909 * this, it will be emulated by a series of
1910 * directory access checks. Otherwise,
1911 * virtual filesystems which do implement
1912 * it need only respond with a positive
1913 * return result if the dirName is a valid
1914 * directory in their filesystem. They
1915 * need not remember the result, since that
1916 * will be automatically remembered for use
1917 * by GetCwd. Real filesystems should
1918 * carry out the correct action (i.e. call
1919 * the correct system 'chdir' api). If not
1920 * implemented, then 'cd' and 'pwd' will
1921 * fail inside the filesystem.
1926 * The following definitions are used as values for the 'linkAction' flag
1927 * to Tcl_FSLink, or the linkProc of any filesystem. Any combination
1928 * of flags can be given. For link creation, the linkProc should create
1929 * a link which matches any of the types given.
1931 * TCL_CREATE_SYMBOLIC_LINK: Create a symbolic or soft link.
1932 * TCL_CREATE_HARD_LINK: Create a hard link.
1934 #define TCL_CREATE_SYMBOLIC_LINK 0x01
1935 #define TCL_CREATE_HARD_LINK 0x02
1938 * The following structure represents the Notifier functions that
1939 * you can override with the Tcl_SetNotifier call.
1941 typedef struct Tcl_NotifierProcs {
1942 Tcl_SetTimerProc *setTimerProc;
1943 Tcl_WaitForEventProc *waitForEventProc;
1944 Tcl_CreateFileHandlerProc *createFileHandlerProc;
1945 Tcl_DeleteFileHandlerProc *deleteFileHandlerProc;
1946 Tcl_InitNotifierProc *initNotifierProc;
1947 Tcl_FinalizeNotifierProc *finalizeNotifierProc;
1948 Tcl_AlertNotifierProc *alertNotifierProc;
1949 Tcl_ServiceModeHookProc *serviceModeHookProc;
1950 } Tcl_NotifierProcs;
1954 * The following structure represents a user-defined encoding. It collects
1955 * together all the functions that are used by the specific encoding.
1957 typedef struct Tcl_EncodingType {
1958 CONST char *encodingName; /* The name of the encoding, e.g. "euc-jp".
1959 * This name is the unique key for this
1961 Tcl_EncodingConvertProc *toUtfProc;
1962 /* Procedure to convert from external
1963 * encoding into UTF-8. */
1964 Tcl_EncodingConvertProc *fromUtfProc;
1965 /* Procedure to convert from UTF-8 into
1966 * external encoding. */
1967 Tcl_EncodingFreeProc *freeProc;
1968 /* If non-NULL, procedure to call when this
1969 * encoding is deleted. */
1970 ClientData clientData; /* Arbitrary value associated with encoding
1971 * type. Passed to conversion procedures. */
1972 int nullSize; /* Number of zero bytes that signify
1973 * end-of-string in this encoding. This
1974 * number is used to determine the source
1975 * string length when the srcLen argument is
1976 * negative. Must be 1 or 2. */
1980 * The following definitions are used as values for the conversion control
1981 * flags argument when converting text from one character set to another:
1983 * TCL_ENCODING_START: Signifies that the source buffer is the first
1984 * block in a (potentially multi-block) input
1985 * stream. Tells the conversion procedure to
1986 * reset to an initial state and perform any
1987 * initialization that needs to occur before the
1988 * first byte is converted. If the source
1989 * buffer contains the entire input stream to be
1990 * converted, this flag should be set.
1992 * TCL_ENCODING_END: Signifies that the source buffer is the last
1993 * block in a (potentially multi-block) input
1994 * stream. Tells the conversion routine to
1995 * perform any finalization that needs to occur
1996 * after the last byte is converted and then to
1997 * reset to an initial state. If the source
1998 * buffer contains the entire input stream to be
1999 * converted, this flag should be set.
2001 * TCL_ENCODING_STOPONERROR: If set, then the converter will return
2002 * immediately upon encountering an invalid
2003 * byte sequence or a source character that has
2004 * no mapping in the target encoding. If clear,
2005 * then the converter will skip the problem,
2006 * substituting one or more "close" characters
2007 * in the destination buffer and then continue
2008 * to sonvert the source.
2010 #define TCL_ENCODING_START 0x01
2011 #define TCL_ENCODING_END 0x02
2012 #define TCL_ENCODING_STOPONERROR 0x04
2016 * The following data structures and declarations are for the new Tcl
2021 * For each word of a command, and for each piece of a word such as a
2022 * variable reference, one of the following structures is created to
2023 * describe the token.
2025 typedef struct Tcl_Token {
2026 int type; /* Type of token, such as TCL_TOKEN_WORD;
2027 * see below for valid types. */
2028 CONST char *start; /* First character in token. */
2029 int size; /* Number of bytes in token. */
2030 int numComponents; /* If this token is composed of other
2031 * tokens, this field tells how many of
2032 * them there are (including components of
2033 * components, etc.). The component tokens
2034 * immediately follow this one. */
2038 * Type values defined for Tcl_Token structures. These values are
2039 * defined as mask bits so that it's easy to check for collections of
2042 * TCL_TOKEN_WORD - The token describes one word of a command,
2043 * from the first non-blank character of
2044 * the word (which may be " or {) up to but
2045 * not including the space, semicolon, or
2046 * bracket that terminates the word.
2047 * NumComponents counts the total number of
2048 * sub-tokens that make up the word. This
2049 * includes, for example, sub-tokens of
2050 * TCL_TOKEN_VARIABLE tokens.
2051 * TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD
2052 * except that the word is guaranteed to
2053 * consist of a single TCL_TOKEN_TEXT
2055 * TCL_TOKEN_TEXT - The token describes a range of literal
2056 * text that is part of a word.
2057 * NumComponents is always 0.
2058 * TCL_TOKEN_BS - The token describes a backslash sequence
2059 * that must be collapsed. NumComponents
2061 * TCL_TOKEN_COMMAND - The token describes a command whose result
2062 * must be substituted into the word. The
2063 * token includes the enclosing brackets.
2064 * NumComponents is always 0.
2065 * TCL_TOKEN_VARIABLE - The token describes a variable
2066 * substitution, including the dollar sign,
2067 * variable name, and array index (if there
2068 * is one) up through the right
2069 * parentheses. NumComponents tells how
2070 * many additional tokens follow to
2071 * represent the variable name. The first
2072 * token will be a TCL_TOKEN_TEXT token
2073 * that describes the variable name. If
2074 * the variable is an array reference then
2075 * there will be one or more additional
2076 * tokens, of type TCL_TOKEN_TEXT,
2077 * TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and
2078 * TCL_TOKEN_VARIABLE, that describe the
2079 * array index; numComponents counts the
2080 * total number of nested tokens that make
2081 * up the variable reference, including
2082 * sub-tokens of TCL_TOKEN_VARIABLE tokens.
2083 * TCL_TOKEN_SUB_EXPR - The token describes one subexpression of a
2084 * expression, from the first non-blank
2085 * character of the subexpression up to but not
2086 * including the space, brace, or bracket
2087 * that terminates the subexpression.
2088 * NumComponents counts the total number of
2089 * following subtokens that make up the
2090 * subexpression; this includes all subtokens
2091 * for any nested TCL_TOKEN_SUB_EXPR tokens.
2092 * For example, a numeric value used as a
2093 * primitive operand is described by a
2094 * TCL_TOKEN_SUB_EXPR token followed by a
2095 * TCL_TOKEN_TEXT token. A binary subexpression
2096 * is described by a TCL_TOKEN_SUB_EXPR token
2097 * followed by the TCL_TOKEN_OPERATOR token
2098 * for the operator, then TCL_TOKEN_SUB_EXPR
2099 * tokens for the left then the right operands.
2100 * TCL_TOKEN_OPERATOR - The token describes one expression operator.
2101 * An operator might be the name of a math
2102 * function such as "abs". A TCL_TOKEN_OPERATOR
2103 * token is always preceeded by one
2104 * TCL_TOKEN_SUB_EXPR token for the operator's
2105 * subexpression, and is followed by zero or
2106 * more TCL_TOKEN_SUB_EXPR tokens for the
2107 * operator's operands. NumComponents is
2110 #define TCL_TOKEN_WORD 1
2111 #define TCL_TOKEN_SIMPLE_WORD 2
2112 #define TCL_TOKEN_TEXT 4
2113 #define TCL_TOKEN_BS 8
2114 #define TCL_TOKEN_COMMAND 16
2115 #define TCL_TOKEN_VARIABLE 32
2116 #define TCL_TOKEN_SUB_EXPR 64
2117 #define TCL_TOKEN_OPERATOR 128
2120 * Parsing error types. On any parsing error, one of these values
2121 * will be stored in the error field of the Tcl_Parse structure
2124 #define TCL_PARSE_SUCCESS 0
2125 #define TCL_PARSE_QUOTE_EXTRA 1
2126 #define TCL_PARSE_BRACE_EXTRA 2
2127 #define TCL_PARSE_MISSING_BRACE 3
2128 #define TCL_PARSE_MISSING_BRACKET 4
2129 #define TCL_PARSE_MISSING_PAREN 5
2130 #define TCL_PARSE_MISSING_QUOTE 6
2131 #define TCL_PARSE_MISSING_VAR_BRACE 7
2132 #define TCL_PARSE_SYNTAX 8
2133 #define TCL_PARSE_BAD_NUMBER 9
2136 * A structure of the following type is filled in by Tcl_ParseCommand.
2137 * It describes a single command parsed from an input string.
2139 #define NUM_STATIC_TOKENS 20
2141 typedef struct Tcl_Parse {
2142 CONST char *commentStart; /* Pointer to # that begins the first of
2143 * one or more comments preceding the
2145 int commentSize; /* Number of bytes in comments (up through
2146 * newline character that terminates the
2147 * last comment). If there were no
2148 * comments, this field is 0. */
2149 CONST char *commandStart; /* First character in first word of command. */
2150 int commandSize; /* Number of bytes in command, including
2151 * first character of first word, up
2152 * through the terminating newline,
2153 * close bracket, or semicolon. */
2154 int numWords; /* Total number of words in command. May
2156 Tcl_Token *tokenPtr; /* Pointer to first token representing
2157 * the words of the command. Initially
2158 * points to staticTokens, but may change
2159 * to point to malloc-ed space if command
2160 * exceeds space in staticTokens. */
2161 int numTokens; /* Total number of tokens in command. */
2162 int tokensAvailable; /* Total number of tokens available at
2164 int errorType; /* One of the parsing error types defined
2168 * The fields below are intended only for the private use of the
2169 * parser. They should not be used by procedures that invoke
2173 CONST char *string; /* The original command string passed to
2174 * Tcl_ParseCommand. */
2175 CONST char *end; /* Points to the character just after the
2176 * last one in the command string. */
2177 Tcl_Interp *interp; /* Interpreter to use for error reporting,
2179 CONST char *term; /* Points to character in string that
2180 * terminated most recent token. Filled in
2181 * by ParseTokens. If an error occurs,
2182 * points to beginning of region where the
2183 * error occurred (e.g. the open brace if
2184 * the close brace is missing). */
2185 int incomplete; /* This field is set to 1 by Tcl_ParseCommand
2186 * if the command appears to be incomplete.
2187 * This information is used by
2188 * Tcl_CommandComplete. */
2189 Tcl_Token staticTokens[NUM_STATIC_TOKENS];
2190 /* Initial space for tokens for command.
2191 * This space should be large enough to
2192 * accommodate most commands; dynamic
2193 * space is allocated for very large
2194 * commands that don't fit here. */
2198 * The following definitions are the error codes returned by the conversion
2201 * TCL_OK: All characters were converted.
2203 * TCL_CONVERT_NOSPACE: The output buffer would not have been large
2204 * enough for all of the converted data; as many
2205 * characters as could fit were converted though.
2207 * TCL_CONVERT_MULTIBYTE: The last few bytes in the source string were
2208 * the beginning of a multibyte sequence, but
2209 * more bytes were needed to complete this
2210 * sequence. A subsequent call to the conversion
2211 * routine should pass the beginning of this
2212 * unconverted sequence plus additional bytes
2213 * from the source stream to properly convert
2214 * the formerly split-up multibyte sequence.
2216 * TCL_CONVERT_SYNTAX: The source stream contained an invalid
2217 * character sequence. This may occur if the
2218 * input stream has been damaged or if the input
2219 * encoding method was misidentified. This error
2220 * is reported only if TCL_ENCODING_STOPONERROR
2223 * TCL_CONVERT_UNKNOWN: The source string contained a character
2224 * that could not be represented in the target
2225 * encoding. This error is reported only if
2226 * TCL_ENCODING_STOPONERROR was specified.
2228 #define TCL_CONVERT_MULTIBYTE -1
2229 #define TCL_CONVERT_SYNTAX -2
2230 #define TCL_CONVERT_UNKNOWN -3
2231 #define TCL_CONVERT_NOSPACE -4
2234 * The maximum number of bytes that are necessary to represent a single
2235 * Unicode character in UTF-8. The valid values should be 3 or 6 (or
2236 * perhaps 1 if we want to support a non-unicode enabled core).
2237 * If 3, then Tcl_UniChar must be 2-bytes in size (UCS-2). (default)
2238 * If 6, then Tcl_UniChar must be 4-bytes in size (UCS-4).
2239 * At this time UCS-2 mode is the default and recommended mode.
2240 * UCS-4 is experimental and not recommended. It works for the core,
2241 * but most extensions expect UCS-2.
2244 #define TCL_UTF_MAX 3
2248 * This represents a Unicode character. Any changes to this should
2249 * also be reflected in regcustom.h.
2253 * unsigned int isn't 100% accurate as it should be a strict 4-byte
2254 * value (perhaps wchar_t). 64-bit systems may have troubles. The
2255 * size of this value must be reflected correctly in regcustom.h and
2257 * XXX: Tcl is currently UCS-2 and planning UTF-16 for the Unicode
2258 * XXX: string rep that Tcl_UniChar represents. Changing the size
2259 * XXX: of Tcl_UniChar is /not/ supported.
2261 typedef unsigned int Tcl_UniChar;
2263 typedef unsigned short Tcl_UniChar;
2268 * Deprecated Tcl procedures:
2270 #ifndef TCL_NO_DEPRECATED
2271 # define Tcl_EvalObj(interp,objPtr) \
2272 Tcl_EvalObjEx((interp),(objPtr),0)
2273 # define Tcl_GlobalEvalObj(interp,objPtr) \
2274 Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL)
2279 * These function have been renamed. The old names are deprecated, but we
2280 * define these macros for backwards compatibilty.
2282 #define Tcl_Ckalloc Tcl_Alloc
2283 #define Tcl_Ckfree Tcl_Free
2284 #define Tcl_Ckrealloc Tcl_Realloc
2285 #define Tcl_Return Tcl_SetResult
2286 #define Tcl_TildeSubst Tcl_TranslateFileName
2287 #define panic Tcl_Panic
2288 #define panicVA Tcl_PanicVA
2292 * The following constant is used to test for older versions of Tcl
2293 * in the stubs tables.
2295 * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different
2296 * value since the stubs tables don't match.
2299 #define TCL_STUB_MAGIC ((int)0xFCA3BACF)
2302 * The following function is required to be defined in all stubs aware
2303 * extensions. The function is actually implemented in the stub
2304 * library, not the main Tcl library, although there is a trivial
2305 * implementation in the main library in case an extension is statically
2306 * linked into an application.
2309 EXTERN CONST char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
2310 CONST char *version, int exact));
2312 #ifndef USE_TCL_STUBS
2315 * When not using stubs, make it a macro.
2318 #define Tcl_InitStubs(interp, version, exact) \
2319 Tcl_PkgRequire(interp, "Tcl", version, exact)
2325 * Include the public function declarations that are accessible via
2329 #include "tclDecls.h"
2332 * Include platform specific public function declarations that are
2333 * accessible via the stubs table.
2337 * tclPlatDecls.h can't be included here on the Mac, as we need
2338 * Mac specific headers to define the Mac types used in this file,
2339 * but these Mac haders conflict with a number of tk types
2340 * and thus can't be included in the globally read tcl.h
2341 * This header was originally added here as a fix for bug 5241
2342 * (stub link error for symbols in TclPlatStubs table), as a work-
2343 * around for the bug on the mac, tclMac.h is included immediately
2344 * after tcl.h in the tcl precompiled header (with DLLEXPORT set).
2347 #if !defined(MAC_TCL)
2348 #include "tclPlatDecls.h"
2352 * Public functions that are not accessible via the stubs table.
2355 EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv,
2356 Tcl_AppInitProc *appInitProc));
2359 * Convenience declaration of Tcl_AppInit for backwards compatibility.
2360 * This function is not *implemented* by the tcl library, so the storage
2361 * class is neither DLLEXPORT nor DLLIMPORT
2363 #undef TCL_STORAGE_CLASS
2364 #define TCL_STORAGE_CLASS
2366 EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp));
2368 #undef TCL_STORAGE_CLASS
2369 #define TCL_STORAGE_CLASS DLLIMPORT
2371 #endif /* RC_INVOKED */