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