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