1/* 2 * tcl.h -- 3 * 4 * This header file describes the externally-visible facilities 5 * of the Tcl interpreter. 6 * 7 * Copyright (c) 1987-1994 The Regents of the University of California. 8 * Copyright (c) 1993-1996 Lucent Technologies. 9 * Copyright (c) 1994-1998 Sun Microsystems, Inc. 10 * Copyright (c) 1998-1999 by Scriptics Corporation. 11 * 12 * See the file "license.terms" for information on usage and redistribution 13 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 14 * 15 * RCS: @(#) $Id: tcl.h,v 1.1 1999/03/21 15:10:58 aku Exp $ 16 */ 17 18#ifndef _TCL 19#define _TCL 20 21/* 22 * The following defines are used to indicate the various release levels. 23 */ 24 25#define TCL_ALPHA_RELEASE 0 26#define TCL_BETA_RELEASE 1 27#define TCL_FINAL_RELEASE 2 28 29/* 30 * When version numbers change here, must also go into the following files 31 * and update the version numbers: 32 * 33 * library/init.tcl (only if major.minor changes, not patchlevel) 34 * unix/configure.in 35 * win/makefile.bc (only if major.minor changes, not patchlevel) 36 * win/makefile.vc (only if major.minor changes, not patchlevel) 37 * win/pkgIndex.tcl (for tclregNN.dll) 38 * README 39 * mac/README 40 * win/README 41 * win/README.binary 42 * unix/README 43 * 44 */ 45 46#define TCL_MAJOR_VERSION 8 47#define TCL_MINOR_VERSION 1 48#define TCL_RELEASE_LEVEL TCL_BETA_RELEASE 49#define TCL_RELEASE_SERIAL 2 50 51#define TCL_VERSION "8.1" 52#define TCL_PATCH_LEVEL "8.1b2" 53 54/* 55 * The following definitions set up the proper options for Windows 56 * compilers. We use this method because there is no autoconf equivalent. 57 */ 58 59#ifndef __WIN32__ 60# if defined(_WIN32) || defined(WIN32) 61# define __WIN32__ 62# endif 63#endif 64 65#ifdef __WIN32__ 66# ifndef STRICT 67# define STRICT 68# endif 69# ifndef USE_PROTOTYPE 70# define USE_PROTOTYPE 1 71# endif 72# ifndef HAS_STDARG 73# define HAS_STDARG 1 74# endif 75# ifndef USE_PROTOTYPE 76# define USE_PROTOTYPE 1 77# endif 78 79/* 80 * Under Windows we need to call Tcl_Alloc in all cases to avoid competing 81 * C run-time library issues. 82 */ 83 84# ifndef USE_TCLALLOC 85# define USE_TCLALLOC 1 86# endif 87#endif /* __WIN32__ */ 88 89/* 90 * The following definitions set up the proper options for Macintosh 91 * compilers. We use this method because there is no autoconf equivalent. 92 */ 93 94#ifdef MAC_TCL 95# ifndef HAS_STDARG 96# define HAS_STDARG 1 97# endif 98# ifndef USE_TCLALLOC 99# define USE_TCLALLOC 1 100# endif 101# ifndef NO_STRERROR 102# define NO_STRERROR 1 103# endif 104# define INLINE 105#endif 106 107/* 108 * Utility macros: STRINGIFY takes an argument and wraps it in "" (double 109 * quotation marks), JOIN joins two arguments. 110 */ 111 112#define VERBATIM(x) x 113#ifdef _MSC_VER 114# define STRINGIFY(x) STRINGIFY1(x) 115# define STRINGIFY1(x) #x 116# define JOIN(a,b) JOIN1(a,b) 117# define JOIN1(a,b) a##b 118#else 119# ifdef RESOURCE_INCLUDED 120# define STRINGIFY(x) STRINGIFY1(x) 121# define STRINGIFY1(x) #x 122# define JOIN(a,b) JOIN1(a,b) 123# define JOIN1(a,b) a##b 124# else 125# ifdef __STDC__ 126# define STRINGIFY(x) #x 127# define JOIN(a,b) a##b 128# else 129# define STRINGIFY(x) "x" 130# define JOIN(a,b) VERBATIM(a)VERBATIM(b) 131# endif 132# endif 133#endif 134 135/* 136 * Special macro to define mutexes, that doesn't do anything 137 * if we are not using threads. 138 */ 139 140#ifdef TCL_THREADS 141#define TCL_DECLARE_MUTEX(name) static Tcl_Mutex name; 142#else 143#define TCL_DECLARE_MUTEX(name) 144#endif 145 146/* 147 * Macros that eliminate the overhead of the thread synchronization 148 * functions when compiling without thread support. 149 */ 150 151#ifndef TCL_THREADS 152#define Tcl_MutexLock(mutexPtr) 153#define Tcl_MutexUnlock(mutexPtr) 154#define Tcl_ConditionNotify(condPtr) 155#define Tcl_ConditionWait(condPtr, mutexPtr, timePtr) 156#endif /* TCL_THREADS */ 157 158/* 159 * A special definition used to allow this header file to be included 160 * in resource files so that they can get obtain version information from 161 * this file. Resource compilers don't like all the C stuff, like typedefs 162 * and procedure declarations, that occur below. 163 */ 164 165#ifndef RESOURCE_INCLUDED 166 167#ifndef BUFSIZ 168#include <stdio.h> 169#endif 170 171/* 172 * Definitions that allow Tcl functions with variable numbers of 173 * arguments to be used with either varargs.h or stdarg.h. TCL_VARARGS 174 * is used in procedure prototypes. TCL_VARARGS_DEF is used to declare 175 * the arguments in a function definiton: it takes the type and name of 176 * the first argument and supplies the appropriate argument declaration 177 * string for use in the function definition. TCL_VARARGS_START 178 * initializes the va_list data structure and returns the first argument. 179 */ 180 181#if defined(__STDC__) || defined(HAS_STDARG) 182# include <stdarg.h> 183 184# define TCL_VARARGS(type, name) (type name, ...) 185# define TCL_VARARGS_DEF(type, name) (type name, ...) 186# define TCL_VARARGS_START(type, name, list) (va_start(list, name), name) 187#else 188# include <varargs.h> 189 190# ifdef __cplusplus 191# define TCL_VARARGS(type, name) (type name, ...) 192# define TCL_VARARGS_DEF(type, name) (type va_alist, ...) 193# else 194# define TCL_VARARGS(type, name) () 195# define TCL_VARARGS_DEF(type, name) (va_alist) 196# endif 197# define TCL_VARARGS_START(type, name, list) \ 198 (va_start(list), va_arg(list, type)) 199#endif 200 201/* 202 * Macros used to declare a function to be exported by a DLL. 203 * Used by Windows, maps to no-op declarations on non-Windows systems. 204 * The default build on windows is for a DLL, which causes the DLLIMPORT 205 * and DLLEXPORT macros to be nonempty. To build a static library, the 206 * macro STATIC_BUILD should be defined. 207 */ 208 209#ifdef STATIC_BUILD 210# define DLLIMPORT 211# define DLLEXPORT 212#else 213# if defined(__WIN32__) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__declspec))) 214# define DLLIMPORT __declspec(dllimport) 215# define DLLEXPORT __declspec(dllexport) 216# else 217# define DLLIMPORT 218# define DLLEXPORT 219# endif 220#endif 221 222/* 223 * These macros are used to control whether functions are being declared for 224 * import or export. If a function is being declared while it is being built 225 * to be included in a shared library, then it should have the DLLEXPORT 226 * storage class. If is being declared for use by a module that is going to 227 * link against the shared library, then it should have the DLLIMPORT storage 228 * class. If the symbol is beind declared for a static build or for use from a 229 * stub library, then the storage class should be empty. 230 * 231 * The convention is that a macro called BUILD_xxxx, where xxxx is the 232 * name of a library we are building, is set on the compile line for sources 233 * that are to be placed in the library. When this macro is set, the 234 * storage class will be set to DLLEXPORT. At the end of the header file, the 235 * storage class will be reset to DLLIMPORt. 236 */ 237 238#undef TCL_STORAGE_CLASS 239#ifdef BUILD_tcl 240# define TCL_STORAGE_CLASS DLLEXPORT 241#else 242# ifdef USE_TCL_STUBS 243# define TCL_STORAGE_CLASS 244# else 245# define TCL_STORAGE_CLASS DLLIMPORT 246# endif 247#endif 248 249/* 250 * Definitions that allow this header file to be used either with or 251 * without ANSI C features like function prototypes. 252 */ 253 254#undef _ANSI_ARGS_ 255#undef CONST 256#ifndef INLINE 257# define INLINE 258#endif 259 260#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE) 261# define _USING_PROTOTYPES_ 1 262# define _ANSI_ARGS_(x) x 263# define CONST const 264#else 265# define _ANSI_ARGS_(x) () 266# define CONST 267#endif 268 269#ifdef __cplusplus 270# define EXTERN extern "C" TCL_STORAGE_CLASS 271#else 272# define EXTERN extern TCL_STORAGE_CLASS 273#endif 274 275/* 276 * Macro to use instead of "void" for arguments that must have 277 * type "void *" in ANSI C; maps them to type "char *" in 278 * non-ANSI systems. 279 */ 280#ifndef __WIN32__ 281#ifndef VOID 282# ifdef __STDC__ 283# define VOID void 284# else 285# define VOID char 286# endif 287#endif 288#else /* __WIN32__ */ 289/* 290 * The following code is copied from winnt.h 291 */ 292#ifndef VOID 293#define VOID void 294typedef char CHAR; 295typedef short SHORT; 296typedef long LONG; 297#endif 298#endif /* __WIN32__ */ 299 300/* 301 * Miscellaneous declarations. 302 */ 303 304#ifndef NULL 305#define NULL 0 306#endif 307 308#ifndef _CLIENTDATA 309# if defined(__STDC__) || defined(__cplusplus) 310 typedef void *ClientData; 311# else 312 typedef int *ClientData; 313# endif /* __STDC__ */ 314#define _CLIENTDATA 315#endif 316 317/* 318 * Data structures defined opaquely in this module. The definitions below 319 * just provide dummy types. A few fields are made visible in Tcl_Interp 320 * structures, namely those used for returning a string result from 321 * commands. Direct access to the result field is discouraged in Tcl 8.0. 322 * The interpreter result is either an object or a string, and the two 323 * values are kept consistent unless some C code sets interp->result 324 * directly. Programmers should use either the procedure Tcl_GetObjResult() 325 * or Tcl_GetStringResult() to read the interpreter's result. See the 326 * SetResult man page for details. 327 * 328 * Note: any change to the Tcl_Interp definition below must be mirrored 329 * in the "real" definition in tclInt.h. 330 * 331 * Note: Tcl_ObjCmdProc procedures do not directly set result and freeProc. 332 * Instead, they set a Tcl_Obj member in the "real" structure that can be 333 * accessed with Tcl_GetObjResult() and Tcl_SetObjResult(). 334 */ 335 336typedef struct Tcl_Interp { 337 char *result; /* If the last command returned a string 338 * result, this points to it. */ 339 void (*freeProc) _ANSI_ARGS_((char *blockPtr)); 340 /* Zero means the string result is 341 * statically allocated. TCL_DYNAMIC means 342 * it was allocated with ckalloc and should 343 * be freed with ckfree. Other values give 344 * the address of procedure to invoke to 345 * free the result. Tcl_Eval must free it 346 * before executing next command. */ 347 int errorLine; /* When TCL_ERROR is returned, this gives 348 * the line number within the command where 349 * the error occurred (1 if first line). */ 350} Tcl_Interp; 351 352typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler; 353typedef struct Tcl_Channel_ *Tcl_Channel; 354typedef struct Tcl_Command_ *Tcl_Command; 355typedef struct Tcl_Condition_ *Tcl_Condition; 356typedef struct Tcl_EncodingState_ *Tcl_EncodingState; 357typedef struct Tcl_Encoding_ *Tcl_Encoding; 358typedef struct Tcl_Event Tcl_Event; 359typedef struct Tcl_Mutex_ *Tcl_Mutex; 360typedef struct Tcl_Pid_ *Tcl_Pid; 361typedef struct Tcl_RegExp_ *Tcl_RegExp; 362typedef struct Tcl_ThreadDataKey_ *Tcl_ThreadDataKey; 363typedef struct Tcl_ThreadId_ *Tcl_ThreadId; 364typedef struct Tcl_TimerToken_ *Tcl_TimerToken; 365typedef struct Tcl_Trace_ *Tcl_Trace; 366typedef struct Tcl_Var_ *Tcl_Var; 367 368/* 369 * When a TCL command returns, the interpreter contains a result from the 370 * command. Programmers are strongly encouraged to use one of the 371 * procedures Tcl_GetObjResult() or Tcl_GetStringResult() to read the 372 * interpreter's result. See the SetResult man page for details. Besides 373 * this result, the command procedure returns an integer code, which is 374 * one of the following: 375 * 376 * TCL_OK Command completed normally; the interpreter's 377 * result contains the command's result. 378 * TCL_ERROR The command couldn't be completed successfully; 379 * the interpreter's result describes what went wrong. 380 * TCL_RETURN The command requests that the current procedure 381 * return; the interpreter's result contains the 382 * procedure's return value. 383 * TCL_BREAK The command requests that the innermost loop 384 * be exited; the interpreter's result is meaningless. 385 * TCL_CONTINUE Go on to the next iteration of the current loop; 386 * the interpreter's result is meaningless. 387 */ 388 389#define TCL_OK 0 390#define TCL_ERROR 1 391#define TCL_RETURN 2 392#define TCL_BREAK 3 393#define TCL_CONTINUE 4 394 395#define TCL_RESULT_SIZE 200 396 397/* 398 * Argument descriptors for math function callbacks in expressions: 399 */ 400 401typedef enum {TCL_INT, TCL_DOUBLE, TCL_EITHER} Tcl_ValueType; 402typedef struct Tcl_Value { 403 Tcl_ValueType type; /* Indicates intValue or doubleValue is 404 * valid, or both. */ 405 long intValue; /* Integer value. */ 406 double doubleValue; /* Double-precision floating value. */ 407} Tcl_Value; 408 409/* 410 * Forward declaration of Tcl_Obj to prevent an error when the forward 411 * reference to Tcl_Obj is encountered in the procedure types declared 412 * below. 413 */ 414 415struct Tcl_Obj; 416 417/* 418 * Procedure types defined by Tcl: 419 */ 420 421typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); 422typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData, 423 Tcl_Interp *interp, int code)); 424typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask)); 425typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data)); 426typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData)); 427typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData, 428 Tcl_Interp *interp, int argc, char *argv[])); 429typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData, 430 Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc, 431 ClientData cmdClientData, int argc, char *argv[])); 432typedef void (Tcl_DupInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *srcPtr, 433 struct Tcl_Obj *dupPtr)); 434typedef int (Tcl_EncodingConvertProc)_ANSI_ARGS_((ClientData clientData, 435 CONST char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, 436 char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, 437 int *dstCharsPtr)); 438typedef void (Tcl_EncodingFreeProc)_ANSI_ARGS_((ClientData clientData)); 439typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); 440typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData, 441 int flags)); 442typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr, 443 ClientData clientData)); 444typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData, 445 int flags)); 446typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData)); 447typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask)); 448typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData)); 449typedef void (Tcl_FreeInternalRepProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); 450typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr)); 451typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData)); 452typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, 453 Tcl_Interp *interp)); 454typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData, 455 Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr)); 456typedef void (Tcl_NamespaceDeleteProc) _ANSI_ARGS_((ClientData clientData)); 457typedef int (Tcl_ObjCmdProc) _ANSI_ARGS_((ClientData clientData, 458 Tcl_Interp *interp, int objc, struct Tcl_Obj *CONST objv[])); 459typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); 460typedef void (Tcl_PanicProc) _ANSI_ARGS_(TCL_VARARGS(char *, format)); 461typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData, 462 Tcl_Channel chan, char *address, int port)); 463typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData)); 464typedef int (Tcl_SetFromAnyProc) _ANSI_ARGS_((Tcl_Interp *interp, 465 struct Tcl_Obj *objPtr)); 466typedef void (Tcl_UpdateStringProc) _ANSI_ARGS_((struct Tcl_Obj *objPtr)); 467typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData, 468 Tcl_Interp *interp, char *part1, char *part2, int flags)); 469 470/* 471 * The following structure represents a type of object, which is a 472 * particular internal representation for an object plus a set of 473 * procedures that provide standard operations on objects of that type. 474 */ 475 476typedef struct Tcl_ObjType { 477 char *name; /* Name of the type, e.g. "int". */ 478 Tcl_FreeInternalRepProc *freeIntRepProc; 479 /* Called to free any storage for the type's 480 * internal rep. NULL if the internal rep 481 * does not need freeing. */ 482 Tcl_DupInternalRepProc *dupIntRepProc; 483 /* Called to create a new object as a copy 484 * of an existing object. */ 485 Tcl_UpdateStringProc *updateStringProc; 486 /* Called to update the string rep from the 487 * type's internal representation. */ 488 Tcl_SetFromAnyProc *setFromAnyProc; 489 /* Called to convert the object's internal 490 * rep to this type. Frees the internal rep 491 * of the old type. Returns TCL_ERROR on 492 * failure. */ 493} Tcl_ObjType; 494 495/* 496 * One of the following structures exists for each object in the Tcl 497 * system. An object stores a value as either a string, some internal 498 * representation, or both. 499 */ 500 501typedef struct Tcl_Obj { 502 int refCount; /* When 0 the object will be freed. */ 503 char *bytes; /* This points to the first byte of the 504 * object's string representation. The array 505 * must be followed by a null byte (i.e., at 506 * offset length) but may also contain 507 * embedded null characters. The array's 508 * storage is allocated by ckalloc. NULL 509 * means the string rep is invalid and must 510 * be regenerated from the internal rep. 511 * Clients should use Tcl_GetStringFromObj 512 * or Tcl_GetString to get a pointer to the 513 * byte array as a readonly value. */ 514 int length; /* The number of bytes at *bytes, not 515 * including the terminating null. */ 516 Tcl_ObjType *typePtr; /* Denotes the object's type. Always 517 * corresponds to the type of the object's 518 * internal rep. NULL indicates the object 519 * has no internal rep (has no type). */ 520 union { /* The internal representation: */ 521 long longValue; /* - an long integer value */ 522 double doubleValue; /* - a double-precision floating value */ 523 VOID *otherValuePtr; /* - another, type-specific value */ 524 struct { /* - internal rep as two pointers */ 525 VOID *ptr1; 526 VOID *ptr2; 527 } twoPtrValue; 528 } internalRep; 529} Tcl_Obj; 530 531/* 532 * Macros to increment and decrement a Tcl_Obj's reference count, and to 533 * test whether an object is shared (i.e. has reference count > 1). 534 * Note: clients should use Tcl_DecrRefCount() when they are finished using 535 * an object, and should never call TclFreeObj() directly. TclFreeObj() is 536 * only defined and made public in tcl.h to support Tcl_DecrRefCount's macro 537 * definition. Note also that Tcl_DecrRefCount() refers to the parameter 538 * "obj" twice. This means that you should avoid calling it with an 539 * expression that is expensive to compute or has side effects. 540 */ 541 542EXTERN void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); 543EXTERN void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); 544EXTERN int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr)); 545 546#ifdef TCL_MEM_DEBUG 547# define Tcl_IncrRefCount(objPtr) \ 548 Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__) 549# define Tcl_DecrRefCount(objPtr) \ 550 Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__) 551# define Tcl_IsShared(objPtr) \ 552 Tcl_DbIsShared(objPtr, __FILE__, __LINE__) 553#else 554# define Tcl_IncrRefCount(objPtr) \ 555 ++(objPtr)->refCount 556# define Tcl_DecrRefCount(objPtr) \ 557 if (--(objPtr)->refCount <= 0) TclFreeObj(objPtr) 558# define Tcl_IsShared(objPtr) \ 559 ((objPtr)->refCount > 1) 560#endif 561 562/* 563 * Macros and definitions that help to debug the use of Tcl objects. 564 * When TCL_MEM_DEBUG is defined, the Tcl_New* declarations are 565 * overridden to call debugging versions of the object creation procedures. 566 */ 567 568#ifdef TCL_MEM_DEBUG 569# define Tcl_NewBooleanObj(val) \ 570 Tcl_DbNewBooleanObj(val, __FILE__, __LINE__) 571# define Tcl_NewByteArrayObj(bytes, len) \ 572 Tcl_DbNewByteArrayObj(bytes, len, __FILE__, __LINE__) 573# define Tcl_NewDoubleObj(val) \ 574 Tcl_DbNewDoubleObj(val, __FILE__, __LINE__) 575# define Tcl_NewIntObj(val) \ 576 Tcl_DbNewLongObj(val, __FILE__, __LINE__) 577# define Tcl_NewListObj(objc, objv) \ 578 Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__) 579# define Tcl_NewLongObj(val) \ 580 Tcl_DbNewLongObj(val, __FILE__, __LINE__) 581# define Tcl_NewObj() \ 582 Tcl_DbNewObj(__FILE__, __LINE__) 583# define Tcl_NewStringObj(bytes, len) \ 584 Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__) 585#endif /* TCL_MEM_DEBUG */ 586 587/* 588 * The following structure contains the state needed by 589 * Tcl_SaveResult. No-one outside of Tcl should access any of these 590 * fields. This structure is typically allocated on the stack. 591 */ 592 593typedef struct Tcl_SavedResult { 594 char *result; 595 Tcl_FreeProc *freeProc; 596 Tcl_Obj *objResultPtr; 597 char *appendResult; 598 int appendAvl; 599 int appendUsed; 600 char resultSpace[TCL_RESULT_SIZE+1]; 601} Tcl_SavedResult; 602 603 604/* 605 * The following definitions support Tcl's namespace facility. 606 * Note: the first five fields must match exactly the fields in a 607 * Namespace structure (see tcl.h). 608 */ 609 610typedef struct Tcl_Namespace { 611 char *name; /* The namespace's name within its parent 612 * namespace. This contains no ::'s. The 613 * name of the global namespace is "" 614 * although "::" is an synonym. */ 615 char *fullName; /* The namespace's fully qualified name. 616 * This starts with ::. */ 617 ClientData clientData; /* Arbitrary value associated with this 618 * namespace. */ 619 Tcl_NamespaceDeleteProc* deleteProc; 620 /* Procedure invoked when deleting the 621 * namespace to, e.g., free clientData. */ 622 struct Tcl_Namespace* parentPtr; 623 /* Points to the namespace that contains 624 * this one. NULL if this is the global 625 * namespace. */ 626} Tcl_Namespace; 627 628/* 629 * The following structure represents a call frame, or activation record. 630 * A call frame defines a naming context for a procedure call: its local 631 * scope (for local variables) and its namespace scope (used for non-local 632 * variables; often the global :: namespace). A call frame can also define 633 * the naming context for a namespace eval or namespace inscope command: 634 * the namespace in which the command's code should execute. The 635 * Tcl_CallFrame structures exist only while procedures or namespace 636 * eval/inscope's are being executed, and provide a Tcl call stack. 637 * 638 * A call frame is initialized and pushed using Tcl_PushCallFrame and 639 * popped using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be 640 * provided by the Tcl_PushCallFrame caller, and callers typically allocate 641 * them on the C call stack for efficiency. For this reason, Tcl_CallFrame 642 * is defined as a structure and not as an opaque token. However, most 643 * Tcl_CallFrame fields are hidden since applications should not access 644 * them directly; others are declared as "dummyX". 645 * 646 * WARNING!! The structure definition must be kept consistent with the 647 * CallFrame structure in tclInt.h. If you change one, change the other. 648 */ 649 650typedef struct Tcl_CallFrame { 651 Tcl_Namespace *nsPtr; 652 int dummy1; 653 int dummy2; 654 char *dummy3; 655 char *dummy4; 656 char *dummy5; 657 int dummy6; 658 char *dummy7; 659 char *dummy8; 660 int dummy9; 661 char* dummy10; 662} Tcl_CallFrame; 663 664/* 665 * Information about commands that is returned by Tcl_GetCommandInfo and 666 * passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based 667 * command procedure while proc is a traditional Tcl argc/argv 668 * string-based procedure. Tcl_CreateObjCommand and Tcl_CreateCommand 669 * ensure that both objProc and proc are non-NULL and can be called to 670 * execute the command. However, it may be faster to call one instead of 671 * the other. The member isNativeObjectProc is set to 1 if an 672 * object-based procedure was registered by Tcl_CreateObjCommand, and to 673 * 0 if a string-based procedure was registered by Tcl_CreateCommand. 674 * The other procedure is typically set to a compatibility wrapper that 675 * does string-to-object or object-to-string argument conversions then 676 * calls the other procedure. 677 */ 678 679typedef struct Tcl_CmdInfo { 680 int isNativeObjectProc; /* 1 if objProc was registered by a call to 681 * Tcl_CreateObjCommand; 0 otherwise. 682 * Tcl_SetCmdInfo does not modify this 683 * field. */ 684 Tcl_ObjCmdProc *objProc; /* Command's object-based procedure. */ 685 ClientData objClientData; /* ClientData for object proc. */ 686 Tcl_CmdProc *proc; /* Command's string-based procedure. */ 687 ClientData clientData; /* ClientData for string proc. */ 688 Tcl_CmdDeleteProc *deleteProc; 689 /* Procedure to call when command is 690 * deleted. */ 691 ClientData deleteData; /* Value to pass to deleteProc (usually 692 * the same as clientData). */ 693 Tcl_Namespace *namespacePtr; /* Points to the namespace that contains 694 * this command. Note that Tcl_SetCmdInfo 695 * will not change a command's namespace; 696 * use Tcl_RenameCommand to do that. */ 697 698} Tcl_CmdInfo; 699 700/* 701 * The structure defined below is used to hold dynamic strings. The only 702 * field that clients should use is the string field, and they should 703 * never modify it. 704 */ 705 706#define TCL_DSTRING_STATIC_SIZE 200 707typedef struct Tcl_DString { 708 char *string; /* Points to beginning of string: either 709 * staticSpace below or a malloced array. */ 710 int length; /* Number of non-NULL characters in the 711 * string. */ 712 int spaceAvl; /* Total number of bytes available for the 713 * string and its terminating NULL char. */ 714 char staticSpace[TCL_DSTRING_STATIC_SIZE]; 715 /* Space to use in common case where string 716 * is small. */ 717} Tcl_DString; 718 719#define Tcl_DStringLength(dsPtr) ((dsPtr)->length) 720#define Tcl_DStringValue(dsPtr) ((dsPtr)->string) 721#define Tcl_DStringTrunc Tcl_DStringSetLength 722 723/* 724 * Definitions for the maximum number of digits of precision that may 725 * be specified in the "tcl_precision" variable, and the number of 726 * bytes of buffer space required by Tcl_PrintDouble. 727 */ 728 729#define TCL_MAX_PREC 17 730#define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10) 731 732/* 733 * Definition for a number of bytes of buffer space sufficient to hold the 734 * string representation of an integer in base 10 (assuming the existence 735 * of 64-bit integers). 736 */ 737 738#define TCL_INTEGER_SPACE 24 739 740/* 741 * Flag that may be passed to Tcl_ConvertElement to force it not to 742 * output braces (careful! if you change this flag be sure to change 743 * the definitions at the front of tclUtil.c). 744 */ 745 746#define TCL_DONT_USE_BRACES 1 747 748/* 749 * Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow 750 * abbreviated strings. 751 */ 752 753#define TCL_EXACT 1 754 755/* 756 * Flag values passed to Tcl_RecordAndEval and/or Tcl_EvalObj. 757 * WARNING: these bit choices must not conflict with the bit choices 758 * for evalFlag bits in tclInt.h!! 759 */ 760 761#define TCL_NO_EVAL 0x10000 762#define TCL_EVAL_GLOBAL 0x20000 763#define TCL_EVAL_DIRECT 0x40000 764 765/* 766 * Special freeProc values that may be passed to Tcl_SetResult (see 767 * the man page for details): 768 */ 769 770#define TCL_VOLATILE ((Tcl_FreeProc *) 1) 771#define TCL_STATIC ((Tcl_FreeProc *) 0) 772#define TCL_DYNAMIC ((Tcl_FreeProc *) 3) 773 774/* 775 * Flag values passed to variable-related procedures. 776 */ 777 778#define TCL_GLOBAL_ONLY 1 779#define TCL_NAMESPACE_ONLY 2 780#define TCL_APPEND_VALUE 4 781#define TCL_LIST_ELEMENT 8 782#define TCL_TRACE_READS 0x10 783#define TCL_TRACE_WRITES 0x20 784#define TCL_TRACE_UNSETS 0x40 785#define TCL_TRACE_DESTROYED 0x80 786#define TCL_INTERP_DESTROYED 0x100 787#define TCL_LEAVE_ERR_MSG 0x200 788#define TCL_TRACE_ARRAY 0x800 789 790/* 791 * The TCL_PARSE_PART1 flag is deprecated and has no effect. 792 * The part1 is now always parsed whenever the part2 is NULL. 793 * (This is to avoid a common error when converting code to 794 * use the new object based APIs and forgetting to give the 795 * flag) 796 */ 797#ifndef TCL_NO_DEPRECATED 798#define TCL_PARSE_PART1 0x400 799#endif 800 801 802/* 803 * Types for linked variables: 804 */ 805 806#define TCL_LINK_INT 1 807#define TCL_LINK_DOUBLE 2 808#define TCL_LINK_BOOLEAN 3 809#define TCL_LINK_STRING 4 810#define TCL_LINK_READ_ONLY 0x80 811 812/* 813 * The following declarations either map ckalloc and ckfree to 814 * malloc and free, or they map them to procedures with all sorts 815 * of debugging hooks defined in tclCkalloc.c. 816 */ 817 818#ifdef TCL_MEM_DEBUG 819 820# define Tcl_Alloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__) 821# define Tcl_Free(x) Tcl_DbCkfree(x, __FILE__, __LINE__) 822# define Tcl_Realloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__) 823# define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__) 824# define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__) 825# define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__) 826 827#else /* !TCL_MEM_DEBUG */ 828 829/* 830 * If USE_TCLALLOC is true, then we need to call Tcl_Alloc instead of 831 * the native malloc/free. The only time USE_TCLALLOC should not be 832 * true is when compiling the Tcl/Tk libraries on Unix systems. In this 833 * case we can safely call the native malloc/free directly as a performance 834 * optimization. 835 */ 836 837# if USE_TCLALLOC 838# define ckalloc(x) Tcl_Alloc(x) 839# define ckfree(x) Tcl_Free(x) 840# define ckrealloc(x,y) Tcl_Realloc(x,y) 841# else 842# define ckalloc(x) malloc(x) 843# define ckfree(x) free(x) 844# define ckrealloc(x,y) realloc(x,y) 845# endif 846# define Tcl_InitMemory(x) 847# define Tcl_DumpActiveMemory(x) 848# define Tcl_ValidateAllMemory(x,y) 849 850#endif /* !TCL_MEM_DEBUG */ 851 852/* 853 * Forward declaration of Tcl_HashTable. Needed by some C++ compilers 854 * to prevent errors when the forward reference to Tcl_HashTable is 855 * encountered in the Tcl_HashEntry structure. 856 */ 857 858#ifdef __cplusplus 859struct Tcl_HashTable; 860#endif 861 862/* 863 * Structure definition for an entry in a hash table. No-one outside 864 * Tcl should access any of these fields directly; use the macros 865 * defined below. 866 */ 867 868typedef struct Tcl_HashEntry { 869 struct Tcl_HashEntry *nextPtr; /* Pointer to next entry in this 870 * hash bucket, or NULL for end of 871 * chain. */ 872 struct Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ 873 struct Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to 874 * first entry in this entry's chain: 875 * used for deleting the entry. */ 876 ClientData clientData; /* Application stores something here 877 * with Tcl_SetHashValue. */ 878 union { /* Key has one of these forms: */ 879 char *oneWordValue; /* One-word value for key. */ 880 int words[1]; /* Multiple integer words for key. 881 * The actual size will be as large 882 * as necessary for this table's 883 * keys. */ 884 char string[4]; /* String for key. The actual size 885 * will be as large as needed to hold 886 * the key. */ 887 } key; /* MUST BE LAST FIELD IN RECORD!! */ 888} Tcl_HashEntry; 889 890/* 891 * Structure definition for a hash table. Must be in tcl.h so clients 892 * can allocate space for these structures, but clients should never 893 * access any fields in this structure. 894 */ 895 896#define TCL_SMALL_HASH_TABLE 4 897typedef struct Tcl_HashTable { 898 Tcl_HashEntry **buckets; /* Pointer to bucket array. Each 899 * element points to first entry in 900 * bucket's hash chain, or NULL. */ 901 Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; 902 /* Bucket array used for small tables 903 * (to avoid mallocs and frees). */ 904 int numBuckets; /* Total number of buckets allocated 905 * at **bucketPtr. */ 906 int numEntries; /* Total number of entries present 907 * in table. */ 908 int rebuildSize; /* Enlarge table when numEntries gets 909 * to be this large. */ 910 int downShift; /* Shift count used in hashing 911 * function. Designed to use high- 912 * order bits of randomized keys. */ 913 int mask; /* Mask value used in hashing 914 * function. */ 915 int keyType; /* Type of keys used in this table. 916 * It's either TCL_STRING_KEYS, 917 * TCL_ONE_WORD_KEYS, or an integer 918 * giving the number of ints that 919 * is the size of the key. 920 */ 921 Tcl_HashEntry *(*findProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr, 922 CONST char *key)); 923 Tcl_HashEntry *(*createProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr, 924 CONST char *key, int *newPtr)); 925} Tcl_HashTable; 926 927/* 928 * Structure definition for information used to keep track of searches 929 * through hash tables: 930 */ 931 932typedef struct Tcl_HashSearch { 933 Tcl_HashTable *tablePtr; /* Table being searched. */ 934 int nextIndex; /* Index of next bucket to be 935 * enumerated after present one. */ 936 Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the 937 * the current bucket. */ 938} Tcl_HashSearch; 939 940/* 941 * Acceptable key types for hash tables: 942 */ 943 944#define TCL_STRING_KEYS 0 945#define TCL_ONE_WORD_KEYS 1 946 947/* 948 * Macros for clients to use to access fields of hash entries: 949 */ 950 951#define Tcl_GetHashValue(h) ((h)->clientData) 952#define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value)) 953#define Tcl_GetHashKey(tablePtr, h) \ 954 ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) ? (h)->key.oneWordValue \ 955 : (h)->key.string)) 956 957/* 958 * Macros to use for clients to use to invoke find and create procedures 959 * for hash tables: 960 */ 961 962#define Tcl_FindHashEntry(tablePtr, key) \ 963 (*((tablePtr)->findProc))(tablePtr, key) 964#define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ 965 (*((tablePtr)->createProc))(tablePtr, key, newPtr) 966 967/* 968 * Flag values to pass to Tcl_DoOneEvent to disable searches 969 * for some kinds of events: 970 */ 971 972#define TCL_DONT_WAIT (1<<1) 973#define TCL_WINDOW_EVENTS (1<<2) 974#define TCL_FILE_EVENTS (1<<3) 975#define TCL_TIMER_EVENTS (1<<4) 976#define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */ 977#define TCL_ALL_EVENTS (~TCL_DONT_WAIT) 978 979/* 980 * The following structure defines a generic event for the Tcl event 981 * system. These are the things that are queued in calls to Tcl_QueueEvent 982 * and serviced later by Tcl_DoOneEvent. There can be many different 983 * kinds of events with different fields, corresponding to window events, 984 * timer events, etc. The structure for a particular event consists of 985 * a Tcl_Event header followed by additional information specific to that 986 * event. 987 */ 988 989struct Tcl_Event { 990 Tcl_EventProc *proc; /* Procedure to call to service this event. */ 991 struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */ 992}; 993 994/* 995 * Positions to pass to Tcl_QueueEvent: 996 */ 997 998typedef enum { 999 TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK 1000} Tcl_QueuePosition; 1001 1002/* 1003 * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier 1004 * event routines. 1005 */ 1006 1007#define TCL_SERVICE_NONE 0 1008#define TCL_SERVICE_ALL 1 1009 1010/* 1011 * The following structure keeps is used to hold a time value, either as 1012 * an absolute time (the number of seconds from the epoch) or as an 1013 * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT. 1014 * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT. 1015 */ 1016 1017typedef struct Tcl_Time { 1018 long sec; /* Seconds. */ 1019 long usec; /* Microseconds. */ 1020} Tcl_Time; 1021 1022/* 1023 * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler 1024 * to indicate what sorts of events are of interest: 1025 */ 1026 1027#define TCL_READABLE (1<<1) 1028#define TCL_WRITABLE (1<<2) 1029#define TCL_EXCEPTION (1<<3) 1030 1031/* 1032 * Flag values to pass to Tcl_OpenCommandChannel to indicate the 1033 * disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, 1034 * are also used in Tcl_GetStdChannel. 1035 */ 1036 1037#define TCL_STDIN (1<<1) 1038#define TCL_STDOUT (1<<2) 1039#define TCL_STDERR (1<<3) 1040#define TCL_ENFORCE_MODE (1<<4) 1041 1042/* 1043 * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel 1044 * should be closed. 1045 */ 1046 1047#define TCL_CLOSE_READ (1<<1) 1048#define TCL_CLOSE_WRITE (1<<2) 1049 1050/* 1051 * Value to use as the closeProc for a channel that supports the 1052 * close2Proc interface. 1053 */ 1054 1055#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1) 1056 1057/* 1058 * Typedefs for the various operations in a channel type: 1059 */ 1060 1061typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_(( 1062 ClientData instanceData, int mode)); 1063typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData, 1064 Tcl_Interp *interp)); 1065typedef int (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData, 1066 Tcl_Interp *interp, int flags)); 1067typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData, 1068 char *buf, int toRead, int *errorCodePtr)); 1069typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData, 1070 char *buf, int toWrite, int *errorCodePtr)); 1071typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData, 1072 long offset, int mode, int *errorCodePtr)); 1073typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_(( 1074 ClientData instanceData, Tcl_Interp *interp, 1075 char *optionName, char *value)); 1076typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_(( 1077 ClientData instanceData, Tcl_Interp *interp, 1078 char *optionName, Tcl_DString *dsPtr)); 1079typedef void (Tcl_DriverWatchProc) _ANSI_ARGS_(( 1080 ClientData instanceData, int mask)); 1081typedef int (Tcl_DriverGetHandleProc) _ANSI_ARGS_(( 1082 ClientData instanceData, int direction, 1083 ClientData *handlePtr)); 1084 1085/* 1086 * Enum for different end of line translation and recognition modes. 1087 */ 1088 1089typedef enum Tcl_EolTranslation { 1090 TCL_TRANSLATE_AUTO, /* Eol == \r, \n and \r\n. */ 1091 TCL_TRANSLATE_CR, /* Eol == \r. */ 1092 TCL_TRANSLATE_LF, /* Eol == \n. */ 1093 TCL_TRANSLATE_CRLF /* Eol == \r\n. */ 1094} Tcl_EolTranslation; 1095 1096/* 1097 * struct Tcl_ChannelType: 1098 * 1099 * One such structure exists for each type (kind) of channel. 1100 * It collects together in one place all the functions that are 1101 * part of the specific channel type. 1102 */ 1103 1104typedef struct Tcl_ChannelType { 1105 char *typeName; /* The name of the channel type in Tcl 1106 * commands. This storage is owned by 1107 * channel type. */ 1108 Tcl_DriverBlockModeProc *blockModeProc; 1109 /* Set blocking mode for the 1110 * raw channel. May be NULL. */ 1111 Tcl_DriverCloseProc *closeProc; /* Procedure to call to close the 1112 * channel, or TCL_CLOSE2PROC if the 1113 * close2Proc should be used 1114 * instead. */ 1115 Tcl_DriverInputProc *inputProc; /* Procedure to call for input 1116 * on channel. */ 1117 Tcl_DriverOutputProc *outputProc; /* Procedure to call for output 1118 * on channel. */ 1119 Tcl_DriverSeekProc *seekProc; /* Procedure to call to seek 1120 * on the channel. May be NULL. */ 1121 Tcl_DriverSetOptionProc *setOptionProc; 1122 /* Set an option on a channel. */ 1123 Tcl_DriverGetOptionProc *getOptionProc; 1124 /* Get an option from a channel. */ 1125 Tcl_DriverWatchProc *watchProc; /* Set up the notifier to watch 1126 * for events on this channel. */ 1127 Tcl_DriverGetHandleProc *getHandleProc; 1128 /* Get an OS handle from the channel 1129 * or NULL if not supported. */ 1130 Tcl_DriverClose2Proc *close2Proc; /* Procedure to call to close the 1131 * channel if the device supports 1132 * closing the read & write sides 1133 * independently. */ 1134} Tcl_ChannelType; 1135 1136/* 1137 * The following flags determine whether the blockModeProc above should 1138 * set the channel into blocking or nonblocking mode. They are passed 1139 * as arguments to the blockModeProc procedure in the above structure. 1140 */ 1141 1142#define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */ 1143#define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking 1144 * mode. */ 1145 1146/* 1147 * Enum for different types of file paths. 1148 */ 1149 1150typedef enum Tcl_PathType { 1151 TCL_PATH_ABSOLUTE, 1152 TCL_PATH_RELATIVE, 1153 TCL_PATH_VOLUME_RELATIVE 1154} Tcl_PathType; 1155 1156/* 1157 * The following structure represents a user-defined encoding. It collects 1158 * together all the functions that are used by the specific encoding. 1159 */ 1160 1161typedef struct Tcl_EncodingType { 1162 CONST char *encodingName; /* The name of the encoding, e.g. "euc-jp". 1163 * This name is the unique key for this 1164 * encoding type. */ 1165 Tcl_EncodingConvertProc *toUtfProc; 1166 /* Procedure to convert from external 1167 * encoding into UTF-8. */ 1168 Tcl_EncodingConvertProc *fromUtfProc; 1169 /* Procedure to convert from UTF-8 into 1170 * external encoding. */ 1171 Tcl_EncodingFreeProc *freeProc; 1172 /* If non-NULL, procedure to call when this 1173 * encoding is deleted. */ 1174 ClientData clientData; /* Arbitrary value associated with encoding 1175 * type. Passed to conversion procedures. */ 1176 int nullSize; /* Number of zero bytes that signify 1177 * end-of-string in this encoding. This 1178 * number is used to determine the source 1179 * string length when the srcLen argument is 1180 * negative. Must be 1 or 2. */ 1181} Tcl_EncodingType; 1182 1183/* 1184 * The following definitions are used as values for the conversion control 1185 * flags argument when converting text from one character set to another: 1186 * 1187 * TCL_ENCODING_START: Signifies that the source buffer is the first 1188 * block in a (potentially multi-block) input 1189 * stream. Tells the conversion procedure to 1190 * reset to an initial state and perform any 1191 * initialization that needs to occur before the 1192 * first byte is converted. If the source 1193 * buffer contains the entire input stream to be 1194 * converted, this flag should be set. 1195 * 1196 * TCL_ENCODING_END: Signifies that the source buffer is the last 1197 * block in a (potentially multi-block) input 1198 * stream. Tells the conversion routine to 1199 * perform any finalization that needs to occur 1200 * after the last byte is converted and then to 1201 * reset to an initial state. If the source 1202 * buffer contains the entire input stream to be 1203 * converted, this flag should be set. 1204 * 1205 * TCL_ENCODING_STOPONERROR: If set, then the converter will return 1206 * immediately upon encountering an invalid 1207 * byte sequence or a source character that has 1208 * no mapping in the target encoding. If clear, 1209 * then the converter will skip the problem, 1210 * substituting one or more "close" characters 1211 * in the destination buffer and then continue 1212 * to sonvert the source. 1213 */ 1214 1215#define TCL_ENCODING_START 0x01 1216#define TCL_ENCODING_END 0x02 1217#define TCL_ENCODING_STOPONERROR 0x04 1218 1219/* 1220 * The following definitions are the error codes returned by the conversion 1221 * routines: 1222 * 1223 * TCL_OK: All characters were converted. 1224 * 1225 * TCL_CONVERT_NOSPACE: The output buffer would not have been large 1226 * enough for all of the converted data; as many 1227 * characters as could fit were converted though. 1228 * 1229 * TCL_CONVERT_MULTIBYTE: The last few bytes in the source string were 1230 * the beginning of a multibyte sequence, but 1231 * more bytes were needed to complete this 1232 * sequence. A subsequent call to the conversion 1233 * routine should pass the beginning of this 1234 * unconverted sequence plus additional bytes 1235 * from the source stream to properly convert 1236 * the formerly split-up multibyte sequence. 1237 * 1238 * TCL_CONVERT_SYNTAX: The source stream contained an invalid 1239 * character sequence. This may occur if the 1240 * input stream has been damaged or if the input 1241 * encoding method was misidentified. This error 1242 * is reported only if TCL_ENCODING_STOPONERROR 1243 * was specified. 1244 * 1245 * TCL_CONVERT_UNKNOWN: The source string contained a character 1246 * that could not be represented in the target 1247 * encoding. This error is reported only if 1248 * TCL_ENCODING_STOPONERROR was specified. 1249 */ 1250 1251#define TCL_CONVERT_MULTIBYTE -1 1252#define TCL_CONVERT_SYNTAX -2 1253#define TCL_CONVERT_UNKNOWN -3 1254#define TCL_CONVERT_NOSPACE -4 1255 1256/* 1257 * The maximum number of bytes that are necessary to represent a single 1258 * Unicode character in UTF-8. 1259 */ 1260 1261#define TCL_UTF_MAX 3 1262 1263/* 1264 * This represents a Unicode character. 1265 */ 1266 1267typedef unsigned short Tcl_UniChar; 1268 1269/* 1270 * Deprecated Tcl procedures: 1271 */ 1272 1273#ifndef TCL_NO_DEPRECATED 1274#define Tcl_EvalObj(interp,objPtr) Tcl_EvalObjEx((interp),(objPtr),0) 1275#define Tcl_GlobalEvalObj(interp,objPtr) \ 1276 Tcl_EvalObjEx((interp),(objPtr),TCL_EVAL_GLOBAL) 1277#endif 1278 1279/* 1280 * These function have been renamed. The old names are deprecated, but we 1281 * define these macros for backwards compatibilty. 1282 */ 1283 1284#define Tcl_Ckalloc Tcl_Alloc 1285#define Tcl_Ckfree Tcl_Free 1286#define Tcl_Ckrealloc Tcl_Realloc 1287#define Tcl_Return Tcl_SetResult 1288#define Tcl_TildeSubst Tcl_TranslateFileName 1289#define panic Tcl_Panic 1290#define panicVA Tcl_PanicVA 1291 1292/* 1293 * The following constant is used to test for older versions of Tcl 1294 * in the stubs tables. 1295 * 1296 * Jan Nijtman's plus patch uses 0xFCA1BACF, so we need to pick a different 1297 * value since the stubs tables don't match. 1298 */ 1299 1300#define TCL_STUB_MAGIC 0xFCA3BACF 1301 1302/* 1303 * The following function is required to be defined in all stubs aware 1304 * extensions. The function is actually implemented in the stub 1305 * library, not the main Tcl library, although there is a trivial 1306 * implementation in the main library in case an extension is statically 1307 * linked into an application. 1308 */ 1309 1310EXTERN char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, 1311 char *version, int exact)); 1312 1313/* 1314 * Include the public function declarations that are accessible via 1315 * the stubs table. 1316 */ 1317 1318#include "tclDecls.h" 1319 1320/* 1321 * Public functions that are not accessible via the stubs table. 1322 */ 1323 1324EXTERN void Tcl_InitMemory _ANSI_ARGS_((Tcl_Interp *interp)); 1325EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv, 1326 Tcl_AppInitProc *appInitProc)); 1327 1328/* 1329 * Convenience declaration of Tcl_AppInit for backwards compatibility. 1330 * This function is not *implemented* by the tcl library, so the storage 1331 * class is neither DLLEXPORT nor DLLIMPORT 1332 */ 1333 1334#undef TCL_STORAGE_CLASS 1335#define TCL_STORAGE_CLASS 1336 1337EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp)); 1338 1339 1340/* Andreas Kupries <a.kupries@westend.com>, 05/31/1997. 1341 * "Trf-Patch for channels with a switchable byteorder" 1342 */ 1343EXTERN int Tcl_GetChannelByteorder _ANSI_ARGS_(( 1344 Tcl_Channel chan)); 1345 1346#endif /* RESOURCE_INCLUDED */ 1347 1348#undef TCL_STORAGE_CLASS 1349#define TCL_STORAGE_CLASS DLLIMPORT 1350 1351#endif /* _TCL */ 1352