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