home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / tclint.h < prev    next >
C/C++ Source or Header  |  1994-09-16  |  37KB  |  943 lines

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