Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/generic/tcl.h @ 64

Last change on this file since 64 was 25, checked in by landauf, 16 years ago

added tcl to libs

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