00001 /* 00002 * tcl.h -- 00003 * 00004 * This header file describes the externally-visible facilities 00005 * of the Tcl interpreter. 00006 * 00007 * Copyright (c) 1987-1994 The Regents of the University of California. 00008 * Copyright (c) 1993-1996 Lucent Technologies. 00009 * Copyright (c) 1994-1998 Sun Microsystems, Inc. 00010 * Copyright (c) 1998-2000 by Scriptics Corporation. 00011 * Copyright (c) 2002 by Kevin B. Kenny. All rights reserved. 00012 * 00013 * See the file "license.terms" for information on usage and redistribution 00014 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 00015 * 00016 * RCS: @(#) $Id: tcl.h,v 1.153 2003/02/15 02:16:29 hobbs Exp $ 00017 */ 00018 00019 #ifndef _TCL 00020 #define _TCL 00021 00022 /* 00023 * For C++ compilers, use extern "C" 00024 */ 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00030 /* 00031 * The following defines are used to indicate the various release levels. 00032 */ 00033 00034 #define TCL_ALPHA_RELEASE 0 00035 #define TCL_BETA_RELEASE 1 00036 #define TCL_FINAL_RELEASE 2 00037 00038 /* 00039 * When version numbers change here, must also go into the following files 00040 * and update the version numbers: 00041 * 00042 * library/init.tcl (only if Major.minor changes, not patchlevel) 1 LOC 00043 * unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch) 00044 * win/configure.in (as above) 00045 * win/tcl.m4 (not patchlevel) 00046 * win/makefile.vc (not patchlevel) 2 LOC 00047 * README (sections 0 and 2) 00048 * mac/README (2 LOC, not patchlevel) 00049 * macosx/Tcl.pbproj/project.pbxproj 00050 * (7 LOC total, 2 LOC patch) 00051 * win/README.binary (sections 0-4) 00052 * win/README (not patchlevel) (sections 0 and 2) 00053 * unix/tcl.spec (2 LOC Major/Minor, 1 LOC patch) 00054 * tests/basic.test (1 LOC M/M, not patchlevel) 00055 * tools/tcl.hpj.in (not patchlevel, for windows installer) 00056 * tools/tcl.wse.in (for windows installer) 00057 * tools/tclSplash.bmp (not patchlevel) 00058 */ 00059 #define TCL_MAJOR_VERSION 8 00060 #define TCL_MINOR_VERSION 4 00061 #define TCL_RELEASE_LEVEL TCL_FINAL_RELEASE 00062 #define TCL_RELEASE_SERIAL 2 00063 00064 #define TCL_PREFIX_IDENT "" 00065 #define TCL_DEBUG_IDENT TCL_DBGX 00066 00067 #define TCL_VERSION "8.4" 00068 #define TCL_PATCH_LEVEL "8.4.2" 00069 00070 /* 00071 * The following definitions set up the proper options for Windows 00072 * compilers. We use this method because there is no autoconf equivalent. 00073 */ 00074 00075 #ifndef __WIN32__ 00076 # if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) || defined(__BORLANDC__) 00077 # define __WIN32__ 00078 # ifndef WIN32 00079 # define WIN32 00080 # endif 00081 # endif 00082 #endif 00083 00084 /* 00085 * STRICT: See MSDN Article Q83456 00086 */ 00087 #ifdef __WIN32__ 00088 # ifndef STRICT 00089 # define STRICT 00090 # endif 00091 #endif /* __WIN32__ */ 00092 00093 /* 00094 * The following definitions set up the proper options for Macintosh 00095 * compilers. We use this method because there is no autoconf equivalent. 00096 */ 00097 00098 #ifdef MAC_TCL 00099 #include <ConditionalMacros.h> 00100 # ifndef USE_TCLALLOC 00101 # define USE_TCLALLOC 1 00102 # endif 00103 # ifndef NO_STRERROR 00104 # define NO_STRERROR 1 00105 # endif 00106 # define INLINE 00107 #endif 00108 00109 00110 /* 00111 * Utility macros: STRINGIFY takes an argument and wraps it in "" (double 00112 * quotation marks), JOIN joins two arguments. 00113 */ 00114 #ifndef STRINGIFY 00115 # define STRINGIFY(x) STRINGIFY1(x) 00116 # define STRINGIFY1(x) #x 00117 #endif 00118 #ifndef JOIN 00119 # define JOIN(a,b) JOIN1(a,b) 00120 # define JOIN1(a,b) a##b 00121 #endif 00122 00123 /* 00124 * A special definition used to allow this header file to be included 00125 * from windows or mac resource files so that they can obtain version 00126 * information. RC_INVOKED is defined by default by the windows RC tool 00127 * and manually set for macintosh. 00128 * 00129 * Resource compilers don't like all the C stuff, like typedefs and 00130 * procedure declarations, that occur below, so block them out. 00131 */ 00132 00133 #ifndef RC_INVOKED 00134 00135 /* 00136 * Special macro to define mutexes, that doesn't do anything 00137 * if we are not using threads. 00138 */ 00139 00140 #ifdef TCL_THREADS 00141 #define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name; 00142 #else 00143 #define TCL_DECLARE_MUTEX(name) 00144 #endif 00145 00146 /* 00147 * Macros that eliminate the overhead of the thread synchronization 00148 * functions when compiling without thread support. 00149 */ 00150 00151 #ifndef TCL_THREADS 00152 #define Tcl_MutexLock(mutexPtr) 00153 #define Tcl_MutexUnlock(mutexPtr) 00154 #define Tcl_MutexFinalize(mutexPtr) 00155 #define Tcl_ConditionNotify(condPtr) 00156 #define Tcl_ConditionWait(condPtr, mutexPtr, timePtr) 00157 #define Tcl_ConditionFinalize(condPtr) 00158 #endif /* TCL_THREADS */ 00159 00160 00161 #ifndef BUFSIZ 00162 # include <stdio.h> 00163 #endif 00164 00165 00166 /* 00167 * Definitions that allow Tcl functions with variable numbers of 00168 * arguments to be used with either varargs.h or stdarg.h. TCL_VARARGS 00169 * is used in procedure prototypes. TCL_VARARGS_DEF is used to declare 00170 * the arguments in a function definiton: it takes the type and name of 00171 * the first argument and supplies the appropriate argument declaration 00172 * string for use in the function definition. TCL_VARARGS_START 00173 * initializes the va_list data structure and returns the first argument. 00174 */ 00175 #if !defined(NO_STDARG) 00176 # include <stdarg.h> 00177 # define TCL_VARARGS(type, name) (type name, ...) 00178 # define TCL_VARARGS_DEF(type, name) (type name, ...) 00179 # define TCL_VARARGS_START(type, name, list) (va_start(list, name), name) 00180 #else 00181 # include <varargs.h> 00182 # define TCL_VARARGS(type, name) () 00183 # define TCL_VARARGS_DEF(type, name) (va_alist) 00184 # define TCL_VARARGS_START(type, name, list) \ 00185 (va_start(list), va_arg(list, type)) 00186 #endif 00187 00188 /* 00189 * Macros used to declare a function to be exported by a DLL. 00190 * Used by Windows, maps to no-op declarations on non-Windows systems. 00191 * The default build on windows is for a DLL, which causes the DLLIMPORT 00192 * and DLLEXPORT macros to be nonempty. To build a static library, the 00193 * macro STATIC_BUILD should be defined. 00194 */ 00195 00196 #ifdef STATIC_BUILD 00197 # define DLLIMPORT 00198 # define DLLEXPORT 00199 #else 00200 # if (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || (defined(__GNUC__) && defined(__declspec)))) || (defined(MAC_TCL) && FUNCTION_DECLSPEC) 00201 # define DLLIMPORT __declspec(dllimport) 00202 # define DLLEXPORT __declspec(dllexport) 00203 # else 00204 # define DLLIMPORT 00205 # define DLLEXPORT 00206 # endif 00207 #endif 00208 00209 /* 00210 * These macros are used to control whether functions are being declared for 00211 * import or export. If a function is being declared while it is being built 00212 * to be included in a shared library, then it should have the DLLEXPORT 00213 * storage class. If is being declared for use by a module that is going to 00214 * link against the shared library, then it should have the DLLIMPORT storage 00215 * class. If the symbol is beind declared for a static build or for use from a 00216 * stub library, then the storage class should be empty. 00217 * 00218 * The convention is that a macro called BUILD_xxxx, where xxxx is the 00219 * name of a library we are building, is set on the compile line for sources 00220 * that are to be placed in the library. When this macro is set, the 00221 * storage class will be set to DLLEXPORT. At the end of the header file, the 00222 * storage class will be reset to DLLIMPORT. 00223 */ 00224 #undef TCL_STORAGE_CLASS 00225 #ifdef BUILD_tcl 00226 # define TCL_STORAGE_CLASS DLLEXPORT 00227 #else 00228 # ifdef USE_TCL_STUBS 00229 # define TCL_STORAGE_CLASS 00230 # else 00231 # define TCL_STORAGE_CLASS DLLIMPORT 00232 # endif 00233 #endif 00234 00235 00236 /* 00237 * Definitions that allow this header file to be used either with or 00238 * without ANSI C features like function prototypes. 00239 */ 00240 #undef _ANSI_ARGS_ 00241 #undef CONST 00242 #ifndef INLINE 00243 # define INLINE 00244 #endif 00245 00246 #ifndef NO_CONST 00247 # define CONST const 00248 #else 00249 # define CONST 00250 #endif 00251 00252 #ifndef NO_PROTOTYPES 00253 # define _ANSI_ARGS_(x) x 00254 #else 00255 # define _ANSI_ARGS_(x) () 00256 #endif 00257 00258 #ifdef USE_NON_CONST 00259 # ifdef USE_COMPAT_CONST 00260 # error define at most one of USE_NON_CONST and USE_COMPAT_CONST 00261 # endif 00262 # define CONST84 00263 # define CONST84_RETURN 00264 #else 00265 # ifdef USE_COMPAT_CONST 00266 # define CONST84 00267 # define CONST84_RETURN CONST 00268 # else 00269 # define CONST84 CONST 00270 # define CONST84_RETURN CONST 00271 # endif 00272 #endif 00273 00274 00275 /* 00276 * Make sure EXTERN isn't defined elsewhere 00277 */ 00278 #ifdef EXTERN 00279 # undef EXTERN 00280 #endif /* EXTERN */ 00281 00282 #ifdef __cplusplus 00283 # define EXTERN extern "C" TCL_STORAGE_CLASS 00284 #else 00285 # define EXTERN extern TCL_STORAGE_CLASS 00286 #endif 00287 00288 00289 /* 00290 * The following code is copied from winnt.h. 00291 * If we don't replicate it here, then <windows.h> can't be included 00292 * after tcl.h, since tcl.h also defines VOID. 00293 * This block is skipped under Cygwin and Mingw. 00294 * 00295 * 00296 */ 00297 #if defined(__WIN32__) && !defined(HAVE_WINNT_IGNORE_VOID) 00298 #ifndef VOID 00299 #define VOID void 00300 typedef char CHAR; 00301 typedef short SHORT; 00302 typedef long LONG; 00303 #endif 00304 #endif /* __WIN32__ && !HAVE_WINNT_IGNORE_VOID */ 00305 00306 /* 00307 * Macro to use instead of "void" for arguments that must have 00308 * type "void *" in ANSI C; maps them to type "char *" in 00309 * non-ANSI systems. 00310 */ 00311 00312 #ifndef NO_VOID 00313 # define VOID void 00314 #else 00315 # define VOID char 00316 #endif 00317 00318 /* 00319 * Miscellaneous declarations. 00320 */ 00321 #ifndef NULL 00322 # define NULL 0 00323 #endif 00324 00325 #ifndef _CLIENTDATA 00326 # ifndef NO_VOID 00327 typedef void *ClientData; 00328 # else 00329 typedef int *ClientData; 00330 # endif 00331 # define _CLIENTDATA 00332 #endif 00333 00334 /* 00335 * Define Tcl_WideInt to be a type that is (at least) 64-bits wide, 00336 * and define Tcl_WideUInt to be the unsigned variant of that type 00337 * (assuming that where we have one, we can have the other.) 00338 * 00339 * Also defines the following macros: 00340 * TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on 00341 * a real 64-bit system.) 00342 * Tcl_WideAsLong - forgetful converter from wideInt to long. 00343 * Tcl_LongAsWide - sign-extending converter from long to wideInt. 00344 * Tcl_WideAsDouble - converter from wideInt to double. 00345 * Tcl_DoubleAsWide - converter from double to wideInt. 00346 * 00347 * The following invariant should hold for any long value 'longVal': 00348 * longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal)) 00349 * 00350 * Note on converting between Tcl_WideInt and strings. This 00351 * implementation (in tclObj.c) depends on the functions strtoull() 00352 * and sprintf(...,"%" TCL_LL_MODIFIER "d",...). TCL_LL_MODIFIER_SIZE 00353 * is the length of the modifier string, which is "ll" on most 32-bit 00354 * Unix systems. It has to be split up like this to allow for the more 00355 * complex formats sometimes needed (e.g. in the format(n) command.) 00356 */ 00357 00358 #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG) 00359 # if defined(__CYGWIN__) 00360 # define TCL_WIDE_INT_TYPE long long 00361 # define TCL_LL_MODIFIER "L" 00362 typedef struct stat Tcl_StatBuf; 00363 # define TCL_LL_MODIFIER_SIZE 1 00364 # elif defined(__WIN32__) 00365 # define TCL_WIDE_INT_TYPE __int64 00366 # ifdef __BORLANDC__ 00367 typedef struct stati64 Tcl_StatBuf; 00368 # define TCL_LL_MODIFIER "L" 00369 # define TCL_LL_MODIFIER_SIZE 1 00370 # else /* __BORLANDC__ */ 00371 typedef struct _stati64 Tcl_StatBuf; 00372 # define TCL_LL_MODIFIER "I64" 00373 # define TCL_LL_MODIFIER_SIZE 3 00374 # endif /* __BORLANDC__ */ 00375 # else /* __WIN32__ */ 00376 /* 00377 * Don't know what platform it is and configure hasn't discovered what 00378 * is going on for us. Try to guess... 00379 */ 00380 # ifdef NO_LIMITS_H 00381 # error please define either TCL_WIDE_INT_TYPE or TCL_WIDE_INT_IS_LONG 00382 # else /* !NO_LIMITS_H */ 00383 # include <limits.h> 00384 # if (INT_MAX < LONG_MAX) 00385 # define TCL_WIDE_INT_IS_LONG 1 00386 # else 00387 # define TCL_WIDE_INT_TYPE long long 00388 # endif 00389 # endif /* NO_LIMITS_H */ 00390 # endif /* __WIN32__ */ 00391 #endif /* !TCL_WIDE_INT_TYPE & !TCL_WIDE_INT_IS_LONG */ 00392 #ifdef TCL_WIDE_INT_IS_LONG 00393 # undef TCL_WIDE_INT_TYPE 00394 # define TCL_WIDE_INT_TYPE long 00395 #endif /* TCL_WIDE_INT_IS_LONG */ 00396 00397 typedef TCL_WIDE_INT_TYPE Tcl_WideInt; 00398 typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; 00399 00400 #ifdef TCL_WIDE_INT_IS_LONG 00401 typedef struct stat Tcl_StatBuf; 00402 # define Tcl_WideAsLong(val) ((long)(val)) 00403 # define Tcl_LongAsWide(val) ((long)(val)) 00404 # define Tcl_WideAsDouble(val) ((double)((long)(val))) 00405 # define Tcl_DoubleAsWide(val) ((long)((double)(val))) 00406 # ifndef TCL_LL_MODIFIER 00407 # define TCL_LL_MODIFIER "l" 00408 # define TCL_LL_MODIFIER_SIZE 1 00409 # endif /* !TCL_LL_MODIFIER */ 00410 #else /* TCL_WIDE_INT_IS_LONG */ 00411 /* 00412 * The next short section of defines are only done when not running on 00413 * Windows or some other strange platform. 00414 */ 00415 # ifndef TCL_LL_MODIFIER 00416 # ifdef HAVE_STRUCT_STAT64 00417 typedef struct stat64 Tcl_StatBuf; 00418 # else 00419 typedef struct stat Tcl_StatBuf; 00420 # endif /* HAVE_STRUCT_STAT64 */ 00421 # define TCL_LL_MODIFIER "ll" 00422 # define TCL_LL_MODIFIER_SIZE 2 00423 # endif /* !TCL_LL_MODIFIER */ 00424 # define Tcl_WideAsLong(val) ((long)((Tcl_WideInt)(val))) 00425 # define Tcl_LongAsWide(val) ((Tcl_WideInt)((long)(val))) 00426 # define Tcl_WideAsDouble(val) ((double)((Tcl_WideInt)(val))) 00427 # define Tcl_DoubleAsWide(val) ((Tcl_WideInt)((double)(val))) 00428 #endif /* TCL_WIDE_INT_IS_LONG */ 00429 00430 00431 /* 00432 * This flag controls whether binary compatability is maintained with 00433 * extensions built against a previous version of Tcl. This is true 00434 * by default. 00435 */ 00436 #ifndef TCL_PRESERVE_BINARY_COMPATABILITY 00437 # define TCL_PRESERVE_BINARY_COMPATABILITY 1 00438 #endif 00439 00440 00441 /* 00442 * Data structures defined opaquely in this module. The definitions below 00443 * just provide dummy types. A few fields are made visible in Tcl_Interp 00444 * structures, namely those used for returning a string result from 00445 * commands. Direct access to the result field is discouraged in Tcl 8.0. 00446 * The interpreter result is either an object or a string, and the two 00447 * values are kept consistent unless some C code sets interp->result 00448 * directly. Programmers should use either the procedure Tcl_GetObjResult() 00449 * or Tcl_GetStringResult() to read the interpreter's result. See the 00450 * SetResult man page for details. 00451 * 00452 * Note: any change to the Tcl_Interp definition below must be mirrored 00453 * in the "real" definition in tclInt.h. 00454 * 00455 * Note: Tcl_ObjCmdProc procedures do not directly set result and freeProc. 00456 * Instead, they set a Tcl_Obj member in the "real" structure that can be 00457 * accessed with Tcl_GetObjResult() and Tcl_SetObjResult(). 00458 */ 00459 00460 typedef struct Tcl_Interp { 00461 char *result; /* If the last command returned a string 00462 * result, this points to it. */ 00463 void (*freeProc) _ANSI_ARGS_((char *blockPtr)); 00464 /* Zero means the string result is 00465 * statically allocated. TCL_DYNAMIC means 00466 * it was allocated with ckalloc and should 00467 * be freed with ckfree. Other values give 00468 * the address of procedure to invoke to 00469 * free the result. Tcl_Eval must free it 00470 * before executing next command. */ 00471 int errorLine; /* When TCL_ERROR is returned, this gives 00472 * the line number within the command where 00473 * the error occurred (1 if first line). */ 00474 } Tcl_Interp; 00475 00476 typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler; 00477 typedef struct Tcl_Channel_ *Tcl_Channel; 00478 typedef struct Tcl_Command_ *Tcl_Command; 00479 typedef struct Tcl_Condition_ *Tcl_Condition; 00480 typedef struct Tcl_EncodingState_ *Tcl_EncodingState; 00481 typedef struct Tcl_Encoding_ *Tcl_Encoding; 00482 typedef struct Tcl_Event Tcl_Event; 00483 typedef struct Tcl_Mutex_ *Tcl_Mutex; 00484 typedef struct Tcl_Pid_ *Tcl_Pid; 00485 typedef struct Tcl_RegExp_ *Tcl_RegExp; 00486 typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey; 00487 typedef struct Tcl_ThreadId_ *Tcl_ThreadId; 00488 typedef struct Tcl_TimerToken_ *Tcl_TimerToken; 00489 typedef struct Tcl_Trace_ *Tcl_Trace; 00490 typedef struct Tcl_Var_ *Tcl_Var; 00491 typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion; 00492 typedef struct Tcl_LoadHandle_ *Tcl_LoadHandle; 00493 00494 /* 00495 * Definition of the interface to procedures implementing threads. 00496 * A procedure following this definition is given to each call of 00497 * 'Tcl_CreateThread' and will be called as the main fuction of 00498 * the new thread created by that call. 00499 */ 00500 #ifdef MAC_TCL 00501 typedef pascal void *(Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); 00502 #elif defined __WIN32__ 00503 typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); 00504 #else 00505 typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); 00506 #endif 00507 00508 00509 /* 00510 * Threading function return types used for abstracting away platform 00511 * differences when writing a Tcl_ThreadCreateProc. See the NewThread 00512 * function in generic/tclThreadTest.c for it's usage. 00513 */ 00514 #ifdef MAC_TCL 00515 # define Tcl_ThreadCreateType pascal void * 00516 # define TCL_THREAD_CREATE_RETURN return NULL 00517 #elif defined __WIN32__ 00518 # define Tcl_ThreadCreateType unsigned __stdcall 00519 # define TCL_THREAD_CREATE_RETURN return 0 00520 #else 00521 # define Tcl_ThreadCreateType void 00522 # define TCL_THREAD_CREATE_RETURN 00523 #endif 00524 00525 00526 /* 00527 * Definition of values for default stacksize and the possible flags to be 00528 * given to Tcl_CreateThread. 00529 */ 00530 #define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack */ 00531 #define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default behaviour */ 00532 #define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable */ 00533 00534 /* 00535 * Flag values passed to Tcl_GetRegExpFromObj. 00536 */ 00537 #define TCL_REG_BASIC 000000 /* BREs (convenience) */ 00538 #define TCL_REG_EXTENDED 000001 /* EREs */ 00539 #define TCL_REG_ADVF 000002 /* advanced features in EREs */ 00540 #define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs) */ 00541 #define TCL_REG_QUOTE 000004 /* no special characters, none */ 00542 #define TCL_REG_NOCASE 000010 /* ignore case */ 00543 #define TCL_REG_NOSUB 000020 /* don't care about subexpressions */ 00544 #define TCL_REG_EXPANDED 000040 /* expanded format, white space & 00545 * comments */ 00546 #define TCL_REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */ 00547 #define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before */ 00548 #define TCL_REG_NEWLINE 000300 /* newlines are line terminators */ 00549 #define TCL_REG_CANMATCH 001000 /* report details on partial/limited 00550 * matches */ 00551 00552 /* 00553 * The following flag is experimental and only intended for use by Expect. It 00554 * will probably go away in a later release. 00555 */ 00556 #define TCL_REG_BOSONLY 002000 /* prepend \A to pattern so it only 00557 * matches at the beginning of the 00558 * string. */ 00559 00560 /* 00561 * Flags values passed to Tcl_RegExpExecObj. 00562 */ 00563 #define TCL_REG_NOTBOL 0001 /* Beginning of string does not match ^. */ 00564 #define TCL_REG_NOTEOL 0002 /* End of string does not match $. */ 00565 00566 /* 00567 * Structures filled in by Tcl_RegExpInfo. Note that all offset values are 00568 * relative to the start of the match string, not the beginning of the 00569 * entire string. 00570 */ 00571 typedef struct Tcl_RegExpIndices { 00572 long start; /* character offset of first character in match */ 00573 long end; /* character offset of first character after the 00574 * match. */ 00575 } Tcl_RegExpIndices; 00576 00577 typedef struct Tcl_RegExpInfo { 00578 int nsubs; /* number of subexpressions in the 00579 * compiled expression */ 00580 Tcl_RegExpIndices *matches; /* array of nsubs match offset 00581 * pairs */ 00582 long extendStart; /* The offset at which a subsequent 00583 * match might begin. */ 00584 long reserved; /* Reserved for later use. */ 00585 } Tcl_RegExpInfo; 00586 00587 /* 00588 * Picky compilers complain if this typdef doesn't appear before the 00589 * struct's reference in tclDecls.h. 00590 */ 00591 typedef Tcl_StatBuf *Tcl_Stat_; 00592 typedef struct stat *Tcl_OldStat_; 00593 00594 /* 00595 * When a TCL command returns, the interpreter contains a result from the 00596 * command. Programmers are strongly encouraged to use one of the 00597 * procedures Tcl_GetObjResult() or Tcl_GetStringResult() to read the 00598 * interpreter's result. See the SetResult man page for details. Besides 00599 * this result, the command procedure returns an integer code, which is 00600 * one of the following: 00601 * 00602 * TCL_OK Command completed normally; the interpreter's 00603 * result contains the command's result. 00604 * TCL_ERROR The command couldn't be completed successfully; 00605 * the interpreter's result describes what went wrong. 00606 * TCL_RETURN The command requests that the current procedure 00607 * return; the interpreter's result contains the 00608 * procedure's return value. 00609 * TCL_BREAK The command requests that the innermost loop 00610 * be exited; the interpreter's result is meaningless. 00611 * TCL_CONTINUE Go on to the next iteration of the current loop; 00612 * the interpreter's result is meaningless. 00613 */ 00614 #define TCL_OK 0 00615 #define TCL_ERROR 1 00616 #define TCL_RETURN 2 00617 #define TCL_BREAK 3 00618 #define TCL_CONTINUE 4 00619 00620 #define TCL_RESULT_SIZE 200 00621 00622 /* 00623 * Flags to control what substitutions are performed by Tcl_SubstObj(): 00624 */ 00625 #define TCL_SUBST_COMMANDS 001 00626 #define TCL_SUBST_VARIABLES 002 00627 #define TCL_SUBST_BACKSLASHES 004 00628 #define TCL_SUBST_ALL 007 00629 00630 00631 /* 00632 * Argument descriptors for math function callbacks in expressions: 00633 */ 00634 typedef enum { 00635 TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT 00636 #ifdef TCL_WIDE_INT_IS_LONG 00637 = TCL_INT 00638 #endif 00639 } Tcl_ValueType; 00640 typedef struct Tcl_Value { 00641 Tcl_ValueType type; /* Indicates intValue or doubleValue is 00642 * valid, or both. */ 00643 long intValue; /* Integer value. */ 00644 double doubleValue; /* Double-precision floating value. */ 00645 #ifndef TCL_WIDE_INT_IS_LONG 00646 Tcl_WideInt wideValue; /* Wide (min. 64-bit) integer value. */ 00647 #endif 00648 } Tcl_Value; 00649 00650 /* 00651 * Forward declaration of Tcl_Obj to prevent an error when the forward 00652 * reference to Tcl_Obj is encountered in the procedure types declared 00653 * below. 00654 */ 00655 struct Tcl_Obj; 00656 00657 00658 /* 00659 * Procedure types defined by Tcl: 00660 */ 00661 00662 typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); 00663 typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData, 00664 Tcl_Interp *interp, int code)); 00665 typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask)); 00666 typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data)); 00667 typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData)); 00668 typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData, 00669 Tcl_Interp *interp, int argc, CONST84 char *argv[])); 00670 typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData, 00671 Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc, 00672 ClientData cmdClientData, int argc, CONST84 char *argv[])); 00673 typedef int (Tcl_CmdObjTraceProc) _ANSI_ARGS_((ClientData clientData, 00674 Tcl_Interp *interp, int level, CONST char *command, 00675 Tcl_Command commandInfo, int objc, struct Tcl_Obj * CONST * objv)); 00676 typedef void (Tcl_CmdObjTraceDeleteProc) _ANSI_ARGS_((ClientData clientData)); 00677 typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, 00678 struct Tcl_Obj *dupPtr)); 00679 typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData, 00680 CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, 00681 char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, 00682 int *dstCharsPtr)); 00683 typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData)); 00684 typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); 00685 typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData, 00686 int flags)); 00687 typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr, 00688 ClientData clientData)); 00689 typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData, 00690 int flags)); 00691 typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData)); 00692 typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask)); 00693 typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData)); 00694 typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); 00695 typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr)); 00696 typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData)); 00697 typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, 00698 Tcl_Interp *interp)); 00699 typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData, 00700 Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr)); 00701 typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData)); 00702 typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData, 00703 Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv)); 00704 typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); 00705 typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(CONST char *, format)); 00706 typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData, 00707 Tcl_Channel chan, char *address, int port)); 00708 typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData)); 00709 typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp, 00710 struct Tcl_Obj *objPtr)); 00711 typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); 00712 typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData, 00713 Tcl_Interp *interp, CONST84 char *part1, CONST84 char *part2, int flags)); 00714 typedef void (Tcl_CommandTraceProc) _ANSI_ARGS_((ClientData clientData, 00715 Tcl_Interp *interp, CONST char *oldName, CONST char *newName, 00716 int flags)); 00717 typedef void (Tcl_CreateFileHandlerProc) _ANSI_ARGS_((int fd, int mask, 00718 Tcl_FileProc *proc, ClientData clientData)); 00719 typedef void (Tcl_DeleteFileHandlerProc) _ANSI_ARGS_((int fd)); 00720 typedef void (Tcl_AlertNotifierProc) _ANSI_ARGS_((ClientData clientData)); 00721 typedef void (Tcl_ServiceModeHookProc) _ANSI_ARGS_((int mode)); 00722 typedef ClientData (Tcl_InitNotifierProc) _ANSI_ARGS_((VOID)); 00723 typedef void (Tcl_FinalizeNotifierProc) _ANSI_ARGS_((ClientData clientData)); 00724 typedef void (Tcl_MainLoopProc) _ANSI_ARGS_((void)); 00725 00726 00727 /* 00728 * The following structure represents a type of object, which is a 00729 * particular internal representation for an object plus a set of 00730 * procedures that provide standard operations on objects of that type. 00731 */ 00732 00733 typedef struct Tcl_ObjType { 00734 char *name; /* Name of the type, e.g. "int". */ 00735 Tcl_FreeInternalRepProc *freeIntRepProc; 00736 /* Called to free any storage for the type's 00737 * internal rep. NULL if the internal rep 00738 * does not need freeing. */ 00739 Tcl_DupInternalRepProc *dupIntRepProc; 00740 /* Called to create a new object as a copy 00741 * of an existing object. */ 00742 Tcl_UpdateStringProc *updateStringProc; 00743 /* Called to update the string rep from the 00744 * type's internal representation. */ 00745 Tcl_SetFromAnyProc *setFromAnyProc; 00746 /* Called to convert the object's internal 00747 * rep to this type. Frees the internal rep 00748 * of the old type. Returns TCL_ERROR on 00749 * failure. */ 00750 } Tcl_ObjType; 00751 00752 00753 /* 00754 * One of the following structures exists for each object in the Tcl 00755 * system. An object stores a value as either a string, some internal 00756 * representation, or both. 00757 */ 00758 00759 typedef struct Tcl_Obj { 00760 int refCount; /* When 0 the object will be freed. */ 00761 char *bytes; /* This points to the first byte of the 00762 * object's string representation. The array 00763 * must be followed by a null byte (i.e., at 00764 * offset length) but may also contain 00765 * embedded null characters. The array's 00766 * storage is allocated by ckalloc. NULL 00767 * means the string rep is invalid and must 00768 * be regenerated from the internal rep. 00769 * Clients should use Tcl_GetStringFromObj 00770 * or Tcl_GetString to get a pointer to the 00771 * byte array as a readonly value. */ 00772 int length; /* The number of bytes at *bytes, not 00773 * including the terminating null. */ 00774 Tcl_ObjType *typePtr; /* Denotes the object's type. Always 00775 * corresponds to the type of the object's 00776 * internal rep. NULL indicates the object 00777 * has no internal rep (has no type). */ 00778 union { /* The internal representation: */ 00779 long longValue; /* - an long integer value */ 00780 double doubleValue; /* - a double-precision floating value */ 00781 VOID *otherValuePtr; /* - another, type-specific value */ 00782 Tcl_WideInt wideValue; /* - a long long value */ 00783 struct { /* - internal rep as two pointers */ 00784 VOID *ptr1; 00785 VOID *ptr2; 00786 } twoPtrValue; 00787 } internalRep; 00788 } Tcl_Obj; 00789 00790 00791 /* 00792 * Macros to increment and decrement a Tcl_Obj's reference count, and to 00793 * test whether an object is shared (i.e. has reference count > 1). 00794 * Note: clients should use Tcl_DecrRefCount() when they are finished using 00795 * an object, and should never call TclFreeObj() directly. TclFreeObj() is 00796 * only defined and made public in tcl.h to support Tcl_DecrRefCount's macro 00797 * definition. Note also that Tcl_DecrRefCount() refers to the parameter 00798 * "obj" twice. This means that you should avoid calling it with an 00799 * expression that is expensive to compute or has side effects. 00800 */ 00801 void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); 00802 void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); 00803 int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr)); 00804 00805 #ifdef TCL_MEM_DEBUG 00806 # define Tcl_IncrRefCount(objPtr) \ 00807 Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__) 00808 # define Tcl_DecrRefCount(objPtr) \ 00809 Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__) 00810 # define Tcl_IsShared(objPtr) \ 00811 Tcl_DbIsShared(objPtr, __FILE__, __LINE__) 00812 #else 00813 # define Tcl_IncrRefCount(objPtr) \ 00814 ++(objPtr)->refCount 00815 # define Tcl_DecrRefCount(objPtr) \ 00816 if (--(objPtr)->refCount <= 0) TclFreeObj(objPtr) 00817 # define Tcl_IsShared(objPtr) \ 00818 ((objPtr)->refCount > 1) 00819 #endif 00820 00821 /* 00822 * Macros and definitions that help to debug the use of Tcl objects. 00823 * When TCL_MEM_DEBUG is defined, the Tcl_New declarations are 00824 * overridden to call debugging versions of the object creation procedures. 00825 */ 00826 00827 #ifdef TCL_MEM_DEBUG 00828 # define Tcl_NewBooleanObj(val) \ 00829 Tcl_DbNewBooleanObj(val, __FILE__, __LINE__) 00830 # define Tcl_NewByteArrayObj(bytes, len) \ 00831 Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__) 00832 # define Tcl_NewDoubleObj(val) \ 00833 Tcl_DbNewDoubleObj(val, __FILE__, __LINE__) 00834 # define Tcl_NewIntObj(val) \ 00835 Tcl_DbNewLongObj(val, __FILE__, __LINE__) 00836 # define Tcl_NewListObj(objc, objv) \ 00837 Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__) 00838 # define Tcl_NewLongObj(val) \ 00839 Tcl_DbNewLongObj(val, __FILE__, __LINE__) 00840 # define Tcl_NewObj() \ 00841 Tcl_DbNewObj(__FILE__, __LINE__) 00842 # define Tcl_NewStringObj(bytes, len) \ 00843 Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__) 00844 # define Tcl_NewWideIntObj(val) \ 00845 Tcl_DbNewWideIntObj(val, __FILE__, __LINE__) 00846 #endif /* TCL_MEM_DEBUG */ 00847 00848 00849 /* 00850 * The following structure contains the state needed by 00851 * Tcl_SaveResult. No-one outside of Tcl should access any of these 00852 * fields. This structure is typically allocated on the stack. 00853 */ 00854 typedef struct Tcl_SavedResult { 00855 char *result; 00856 Tcl_FreeProc *freeProc; 00857 Tcl_Obj *objResultPtr; 00858 char *appendResult; 00859 int appendAvl; 00860 int appendUsed; 00861 char resultSpace[TCL_RESULT_SIZE+1]; 00862 } Tcl_SavedResult; 00863 00864 00865 /* 00866 * The following definitions support Tcl's namespace facility. 00867 * Note: the first five fields must match exactly the fields in a 00868 * Namespace structure (see tclInt.h). 00869 */ 00870 00871 typedef struct Tcl_Namespace { 00872 char *name; /* The namespace's name within its parent 00873 * namespace. This contains no ::'s. The 00874 * name of the global namespace is "" 00875 * although "::" is an synonym. */ 00876 char *fullName; /* The namespace's fully qualified name. 00877 * This starts with ::. */ 00878 ClientData clientData; /* Arbitrary value associated with this 00879 * namespace. */ 00880 Tcl_NamespaceDeleteProc* deleteProc; 00881 /* Procedure invoked when deleting the 00882 * namespace to, e.g., free clientData. */ 00883 struct Tcl_Namespace* parentPtr; 00884 /* Points to the namespace that contains 00885 * this one. NULL if this is the global 00886 * namespace. */ 00887 } Tcl_Namespace; 00888 00889 00890 /* 00891 * The following structure represents a call frame, or activation record. 00892 * A call frame defines a naming context for a procedure call: its local 00893 * scope (for local variables) and its namespace scope (used for non-local 00894 * variables; often the global :: namespace). A call frame can also define 00895 * the naming context for a namespace eval or namespace inscope command: 00896 * the namespace in which the command's code should execute. The 00897 * Tcl_CallFrame structures exist only while procedures or namespace 00898 * eval/inscope's are being executed, and provide a Tcl call stack. 00899 * 00900 * A call frame is initialized and pushed using Tcl_PushCallFrame and 00901 * popped using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be 00902 * provided by the Tcl_PushCallFrame caller, and callers typically allocate 00903 * them on the C call stack for efficiency. For this reason, Tcl_CallFrame 00904 * is defined as a structure and not as an opaque token. However, most 00905 * Tcl_CallFrame fields are hidden since applications should not access 00906 * them directly; others are declared as "dummyX". 00907 * 00908 * WARNING!! The structure definition must be kept consistent with the 00909 * CallFrame structure in tclInt.h. If you change one, change the other. 00910 */ 00911 00912 typedef struct Tcl_CallFrame { 00913 Tcl_Namespace *nsPtr; 00914 int dummy1; 00915 int dummy2; 00916 char *dummy3; 00917 char *dummy4; 00918 char *dummy5; 00919 int dummy6; 00920 char *dummy7; 00921 char *dummy8; 00922 int dummy9; 00923 char* dummy10; 00924 } Tcl_CallFrame; 00925 00926 00927 /* 00928 * Information about commands that is returned by Tcl_GetCommandInfo and 00929 * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based 00930 * command procedure while proc is a traditional Tcl argc/argv 00931 * string-based procedure. Tcl_CreateObjCommand and Tcl_CreateCommand 00932 * ensure that both objProc and proc are non-NULL and can be called to 00933 * execute the command. However, it may be faster to call one instead of 00934 * the other. The member isNativeObjectProc is set to 1 if an 00935 * object-based procedure was registered by Tcl_CreateObjCommand, and to 00936 * 0 if a string-based procedure was registered by Tcl_CreateCommand. 00937 * The other procedure is typically set to a compatibility wrapper that 00938 * does string-to-object or object-to-string argument conversions then 00939 * calls the other procedure. 00940 */ 00941 00942 typedef struct Tcl_CmdInfo { 00943 int isNativeObjectProc; /* 1 if objProc was registered by a call to 00944 * Tcl_CreateObjCommand; 0 otherwise. 00945 * Tcl_SetCmdInfo does not modify this 00946 * field. */ 00947 Tcl_ObjCmdProc *objProc; /* Command's object-based procedure. */ 00948 ClientData objClientData; /* ClientData for object proc. */ 00949 Tcl_CmdProc *proc; /* Command's string-based procedure. */ 00950 ClientData clientData; /* ClientData for string proc. */ 00951 Tcl_CmdDeleteProc *deleteProc; 00952 /* Procedure to call when command is 00953 * deleted. */ 00954 ClientData deleteData; /* Value to pass to deleteProc (usually 00955 * the same as clientData). */ 00956 Tcl_Namespace *namespacePtr; /* Points to the namespace that contains 00957 * this command. Note that Tcl_SetCmdInfo 00958 * will not change a command's namespace; 00959 * use Tcl_RenameCommand to do that. */ 00960 00961 } Tcl_CmdInfo; 00962 00963 /* 00964 * The structure defined below is used to hold dynamic strings. The only 00965 * field that clients should use is the string field, accessible via the 00966 * macro Tcl_DStringValue. 00967 */ 00968 #define TCL_DSTRING_STATIC_SIZE 200 00969 typedef struct Tcl_DString { 00970 char *string; /* Points to beginning of string: either 00971 * staticSpace below or a malloced array. */ 00972 int length; /* Number of non-NULL characters in the 00973 * string. */ 00974 int spaceAvl; /* Total number of bytes available for the 00975 * string and its terminating NULL char. */ 00976 char staticSpace[TCL_DSTRING_STATIC_SIZE]; 00977 /* Space to use in common case where string 00978 * is small. */ 00979 } Tcl_DString; 00980 00981 #define Tcl_DStringLength(dsPtr) ((dsPtr)->length) 00982 #define Tcl_DStringValue(dsPtr) ((dsPtr)->string) 00983 #define Tcl_DStringTrunc Tcl_DStringSetLength 00984 00985 /* 00986 * Definitions for the maximum number of digits of precision that may 00987 * be specified in the "tcl_precision" variable, and the number of 00988 * bytes of buffer space required by Tcl_PrintDouble. 00989 */ 00990 #define TCL_MAX_PREC 17 00991 #define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10) 00992 00993 /* 00994 * Definition for a number of bytes of buffer space sufficient to hold the 00995 * string representation of an integer in base 10 (assuming the existence 00996 * of 64-bit integers). 00997 */ 00998 #define TCL_INTEGER_SPACE 24 00999 01000 /* 01001 * Flag that may be passed to Tcl_ConvertElement to force it not to 01002 * output braces (careful! if you change this flag be sure to change 01003 * the definitions at the front of tclUtil.c). 01004 */ 01005 #define TCL_DONT_USE_BRACES 1 01006 01007 /* 01008 * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow 01009 * abbreviated strings. 01010 */ 01011 #define TCL_EXACT 1 01012 01013 /* 01014 * Flag values passed to Tcl_RecordAndEval and/or Tcl_EvalObj. 01015 * WARNING: these bit choices must not conflict with the bit choices 01016 * for evalFlag bits in tclInt.h!! 01017 */ 01018 #define TCL_NO_EVAL 0x10000 01019 #define TCL_EVAL_GLOBAL 0x20000 01020 #define TCL_EVAL_DIRECT 0x40000 01021 #define TCL_EVAL_INVOKE 0x80000 01022 01023 /* 01024 * Special freeProc values that may be passed to Tcl_SetResult (see 01025 * the man page for details): 01026 */ 01027 #define TCL_VOLATILE ((Tcl_FreeProc *) 1) 01028 #define TCL_STATIC ((Tcl_FreeProc *) 0) 01029 #define TCL_DYNAMIC ((Tcl_FreeProc *) 3) 01030 01031 /* 01032 * Flag values passed to variable-related procedures. 01033 */ 01034 #define TCL_GLOBAL_ONLY 1 01035 #define TCL_NAMESPACE_ONLY 2 01036 #define TCL_APPEND_VALUE 4 01037 #define TCL_LIST_ELEMENT 8 01038 #define TCL_TRACE_READS 0x10 01039 #define TCL_TRACE_WRITES 0x20 01040 #define TCL_TRACE_UNSETS 0x40 01041 #define TCL_TRACE_DESTROYED 0x80 01042 #define TCL_INTERP_DESTROYED 0x100 01043 #define TCL_LEAVE_ERR_MSG 0x200 01044 #define TCL_TRACE_ARRAY 0x800 01045 #ifndef TCL_REMOVE_OBSOLETE_TRACES 01046 /* Required to support old variable/vdelete/vinfo traces */ 01047 #define TCL_TRACE_OLD_STYLE 0x1000 01048 #endif 01049 /* Indicate the semantics of the result of a trace */ 01050 #define TCL_TRACE_RESULT_DYNAMIC 0x8000 01051 #define TCL_TRACE_RESULT_OBJECT 0x10000 01052 01053 /* 01054 * Flag values passed to command-related procedures. 01055 */ 01056 01057 #define TCL_TRACE_RENAME 0x2000 01058 #define TCL_TRACE_DELETE 0x4000 01059 01060 #define TCL_ALLOW_INLINE_COMPILATION 0x20000 01061 01062 /* 01063 * Flag values passed to Tcl_CreateObjTrace, and used internally 01064 * by command execution traces. Slots 4,8,16 and 32 are 01065 * used internally by execution traces (see tclCmdMZ.c) 01066 */ 01067 #define TCL_TRACE_ENTER_EXEC 1 01068 #define TCL_TRACE_LEAVE_EXEC 2 01069 01070 /* 01071 * The TCL_PARSE_PART1 flag is deprecated and has no effect. 01072 * The part1 is now always parsed whenever the part2 is NULL. 01073 * (This is to avoid a common error when converting code to 01074 * use the new object based APIs and forgetting to give the 01075 * flag) 01076 */ 01077 #ifndef TCL_NO_DEPRECATED 01078 # define TCL_PARSE_PART1 0x400 01079 #endif 01080 01081 01082 /* 01083 * Types for linked variables: 01084 */ 01085 #define TCL_LINK_INT 1 01086 #define TCL_LINK_DOUBLE 2 01087 #define TCL_LINK_BOOLEAN 3 01088 #define TCL_LINK_STRING 4 01089 #define TCL_LINK_WIDE_INT 5 01090 #define TCL_LINK_READ_ONLY 0x80 01091 01092 01093 /* 01094 * Forward declarations of Tcl_HashTable and related types. 01095 */ 01096 typedef struct Tcl_HashKeyType Tcl_HashKeyType; 01097 typedef struct Tcl_HashTable Tcl_HashTable; 01098 typedef struct Tcl_HashEntry Tcl_HashEntry; 01099 01100 typedef unsigned int (Tcl_HashKeyProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, 01101 VOID *keyPtr)); 01102 typedef int (Tcl_CompareHashKeysProc) _ANSI_ARGS_((VOID *keyPtr, 01103 Tcl_HashEntry *hPtr)); 01104 typedef Tcl_HashEntry *(Tcl_AllocHashEntryProc) _ANSI_ARGS_(( 01105 Tcl_HashTable *tablePtr, VOID *keyPtr)); 01106 typedef void (Tcl_FreeHashEntryProc) _ANSI_ARGS_((Tcl_HashEntry *hPtr)); 01107 01108 /* 01109 * This flag controls whether the hash table stores the hash of a key, or 01110 * recalculates it. There should be no reason for turning this flag off 01111 * as it is completely binary and source compatible unless you directly 01112 * access the bucketPtr member of the Tcl_HashTableEntry structure. This 01113 * member has been removed and the space used to store the hash value. 01114 */ 01115 #ifndef TCL_HASH_KEY_STORE_HASH 01116 # define TCL_HASH_KEY_STORE_HASH 1 01117 #endif 01118 01119 /* 01120 * Structure definition for an entry in a hash table. No-one outside 01121 * Tcl should access any of these fields directly; use the macros 01122 * defined below. 01123 */ 01124 01125 struct Tcl_HashEntry { 01126 Tcl_HashEntry *nextPtr; /* Pointer to next entry in this 01127 * hash bucket, or NULL for end of 01128 * chain. */ 01129 Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ 01130 #if TCL_HASH_KEY_STORE_HASH 01131 # if TCL_PRESERVE_BINARY_COMPATABILITY 01132 VOID *hash; /* Hash value, stored as pointer to 01133 * ensure that the offsets of the 01134 * fields in this structure are not 01135 * changed. */ 01136 # else 01137 unsigned int hash; /* Hash value. */ 01138 # endif 01139 #else 01140 Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to 01141 * first entry in this entry's chain: 01142 * used for deleting the entry. */ 01143 #endif 01144 ClientData clientData; /* Application stores something here 01145 * with Tcl_SetHashValue. */ 01146 union { /* Key has one of these forms: */ 01147 char *oneWordValue; /* One-word value for key. */ 01148 Tcl_Obj *objPtr; /* Tcl_Obj * key value. */ 01149 int words[1]; /* Multiple integer words for key. 01150 * The actual size will be as large 01151 * as necessary for this table's 01152 * keys. */ 01153 char string[4]; /* String for key. The actual size 01154 * will be as large as needed to hold 01155 * the key. */ 01156 } key; /* MUST BE LAST FIELD IN RECORD!! */ 01157 }; 01158 01159 /* 01160 * Flags used in Tcl_HashKeyType. 01161 * 01162 * TCL_HASH_KEY_RANDOMIZE_HASH: 01163 * There are some things, pointers for example 01164 * which don't hash well because they do not use 01165 * the lower bits. If this flag is set then the 01166 * hash table will attempt to rectify this by 01167 * randomising the bits and then using the upper 01168 * N bits as the index into the table. 01169 */ 01170 #define TCL_HASH_KEY_RANDOMIZE_HASH 0x1 01171 01172 /* 01173 * Structure definition for the methods associated with a hash table 01174 * key type. 01175 */ 01176 #define TCL_HASH_KEY_TYPE_VERSION 1 01177 struct Tcl_HashKeyType { 01178 int version; /* Version of the table. If this structure is 01179 * extended in future then the version can be 01180 * used to distinguish between different 01181 * structures. 01182 */ 01183 01184 int flags; /* Flags, see above for details. */ 01185 01186 /* Calculates a hash value for the key. If this is NULL then the pointer 01187 * itself is used as a hash value. 01188 */ 01189 Tcl_HashKeyProc *hashKeyProc; 01190 01191 /* Compares two keys and returns zero if they do not match, and non-zero 01192 * if they do. If this is NULL then the pointers are compared. 01193 */ 01194 Tcl_CompareHashKeysProc *compareKeysProc; 01195 01196 /* Called to allocate memory for a new entry, i.e. if the key is a 01197 * string then this could allocate a single block which contains enough 01198 * space for both the entry and the string. Only the key field of the 01199 * allocated Tcl_HashEntry structure needs to be filled in. If something 01200 * else needs to be done to the key, i.e. incrementing a reference count 01201 * then that should be done by this function. If this is NULL then Tcl_Alloc 01202 * is used to allocate enough space for a Tcl_HashEntry and the key pointer 01203 * is assigned to key.oneWordValue. 01204 */ 01205 Tcl_AllocHashEntryProc *allocEntryProc; 01206 01207 /* Called to free memory associated with an entry. If something else needs 01208 * to be done to the key, i.e. decrementing a reference count then that 01209 * should be done by this function. If this is NULL then Tcl_Free is used 01210 * to free the Tcl_HashEntry. 01211 */ 01212 Tcl_FreeHashEntryProc *freeEntryProc; 01213 }; 01214 01215 /* 01216 * Structure definition for a hash table. Must be in tcl.h so clients 01217 * can allocate space for these structures, but clients should never 01218 * access any fields in this structure. 01219 */ 01220 01221 #define TCL_SMALL_HASH_TABLE 4 01222 struct Tcl_HashTable { 01223 Tcl_HashEntry **buckets; /* Pointer to bucket array. Each 01224 * element points to first entry in 01225 * bucket's hash chain, or NULL. */ 01226 Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; 01227 /* Bucket array used for small tables 01228 * (to avoid mallocs and frees). */ 01229 int numBuckets; /* Total number of buckets allocated 01230 * at **bucketPtr. */ 01231 int numEntries; /* Total number of entries present 01232 * in table. */ 01233 int rebuildSize; /* Enlarge table when numEntries gets 01234 * to be this large. */ 01235 int downShift; /* Shift count used in hashing 01236 * function. Designed to use high- 01237 * order bits of randomized keys. */ 01238 int mask; /* Mask value used in hashing 01239 * function. */ 01240 int keyType; /* Type of keys used in this table. 01241 * It's either TCL_CUSTOM_KEYS, 01242 * TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, 01243 * or an integer giving the number of 01244 * ints that is the size of the key. 01245 */ 01246 #if TCL_PRESERVE_BINARY_COMPATABILITY 01247 Tcl_HashEntry *(*findProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, 01248 CONST char *key)); 01249 Tcl_HashEntry *(*createProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, 01250 CONST char *key, int *newPtr)); 01251 #endif 01252 Tcl_HashKeyType *typePtr; /* Type of the keys used in the 01253 * Tcl_HashTable. */ 01254 }; 01255 01256 /* 01257 * Structure definition for information used to keep track of searches 01258 * through hash tables: 01259 */ 01260 01261 typedef struct Tcl_HashSearch { 01262 Tcl_HashTable *tablePtr; /* Table being searched. */ 01263 int nextIndex; /* Index of next bucket to be 01264 * enumerated after present one. */ 01265 Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the 01266 * the current bucket. */ 01267 } Tcl_HashSearch; 01268 01269 /* 01270 * Acceptable key types for hash tables: 01271 * 01272 * TCL_STRING_KEYS: The keys are strings, they are copied into 01273 * the entry. 01274 * TCL_ONE_WORD_KEYS: The keys are pointers, the pointer is stored 01275 * in the entry. 01276 * TCL_CUSTOM_TYPE_KEYS: The keys are arbitrary types which are copied 01277 * into the entry. 01278 * TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the 01279 * pointer is stored in the entry. 01280 * 01281 * While maintaining binary compatability the above have to be distinct 01282 * values as they are used to differentiate between old versions of the 01283 * hash table which don't have a typePtr and new ones which do. Once binary 01284 * compatability is discarded in favour of making more wide spread changes 01285 * TCL_STRING_KEYS can be the same as TCL_CUSTOM_TYPE_KEYS, and 01286 * TCL_ONE_WORD_KEYS can be the same as TCL_CUSTOM_PTR_KEYS because they 01287 * simply determine how the key is accessed from the entry and not the 01288 * behaviour. 01289 */ 01290 01291 #define TCL_STRING_KEYS 0 01292 #define TCL_ONE_WORD_KEYS 1 01293 01294 #if TCL_PRESERVE_BINARY_COMPATABILITY 01295 # define TCL_CUSTOM_TYPE_KEYS -2 01296 # define TCL_CUSTOM_PTR_KEYS -1 01297 #else 01298 # define TCL_CUSTOM_TYPE_KEYS TCL_STRING_KEYS 01299 # define TCL_CUSTOM_PTR_KEYS TCL_ONE_WORD_KEYS 01300 #endif 01301 01302 /* 01303 * Macros for clients to use to access fields of hash entries: 01304 */ 01305 01306 #define Tcl_GetHashValue(h) ((h)->clientData) 01307 #define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value)) 01308 #if TCL_PRESERVE_BINARY_COMPATABILITY 01309 # define Tcl_GetHashKey(tablePtr, h) \ 01310 ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \ 01311 (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \ 01312 ? (h)->key.oneWordValue \ 01313 : (h)->key.string)) 01314 #else 01315 # define Tcl_GetHashKey(tablePtr, h) \ 01316 ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) \ 01317 ? (h)->key.oneWordValue \ 01318 : (h)->key.string)) 01319 #endif 01320 01321 /* 01322 * Macros to use for clients to use to invoke find and create procedures 01323 * for hash tables: 01324 */ 01325 01326 #if TCL_PRESERVE_BINARY_COMPATABILITY 01327 # define Tcl_FindHashEntry(tablePtr, key) \ 01328 (*((tablePtr)->findProc))(tablePtr, key) 01329 # define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ 01330 (*((tablePtr)->createProc))(tablePtr, key, newPtr) 01331 #else /* !TCL_PRESERVE_BINARY_COMPATABILITY */ 01332 /* 01333 * Macro to use new extended version of Tcl_InitHashTable. 01334 */ 01335 # define Tcl_InitHashTable(tablePtr, keyType) \ 01336 Tcl_InitHashTableEx(tablePtr, keyType, NULL) 01337 #endif /* TCL_PRESERVE_BINARY_COMPATABILITY */ 01338 01339 01340 /* 01341 * Flag values to pass to Tcl_DoOneEvent to disable searches 01342 * for some kinds of events: 01343 */ 01344 #define TCL_DONT_WAIT (1<<1) 01345 #define TCL_WINDOW_EVENTS (1<<2) 01346 #define TCL_FILE_EVENTS (1<<3) 01347 #define TCL_TIMER_EVENTS (1<<4) 01348 #define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */ 01349 #define TCL_ALL_EVENTS (~TCL_DONT_WAIT) 01350 01351 /* 01352 * The following structure defines a generic event for the Tcl event 01353 * system. These are the things that are queued in calls to Tcl_QueueEvent 01354 * and serviced later by Tcl_DoOneEvent. There can be many different 01355 * kinds of events with different fields, corresponding to window events, 01356 * timer events, etc. The structure for a particular event consists of 01357 * a Tcl_Event header followed by additional information specific to that 01358 * event. 01359 */ 01360 struct Tcl_Event { 01361 Tcl_EventProc *proc; /* Procedure to call to service this event. */ 01362 struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */ 01363 }; 01364 01365 /* 01366 * Positions to pass to Tcl_QueueEvent: 01367 */ 01368 typedef enum { 01369 TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK 01370 } Tcl_QueuePosition; 01371 01372 /* 01373 * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier 01374 * event routines. 01375 */ 01376 #define TCL_SERVICE_NONE 0 01377 #define TCL_SERVICE_ALL 1 01378 01379 01380 /* 01381 * The following structure keeps is used to hold a time value, either as 01382 * an absolute time (the number of seconds from the epoch) or as an 01383 * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT. 01384 * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT. 01385 */ 01386 typedef struct Tcl_Time { 01387 long sec; /* Seconds. */ 01388 long usec; /* Microseconds. */ 01389 } Tcl_Time; 01390 01391 typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr)); 01392 typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr)); 01393 01394 01395 /* 01396 * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler 01397 * to indicate what sorts of events are of interest: 01398 */ 01399 #define TCL_READABLE (1<<1) 01400 #define TCL_WRITABLE (1<<2) 01401 #define TCL_EXCEPTION (1<<3) 01402 01403 /* 01404 * Flag values to pass to Tcl_OpenCommandChannel to indicate the 01405 * disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, 01406 * are also used in Tcl_GetStdChannel. 01407 */ 01408 #define TCL_STDIN (1<<1) 01409 #define TCL_STDOUT (1<<2) 01410 #define TCL_STDERR (1<<3) 01411 #define TCL_ENFORCE_MODE (1<<4) 01412 01413 /* 01414 * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel 01415 * should be closed. 01416 */ 01417 #define TCL_CLOSE_READ (1<<1) 01418 #define TCL_CLOSE_WRITE (1<<2) 01419 01420 /* 01421 * Value to use as the closeProc for a channel that supports the 01422 * close2Proc interface. 01423 */ 01424 #define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1) 01425 01426 /* 01427 * Channel version tag. This was introduced in 8.3.2/8.4. 01428 */ 01429 #define TCL_CHANNEL_VERSION_1 ((Tcl_ChannelTypeVersion) 0x1) 01430 #define TCL_CHANNEL_VERSION_2 ((Tcl_ChannelTypeVersion) 0x2) 01431 #define TCL_CHANNEL_VERSION_3 ((Tcl_ChannelTypeVersion) 0x3) 01432 01433 /* 01434 * Typedefs for the various operations in a channel type: 01435 */ 01436 typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_(( 01437 ClientData instanceData, int mode)); 01438 typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData, 01439 Tcl_Interp *interp)); 01440 typedef int (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData, 01441 Tcl_Interp *interp, int flags)); 01442 typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData, 01443 char *buf, int toRead, int *errorCodePtr)); 01444 typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData, 01445 CONST84 char *buf, int toWrite, int *errorCodePtr)); 01446 typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData, 01447 long offset, int mode, int *errorCodePtr)); 01448 typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_(( 01449 ClientData instanceData, Tcl_Interp *interp, 01450 CONST char *optionName, CONST char *value)); 01451 typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_(( 01452 ClientData instanceData, Tcl_Interp *interp, 01453 CONST84 char *optionName, Tcl_DString *dsPtr)); 01454 typedef void (Tcl_DriverWatchProc) _ANSI_ARGS_(( 01455 ClientData instanceData, int mask)); 01456 typedef int (Tcl_DriverGetHandleProc) _ANSI_ARGS_(( 01457 ClientData instanceData, int direction, 01458 ClientData *handlePtr)); 01459 typedef int (Tcl_DriverFlushProc) _ANSI_ARGS_(( 01460 ClientData instanceData)); 01461 typedef int (Tcl_DriverHandlerProc) _ANSI_ARGS_(( 01462 ClientData instanceData, int interestMask)); 01463 typedef Tcl_WideInt (Tcl_DriverWideSeekProc) _ANSI_ARGS_(( 01464 ClientData instanceData, Tcl_WideInt offset, 01465 int mode, int *errorCodePtr)); 01466 01467 01468 /* 01469 * The following declarations either map ckalloc and ckfree to 01470 * malloc and free, or they map them to procedures with all sorts 01471 * of debugging hooks defined in tclCkalloc.c. 01472 */ 01473 #ifdef TCL_MEM_DEBUG 01474 01475 # define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__) 01476 # define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__) 01477 # define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__) 01478 # define attemptckalloc(x) Tcl_AttemptDbCkalloc(x, __FILE__, __LINE__) 01479 # define attemptckrealloc(x,y) Tcl_AttemptDbCkrealloc((x), (y), __FILE__, __LINE__) 01480 #else /* !TCL_MEM_DEBUG */ 01481 01482 /* 01483 * If we are not using the debugging allocator, we should call the 01484 * Tcl_Alloc, et al. routines in order to guarantee that every module 01485 * is using the same memory allocator both inside and outside of the 01486 * Tcl library. 01487 */ 01488 # define ckalloc(x) Tcl_Alloc(x) 01489 # define ckfree(x) Tcl_Free(x) 01490 # define ckrealloc(x,y) Tcl_Realloc(x,y) 01491 # define attemptckalloc(x) Tcl_AttemptAlloc(x) 01492 # define attemptckrealloc(x,y) Tcl_AttemptRealloc(x,y) 01493 # define Tcl_InitMemory(x) 01494 # define Tcl_DumpActiveMemory(x) 01495 # define Tcl_ValidateAllMemory(x,y) 01496 01497 #endif /* !TCL_MEM_DEBUG */ 01498 01499 /* 01500 * struct Tcl_ChannelType: 01501 * 01502 * One such structure exists for each type (kind) of channel. 01503 * It collects together in one place all the functions that are 01504 * part of the specific channel type. 01505 * 01506 * It is recommend that the Tcl_Channel* functions are used to access 01507 * elements of this structure, instead of direct accessing. 01508 */ 01509 typedef struct Tcl_ChannelType { 01510 char *typeName; /* The name of the channel type in Tcl 01511 * commands. This storage is owned by 01512 * channel type. */ 01513 Tcl_ChannelTypeVersion version; /* Version of the channel type. */ 01514 Tcl_DriverCloseProc *closeProc; /* Procedure to call to close the 01515 * channel, or TCL_CLOSE2PROC if the 01516 * close2Proc should be used 01517 * instead. */ 01518 Tcl_DriverInputProc *inputProc; /* Procedure to call for input 01519 * on channel. */ 01520 Tcl_DriverOutputProc *outputProc; /* Procedure to call for output 01521 * on channel. */ 01522 Tcl_DriverSeekProc *seekProc; /* Procedure to call to seek 01523 * on the channel. May be NULL. */ 01524 Tcl_DriverSetOptionProc *setOptionProc; 01525 /* Set an option on a channel. */ 01526 Tcl_DriverGetOptionProc *getOptionProc; 01527 /* Get an option from a channel. */ 01528 Tcl_DriverWatchProc *watchProc; /* Set up the notifier to watch 01529 * for events on this channel. */ 01530 Tcl_DriverGetHandleProc *getHandleProc; 01531 /* Get an OS handle from the channel 01532 * or NULL if not supported. */ 01533 Tcl_DriverClose2Proc *close2Proc; /* Procedure to call to close the 01534 * channel if the device supports 01535 * closing the read & write sides 01536 * independently. */ 01537 Tcl_DriverBlockModeProc *blockModeProc; 01538 /* Set blocking mode for the 01539 * raw channel. May be NULL. */ 01540 /* 01541 * Only valid in TCL_CHANNEL_VERSION_2 channels or later 01542 */ 01543 Tcl_DriverFlushProc *flushProc; /* Procedure to call to flush a 01544 * channel. May be NULL. */ 01545 Tcl_DriverHandlerProc *handlerProc; /* Procedure to call to handle a 01546 * channel event. This will be passed 01547 * up the stacked channel chain. */ 01548 /* 01549 * Only valid in TCL_CHANNEL_VERSION_3 channels or later 01550 */ 01551 Tcl_DriverWideSeekProc *wideSeekProc; 01552 /* Procedure to call to seek 01553 * on the channel which can 01554 * handle 64-bit offsets. May be 01555 * NULL, and must be NULL if 01556 * seekProc is NULL. */ 01557 } Tcl_ChannelType; 01558 01559 /* 01560 * The following flags determine whether the blockModeProc above should 01561 * set the channel into blocking or nonblocking mode. They are passed 01562 * as arguments to the blockModeProc procedure in the above structure. 01563 */ 01564 #define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */ 01565 #define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking 01566 * mode. */ 01567 01568 /* 01569 * Enum for different types of file paths. 01570 */ 01571 typedef enum Tcl_PathType { 01572 TCL_PATH_ABSOLUTE, 01573 TCL_PATH_RELATIVE, 01574 TCL_PATH_VOLUME_RELATIVE 01575 } Tcl_PathType; 01576 01577 01578 /* 01579 * The following structure is used to pass glob type data amongst 01580 * the various glob routines and Tcl_FSMatchInDirectory. 01581 */ 01582 typedef struct Tcl_GlobTypeData { 01583 /* Corresponds to bcdpfls as in 'find -t' */ 01584 int type; 01585 /* Corresponds to file permissions */ 01586 int perm; 01587 /* Acceptable mac type */ 01588 Tcl_Obj* macType; 01589 /* Acceptable mac creator */ 01590 Tcl_Obj* macCreator; 01591 } Tcl_GlobTypeData; 01592 01593 /* 01594 * type and permission definitions for glob command 01595 */ 01596 #define TCL_GLOB_TYPE_BLOCK (1<<0) 01597 #define TCL_GLOB_TYPE_CHAR (1<<1) 01598 #define TCL_GLOB_TYPE_DIR (1<<2) 01599 #define TCL_GLOB_TYPE_PIPE (1<<3) 01600 #define TCL_GLOB_TYPE_FILE (1<<4) 01601 #define TCL_GLOB_TYPE_LINK (1<<5) 01602 #define TCL_GLOB_TYPE_SOCK (1<<6) 01603 01604 #define TCL_GLOB_PERM_RONLY (1<<0) 01605 #define TCL_GLOB_PERM_HIDDEN (1<<1) 01606 #define TCL_GLOB_PERM_R (1<<2) 01607 #define TCL_GLOB_PERM_W (1<<3) 01608 #define TCL_GLOB_PERM_X (1<<4) 01609 01610 01611 /* 01612 * Typedefs for the various filesystem operations: 01613 */ 01614 typedef int (Tcl_FSStatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf)); 01615 typedef int (Tcl_FSAccessProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, int mode)); 01616 typedef Tcl_Channel (Tcl_FSOpenFileChannelProc) 01617 _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *pathPtr, 01618 int mode, int permissions)); 01619 typedef int (Tcl_FSMatchInDirectoryProc) _ANSI_ARGS_((Tcl_Interp* interp, 01620 Tcl_Obj *result, Tcl_Obj *pathPtr, CONST char *pattern, 01621 Tcl_GlobTypeData * types)); 01622 typedef Tcl_Obj* (Tcl_FSGetCwdProc) _ANSI_ARGS_((Tcl_Interp *interp)); 01623 typedef int (Tcl_FSChdirProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); 01624 typedef int (Tcl_FSLstatProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 01625 Tcl_StatBuf *buf)); 01626 typedef int (Tcl_FSCreateDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); 01627 typedef int (Tcl_FSDeleteFileProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); 01628 typedef int (Tcl_FSCopyDirectoryProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 01629 Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr)); 01630 typedef int (Tcl_FSCopyFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 01631 Tcl_Obj *destPathPtr)); 01632 typedef int (Tcl_FSRemoveDirectoryProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 01633 int recursive, Tcl_Obj **errorPtr)); 01634 typedef int (Tcl_FSRenameFileProc) _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 01635 Tcl_Obj *destPathPtr)); 01636 typedef void (Tcl_FSUnloadFileProc) _ANSI_ARGS_((Tcl_LoadHandle loadHandle)); 01637 typedef Tcl_Obj* (Tcl_FSListVolumesProc) _ANSI_ARGS_((void)); 01638 /* We have to declare the utime structure here. */ 01639 struct utimbuf; 01640 typedef int (Tcl_FSUtimeProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 01641 struct utimbuf *tval)); 01642 typedef int (Tcl_FSNormalizePathProc) _ANSI_ARGS_((Tcl_Interp *interp, 01643 Tcl_Obj *pathPtr, int nextCheckpoint)); 01644 typedef int (Tcl_FSFileAttrsGetProc) _ANSI_ARGS_((Tcl_Interp *interp, 01645 int index, Tcl_Obj *pathPtr, 01646 Tcl_Obj **objPtrRef)); 01647 typedef CONST char** (Tcl_FSFileAttrStringsProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 01648 Tcl_Obj** objPtrRef)); 01649 typedef int (Tcl_FSFileAttrsSetProc) _ANSI_ARGS_((Tcl_Interp *interp, 01650 int index, Tcl_Obj *pathPtr, 01651 Tcl_Obj *objPtr)); 01652 typedef Tcl_Obj* (Tcl_FSLinkProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 01653 Tcl_Obj *toPtr, int linkType)); 01654 typedef int (Tcl_FSLoadFileProc) _ANSI_ARGS_((Tcl_Interp * interp, 01655 Tcl_Obj *pathPtr, 01656 Tcl_LoadHandle *handlePtr, 01657 Tcl_FSUnloadFileProc **unloadProcPtr)); 01658 typedef int (Tcl_FSPathInFilesystemProc) _ANSI_ARGS_((Tcl_Obj *pathPtr, 01659 ClientData *clientDataPtr)); 01660 typedef Tcl_Obj* (Tcl_FSFilesystemPathTypeProc) 01661 _ANSI_ARGS_((Tcl_Obj *pathPtr)); 01662 typedef Tcl_Obj* (Tcl_FSFilesystemSeparatorProc) 01663 _ANSI_ARGS_((Tcl_Obj *pathPtr)); 01664 typedef void (Tcl_FSFreeInternalRepProc) _ANSI_ARGS_((ClientData clientData)); 01665 typedef ClientData (Tcl_FSDupInternalRepProc) 01666 _ANSI_ARGS_((ClientData clientData)); 01667 typedef Tcl_Obj* (Tcl_FSInternalToNormalizedProc) 01668 _ANSI_ARGS_((ClientData clientData)); 01669 typedef ClientData (Tcl_FSCreateInternalRepProc) _ANSI_ARGS_((Tcl_Obj *pathPtr)); 01670 01671 typedef struct Tcl_FSVersion_ *Tcl_FSVersion; 01672 01673 /* 01674 *---------------------------------------------------------------- 01675 * Data structures related to hooking into the filesystem 01676 *---------------------------------------------------------------- 01677 */ 01678 01679 /* 01680 * Filesystem version tag. This was introduced in 8.4. 01681 */ 01682 #define TCL_FILESYSTEM_VERSION_1 ((Tcl_FSVersion) 0x1) 01683 01684 /* 01685 * struct Tcl_Filesystem: 01686 * 01687 * One such structure exists for each type (kind) of filesystem. 01688 * It collects together in one place all the functions that are 01689 * part of the specific filesystem. Tcl always accesses the 01690 * filesystem through one of these structures. 01691 * 01692 * Not all entries need be non-NULL; any which are NULL are simply 01693 * ignored. However, a complete filesystem should provide all of 01694 * these functions. The explanations in the structure show 01695 * the importance of each function. 01696 */ 01697 01698 typedef struct Tcl_Filesystem { 01699 CONST char *typeName; /* The name of the filesystem. */ 01700 int structureLength; /* Length of this structure, so future 01701 * binary compatibility can be assured. */ 01702 Tcl_FSVersion version; 01703 /* Version of the filesystem type. */ 01704 Tcl_FSPathInFilesystemProc *pathInFilesystemProc; 01705 /* Function to check whether a path is in 01706 * this filesystem. This is the most 01707 * important filesystem procedure. */ 01708 Tcl_FSDupInternalRepProc *dupInternalRepProc; 01709 /* Function to duplicate internal fs rep. May 01710 * be NULL (but then fs is less efficient). */ 01711 Tcl_FSFreeInternalRepProc *freeInternalRepProc; 01712 /* Function to free internal fs rep. Must 01713 * be implemented, if internal representations 01714 * need freeing, otherwise it can be NULL. */ 01715 Tcl_FSInternalToNormalizedProc *internalToNormalizedProc; 01716 /* Function to convert internal representation 01717 * to a normalized path. Only required if 01718 * the fs creates pure path objects with no 01719 * string/path representation. */ 01720 Tcl_FSCreateInternalRepProc *createInternalRepProc; 01721 /* Function to create a filesystem-specific 01722 * internal representation. May be NULL 01723 * if paths have no internal representation, 01724 * or if the Tcl_FSPathInFilesystemProc 01725 * for this filesystem always immediately 01726 * creates an internal representation for 01727 * paths it accepts. */ 01728 Tcl_FSNormalizePathProc *normalizePathProc; 01729 /* Function to normalize a path. Should 01730 * be implemented for all filesystems 01731 * which can have multiple string 01732 * representations for the same path 01733 * object. */ 01734 Tcl_FSFilesystemPathTypeProc *filesystemPathTypeProc; 01735 /* Function to determine the type of a 01736 * path in this filesystem. May be NULL. */ 01737 Tcl_FSFilesystemSeparatorProc *filesystemSeparatorProc; 01738 /* Function to return the separator 01739 * character(s) for this filesystem. Must 01740 * be implemented. */ 01741 Tcl_FSStatProc *statProc; 01742 /* 01743 * Function to process a 'Tcl_FSStat()' 01744 * call. Must be implemented for any 01745 * reasonable filesystem. 01746 */ 01747 Tcl_FSAccessProc *accessProc; 01748 /* 01749 * Function to process a 'Tcl_FSAccess()' 01750 * call. Must be implemented for any 01751 * reasonable filesystem. 01752 */ 01753 Tcl_FSOpenFileChannelProc *openFileChannelProc; 01754 /* 01755 * Function to process a 01756 * 'Tcl_FSOpenFileChannel()' call. Must be 01757 * implemented for any reasonable 01758 * filesystem. 01759 */ 01760 Tcl_FSMatchInDirectoryProc *matchInDirectoryProc; 01761 /* Function to process a 01762 * 'Tcl_FSMatchInDirectory()'. If not 01763 * implemented, then glob and recursive 01764 * copy functionality will be lacking in 01765 * the filesystem. */ 01766 Tcl_FSUtimeProc *utimeProc; 01767 /* Function to process a 01768 * 'Tcl_FSUtime()' call. Required to 01769 * allow setting (not reading) of times 01770 * with 'file mtime', 'file atime' and 01771 * the open-r/open-w/fcopy implementation 01772 * of 'file copy'. */ 01773 Tcl_FSLinkProc *linkProc; 01774 /* Function to process a 01775 * 'Tcl_FSLink()' call. Should be 01776 * implemented only if the filesystem supports 01777 * links (reading or creating). */ 01778 Tcl_FSListVolumesProc *listVolumesProc; 01779 /* Function to list any filesystem volumes 01780 * added by this filesystem. Should be 01781 * implemented only if the filesystem adds 01782 * volumes at the head of the filesystem. */ 01783 Tcl_FSFileAttrStringsProc *fileAttrStringsProc; 01784 /* Function to list all attributes strings 01785 * which are valid for this filesystem. 01786 * If not implemented the filesystem will 01787 * not support the 'file attributes' command. 01788 * This allows arbitrary additional information 01789 * to be attached to files in the filesystem. */ 01790 Tcl_FSFileAttrsGetProc *fileAttrsGetProc; 01791 /* Function to process a 01792 * 'Tcl_FSFileAttrsGet()' call, used by 01793 * 'file attributes'. */ 01794 Tcl_FSFileAttrsSetProc *fileAttrsSetProc; 01795 /* Function to process a 01796 * 'Tcl_FSFileAttrsSet()' call, used by 01797 * 'file attributes'. */ 01798 Tcl_FSCreateDirectoryProc *createDirectoryProc; 01799 /* Function to process a 01800 * 'Tcl_FSCreateDirectory()' call. Should 01801 * be implemented unless the FS is 01802 * read-only. */ 01803 Tcl_FSRemoveDirectoryProc *removeDirectoryProc; 01804 /* Function to process a 01805 * 'Tcl_FSRemoveDirectory()' call. Should 01806 * be implemented unless the FS is 01807 * read-only. */ 01808 Tcl_FSDeleteFileProc *deleteFileProc; 01809 /* Function to process a 01810 * 'Tcl_FSDeleteFile()' call. Should 01811 * be implemented unless the FS is 01812 * read-only. */ 01813 Tcl_FSCopyFileProc *copyFileProc; 01814 /* Function to process a 01815 * 'Tcl_FSCopyFile()' call. If not 01816 * implemented Tcl will fall back 01817 * on open-r, open-w and fcopy as 01818 * a copying mechanism, for copying 01819 * actions initiated in Tcl (not C). */ 01820 Tcl_FSRenameFileProc *renameFileProc; 01821 /* Function to process a 01822 * 'Tcl_FSRenameFile()' call. If not 01823 * implemented, Tcl will fall back on 01824 * a copy and delete mechanism, for 01825 * rename actions initiated in Tcl (not C). */ 01826 Tcl_FSCopyDirectoryProc *copyDirectoryProc; 01827 /* Function to process a 01828 * 'Tcl_FSCopyDirectory()' call. If 01829 * not implemented, Tcl will fall back 01830 * on a recursive create-dir, file copy 01831 * mechanism, for copying actions 01832 * initiated in Tcl (not C). */ 01833 Tcl_FSLstatProc *lstatProc; 01834 /* Function to process a 01835 * 'Tcl_FSLstat()' call. If not implemented, 01836 * Tcl will attempt to use the 'statProc' 01837 * defined above instead. */ 01838 Tcl_FSLoadFileProc *loadFileProc; 01839 /* Function to process a 01840 * 'Tcl_FSLoadFile()' call. If not 01841 * implemented, Tcl will fall back on 01842 * a copy to native-temp followed by a 01843 * Tcl_FSLoadFile on that temporary copy. */ 01844 Tcl_FSGetCwdProc *getCwdProc; 01845 /* 01846 * Function to process a 'Tcl_FSGetCwd()' 01847 * call. Most filesystems need not 01848 * implement this. It will usually only be 01849 * called once, if 'getcwd' is called 01850 * before 'chdir'. May be NULL. 01851 */ 01852 Tcl_FSChdirProc *chdirProc; 01853 /* 01854 * Function to process a 'Tcl_FSChdir()' 01855 * call. If filesystems do not implement 01856 * this, it will be emulated by a series of 01857 * directory access checks. Otherwise, 01858 * virtual filesystems which do implement 01859 * it need only respond with a positive 01860 * return result if the dirName is a valid 01861 * directory in their filesystem. They 01862 * need not remember the result, since that 01863 * will be automatically remembered for use 01864 * by GetCwd. Real filesystems should 01865 * carry out the correct action (i.e. call 01866 * the correct system 'chdir' api). If not 01867 * implemented, then 'cd' and 'pwd' will 01868 * fail inside the filesystem. 01869 */ 01870 } Tcl_Filesystem; 01871 01872 /* 01873 * The following definitions are used as values for the 'linkAction' flag 01874 * to Tcl_FSLink, or the linkProc of any filesystem. Any combination 01875 * of flags can be given. For link creation, the linkProc should create 01876 * a link which matches any of the types given. 01877 * 01878 * TCL_CREATE_SYMBOLIC_LINK: Create a symbolic or soft link. 01879 * TCL_CREATE_HARD_LINK: Create a hard link. 01880 */ 01881 #define TCL_CREATE_SYMBOLIC_LINK 0x01 01882 #define TCL_CREATE_HARD_LINK 0x02 01883 01884 /* 01885 * The following structure represents the Notifier functions that 01886 * you can override with the Tcl_SetNotifier call. 01887 */ 01888 typedef struct Tcl_NotifierProcs { 01889 Tcl_SetTimerProc *setTimerProc; 01890 Tcl_WaitForEventProc *waitForEventProc; 01891 Tcl_CreateFileHandlerProc *createFileHandlerProc; 01892 Tcl_DeleteFileHandlerProc *deleteFileHandlerProc; 01893 Tcl_InitNotifierProc *initNotifierProc; 01894 Tcl_FinalizeNotifierProc *finalizeNotifierProc; 01895 Tcl_AlertNotifierProc *alertNotifierProc; 01896 Tcl_ServiceModeHookProc *serviceModeHookProc; 01897 } Tcl_NotifierProcs; 01898 01899 01900 /* 01901 * The following structure represents a user-defined encoding. It collects 01902 * together all the functions that are used by the specific encoding. 01903 */ 01904 typedef struct Tcl_EncodingType { 01905 CONST char *encodingName; /* The name of the encoding, e.g. "euc-jp". 01906 * This name is the unique key for this 01907 * encoding type. */ 01908 Tcl_EncodingConvertProc *toUtfProc; 01909 /* Procedure to convert from external 01910 * encoding into UTF-8. */ 01911 Tcl_EncodingConvertProc *fromUtfProc; 01912 /* Procedure to convert from UTF-8 into 01913 * external encoding. */ 01914 Tcl_EncodingFreeProc *freeProc; 01915 /* If non-NULL, procedure to call when this 01916 * encoding is deleted. */ 01917 ClientData clientData; /* Arbitrary value associated with encoding 01918 * type. Passed to conversion procedures. */ 01919 int nullSize; /* Number of zero bytes that signify 01920 * end-of-string in this encoding. This 01921 * number is used to determine the source 01922 * string length when the srcLen argument is 01923 * negative. Must be 1 or 2. */ 01924 } Tcl_EncodingType; 01925 01926 /* 01927 * The following definitions are used as values for the conversion control 01928 * flags argument when converting text from one character set to another: 01929 * 01930 * TCL_ENCODING_START: Signifies that the source buffer is the first 01931 * block in a (potentially multi-block) input 01932 * stream. Tells the conversion procedure to 01933 * reset to an initial state and perform any 01934 * initialization that needs to occur before the 01935 * first byte is converted. If the source 01936 * buffer contains the entire input stream to be 01937 * converted, this flag should be set. 01938 * 01939 * TCL_ENCODING_END: Signifies that the source buffer is the last 01940 * block in a (potentially multi-block) input 01941 * stream. Tells the conversion routine to 01942 * perform any finalization that needs to occur 01943 * after the last byte is converted and then to 01944 * reset to an initial state. If the source 01945 * buffer contains the entire input stream to be 01946 * converted, this flag should be set. 01947 * 01948 * TCL_ENCODING_STOPONERROR: If set, then the converter will return 01949 * immediately upon encountering an invalid 01950 * byte sequence or a source character that has 01951 * no mapping in the target encoding. If clear, 01952 * then the converter will skip the problem, 01953 * substituting one or more "close" characters 01954 * in the destination buffer and then continue 01955 * to sonvert the source. 01956 */ 01957 #define TCL_ENCODING_START 0x01 01958 #define TCL_ENCODING_END 0x02 01959 #define TCL_ENCODING_STOPONERROR 0x04 01960 01961 01962 /* 01963 * The following data structures and declarations are for the new Tcl 01964 * parser. 01965 */ 01966 01967 /* 01968 * For each word of a command, and for each piece of a word such as a 01969 * variable reference, one of the following structures is created to 01970 * describe the token. 01971 */ 01972 typedef struct Tcl_Token { 01973 int type; /* Type of token, such as TCL_TOKEN_WORD; 01974 * see below for valid types. */ 01975 CONST char *start; /* First character in token. */ 01976 int size; /* Number of bytes in token. */ 01977 int numComponents; /* If this token is composed of other 01978 * tokens, this field tells how many of 01979 * them there are (including components of 01980 * components, etc.). The component tokens 01981 * immediately follow this one. */ 01982 } Tcl_Token; 01983 01984 /* 01985 * Type values defined for Tcl_Token structures. These values are 01986 * defined as mask bits so that it's easy to check for collections of 01987 * types. 01988 * 01989 * TCL_TOKEN_WORD - The token describes one word of a command, 01990 * from the first non-blank character of 01991 * the word (which may be " or {) up to but 01992 * not including the space, semicolon, or 01993 * bracket that terminates the word. 01994 * NumComponents counts the total number of 01995 * sub-tokens that make up the word. This 01996 * includes, for example, sub-tokens of 01997 * TCL_TOKEN_VARIABLE tokens. 01998 * TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD 01999 * except that the word is guaranteed to 02000 * consist of a single TCL_TOKEN_TEXT 02001 * sub-token. 02002 * TCL_TOKEN_TEXT - The token describes a range of literal 02003 * text that is part of a word. 02004 * NumComponents is always 0. 02005 * TCL_TOKEN_BS - The token describes a backslash sequence 02006 * that must be collapsed. NumComponents 02007 * is always 0. 02008 * TCL_TOKEN_COMMAND - The token describes a command whose result 02009 * must be substituted into the word. The 02010 * token includes the enclosing brackets. 02011 * NumComponents is always 0. 02012 * TCL_TOKEN_VARIABLE - The token describes a variable 02013 * substitution, including the dollar sign, 02014 * variable name, and array index (if there 02015 * is one) up through the right 02016 * parentheses. NumComponents tells how 02017 * many additional tokens follow to 02018 * represent the variable name. The first 02019 * token will be a TCL_TOKEN_TEXT token 02020 * that describes the variable name. If 02021 * the variable is an array reference then 02022 * there will be one or more additional 02023 * tokens, of type TCL_TOKEN_TEXT, 02024 * TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and 02025 * TCL_TOKEN_VARIABLE, that describe the 02026 * array index; numComponents counts the 02027 * total number of nested tokens that make 02028 * up the variable reference, including 02029 * sub-tokens of TCL_TOKEN_VARIABLE tokens. 02030 * TCL_TOKEN_SUB_EXPR - The token describes one subexpression of a 02031 * expression, from the first non-blank 02032 * character of the subexpression up to but not 02033 * including the space, brace, or bracket 02034 * that terminates the subexpression. 02035 * NumComponents counts the total number of 02036 * following subtokens that make up the 02037 * subexpression; this includes all subtokens 02038 * for any nested TCL_TOKEN_SUB_EXPR tokens. 02039 * For example, a numeric value used as a 02040 * primitive operand is described by a 02041 * TCL_TOKEN_SUB_EXPR token followed by a 02042 * TCL_TOKEN_TEXT token. A binary subexpression 02043 * is described by a TCL_TOKEN_SUB_EXPR token 02044 * followed by the TCL_TOKEN_OPERATOR token 02045 * for the operator, then TCL_TOKEN_SUB_EXPR 02046 * tokens for the left then the right operands. 02047 * TCL_TOKEN_OPERATOR - The token describes one expression operator. 02048 * An operator might be the name of a math 02049 * function such as "abs". A TCL_TOKEN_OPERATOR 02050 * token is always preceeded by one 02051 * TCL_TOKEN_SUB_EXPR token for the operator's 02052 * subexpression, and is followed by zero or 02053 * more TCL_TOKEN_SUB_EXPR tokens for the 02054 * operator's operands. NumComponents is 02055 * always 0. 02056 */ 02057 #define TCL_TOKEN_WORD 1 02058 #define TCL_TOKEN_SIMPLE_WORD 2 02059 #define TCL_TOKEN_TEXT 4 02060 #define TCL_TOKEN_BS 8 02061 #define TCL_TOKEN_COMMAND 16 02062 #define TCL_TOKEN_VARIABLE 32 02063 #define TCL_TOKEN_SUB_EXPR 64 02064 #define TCL_TOKEN_OPERATOR 128 02065 02066 /* 02067 * Parsing error types. On any parsing error, one of these values 02068 * will be stored in the error field of the Tcl_Parse structure 02069 * defined below. 02070 */ 02071 #define TCL_PARSE_SUCCESS 0 02072 #define TCL_PARSE_QUOTE_EXTRA 1 02073 #define TCL_PARSE_BRACE_EXTRA 2 02074 #define TCL_PARSE_MISSING_BRACE 3 02075 #define TCL_PARSE_MISSING_BRACKET 4 02076 #define TCL_PARSE_MISSING_PAREN 5 02077 #define TCL_PARSE_MISSING_QUOTE 6 02078 #define TCL_PARSE_MISSING_VAR_BRACE 7 02079 #define TCL_PARSE_SYNTAX 8 02080 #define TCL_PARSE_BAD_NUMBER 9 02081 02082 /* 02083 * A structure of the following type is filled in by Tcl_ParseCommand. 02084 * It describes a single command parsed from an input string. 02085 */ 02086 #define NUM_STATIC_TOKENS 20 02087 02088 typedef struct Tcl_Parse { 02089 CONST char *commentStart; /* Pointer to # that begins the first of 02090 * one or more comments preceding the 02091 * command. */ 02092 int commentSize; /* Number of bytes in comments (up through 02093 * newline character that terminates the 02094 * last comment). If there were no 02095 * comments, this field is 0. */ 02096 CONST char *commandStart; /* First character in first word of command. */ 02097 int commandSize; /* Number of bytes in command, including 02098 * first character of first word, up 02099 * through the terminating newline, 02100 * close bracket, or semicolon. */ 02101 int numWords; /* Total number of words in command. May 02102 * be 0. */ 02103 Tcl_Token *tokenPtr; /* Pointer to first token representing 02104 * the words of the command. Initially 02105 * points to staticTokens, but may change 02106 * to point to malloc-ed space if command 02107 * exceeds space in staticTokens. */ 02108 int numTokens; /* Total number of tokens in command. */ 02109 int tokensAvailable; /* Total number of tokens available at 02110 * *tokenPtr. */ 02111 int errorType; /* One of the parsing error types defined 02112 * above. */ 02113 02114 /* 02115 * The fields below are intended only for the private use of the 02116 * parser. They should not be used by procedures that invoke 02117 * Tcl_ParseCommand. 02118 */ 02119 02120 CONST char *string; /* The original command string passed to 02121 * Tcl_ParseCommand. */ 02122 CONST char *end; /* Points to the character just after the 02123 * last one in the command string. */ 02124 Tcl_Interp *interp; /* Interpreter to use for error reporting, 02125 * or NULL. */ 02126 CONST char *term; /* Points to character in string that 02127 * terminated most recent token. Filled in 02128 * by ParseTokens. If an error occurs, 02129 * points to beginning of region where the 02130 * error occurred (e.g. the open brace if 02131 * the close brace is missing). */ 02132 int incomplete; /* This field is set to 1 by Tcl_ParseCommand 02133 * if the command appears to be incomplete. 02134 * This information is used by 02135 * Tcl_CommandComplete. */ 02136 Tcl_Token staticTokens[NUM_STATIC_TOKENS]; 02137 /* Initial space for tokens for command. 02138 * This space should be large enough to 02139 * accommodate most commands; dynamic 02140 * space is allocated for very large 02141 * commands that don't fit here. */ 02142 } Tcl_Parse; 02143 02144 /* 02145 * The following definitions are the error codes returned by the conversion 02146 * routines: 02147 * 02148 * TCL_OK: All characters were converted. 02149 * 02150 * TCL_CONVERT_NOSPACE: The output buffer would not have been large 02151 * enough for all of the converted data; as many 02152 * characters as could fit were converted though. 02153 * 02154 * TCL_CONVERT_MULTIBYTE: The last few bytes in the source string were 02155 * the beginning of a multibyte sequence, but 02156 * more bytes were needed to complete this 02157 * sequence. A subsequent call to the conversion 02158 * routine should pass the beginning of this 02159 * unconverted sequence plus additional bytes 02160 * from the source stream to properly convert 02161 * the formerly split-up multibyte sequence. 02162 * 02163 * TCL_CONVERT_SYNTAX: The source stream contained an invalid 02164 * character sequence. This may occur if the 02165 * input stream has been damaged or if the input 02166 * encoding method was misidentified. This error 02167 * is reported only if TCL_ENCODING_STOPONERROR 02168 * was specified. 02169 * 02170 * TCL_CONVERT_UNKNOWN: The source string contained a character 02171 * that could not be represented in the target 02172 * encoding. This error is reported only if 02173 * TCL_ENCODING_STOPONERROR was specified. 02174 */ 02175 #define TCL_CONVERT_MULTIBYTE -1 02176 #define TCL_CONVERT_SYNTAX -2 02177 #define TCL_CONVERT_UNKNOWN -3 02178 #define TCL_CONVERT_NOSPACE -4 02179 02180 02181 /* 02182 * The maximum number of bytes that are necessary to represent a single 02183 * Unicode character in UTF-8. 02184 */ 02185 #define TCL_UTF_MAX 3 02186 02187 /* 02188 * This represents a Unicode character. Any changes to this should 02189 * also be reflected in regcustom.h. 02190 */ 02191 typedef unsigned short Tcl_UniChar; 02192 02193 02194 /* 02195 * Deprecated Tcl procedures: 02196 */ 02197 #ifndef TCL_NO_DEPRECATED 02198 # define Tcl_EvalObj(interp,objPtr) \ 02199 Tcl_EvalObjEx((interp),(objPtr),0) 02200 # define Tcl_GlobalEvalObj(interp,objPtr) \ 02201 Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL) 02202 #endif 02203 02204 02205 /* 02206 * These function have been renamed. The old names are deprecated, but we 02207 * define these macros for backwards compatibilty. 02208 */ 02209 #define Tcl_Ckalloc Tcl_Alloc 02210 #define Tcl_Ckfree Tcl_Free 02211 #define Tcl_Ckrealloc Tcl_Realloc 02212 #define Tcl_Return Tcl_SetResult 02213 #define Tcl_TildeSubst Tcl_TranslateFileName 02214 #define panic Tcl_Panic 02215 #define panicVA Tcl_PanicVA 02216 02217 02218 /* 02219 * The following constant is used to test for older versions of Tcl 02220 * in the stubs tables. 02221 * 02222 * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different 02223 * value since the stubs tables don't match. 02224 */ 02225 02226 #define TCL_STUB_MAGIC ((int)0xFCA3BACF) 02227 02228 /* 02229 * The following function is required to be defined in all stubs aware 02230 * extensions. The function is actually implemented in the stub 02231 * library, not the main Tcl library, although there is a trivial 02232 * implementation in the main library in case an extension is statically 02233 * linked into an application. 02234 */ 02235 02236 EXTERN CONST char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, 02237 CONST char *version, int exact)); 02238 02239 #ifndef USE_TCL_STUBS 02240 02241 /* 02242 * When not using stubs, make it a macro. 02243 */ 02244 02245 #define Tcl_InitStubs(interp, version, exact) \ 02246 Tcl_PkgRequire(interp, "Tcl", version, exact) 02247 02248 #endif 02249 02250 02251 /* 02252 * Include the public function declarations that are accessible via 02253 * the stubs table. 02254 */ 02255 02256 #include "tclDecls.h" 02257 02258 /* 02259 * Include platform specific public function declarations that are 02260 * accessible via the stubs table. 02261 */ 02262 02263 /* 02264 * tclPlatDecls.h can't be included here on the Mac, as we need 02265 * Mac specific headers to define the Mac types used in this file, 02266 * but these Mac haders conflict with a number of tk types 02267 * and thus can't be included in the globally read tcl.h 02268 * This header was originally added here as a fix for bug 5241 02269 * (stub link error for symbols in TclPlatStubs table), as a work- 02270 * around for the bug on the mac, tclMac.h is included immediately 02271 * after tcl.h in the tcl precompiled header (with DLLEXPORT set). 02272 */ 02273 02274 #if !defined(MAC_TCL) 02275 #include "tclPlatDecls.h" 02276 #endif 02277 02278 /* 02279 * Public functions that are not accessible via the stubs table. 02280 */ 02281 02282 EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv, 02283 Tcl_AppInitProc *appInitProc)); 02284 02285 /* 02286 * Convenience declaration of Tcl_AppInit for backwards compatibility. 02287 * This function is not *implemented* by the tcl library, so the storage 02288 * class is neither DLLEXPORT nor DLLIMPORT 02289 */ 02290 #undef TCL_STORAGE_CLASS 02291 #define TCL_STORAGE_CLASS 02292 02293 EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp)); 02294 02295 #undef TCL_STORAGE_CLASS 02296 #define TCL_STORAGE_CLASS DLLIMPORT 02297 02298 #endif /* RC_INVOKED */ 02299 02300 /* 02301 * end block for C++ 02302 */ 02303 #ifdef __cplusplus 02304 } 02305 #endif 02306 02307 #endif /* _TCL */
1.5.7.1