prevent a C++ compiler error
[catagits/fcgi2.git] / include / tclInt.h
1 /*
2  * tclInt.h --
3  *
4  *      Declarations of things used internally by the Tcl interpreter.
5  *
6  * Copyright (c) 1987-1993 The Regents of the University of California.
7  * Copyright (c) 1994-1995 Sun Microsystems, Inc.
8  *
9  * This software is copyrighted by the Regents of the University of
10  * California, Sun Microsystems, Inc., and other parties.  The following
11  * terms apply to all files associated with the software unless explicitly
12  * disclaimed in individual files.
13  *
14  * The authors hereby grant permission to use, copy, modify, distribute,
15  * and license this software and its documentation for any purpose, provided
16  * that existing copyright notices are retained in all copies and that this
17  * notice is included verbatim in any distributions. No written agreement,
18  * license, or royalty fee is required for any of the authorized uses.
19  * Modifications to this software may be copyrighted by their authors
20  * and need not follow the licensing terms described here, provided that
21  * the new terms are clearly indicated on the first page of each file where
22  * they apply.
23  *
24  * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
25  * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
26  * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
27  * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
31  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
32  * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
33  * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
34  * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
35  * MODIFICATIONS.
36  *
37  * RESTRICTED RIGHTS: Use, duplication or disclosure by the government
38  * is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
39  * of the Rights in Technical Data and Computer Software Clause as DFARS
40  * 252.227-7013 and FAR 52.227-19.
41  *
42  * $Id: tclInt.h,v 1.2 1999/07/28 00:25:18 roberts Exp $
43  *
44  * @(#) tclInt.h 1.106 95/08/25 15:44:50
45  */
46
47 #ifndef _TCLINT
48 #define _TCLINT
49
50 /*
51  * Common include files needed by most of the Tcl source files are
52  * included here, so that system-dependent personalizations for the
53  * include files only have to be made in once place.  This results
54  * in a few extra includes, but greater modularity.  The order of
55  * the three groups of #includes is important.  For example, stdio.h
56  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
57  * needed by stdlib.h in some configurations.
58  */
59
60 #include <stdio.h>
61 #include <assert.h>
62
63 #ifndef _TCL
64 #include "tcl.h"
65 #endif
66 #ifndef _REGEXP
67 #include "tclRegexp.h"
68 #endif
69
70 #include <ctype.h>
71 #ifdef NO_LIMITS_H
72 #   include "compat/limits.h"
73 #else
74 #   include <limits.h>
75 #endif
76 #ifdef NO_STDLIB_H
77 #   include "compat/stdlib.h"
78 #else
79 #   include <stdlib.h>
80 #endif
81 #ifdef NO_STRING_H
82 #include "compat/string.h"
83 #else
84 #include <string.h>
85 #endif
86 #include <varargs.h>
87
88 /*
89  * At present (12/91) not all stdlib.h implementations declare strtod.
90  * The declaration below is here to ensure that it's declared, so that
91  * the compiler won't take the default approach of assuming it returns
92  * an int.  There's no ANSI prototype for it because there would end
93  * up being too many conflicts with slightly-different prototypes.
94  */
95
96 extern double strtod();
97
98 /*
99  *----------------------------------------------------------------
100  * Data structures related to variables.   These are used primarily
101  * in tclVar.c
102  *----------------------------------------------------------------
103  */
104
105 /*
106  * The following structure defines a variable trace, which is used to
107  * invoke a specific C procedure whenever certain operations are performed
108  * on a variable.
109  */
110
111 typedef struct VarTrace {
112     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
113                                  * by flags are performed on variable. */
114     ClientData clientData;      /* Argument to pass to proc. */
115     int flags;                  /* What events the trace procedure is
116                                  * interested in:  OR-ed combination of
117                                  * TCL_TRACE_READS, TCL_TRACE_WRITES, and
118                                  * TCL_TRACE_UNSETS. */
119     struct VarTrace *nextPtr;   /* Next in list of traces associated with
120                                  * a particular variable. */
121 } VarTrace;
122
123 /*
124  * When a variable trace is active (i.e. its associated procedure is
125  * executing), one of the following structures is linked into a list
126  * associated with the variable's interpreter.  The information in
127  * the structure is needed in order for Tcl to behave reasonably
128  * if traces are deleted while traces are active.
129  */
130
131 typedef struct ActiveVarTrace {
132     struct Var *varPtr;         /* Variable that's being traced. */
133     struct ActiveVarTrace *nextPtr;
134                                 /* Next in list of all active variable
135                                  * traces for the interpreter, or NULL
136                                  * if no more. */
137     VarTrace *nextTracePtr;     /* Next trace to check after current
138                                  * trace procedure returns;  if this
139                                  * trace gets deleted, must update pointer
140                                  * to avoid using free'd memory. */
141 } ActiveVarTrace;
142
143 /*
144  * The following structure describes an enumerative search in progress on
145  * an array variable;  this are invoked with options to the "array"
146  * command.
147  */
148
149 typedef struct ArraySearch {
150     int id;                     /* Integer id used to distinguish among
151                                  * multiple concurrent searches for the
152                                  * same array. */
153     struct Var *varPtr;         /* Pointer to array variable that's being
154                                  * searched. */
155     Tcl_HashSearch search;      /* Info kept by the hash module about
156                                  * progress through the array. */
157     Tcl_HashEntry *nextEntry;   /* Non-null means this is the next element
158                                  * to be enumerated (it's leftover from
159                                  * the Tcl_FirstHashEntry call or from
160                                  * an "array anymore" command).  NULL
161                                  * means must call Tcl_NextHashEntry
162                                  * to get value to return. */
163     struct ArraySearch *nextPtr;/* Next in list of all active searches
164                                  * for this variable, or NULL if this is
165                                  * the last one. */
166 } ArraySearch;
167
168 /*
169  * The structure below defines a variable, which associates a string name
170  * with a string value.  Pointers to these structures are kept as the
171  * values of hash table entries, and the name of each variable is stored
172  * in the hash entry.
173  */
174
175 typedef struct Var {
176     int valueLength;            /* Holds the number of non-null bytes
177                                  * actually occupied by the variable's
178                                  * current value in value.string (extra
179                                  * space is sometimes left for expansion).
180                                  * For array and global variables this is
181                                  * meaningless. */
182     int valueSpace;             /* Total number of bytes of space allocated
183                                  * at value.string.  0 means there is no
184                                  * space allocated. */
185     union {
186         char *string;           /* String value of variable, used for scalar
187                                  * variables and array elements.  Malloc-ed. */
188         Tcl_HashTable *tablePtr;/* For array variables, this points to
189                                  * information about the hash table used
190                                  * to implement the associative array.
191                                  * Points to malloc-ed data. */
192         struct Var *upvarPtr;   /* If this is a global variable being
193                                  * referred to in a procedure, or a variable
194                                  * created by "upvar", this field points to
195                                  * the record for the higher-level variable. */
196     } value;
197     Tcl_HashEntry *hPtr;        /* Hash table entry that refers to this
198                                  * variable, or NULL if the variable has
199                                  * been detached from its hash table (e.g.
200                                  * an array is deleted, but some of its
201                                  * elements are still referred to in upvars). */
202     int refCount;               /* Counts number of active uses of this
203                                  * variable, not including its main hash
204                                  * table entry: 1 for each additional variable
205                                  * whose upVarPtr points here, 1 for each
206                                  * nested trace active on variable.  This
207                                  * record can't be deleted until refCount
208                                  * becomes 0. */
209     VarTrace *tracePtr;         /* First in list of all traces set for this
210                                  * variable. */
211     ArraySearch *searchPtr;     /* First in list of all searches active
212                                  * for this variable, or NULL if none. */
213     int flags;                  /* Miscellaneous bits of information about
214                                  * variable.  See below for definitions. */
215 } Var;
216
217 /*
218  * Flag bits for variables:
219  *
220  * VAR_ARRAY    -               1 means this is an array variable rather
221  *                              than a scalar variable.
222  * VAR_UPVAR -                  1 means this variable just contains a
223  *                              pointer to another variable that has the
224  *                              real value.  Variables like this come
225  *                              about through the "upvar" and "global"
226  *                              commands.
227  * VAR_UNDEFINED -              1 means that the variable is currently
228  *                              undefined.  Undefined variables usually
229  *                              go away completely, but if an undefined
230  *                              variable has a trace on it, or if it is
231  *                              a global variable being used by a procedure,
232  *                              then it stays around even when undefined.
233  * VAR_TRACE_ACTIVE -           1 means that trace processing is currently
234  *                              underway for a read or write access, so
235  *                              new read or write accesses should not cause
236  *                              trace procedures to be called and the
237  *                              variable can't be deleted.
238  */
239
240 #define VAR_ARRAY               1
241 #define VAR_UPVAR               2
242 #define VAR_UNDEFINED           4
243 #define VAR_TRACE_ACTIVE        0x10
244
245 /*
246  *----------------------------------------------------------------
247  * Data structures related to procedures.   These are used primarily
248  * in tclProc.c
249  *----------------------------------------------------------------
250  */
251
252 /*
253  * The structure below defines an argument to a procedure, which
254  * consists of a name and an (optional) default value.
255  */
256
257 typedef struct Arg {
258     struct Arg *nextPtr;        /* Next argument for this procedure,
259                                  * or NULL if this is the last argument. */
260     char *defValue;             /* Pointer to arg's default value, or NULL
261                                  * if no default value. */
262     char name[4];               /* Name of argument starts here.  The name
263                                  * is followed by space for the default,
264                                  * if there is one.  The actual size of this
265                                  * field will be as large as necessary to
266                                  * hold both name and default value.  THIS
267                                  * MUST BE THE LAST FIELD IN THE STRUCTURE!! */
268 } Arg;
269
270 /*
271  * The structure below defines a command procedure, which consists of
272  * a collection of Tcl commands plus information about arguments and
273  * variables.
274  */
275
276 typedef struct Proc {
277     struct Interp *iPtr;        /* Interpreter for which this command
278                                  * is defined. */
279     int refCount;               /* Reference count:  1 if still present
280                                  * in command table plus 1 for each call
281                                  * to the procedure that is currently
282                                  * active.  This structure can be freed
283                                  * when refCount becomes zero. */
284     char *command;              /* Command that constitutes the body of
285                                  * the procedure (dynamically allocated). */
286     Arg *argPtr;                /* Pointer to first of procedure's formal
287                                  * arguments, or NULL if none. */
288 } Proc;
289
290 /*
291  * The structure below defines a command trace.  This is used to allow Tcl
292  * clients to find out whenever a command is about to be executed.
293  */
294
295 typedef struct Trace {
296     int level;                  /* Only trace commands at nesting level
297                                  * less than or equal to this. */
298     Tcl_CmdTraceProc *proc;     /* Procedure to call to trace command. */
299     ClientData clientData;      /* Arbitrary value to pass to proc. */
300     struct Trace *nextPtr;      /* Next in list of traces for this interp. */
301 } Trace;
302
303 /*
304  * The stucture below defines a deletion callback, which is
305  * a procedure to invoke just before an interpreter is deleted.
306  */
307
308 typedef struct DeleteCallback {
309     Tcl_InterpDeleteProc *proc; /* Procedure to call. */
310     ClientData clientData;      /* Value to pass to procedure. */
311     struct DeleteCallback *nextPtr;
312                                 /* Next in list of callbacks for this
313                                  * interpreter (or NULL for end of list). */
314 } DeleteCallback;
315
316 /*
317  * The structure below defines a frame, which is a procedure invocation.
318  * These structures exist only while procedures are being executed, and
319  * provide a sort of call stack.
320  */
321
322 typedef struct CallFrame {
323     Tcl_HashTable varTable;     /* Hash table containing all of procedure's
324                                  * local variables. */
325     int level;                  /* Level of this procedure, for "uplevel"
326                                  * purposes (i.e. corresponds to nesting of
327                                  * callerVarPtr's, not callerPtr's).  1 means
328                                  * outer-most procedure, 0 means top-level. */
329     int argc;                   /* This and argv below describe name and
330                                  * arguments for this procedure invocation. */
331     char **argv;                /* Array of arguments. */
332     struct CallFrame *callerPtr;
333                                 /* Value of interp->framePtr when this
334                                  * procedure was invoked (i.e. next in
335                                  * stack of all active procedures). */
336     struct CallFrame *callerVarPtr;
337                                 /* Value of interp->varFramePtr when this
338                                  * procedure was invoked (i.e. determines
339                                  * variable scoping within caller;  same
340                                  * as callerPtr unless an "uplevel" command
341                                  * or something equivalent was active in
342                                  * the caller). */
343 } CallFrame;
344
345 /*
346  * The structure below defines one history event (a previously-executed
347  * command that can be re-executed in whole or in part).
348  */
349
350 typedef struct {
351     char *command;              /* String containing previously-executed
352                                  * command. */
353     int bytesAvl;               /* Total # of bytes available at *event (not
354                                  * all are necessarily in use now). */
355 } HistoryEvent;
356
357 /*
358  *----------------------------------------------------------------
359  * Data structures related to history.   These are used primarily
360  * in tclHistory.c
361  *----------------------------------------------------------------
362  */
363
364 /*
365  * The structure below defines a pending revision to the most recent
366  * history event.  Changes are linked together into a list and applied
367  * during the next call to Tcl_RecordHistory.  See the comments at the
368  * beginning of tclHistory.c for information on revisions.
369  */
370
371 typedef struct HistoryRev {
372     int firstIndex;             /* Index of the first byte to replace in
373                                  * current history event. */
374     int lastIndex;              /* Index of last byte to replace in
375                                  * current history event. */
376     int newSize;                /* Number of bytes in newBytes. */
377     char *newBytes;             /* Replacement for the range given by
378                                  * firstIndex and lastIndex (malloced). */
379     struct HistoryRev *nextPtr; /* Next in chain of revisions to apply, or
380                                  * NULL for end of list. */
381 } HistoryRev;
382
383 /*
384  *----------------------------------------------------------------
385  * Data structures related to files.  These are used primarily in
386  * tclUnixUtil.c and tclUnixAZ.c.
387  *----------------------------------------------------------------
388  */
389
390 /*
391  * The data structure below defines an open file (or connection to
392  * a process pipeline) as returned by the "open" command.
393  */
394
395 typedef struct OpenFile {
396     FILE *f;                    /* Stdio file to use for reading and/or
397                                  * writing. */
398     FILE *f2;                   /* Normally NULL.  In the special case of
399                                  * a command pipeline with pipes for both
400                                  * input and output, this is a stdio file
401                                  * to use for writing to the pipeline. */
402     int permissions;            /* OR-ed combination of TCL_FILE_READABLE
403                                  * and TCL_FILE_WRITABLE. */
404     int numPids;                /* If this is a connection to a process
405                                  * pipeline, gives number of processes
406                                  * in pidPtr array below;  otherwise it
407                                  * is 0. */
408     int *pidPtr;                /* Pointer to malloc-ed array of child
409                                  * process ids (numPids of them), or NULL
410                                  * if this isn't a connection to a process
411                                  * pipeline. */
412     int errorId;                /* File id of file that receives error
413                                  * output from pipeline.  -1 means not
414                                  * used (i.e. this is a normal file). */
415 } OpenFile;
416
417 /*
418  *----------------------------------------------------------------
419  * Data structures related to expressions.  These are used only in
420  * tclExpr.c.
421  *----------------------------------------------------------------
422  */
423
424 /*
425  * The data structure below defines a math function (e.g. sin or hypot)
426  * for use in Tcl expressions.
427  */
428
429 #define MAX_MATH_ARGS 5
430 typedef struct MathFunc {
431     int numArgs;                /* Number of arguments for function. */
432     Tcl_ValueType argTypes[MAX_MATH_ARGS];
433                                 /* Acceptable types for each argument. */
434     Tcl_MathProc *proc;         /* Procedure that implements this function. */
435     ClientData clientData;      /* Additional argument to pass to the function
436                                  * when invoking it. */
437 } MathFunc;
438
439 /*
440  *----------------------------------------------------------------
441  * One of the following structures exists for each command in
442  * an interpreter.  The Tcl_Command opaque type actually refers
443  * to these structures.
444  *----------------------------------------------------------------
445  */
446
447 typedef struct Command {
448     Tcl_HashEntry *hPtr;        /* Pointer to the hash table entry in
449                                  * interp->commandTable that refers to
450                                  * this command.  Used to get a command's
451                                  * name from its Tcl_Command handle.  NULL
452                                  * means that the hash table entry has
453                                  * been removed already (this can happen
454                                  * if deleteProc causes the command to be
455                                  * deleted or recreated). */
456     Tcl_CmdProc *proc;          /* Procedure to process command. */
457     ClientData clientData;      /* Arbitrary value to pass to proc. */
458     Tcl_CmdDeleteProc *deleteProc;
459                                 /* Procedure to invoke when deleting
460                                  * command. */
461     ClientData deleteData;      /* Arbitrary value to pass to deleteProc
462                                  * (usually the same as clientData). */
463     int deleted;                /* Means that the command is in the process
464                                  * of being deleted (its deleteProc is
465                                  * currently executing).  Any other attempts
466                                  * to delete the command should be ignored. */
467 } Command;
468
469 /*
470  *----------------------------------------------------------------
471  * This structure defines an interpreter, which is a collection of
472  * commands plus other state information related to interpreting
473  * commands, such as variable storage.  Primary responsibility for
474  * this data structure is in tclBasic.c, but almost every Tcl
475  * source file uses something in here.
476  *----------------------------------------------------------------
477  */
478
479 typedef struct Interp {
480
481     /*
482      * Note:  the first three fields must match exactly the fields in
483      * a Tcl_Interp struct (see tcl.h).  If you change one, be sure to
484      * change the other.
485      */
486
487     char *result;               /* Points to result returned by last
488                                  * command. */
489     Tcl_FreeProc *freeProc;     /* Zero means result is statically allocated.
490                                  * If non-zero, gives address of procedure
491                                  * to invoke to free the result.  Must be
492                                  * freed by Tcl_Eval before executing next
493                                  * command. */
494     int errorLine;              /* When TCL_ERROR is returned, this gives
495                                  * the line number within the command where
496                                  * the error occurred (1 means first line). */
497     Tcl_HashTable commandTable; /* Contains all of the commands currently
498                                  * registered in this interpreter.  Indexed
499                                  * by strings; values have type (Command *). */
500     Tcl_HashTable mathFuncTable;/* Contains all of the math functions currently
501                                  * defined for the interpreter.  Indexed by
502                                  * strings (function names);  values have
503                                  * type (MathFunc *). */
504
505     /*
506      * Information related to procedures and variables.  See tclProc.c
507      * and tclvar.c for usage.
508      */
509
510     Tcl_HashTable globalTable;  /* Contains all global variables for
511                                  * interpreter. */
512     int numLevels;              /* Keeps track of how many nested calls to
513                                  * Tcl_Eval are in progress for this
514                                  * interpreter.  It's used to delay deletion
515                                  * of the table until all Tcl_Eval invocations
516                                  * are completed. */
517     int maxNestingDepth;        /* If numLevels exceeds this value then Tcl
518                                  * assumes that infinite recursion has
519                                  * occurred and it generates an error. */
520     CallFrame *framePtr;        /* Points to top-most in stack of all nested
521                                  * procedure invocations.  NULL means there
522                                  * are no active procedures. */
523     CallFrame *varFramePtr;     /* Points to the call frame whose variables
524                                  * are currently in use (same as framePtr
525                                  * unless an "uplevel" command is being
526                                  * executed).  NULL means no procedure is
527                                  * active or "uplevel 0" is being exec'ed. */
528     ActiveVarTrace *activeTracePtr;
529                                 /* First in list of active traces for interp,
530                                  * or NULL if no active traces. */
531     int returnCode;             /* Completion code to return if current
532                                  * procedure exits with a TCL_RETURN code. */
533     char *errorInfo;            /* Value to store in errorInfo if returnCode
534                                  * is TCL_ERROR.  Malloc'ed, may be NULL */
535     char *errorCode;            /* Value to store in errorCode if returnCode
536                                  * is TCL_ERROR.  Malloc'ed, may be NULL */
537
538     /*
539      * Information related to history:
540      */
541
542     int numEvents;              /* Number of previously-executed commands
543                                  * to retain. */
544     HistoryEvent *events;       /* Array containing numEvents entries
545                                  * (dynamically allocated). */
546     int curEvent;               /* Index into events of place where current
547                                  * (or most recent) command is recorded. */
548     int curEventNum;            /* Event number associated with the slot
549                                  * given by curEvent. */
550     HistoryRev *revPtr;         /* First in list of pending revisions. */
551     char *historyFirst;         /* First char. of current command executed
552                                  * from history module or NULL if none. */
553     int revDisables;            /* 0 means history revision OK;  > 0 gives
554                                  * a count of number of times revision has
555                                  * been disabled. */
556     char *evalFirst;            /* If TCL_RECORD_BOUNDS flag set, Tcl_Eval
557                                  * sets this field to point to the first
558                                  * char. of text from which the current
559                                  * command came.  Otherwise Tcl_Eval sets
560                                  * this to NULL. */
561     char *evalLast;             /* Similar to evalFirst, except points to
562                                  * last character of current command. */
563
564     /*
565      * Information used by Tcl_AppendResult to keep track of partial
566      * results.  See Tcl_AppendResult code for details.
567      */
568
569     char *appendResult;         /* Storage space for results generated
570                                  * by Tcl_AppendResult.  Malloc-ed.  NULL
571                                  * means not yet allocated. */
572     int appendAvl;              /* Total amount of space available at
573                                  * partialResult. */
574     int appendUsed;             /* Number of non-null bytes currently
575                                  * stored at partialResult. */
576
577     /*
578      * A cache of compiled regular expressions.  See Tcl_RegExpCompile
579      * in tclUtil.c for details.
580      */
581
582 #define NUM_REGEXPS 5
583     char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
584                                  * regular expression patterns.  NULL
585                                  * means that this slot isn't used.
586                                  * Malloc-ed. */
587     int patLengths[NUM_REGEXPS];/* Number of non-null characters in
588                                  * corresponding entry in patterns.
589                                  * -1 means entry isn't used. */
590     regexp *regexps[NUM_REGEXPS];
591                                 /* Compiled forms of above strings.  Also
592                                  * malloc-ed, or NULL if not in use yet. */
593
594     /*
595      * Information used by Tcl_PrintDouble:
596      */
597
598     char pdFormat[10];          /* Format string used by Tcl_PrintDouble. */
599     int pdPrec;                 /* Current precision (used to restore the
600                                  * the tcl_precision variable after a bogus
601                                  * value has been put into it). */
602
603     /*
604      * Miscellaneous information:
605      */
606
607     int cmdCount;               /* Total number of times a command procedure
608                                  * has been called for this interpreter. */
609     int noEval;                 /* Non-zero means no commands should actually
610                                  * be executed:  just parse only.  Used in
611                                  * expressions when the result is already
612                                  * determined. */
613     int evalFlags;              /* Flags to control next call to Tcl_Eval.
614                                  * Normally zero, but may be set before
615                                  * calling Tcl_Eval.  See below for valid
616                                  * values. */
617     char *termPtr;              /* Character just after the last one in
618                                  * a command.  Set by Tcl_Eval before
619                                  * returning. */
620     char *scriptFile;           /* NULL means there is no nested source
621                                  * command active;  otherwise this points to
622                                  * the name of the file being sourced (it's
623                                  * not malloc-ed:  it points to an argument
624                                  * to Tcl_EvalFile. */
625     int flags;                  /* Various flag bits.  See below. */
626     Trace *tracePtr;            /* List of traces for this interpreter. */
627     DeleteCallback *deleteCallbackPtr;
628                                 /* First in list of callbacks to invoke when
629                                  * interpreter is deleted. */
630     char resultSpace[TCL_RESULT_SIZE+1];
631                                 /* Static space for storing small results. */
632 } Interp;
633
634 /*
635  * EvalFlag bits for Interp structures:
636  *
637  * TCL_BRACKET_TERM     1 means that the current script is terminated by
638  *                      a close bracket rather than the end of the string.
639  * TCL_RECORD_BOUNDS    Tells Tcl_Eval to record information in the
640  *                      evalFirst and evalLast fields for each command
641  *                      executed directly from the string (top-level
642  *                      commands and those from command substitution).
643  * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with
644  *                      a code other than TCL_OK or TCL_ERROR;  0 means
645  *                      codes other than these should be turned into errors.
646  */
647
648 #define TCL_BRACKET_TERM        1
649 #define TCL_RECORD_BOUNDS       2
650 #define TCL_ALLOW_EXCEPTIONS    4
651
652 /*
653  * Flag bits for Interp structures:
654  *
655  * DELETED:             Non-zero means the interpreter has been deleted:
656  *                      don't process any more commands for it, and destroy
657  *                      the structure as soon as all nested invocations of
658  *                      Tcl_Eval are done.
659  * ERR_IN_PROGRESS:     Non-zero means an error unwind is already in progress.
660  *                      Zero means a command proc has been invoked since last
661  *                      error occured.
662  * ERR_ALREADY_LOGGED:  Non-zero means information has already been logged
663  *                      in $errorInfo for the current Tcl_Eval instance,
664  *                      so Tcl_Eval needn't log it (used to implement the
665  *                      "error message log" command).
666  * ERROR_CODE_SET:      Non-zero means that Tcl_SetErrorCode has been
667  *                      called to record information for the current
668  *                      error.  Zero means Tcl_Eval must clear the
669  *                      errorCode variable if an error is returned.
670  * EXPR_INITIALIZED:    1 means initialization specific to expressions has
671  *                      been carried out.
672  */
673
674 #define DELETED                 1
675 #define ERR_IN_PROGRESS         2
676 #define ERR_ALREADY_LOGGED      4
677 #define ERROR_CODE_SET          8
678 #define EXPR_INITIALIZED        0x10
679
680 /*
681  * Default value for the pdPrec and pdFormat fields of interpreters:
682  */
683
684 #define DEFAULT_PD_PREC 6
685 #define DEFAULT_PD_FORMAT "%g"
686
687 /*
688  *----------------------------------------------------------------
689  * Data structures related to command parsing.   These are used in
690  * tclParse.c and its clients.
691  *----------------------------------------------------------------
692  */
693
694 /*
695  * The following data structure is used by various parsing procedures
696  * to hold information about where to store the results of parsing
697  * (e.g. the substituted contents of a quoted argument, or the result
698  * of a nested command).  At any given time, the space available
699  * for output is fixed, but a procedure may be called to expand the
700  * space available if the current space runs out.
701  */
702
703 typedef struct ParseValue {
704     char *buffer;               /* Address of first character in
705                                  * output buffer. */
706     char *next;                 /* Place to store next character in
707                                  * output buffer. */
708     char *end;                  /* Address of the last usable character
709                                  * in the buffer. */
710     void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
711                                 /* Procedure to call when space runs out;
712                                  * it will make more space. */
713     ClientData clientData;      /* Arbitrary information for use of
714                                  * expandProc. */
715 } ParseValue;
716
717 /*
718  * A table used to classify input characters to assist in parsing
719  * Tcl commands.  The table should be indexed with a signed character
720  * using the CHAR_TYPE macro.  The character may have a negative
721  * value.
722  */
723
724 extern char tclTypeTable[];
725 #define CHAR_TYPE(c) (tclTypeTable+128)[c]
726
727 /*
728  * Possible values returned by CHAR_TYPE:
729  *
730  * TCL_NORMAL -         All characters that don't have special significance
731  *                      to the Tcl language.
732  * TCL_SPACE -          Character is space, tab, or return.
733  * TCL_COMMAND_END -    Character is newline or null or semicolon or
734  *                      close-bracket.
735  * TCL_QUOTE -          Character is a double-quote.
736  * TCL_OPEN_BRACKET -   Character is a "[".
737  * TCL_OPEN_BRACE -     Character is a "{".
738  * TCL_CLOSE_BRACE -    Character is a "}".
739  * TCL_BACKSLASH -      Character is a "\".
740  * TCL_DOLLAR -         Character is a "$".
741  */
742
743 #define TCL_NORMAL              0
744 #define TCL_SPACE               1
745 #define TCL_COMMAND_END         2
746 #define TCL_QUOTE               3
747 #define TCL_OPEN_BRACKET        4
748 #define TCL_OPEN_BRACE          5
749 #define TCL_CLOSE_BRACE         6
750 #define TCL_BACKSLASH           7
751 #define TCL_DOLLAR              8
752
753 /*
754  * Maximum number of levels of nesting permitted in Tcl commands (used
755  * to catch infinite recursion).
756  */
757
758 #define MAX_NESTING_DEPTH       1000
759
760 /*
761  * The macro below is used to modify a "char" value (e.g. by casting
762  * it to an unsigned character) so that it can be used safely with
763  * macros such as isspace.
764  */
765
766 #define UCHAR(c) ((unsigned char) (c))
767
768 /*
769  * Given a size or address, the macro below "aligns" it to the machine's
770  * memory unit size (e.g. an 8-byte boundary) so that anything can be
771  * placed at the aligned address without fear of an alignment error.
772  */
773
774 #define TCL_ALIGN(x) ((x + 7) & ~7)
775
776 /*
777  * Variables shared among Tcl modules but not used by the outside
778  * world:
779  */
780
781 extern int              tclNumFiles;
782 extern OpenFile **      tclOpenFiles;
783
784 /*
785  *----------------------------------------------------------------
786  * Procedures shared among Tcl modules but not used by the outside
787  * world:
788  *----------------------------------------------------------------
789  */
790
791 #define panic(a)  assert(a)
792 extern void             TclCopyAndCollapse _ANSI_ARGS_((int count, char *src,
793                             char *dst));
794 extern void             TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
795                             Tcl_HashTable *tablePtr));
796 extern void             TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr,
797                             int needed));
798 extern void             TclExprFloatError _ANSI_ARGS_((Tcl_Interp *interp,
799                             double value));
800 extern int              TclFindElement _ANSI_ARGS_((Tcl_Interp *interp,
801                             char *list, char **elementPtr, char **nextPtr,
802                             int *sizePtr, int *bracePtr));
803 extern Proc *           TclFindProc _ANSI_ARGS_((Interp *iPtr,
804                             char *procName));
805 extern int              TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
806                             char *string, CallFrame **framePtrPtr));
807 extern int              TclGetListIndex _ANSI_ARGS_((Tcl_Interp *interp,
808                             char *string, int *indexPtr));
809 extern Proc *           TclIsProc _ANSI_ARGS_((Command *cmdPtr));
810 extern int              TclNeedSpace _ANSI_ARGS_((char *start, char *end));
811 extern int              TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp,
812                             char *string, char **termPtr, ParseValue *pvPtr));
813 extern int              TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp,
814                             char *string, int flags, char **termPtr,
815                             ParseValue *pvPtr));
816 extern int              TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp,
817                             char *string, int termChar, int flags,
818                             char **termPtr, ParseValue *pvPtr));
819 extern int              TclParseWords _ANSI_ARGS_((Tcl_Interp *interp,
820                             char *string, int flags, int maxWords,
821                             char **termPtr, int *argcPtr, char **argv,
822                             ParseValue *pvPtr));
823 extern char *           TclPrecTraceProc _ANSI_ARGS_((ClientData clientData,
824                             Tcl_Interp *interp, char *name1, char *name2,
825                             int flags));
826 extern void             TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
827 extern int              TclUpdateReturnInfo _ANSI_ARGS_((Interp *iPtr));
828 extern char *           TclWordEnd _ANSI_ARGS_((char *start, int nested,
829                             int *semiPtr));
830
831 /*
832  *----------------------------------------------------------------
833  * Command procedures in the generic core:
834  *----------------------------------------------------------------
835  */
836
837 extern int      Tcl_AppendCmd _ANSI_ARGS_((ClientData clientData,
838                     Tcl_Interp *interp, int argc, char **argv));
839 extern int      Tcl_ArrayCmd _ANSI_ARGS_((ClientData clientData,
840                     Tcl_Interp *interp, int argc, char **argv));
841 extern int      Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData,
842                     Tcl_Interp *interp, int argc, char **argv));
843 extern int      Tcl_CaseCmd _ANSI_ARGS_((ClientData clientData,
844                     Tcl_Interp *interp, int argc, char **argv));
845 extern int      Tcl_CatchCmd _ANSI_ARGS_((ClientData clientData,
846                     Tcl_Interp *interp, int argc, char **argv));
847 extern int      Tcl_ConcatCmd _ANSI_ARGS_((ClientData clientData,
848                     Tcl_Interp *interp, int argc, char **argv));
849 extern int      Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData,
850                     Tcl_Interp *interp, int argc, char **argv));
851 extern int      Tcl_ErrorCmd _ANSI_ARGS_((ClientData clientData,
852                     Tcl_Interp *interp, int argc, char **argv));
853 extern int      Tcl_EvalCmd _ANSI_ARGS_((ClientData clientData,
854                     Tcl_Interp *interp, int argc, char **argv));
855 extern int      Tcl_ExprCmd _ANSI_ARGS_((ClientData clientData,
856                     Tcl_Interp *interp, int argc, char **argv));
857 extern int      Tcl_ForCmd _ANSI_ARGS_((ClientData clientData,
858                     Tcl_Interp *interp, int argc, char **argv));
859 extern int      Tcl_ForeachCmd _ANSI_ARGS_((ClientData clientData,
860                     Tcl_Interp *interp, int argc, char **argv));
861 extern int      Tcl_FormatCmd _ANSI_ARGS_((ClientData clientData,
862                     Tcl_Interp *interp, int argc, char **argv));
863 extern int      Tcl_GlobalCmd _ANSI_ARGS_((ClientData clientData,
864                     Tcl_Interp *interp, int argc, char **argv));
865 extern int      Tcl_HistoryCmd _ANSI_ARGS_((ClientData clientData,
866                     Tcl_Interp *interp, int argc, char **argv));
867 extern int      Tcl_IfCmd _ANSI_ARGS_((ClientData clientData,
868                     Tcl_Interp *interp, int argc, char **argv));
869 extern int      Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData,
870                     Tcl_Interp *interp, int argc, char **argv));
871 extern int      Tcl_InfoCmd _ANSI_ARGS_((ClientData clientData,
872                     Tcl_Interp *interp, int argc, char **argv));
873 extern int      Tcl_JoinCmd _ANSI_ARGS_((ClientData clientData,
874                     Tcl_Interp *interp, int argc, char **argv));
875 extern int      Tcl_LappendCmd _ANSI_ARGS_((ClientData clientData,
876                     Tcl_Interp *interp, int argc, char **argv));
877 extern int      Tcl_LindexCmd _ANSI_ARGS_((ClientData clientData,
878                     Tcl_Interp *interp, int argc, char **argv));
879 extern int      Tcl_LinsertCmd _ANSI_ARGS_((ClientData clientData,
880                     Tcl_Interp *interp, int argc, char **argv));
881 extern int      Tcl_LlengthCmd _ANSI_ARGS_((ClientData clientData,
882                     Tcl_Interp *interp, int argc, char **argv));
883 extern int      Tcl_ListCmd _ANSI_ARGS_((ClientData clientData,
884                     Tcl_Interp *interp, int argc, char **argv));
885 extern int      Tcl_LrangeCmd _ANSI_ARGS_((ClientData clientData,
886                     Tcl_Interp *interp, int argc, char **argv));
887 extern int      Tcl_LreplaceCmd _ANSI_ARGS_((ClientData clientData,
888                     Tcl_Interp *interp, int argc, char **argv));
889 extern int      Tcl_LsearchCmd _ANSI_ARGS_((ClientData clientData,
890                     Tcl_Interp *interp, int argc, char **argv));
891 extern int      Tcl_LsortCmd _ANSI_ARGS_((ClientData clientData,
892                     Tcl_Interp *interp, int argc, char **argv));
893 extern int      Tcl_ProcCmd _ANSI_ARGS_((ClientData clientData,
894                     Tcl_Interp *interp, int argc, char **argv));
895 extern int      Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData,
896                     Tcl_Interp *interp, int argc, char **argv));
897 extern int      Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData,
898                     Tcl_Interp *interp, int argc, char **argv));
899 extern int      Tcl_RenameCmd _ANSI_ARGS_((ClientData clientData,
900                     Tcl_Interp *interp, int argc, char **argv));
901 extern int      Tcl_ReturnCmd _ANSI_ARGS_((ClientData clientData,
902                     Tcl_Interp *interp, int argc, char **argv));
903 extern int      Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData,
904                     Tcl_Interp *interp, int argc, char **argv));
905 extern int      Tcl_SetCmd _ANSI_ARGS_((ClientData clientData,
906                     Tcl_Interp *interp, int argc, char **argv));
907 extern int      Tcl_SplitCmd _ANSI_ARGS_((ClientData clientData,
908                     Tcl_Interp *interp, int argc, char **argv));
909 extern int      Tcl_StringCmd _ANSI_ARGS_((ClientData clientData,
910                     Tcl_Interp *interp, int argc, char **argv));
911 extern int      Tcl_SubstCmd _ANSI_ARGS_((ClientData clientData,
912                     Tcl_Interp *interp, int argc, char **argv));
913 extern int      Tcl_SwitchCmd _ANSI_ARGS_((ClientData clientData,
914                     Tcl_Interp *interp, int argc, char **argv));
915 extern int      Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData,
916                     Tcl_Interp *interp, int argc, char **argv));
917 extern int      Tcl_UnsetCmd _ANSI_ARGS_((ClientData clientData,
918                     Tcl_Interp *interp, int argc, char **argv));
919 extern int      Tcl_UplevelCmd _ANSI_ARGS_((ClientData clientData,
920                     Tcl_Interp *interp, int argc, char **argv));
921 extern int      Tcl_UpvarCmd _ANSI_ARGS_((ClientData clientData,
922                     Tcl_Interp *interp, int argc, char **argv));
923 extern int      Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData,
924                     Tcl_Interp *interp, int argc, char **argv));
925 extern int      Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
926                     Tcl_Interp *interp, int argc, char **argv));
927 extern int      Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
928                     Tcl_Interp *interp, int argc, char **argv));
929
930 /*
931  *----------------------------------------------------------------
932  * Command procedures in the UNIX core:
933  *----------------------------------------------------------------
934  */
935
936 extern int      Tcl_CdCmd _ANSI_ARGS_((ClientData clientData,
937                     Tcl_Interp *interp, int argc, char **argv));
938 extern int      Tcl_CloseCmd _ANSI_ARGS_((ClientData clientData,
939                     Tcl_Interp *interp, int argc, char **argv));
940 extern int      Tcl_EofCmd _ANSI_ARGS_((ClientData clientData,
941                     Tcl_Interp *interp, int argc, char **argv));
942 extern int      Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData,
943                     Tcl_Interp *interp, int argc, char **argv));
944 extern int      Tcl_ExitCmd _ANSI_ARGS_((ClientData clientData,
945                     Tcl_Interp *interp, int argc, char **argv));
946 extern int      Tcl_FileCmd _ANSI_ARGS_((ClientData clientData,
947                     Tcl_Interp *interp, int argc, char **argv));
948 extern int      Tcl_FlushCmd _ANSI_ARGS_((ClientData clientData,
949                     Tcl_Interp *interp, int argc, char **argv));
950 extern int      Tcl_GetsCmd _ANSI_ARGS_((ClientData clientData,
951                     Tcl_Interp *interp, int argc, char **argv));
952 extern int      Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData,
953                     Tcl_Interp *interp, int argc, char **argv));
954 extern int      Tcl_OpenCmd _ANSI_ARGS_((ClientData clientData,
955                     Tcl_Interp *interp, int argc, char **argv));
956 extern int      Tcl_PutsCmd _ANSI_ARGS_((ClientData clientData,
957                     Tcl_Interp *interp, int argc, char **argv));
958 extern int      Tcl_PidCmd _ANSI_ARGS_((ClientData clientData,
959                     Tcl_Interp *interp, int argc, char **argv));
960 extern int      Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData,
961                     Tcl_Interp *interp, int argc, char **argv));
962 extern int      Tcl_ReadCmd _ANSI_ARGS_((ClientData clientData,
963                     Tcl_Interp *interp, int argc, char **argv));
964 extern int      Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData,
965                     Tcl_Interp *interp, int argc, char **argv));
966 extern int      Tcl_SourceCmd _ANSI_ARGS_((ClientData clientData,
967                     Tcl_Interp *interp, int argc, char **argv));
968 extern int      Tcl_TellCmd _ANSI_ARGS_((ClientData clientData,
969                     Tcl_Interp *interp, int argc, char **argv));
970 extern int      Tcl_TimeCmd _ANSI_ARGS_((ClientData clientData,
971                     Tcl_Interp *interp, int argc, char **argv));
972
973 #endif /* _TCLINT */