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