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