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