Home | History | Annotate | Line # | Download | only in csh
csh.h revision 1.29
      1  1.29     joerg /* $NetBSD: csh.h,v 1.29 2020/04/03 18:11:29 joerg Exp $ */
      2   1.9       cgd 
      3   1.1       cgd /*-
      4   1.6   mycroft  * Copyright (c) 1980, 1991, 1993
      5   1.6   mycroft  *	The Regents of the University of California.  All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1       cgd  * modification, are permitted provided that the following conditions
      9   1.1       cgd  * are met:
     10   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15  1.15       agc  * 3. Neither the name of the University nor the names of its contributors
     16   1.1       cgd  *    may be used to endorse or promote products derived from this software
     17   1.1       cgd  *    without specific prior written permission.
     18   1.1       cgd  *
     19   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29   1.1       cgd  * SUCH DAMAGE.
     30   1.1       cgd  *
     31   1.9       cgd  *	@(#)csh.h	8.1 (Berkeley) 5/31/93
     32   1.1       cgd  */
     33   1.1       cgd 
     34  1.14       wiz #ifndef _CSH_H_
     35  1.14       wiz #define _CSH_H_
     36  1.14       wiz 
     37   1.1       cgd /*
     38   1.1       cgd  * Fundamental definitions which may vary from system to system.
     39   1.1       cgd  *
     40  1.12  christos  *	BUFSIZE		The i/o buffering size; also limits word size
     41   1.1       cgd  *	MAILINTVL	How often to mailcheck; more often is more expensive
     42   1.1       cgd  */
     43  1.12  christos #ifndef BUFSIZE
     44  1.12  christos #define	BUFSIZE	4096		/* default buffer size */
     45  1.12  christos #endif				/* BUFSIZE */
     46   1.1       cgd 
     47  1.14       wiz #define FORKSLEEP 10		/* delay loop on non-interactive fork failure */
     48  1.14       wiz #define	MAILINTVL 600		/* 10 minutes */
     49   1.1       cgd 
     50   1.1       cgd /*
     51   1.1       cgd  * The shell moves std in/out/diag and the old std input away from units
     52   1.1       cgd  * 0, 1, and 2 so that it is easy to set up these standards for invoked
     53   1.1       cgd  * commands.
     54   1.1       cgd  */
     55  1.14       wiz #define	FSHTTY 15		/* /dev/tty when manip pgrps */
     56  1.14       wiz #define	FSHIN 16		/* Preferred desc for shell input */
     57  1.14       wiz #define	FSHOUT 17		/* ... shell output */
     58  1.14       wiz #define	FSHERR 18		/* ... shell diagnostics */
     59   1.1       cgd #define	FOLDSTD	19		/* ... old std input */
     60   1.1       cgd 
     61   1.1       cgd #ifdef PROF
     62  1.14       wiz #define	xexit(n) done(n)
     63   1.1       cgd #endif
     64   1.1       cgd 
     65   1.1       cgd #ifdef SHORT_STRINGS
     66   1.1       cgd typedef short Char;
     67   1.1       cgd 
     68   1.1       cgd #define SAVE(a) (Strsave(str2short(a)))
     69   1.1       cgd #else
     70   1.1       cgd typedef char Char;
     71   1.1       cgd 
     72   1.1       cgd #define SAVE(a) (strsave(a))
     73   1.1       cgd #endif
     74   1.1       cgd 
     75   1.6   mycroft /*
     76   1.6   mycroft  * Make sure a variable is not stored in a register by taking its address
     77   1.6   mycroft  * This is used where variables might be clobbered by longjmp.
     78   1.6   mycroft  */
     79   1.6   mycroft #define UNREGISTER(a)	(void) &a
     80   1.6   mycroft 
     81   1.1       cgd typedef void *ioctl_t;		/* Third arg of ioctl */
     82   1.1       cgd 
     83   1.1       cgd #include "const.h"
     84   1.1       cgd #include "char.h"
     85  1.10  christos #include "errnum.h"
     86   1.1       cgd 
     87  1.14       wiz #define xmalloc(i) Malloc(i)
     88  1.14       wiz #define xrealloc(p, i) Realloc(p, i)
     89  1.14       wiz #define xcalloc(n, s) Calloc(n, s)
     90   1.6   mycroft 
     91   1.6   mycroft #include <stdio.h>
     92  1.29     joerg extern FILE *cshin, *cshout, *csherr;
     93   1.1       cgd 
     94  1.14       wiz #define	isdir(d) (S_ISDIR(d.st_mode))
     95   1.1       cgd 
     96  1.14       wiz #define	eq(a, b) (Strcmp(a, b) == 0)
     97   1.1       cgd 
     98   1.1       cgd /* globone() flags */
     99  1.14       wiz #define G_ERROR	0		/* default action: error if multiple words */
    100  1.14       wiz #define G_IGNORE 1		/* ignore the rest of the words */
    101  1.14       wiz #define G_APPEND 2		/* make a sentence by cat'ing the words */
    102   1.1       cgd 
    103   1.1       cgd /*
    104   1.1       cgd  * Global flags
    105   1.1       cgd  */
    106  1.29     joerg extern int child;		/* Child shell ... errors cause exit */
    107  1.29     joerg extern int chkstop;		/* Warned of stopped jobs... allow exit */
    108  1.29     joerg extern int didfds;		/* Have setup i/o fd's for child */
    109  1.29     joerg extern int doneinp;		/* EOF indicator after reset from readc */
    110  1.29     joerg extern int exiterr;		/* Exit if error or non-zero exit status */
    111  1.29     joerg extern int haderr;		/* Reset was because of an error */
    112  1.29     joerg extern int havhash;		/* path hashing is available */
    113  1.29     joerg extern int intact;		/* We are interactive... therefore prompt */
    114  1.29     joerg extern int intty;		/* Input is a tty */
    115  1.29     joerg extern int justpr;		/* Just print because of :p hist mod */
    116  1.29     joerg extern int loginsh;		/* We are a loginsh -> .login/.logout */
    117  1.29     joerg extern int neednote;		/* Need to pnotify() */
    118  1.29     joerg extern int noexec;		/* Don't execute, just syntax check */
    119  1.29     joerg extern int pjobs;		/* want to print jobs if interrupted */
    120  1.29     joerg extern int setintr;		/* Set interrupts on/off -> Wait intr... */
    121  1.29     joerg extern int timflg;		/* Time the next waited for command */
    122   1.1       cgd 
    123   1.1       cgd #ifdef FILEC
    124  1.21  christos extern int filec;		/* doing filename expansion */
    125   1.1       cgd #endif
    126   1.1       cgd 
    127   1.1       cgd /*
    128   1.1       cgd  * Global i/o info
    129   1.1       cgd  */
    130  1.29     joerg extern Char *arginp;		/* Argument input for sh -c and internal `xx` */
    131  1.29     joerg extern Char *ffile;		/* Name of shell file for $0 */
    132  1.29     joerg extern int onelflg;		/* 2 -> need line for -t, 1 -> exit on read */
    133   1.1       cgd 
    134  1.14       wiz extern char *seterr;		/* Error message from scanner/parser */
    135  1.29     joerg extern Char *shtemp;		/* Temp name for << shell files in /tmp */
    136   1.1       cgd 
    137  1.14       wiz #include <sys/resource.h>
    138  1.14       wiz #include <sys/time.h>
    139   1.6   mycroft #include <sys/types.h>
    140   1.1       cgd 
    141  1.29     joerg extern struct timespec time0;	/* Time at which the shell started */
    142  1.29     joerg extern struct rusage ru0;
    143   1.1       cgd 
    144   1.1       cgd /*
    145   1.1       cgd  * Miscellany
    146   1.1       cgd  */
    147  1.29     joerg extern time_t chktim;		/* Time mail last checked */
    148  1.29     joerg extern Char *doldol;		/* Character pid for $$ */
    149  1.29     joerg extern pid_t backpid;		/* Pid of the last background process */
    150  1.29     joerg extern gid_t egid, gid;		/* Invokers gid */
    151  1.29     joerg extern uid_t euid, uid;		/* Invokers uid */
    152  1.29     joerg extern int shpgrp;		/* Pgrp of shell */
    153  1.29     joerg extern int tpgrp;		/* Terminal process group */
    154   1.1       cgd 
    155   1.1       cgd /* If tpgrp is -1, leave tty alone! */
    156  1.29     joerg extern int opgrp;		/* Initial pgrp and tty pgrp */
    157   1.1       cgd 
    158   1.1       cgd 
    159   1.1       cgd /*
    160   1.1       cgd  * To be able to redirect i/o for builtins easily, the shell moves the i/o
    161   1.1       cgd  * descriptors it uses away from 0,1,2.
    162   1.1       cgd  * Ideally these should be in units which are closed across exec's
    163   1.1       cgd  * (this saves work) but for version 6, this is not usually possible.
    164   1.6   mycroft  * The desired initial values for these descriptors are F{SHIN,...}.
    165   1.1       cgd  */
    166  1.29     joerg extern int SHIN;		/* Current shell input (script) */
    167  1.29     joerg extern int SHOUT;		/* Shell output */
    168  1.29     joerg extern int SHERR;		/* Diagnostic output... shell errs go here */
    169  1.29     joerg extern int OLDSTD;		/* Old standard input (def for cmds) */
    170   1.1       cgd 
    171   1.1       cgd /*
    172   1.1       cgd  * Error control
    173   1.1       cgd  *
    174   1.1       cgd  * Errors in scanning and parsing set up an error message to be printed
    175   1.1       cgd  * at the end and complete.  Other errors always cause a reset.
    176   1.1       cgd  * Because of source commands and .cshrc we need nested error catches.
    177   1.1       cgd  */
    178   1.1       cgd 
    179   1.1       cgd #include <setjmp.h>
    180  1.29     joerg extern jmp_buf reslab;
    181   1.1       cgd 
    182  1.14       wiz #define	setexit() (setjmp(reslab))
    183  1.14       wiz #define	reset()	longjmp(reslab, 1)
    184   1.1       cgd  /* Should use structure assignment here */
    185  1.14       wiz #define	getexit(a) (void)memcpy((a), reslab, sizeof reslab)
    186  1.14       wiz #define	resexit(a) (void)memcpy(reslab, (a), sizeof reslab)
    187   1.1       cgd 
    188  1.29     joerg extern Char *gointr;		/* Label for an onintr transfer */
    189   1.1       cgd 
    190   1.1       cgd #include <signal.h>
    191  1.29     joerg extern sig_t parintr;		/* Parents interrupt catch */
    192  1.29     joerg extern sig_t parterm;		/* Parents terminate catch */
    193   1.1       cgd 
    194   1.1       cgd /*
    195   1.1       cgd  * Lexical definitions.
    196   1.1       cgd  *
    197   1.1       cgd  * All lexical space is allocated dynamically.
    198   1.6   mycroft  * The eighth/sixteenth bit of characters is used to prevent recognition,
    199   1.1       cgd  * and eventually stripped.
    200   1.1       cgd  */
    201  1.26  christos #define	META 0x80
    202  1.26  christos #define	ASCII 0x7f
    203   1.1       cgd #ifdef SHORT_STRINGS
    204  1.26  christos #define	CHAR ((Char)0xff)
    205  1.26  christos #define	QUOTE ((Char)0x8000)	/* 16nth char bit used for 'ing */
    206  1.26  christos #define	TRIM ((Char)0x7fff)	/* Mask to strip quote bit */
    207   1.1       cgd #else
    208  1.26  christos #define	CHAR ((Char)0x7f)
    209  1.26  christos #define	QUOTE ((Char)0x80)	/* Eighth char bit used for 'ing */
    210  1.26  christos #define	TRIM ((Char)0x7f)	/* Mask to strip quote bit */
    211   1.1       cgd #endif
    212   1.1       cgd 
    213  1.29     joerg extern int AsciiOnly;			/* If set only 7 bits is expected in characters */
    214   1.1       cgd 
    215   1.1       cgd /*
    216   1.1       cgd  * Each level of input has a buffered input structure.
    217   1.1       cgd  * There are one or more blocks of buffered input for each level,
    218   1.1       cgd  * exactly one if the input is seekable and tell is available.
    219   1.1       cgd  * In other cases, the shell buffers enough blocks to keep all loops
    220   1.1       cgd  * in the buffer.
    221   1.1       cgd  */
    222  1.29     joerg extern struct Bin {
    223  1.14       wiz     off_t Bfseekp;		/* Seek pointer */
    224  1.14       wiz     off_t Bfbobp;		/* Seekp of beginning of buffers */
    225  1.14       wiz     off_t Bfeobp;		/* Seekp of end of buffers */
    226  1.14       wiz     int Bfblocks;		/* Number of buffer blocks */
    227  1.14       wiz     Char **Bfbuf;		/* The array of buffer blocks */
    228  1.29     joerg } B;
    229   1.1       cgd 
    230   1.6   mycroft /*
    231   1.6   mycroft  * This structure allows us to seek inside aliases
    232   1.6   mycroft  */
    233   1.6   mycroft struct Ain {
    234   1.6   mycroft     int type;
    235   1.6   mycroft #define I_SEEK -1		/* Invalid seek */
    236  1.14       wiz #define A_SEEK 0		/* Alias seek */
    237  1.14       wiz #define F_SEEK 1		/* File seek */
    238  1.14       wiz #define E_SEEK 2		/* Eval seek */
    239   1.6   mycroft     union {
    240   1.6   mycroft 	off_t _f_seek;
    241   1.6   mycroft 	Char* _c_seek;
    242   1.6   mycroft     } fc;
    243   1.6   mycroft #define f_seek fc._f_seek
    244   1.6   mycroft #define c_seek fc._c_seek
    245   1.6   mycroft     Char **a_seek;
    246  1.29     joerg };
    247   1.6   mycroft extern int aret;		/* What was the last character returned */
    248   1.6   mycroft #define SEEKEQ(a, b) ((a)->type == (b)->type && \
    249   1.6   mycroft 		      (a)->f_seek == (b)->f_seek && \
    250   1.6   mycroft 		      (a)->a_seek == (b)->a_seek)
    251   1.6   mycroft 
    252  1.14       wiz #define	fseekp B.Bfseekp
    253  1.14       wiz #define	fbobp B.Bfbobp
    254  1.14       wiz #define	feobp B.Bfeobp
    255   1.1       cgd #define	fblocks	B.Bfblocks
    256  1.14       wiz #define	fbuf B.Bfbuf
    257   1.1       cgd 
    258   1.1       cgd /*
    259   1.1       cgd  * The shell finds commands in loops by reseeking the input
    260   1.1       cgd  * For whiles, in particular, it reseeks to the beginning of the
    261   1.1       cgd  * line the while was on; hence the while placement restrictions.
    262   1.1       cgd  */
    263  1.29     joerg extern struct Ain lineloc;
    264   1.1       cgd 
    265  1.29     joerg extern int cantell;	/* Is current source tellable ? */
    266   1.1       cgd 
    267   1.1       cgd /*
    268   1.1       cgd  * Input lines are parsed into doubly linked circular
    269   1.1       cgd  * lists of words of the following form.
    270   1.1       cgd  */
    271   1.1       cgd struct wordent {
    272  1.14       wiz     Char *word;
    273   1.1       cgd     struct wordent *prev;
    274   1.1       cgd     struct wordent *next;
    275   1.1       cgd };
    276   1.1       cgd 
    277   1.1       cgd /*
    278   1.1       cgd  * During word building, both in the initial lexical phase and
    279   1.1       cgd  * when expanding $ variable substitutions, expansion by `!' and `$'
    280   1.1       cgd  * must be inhibited when reading ahead in routines which are themselves
    281   1.1       cgd  * processing `!' and `$' expansion or after characters such as `\' or in
    282   1.1       cgd  * quotations.  The following flags are passed to the getC routines
    283   1.1       cgd  * telling them which of these substitutions are appropriate for the
    284   1.1       cgd  * next character to be returned.
    285   1.1       cgd  */
    286  1.14       wiz #define	DODOL 1
    287  1.14       wiz #define	DOEXCL 2
    288  1.14       wiz #define	DOALL DODOL|DOEXCL
    289   1.1       cgd 
    290   1.1       cgd /*
    291   1.1       cgd  * Labuf implements a general buffer for lookahead during lexical operations.
    292   1.1       cgd  * Text which is to be placed in the input stream can be stuck here.
    293   1.1       cgd  * We stick parsed ahead $ constructs during initial input,
    294   1.1       cgd  * process id's from `$$', and modified variable values (from qualifiers
    295   1.1       cgd  * during expansion in sh.dol.c) here.
    296   1.1       cgd  */
    297  1.29     joerg extern Char *lap;
    298   1.1       cgd 
    299   1.1       cgd /*
    300   1.1       cgd  * Parser structure
    301   1.1       cgd  *
    302   1.1       cgd  * Each command is parsed to a tree of command structures and
    303   1.1       cgd  * flags are set bottom up during this process, to be propagated down
    304  1.17   msaitoh  * as needed during the semantics/execution pass (sh.sem.c).
    305   1.1       cgd  */
    306   1.1       cgd struct command {
    307  1.26  christos     int t_dtyp;			/* Type of node 		 */
    308   1.1       cgd #define	NODE_COMMAND	1	/* t_dcom <t_dlef >t_drit	 */
    309   1.1       cgd #define	NODE_PAREN	2	/* ( t_dspr ) <t_dlef >t_drit	 */
    310   1.1       cgd #define	NODE_PIPE	3	/* t_dlef | t_drit		 */
    311   1.1       cgd #define	NODE_LIST	4	/* t_dlef ; t_drit		 */
    312   1.1       cgd #define	NODE_OR		5	/* t_dlef || t_drit		 */
    313   1.1       cgd #define	NODE_AND	6	/* t_dlef && t_drit		 */
    314  1.26  christos     int t_dflg;			/* Flags, e.g. F_AMPERSAND|... 	 */
    315   1.1       cgd #define	F_SAVE	(F_NICE|F_TIME|F_NOHUP)	/* save these when re-doing 	 */
    316   1.1       cgd 
    317   1.1       cgd #define	F_AMPERSAND	(1<<0)	/* executes in background	 */
    318   1.1       cgd #define	F_APPEND	(1<<1)	/* output is redirected >>	 */
    319   1.1       cgd #define	F_PIPEIN	(1<<2)	/* input is a pipe		 */
    320   1.1       cgd #define	F_PIPEOUT	(1<<3)	/* output is a pipe		 */
    321   1.1       cgd #define	F_NOFORK	(1<<4)	/* don't fork, last ()ized cmd	 */
    322   1.1       cgd #define	F_NOINTERRUPT	(1<<5)	/* should be immune from intr's */
    323   1.1       cgd /* spare */
    324   1.1       cgd #define	F_STDERR	(1<<7)	/* redirect unit 2 with unit 1	 */
    325   1.1       cgd #define	F_OVERWRITE	(1<<8)	/* output was !			 */
    326   1.1       cgd #define	F_READ		(1<<9)	/* input redirection is <<	 */
    327   1.1       cgd #define	F_REPEAT	(1<<10)	/* reexec aft if, repeat,...	 */
    328   1.1       cgd #define	F_NICE		(1<<11)	/* t_nice is meaningful 	 */
    329   1.1       cgd #define	F_NOHUP		(1<<12)	/* nohup this command 		 */
    330   1.1       cgd #define	F_TIME		(1<<13)	/* time this command 		 */
    331   1.1       cgd     union {
    332  1.14       wiz 	Char *T_dlef;		/* Input redirect word 		 */
    333   1.1       cgd 	struct command *T_dcar;	/* Left part of list/pipe 	 */
    334   1.1       cgd     }       L;
    335   1.1       cgd     union {
    336  1.14       wiz 	Char *T_drit;		/* Output redirect word 	 */
    337   1.1       cgd 	struct command *T_dcdr;	/* Right part of list/pipe 	 */
    338   1.1       cgd     }       R;
    339  1.14       wiz #define	t_dlef L.T_dlef
    340  1.14       wiz #define	t_dcar L.T_dcar
    341  1.14       wiz #define	t_drit R.T_drit
    342  1.14       wiz #define	t_dcdr R.T_dcdr
    343  1.14       wiz     Char **t_dcom;		/* Command/argument vector 	 */
    344   1.1       cgd     struct command *t_dspr;	/* Pointer to ()'d subtree 	 */
    345  1.14       wiz     int t_nice;
    346   1.1       cgd };
    347   1.1       cgd 
    348   1.1       cgd 
    349   1.1       cgd /*
    350   1.6   mycroft  * These are declared here because they want to be
    351   1.6   mycroft  * initialized in sh.init.c (to allow them to be made readonly)
    352   1.6   mycroft  */
    353   1.6   mycroft 
    354   1.6   mycroft extern struct biltins {
    355  1.16  christos     const char *bname;
    356  1.14       wiz     void (*bfunct)(Char **, struct command *);
    357  1.14       wiz     short minargs, maxargs;
    358  1.14       wiz } bfunc[];
    359  1.14       wiz 
    360   1.6   mycroft extern int nbfunc;
    361  1.14       wiz extern int nsrchn;
    362   1.6   mycroft 
    363   1.6   mycroft extern struct srch {
    364  1.16  christos     const char *s_name;
    365  1.14       wiz     short s_value;
    366  1.14       wiz } srchn[];
    367   1.6   mycroft 
    368   1.6   mycroft /*
    369   1.1       cgd  * The keywords for the parser
    370   1.1       cgd  */
    371   1.1       cgd #define	T_BREAK		0
    372   1.1       cgd #define	T_BRKSW		1
    373   1.1       cgd #define	T_CASE		2
    374   1.1       cgd #define	T_DEFAULT 	3
    375   1.1       cgd #define	T_ELSE		4
    376   1.1       cgd #define	T_END		5
    377   1.1       cgd #define	T_ENDIF		6
    378   1.1       cgd #define	T_ENDSW		7
    379   1.1       cgd #define	T_EXIT		8
    380   1.1       cgd #define	T_FOREACH	9
    381   1.1       cgd #define	T_GOTO		10
    382   1.1       cgd #define	T_IF		11
    383   1.1       cgd #define	T_LABEL		12
    384   1.1       cgd #define	T_LET		13
    385   1.1       cgd #define	T_SET		14
    386   1.1       cgd #define	T_SWITCH	15
    387   1.1       cgd #define	T_TEST		16
    388   1.1       cgd #define	T_THEN		17
    389   1.1       cgd #define	T_WHILE		18
    390   1.1       cgd 
    391   1.1       cgd /*
    392   1.1       cgd  * Structure defining the existing while/foreach loops at this
    393   1.1       cgd  * source level.  Loops are implemented by seeking back in the
    394   1.1       cgd  * input.  For foreach (fe), the word list is attached here.
    395   1.1       cgd  */
    396  1.29     joerg extern struct whyle {
    397  1.14       wiz     struct Ain w_start;		/* Point to restart loop */
    398  1.14       wiz     struct Ain w_end;		/* End of loop (0 if unknown) */
    399  1.14       wiz     Char **w_fe, **w_fe0;	/* Current/initial wordlist for fe */
    400  1.14       wiz     Char *w_fename;		/* Name for fe */
    401   1.1       cgd     struct whyle *w_next;	/* Next (more outer) loop */
    402  1.14       wiz } *whyles;
    403   1.1       cgd 
    404   1.1       cgd /*
    405   1.1       cgd  * Variable structure
    406   1.1       cgd  *
    407   1.1       cgd  * Aliases and variables are stored in AVL balanced binary trees.
    408   1.1       cgd  */
    409  1.29     joerg extern struct varent {
    410  1.14       wiz     Char **vec;			/* Array of words which is the value */
    411  1.14       wiz     Char *v_name;		/* Name of variable/alias */
    412   1.1       cgd     struct varent *v_link[3];	/* The links, see below */
    413  1.14       wiz     int v_bal;			/* Balance factor */
    414  1.14       wiz } shvhed, aliases;
    415   1.1       cgd 
    416  1.14       wiz #define v_left v_link[0]
    417  1.14       wiz #define v_right	v_link[1]
    418  1.14       wiz #define v_parent v_link[2]
    419   1.1       cgd 
    420  1.14       wiz #define adrof(v) adrof1(v, &shvhed)
    421  1.14       wiz #define value(v) value1(v, &shvhed)
    422   1.1       cgd 
    423   1.1       cgd /*
    424   1.1       cgd  * The following are for interfacing redo substitution in
    425   1.1       cgd  * aliases to the lexical routines.
    426   1.1       cgd  */
    427  1.29     joerg extern struct wordent *alhistp;	/* Argument list (first) */
    428  1.29     joerg extern struct wordent *alhistt;	/* Node after last in arg list */
    429  1.14       wiz extern Char **alvec, *alvecp;	/* The (remnants of) alias vector */
    430   1.1       cgd 
    431   1.1       cgd /*
    432   1.1       cgd  * Filename/command name expansion variables
    433   1.1       cgd  */
    434  1.29     joerg extern int gflag;		/* After tglob -> is globbing needed? */
    435   1.1       cgd 
    436   1.1       cgd #define MAXVARLEN 30		/* Maximum number of char in a variable name */
    437   1.1       cgd 
    438   1.1       cgd /*
    439   1.1       cgd  * Variables for filename expansion
    440   1.1       cgd  */
    441  1.14       wiz extern long gargc;		/* Number args in gargv */
    442   1.1       cgd extern Char **gargv;		/* Pointer to the (stack) arglist */
    443   1.1       cgd 
    444   1.1       cgd /*
    445   1.1       cgd  * Variables for command expansion.
    446   1.1       cgd  */
    447   1.1       cgd extern Char **pargv;		/* Pointer to the argv list space */
    448   1.1       cgd extern long pargc;		/* Count of arguments in pargv */
    449  1.29     joerg extern long pnleft;		/* Number of chars left in pargs */
    450  1.29     joerg extern Char *pargs;		/* Pointer to start current word */
    451  1.29     joerg extern Char *pargcp;		/* Current index into pargs */
    452   1.1       cgd 
    453   1.1       cgd /*
    454   1.1       cgd  * History list
    455   1.1       cgd  *
    456   1.1       cgd  * Each history list entry contains an embedded wordlist
    457   1.1       cgd  * from the scanner, a number for the event, and a reference count
    458   1.1       cgd  * to aid in discarding old entries.
    459   1.1       cgd  *
    460   1.1       cgd  * Essentially "invisible" entries are put on the history list
    461   1.1       cgd  * when history substitution includes modifiers, and thrown away
    462   1.1       cgd  * at the next discarding since their event numbers are very negative.
    463   1.1       cgd  */
    464  1.29     joerg extern struct Hist {
    465   1.1       cgd     struct wordent Hlex;
    466  1.14       wiz     int Hnum;
    467  1.14       wiz     int Href;
    468   1.1       cgd     struct Hist *Hnext;
    469  1.14       wiz } Histlist;
    470   1.1       cgd 
    471  1.29     joerg extern struct wordent paraml;	/* Current lexical word list */
    472  1.29     joerg extern int eventno;		/* Next events number */
    473  1.29     joerg extern int lastev;		/* Last event reference (default) */
    474   1.1       cgd 
    475  1.29     joerg extern Char HIST;		/* history invocation character */
    476  1.29     joerg extern Char HISTSUB;		/* auto-substitute character */
    477   1.1       cgd 
    478   1.1       cgd /*
    479   1.1       cgd  * strings.h:
    480   1.1       cgd  */
    481   1.1       cgd #ifndef SHORT_STRINGS
    482  1.14       wiz #define Strchr(a, b) 		strchr(a, b)
    483   1.1       cgd #define Strrchr(a, b)		strrchr(a, b)
    484   1.1       cgd #define Strcat(a, b)		strcat(a, b)
    485  1.14       wiz #define Strncat(a, b, c)	strncat(a, b, c)
    486   1.1       cgd #define Strcpy(a, b)		strcpy(a, b)
    487  1.14       wiz #define Strncpy(a, b, c)	strncpy(a, b, c)
    488   1.1       cgd #define Strlen(a)		strlen(a)
    489   1.1       cgd #define Strcmp(a, b)		strcmp(a, b)
    490   1.1       cgd #define Strncmp(a, b, c)	strncmp(a, b, c)
    491   1.1       cgd 
    492   1.1       cgd #define Strspl(a, b)		strspl(a, b)
    493   1.1       cgd #define Strsave(a)		strsave(a)
    494   1.1       cgd #define Strend(a)		strend(a)
    495   1.1       cgd #define Strstr(a, b)		strstr(a, b)
    496   1.1       cgd 
    497  1.14       wiz #define str2short(a)		(a)
    498  1.14       wiz #define blk2short(a)		saveblk(a)
    499  1.14       wiz #define short2blk(a)		saveblk(a)
    500  1.14       wiz #define short2str(a)		strip(a)
    501   1.1       cgd #else
    502   1.1       cgd #define Strchr(a, b)		s_strchr(a, b)
    503  1.14       wiz #define Strrchr(a, b)		s_strrchr(a, b)
    504   1.1       cgd #define Strcat(a, b)		s_strcat(a, b)
    505   1.1       cgd #define Strncat(a, b, c) 	s_strncat(a, b, c)
    506   1.1       cgd #define Strcpy(a, b)		s_strcpy(a, b)
    507   1.1       cgd #define Strncpy(a, b, c)	s_strncpy(a, b, c)
    508   1.1       cgd #define Strlen(a)		s_strlen(a)
    509   1.1       cgd #define Strcmp(a, b)		s_strcmp(a, b)
    510   1.1       cgd #define Strncmp(a, b, c)	s_strncmp(a, b, c)
    511   1.1       cgd 
    512   1.1       cgd #define Strspl(a, b)		s_strspl(a, b)
    513   1.1       cgd #define Strsave(a)		s_strsave(a)
    514   1.1       cgd #define Strend(a)		s_strend(a)
    515   1.1       cgd #define Strstr(a, b)		s_strstr(a, b)
    516   1.1       cgd #endif
    517   1.1       cgd 
    518   1.1       cgd /*
    519   1.1       cgd  * setname is a macro to save space (see sh.err.c)
    520   1.1       cgd  */
    521  1.29     joerg extern const char *bname;
    522   1.1       cgd 
    523  1.14       wiz #define	setname(a) (bname = (a))
    524   1.1       cgd 
    525  1.29     joerg extern Char *Vsav;
    526  1.29     joerg extern Char *Vdp;
    527  1.29     joerg extern Char *Vexpath;
    528  1.29     joerg extern char **Vt;
    529   1.1       cgd 
    530  1.29     joerg extern Char **evalvec;
    531  1.29     joerg extern Char *evalp;
    532   1.1       cgd 
    533   1.1       cgd /* word_chars is set by default to WORD_CHARS but can be overridden by
    534   1.1       cgd    the worchars variable--if unset, reverts to WORD_CHARS */
    535   1.1       cgd 
    536  1.29     joerg extern Char *word_chars;
    537   1.1       cgd 
    538   1.1       cgd #define WORD_CHARS "*?_-.[]~="	/* default chars besides alnums in words */
    539   1.1       cgd 
    540  1.29     joerg extern Char *STR_SHELLPATH;
    541   1.1       cgd 
    542   1.1       cgd #include <paths.h>
    543   1.1       cgd #ifdef _PATH_BSHELL
    544  1.29     joerg extern Char *STR_BSHELL;
    545   1.1       cgd #endif
    546  1.29     joerg extern Char *STR_WORD_CHARS;
    547  1.29     joerg extern Char **STR_environ;
    548  1.14       wiz 
    549  1.23  christos #ifdef EDIT
    550  1.23  christos #include <histedit.h>
    551  1.29     joerg extern EditLine *el;
    552  1.29     joerg extern History *hi;
    553  1.24  christos #endif
    554  1.29     joerg extern int editing;
    555  1.23  christos 
    556  1.14       wiz #endif /* !_CSH_H_ */
    557