csh.h revision 1.1 1 1.1 cgd /*-
2 1.1 cgd * Copyright (c) 1980, 1991 The Regents of the University of California.
3 1.1 cgd * All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd *
33 1.1 cgd * @(#)csh.h 5.15 (Berkeley) 6/8/91
34 1.1 cgd */
35 1.1 cgd
36 1.1 cgd /*
37 1.1 cgd * Fundamental definitions which may vary from system to system.
38 1.1 cgd *
39 1.1 cgd * BUFSIZ The i/o buffering size; also limits word size
40 1.1 cgd * MAILINTVL How often to mailcheck; more often is more expensive
41 1.1 cgd */
42 1.1 cgd #ifndef BUFSIZ
43 1.1 cgd #define BUFSIZ 1024 /* default buffer size */
44 1.1 cgd #endif /* BUFSIZ */
45 1.1 cgd
46 1.1 cgd #define FORKSLEEP 10 /* delay loop on non-interactive fork failure */
47 1.1 cgd #define MAILINTVL 600 /* 10 minutes */
48 1.1 cgd
49 1.1 cgd /*
50 1.1 cgd * The shell moves std in/out/diag and the old std input away from units
51 1.1 cgd * 0, 1, and 2 so that it is easy to set up these standards for invoked
52 1.1 cgd * commands.
53 1.1 cgd */
54 1.1 cgd #define FSHTTY 15 /* /dev/tty when manip pgrps */
55 1.1 cgd #define FSHIN 16 /* Preferred desc for shell input */
56 1.1 cgd #define FSHOUT 17 /* ... shell output */
57 1.1 cgd #define FSHDIAG 18 /* ... shell diagnostics */
58 1.1 cgd #define FOLDSTD 19 /* ... old std input */
59 1.1 cgd
60 1.1 cgd #ifdef PROF
61 1.1 cgd #define xexit(n) done(n)
62 1.1 cgd #endif
63 1.1 cgd
64 1.1 cgd #ifdef SHORT_STRINGS
65 1.1 cgd typedef short Char;
66 1.1 cgd
67 1.1 cgd #define SAVE(a) (Strsave(str2short(a)))
68 1.1 cgd #else
69 1.1 cgd typedef char Char;
70 1.1 cgd
71 1.1 cgd #define SAVE(a) (strsave(a))
72 1.1 cgd #endif
73 1.1 cgd
74 1.1 cgd typedef void *ioctl_t; /* Third arg of ioctl */
75 1.1 cgd
76 1.1 cgd typedef void *ptr_t;
77 1.1 cgd
78 1.1 cgd #include "const.h"
79 1.1 cgd #include "char.h"
80 1.1 cgd #include "err.h"
81 1.1 cgd
82 1.1 cgd #ifdef SYSMALLOC
83 1.1 cgd #define xmalloc(i) Malloc(i)
84 1.1 cgd #define xrealloc(p, i) Realloc(p, i)
85 1.1 cgd #define xcalloc(n, s) Calloc(n, s)
86 1.1 cgd #define xfree(p) Free(p)
87 1.1 cgd #else
88 1.1 cgd #define xmalloc(i) malloc(i)
89 1.1 cgd #define xrealloc(p, i) realloc(p, i)
90 1.1 cgd #define xcalloc(n, s) calloc(n, s)
91 1.1 cgd #define xfree(p) free(p)
92 1.1 cgd #endif /* SYSMALLOC */
93 1.1 cgd
94 1.1 cgd #define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR)
95 1.1 cgd
96 1.1 cgd #define SIGN_EXTEND_CHAR(a) \
97 1.1 cgd ((a) & 0x80 ? ((int) (a)) | 0xffffff00 : ((int) a) & 0x000000ff)
98 1.1 cgd
99 1.1 cgd
100 1.1 cgd typedef int bool;
101 1.1 cgd
102 1.1 cgd #define eq(a, b) (Strcmp(a, b) == 0)
103 1.1 cgd
104 1.1 cgd /* globone() flags */
105 1.1 cgd #define G_ERROR 0 /* default action: error if multiple words */
106 1.1 cgd #define G_IGNORE 1 /* ignore the rest of the words */
107 1.1 cgd #define G_APPEND 2 /* make a sentence by cat'ing the words */
108 1.1 cgd
109 1.1 cgd /*
110 1.1 cgd * Global flags
111 1.1 cgd */
112 1.1 cgd bool chkstop; /* Warned of stopped jobs... allow exit */
113 1.1 cgd bool didfds; /* Have setup i/o fd's for child */
114 1.1 cgd bool doneinp; /* EOF indicator after reset from readc */
115 1.1 cgd bool exiterr; /* Exit if error or non-zero exit status */
116 1.1 cgd bool child; /* Child shell ... errors cause exit */
117 1.1 cgd bool haderr; /* Reset was because of an error */
118 1.1 cgd bool intty; /* Input is a tty */
119 1.1 cgd bool intact; /* We are interactive... therefore prompt */
120 1.1 cgd bool justpr; /* Just print because of :p hist mod */
121 1.1 cgd bool loginsh; /* We are a loginsh -> .login/.logout */
122 1.1 cgd bool neednote; /* Need to pnotify() */
123 1.1 cgd bool noexec; /* Don't execute, just syntax check */
124 1.1 cgd bool pjobs; /* want to print jobs if interrupted */
125 1.1 cgd bool setintr; /* Set interrupts on/off -> Wait intr... */
126 1.1 cgd bool timflg; /* Time the next waited for command */
127 1.1 cgd bool havhash; /* path hashing is available */
128 1.1 cgd
129 1.1 cgd #ifdef FILEC
130 1.1 cgd bool filec; /* doing filename expansion */
131 1.1 cgd #endif
132 1.1 cgd
133 1.1 cgd /*
134 1.1 cgd * Global i/o info
135 1.1 cgd */
136 1.1 cgd Char *arginp; /* Argument input for sh -c and internal `xx` */
137 1.1 cgd int onelflg; /* 2 -> need line for -t, 1 -> exit on read */
138 1.1 cgd Char *ffile; /* Name of shell file for $0 */
139 1.1 cgd
140 1.1 cgd char *seterr; /* Error message from scanner/parser */
141 1.1 cgd Char *shtemp; /* Temp name for << shell files in /tmp */
142 1.1 cgd
143 1.1 cgd #include <sys/time.h>
144 1.1 cgd #include <sys/resource.h>
145 1.1 cgd
146 1.1 cgd struct timeval time0; /* Time at which the shell started */
147 1.1 cgd struct rusage ru0;
148 1.1 cgd
149 1.1 cgd /*
150 1.1 cgd * Miscellany
151 1.1 cgd */
152 1.1 cgd Char *doldol; /* Character pid for $$ */
153 1.1 cgd int uid; /* Invokers uid */
154 1.1 cgd int gid; /* Invokers gid */
155 1.1 cgd time_t chktim; /* Time mail last checked */
156 1.1 cgd int shpgrp; /* Pgrp of shell */
157 1.1 cgd int tpgrp; /* Terminal process group */
158 1.1 cgd
159 1.1 cgd /* If tpgrp is -1, leave tty alone! */
160 1.1 cgd int opgrp; /* Initial pgrp and tty pgrp */
161 1.1 cgd
162 1.1 cgd /*
163 1.1 cgd * These are declared here because they want to be
164 1.1 cgd * initialized in sh.init.c (to allow them to be made readonly)
165 1.1 cgd */
166 1.1 cgd
167 1.1 cgd extern struct biltins {
168 1.1 cgd char *bname;
169 1.1 cgd void (*bfunct) ();
170 1.1 cgd short minargs, maxargs;
171 1.1 cgd } bfunc[];
172 1.1 cgd extern int nbfunc;
173 1.1 cgd
174 1.1 cgd extern struct srch {
175 1.1 cgd char *s_name;
176 1.1 cgd short s_value;
177 1.1 cgd } srchn[];
178 1.1 cgd extern int nsrchn;
179 1.1 cgd
180 1.1 cgd /*
181 1.1 cgd * To be able to redirect i/o for builtins easily, the shell moves the i/o
182 1.1 cgd * descriptors it uses away from 0,1,2.
183 1.1 cgd * Ideally these should be in units which are closed across exec's
184 1.1 cgd * (this saves work) but for version 6, this is not usually possible.
185 1.1 cgd * The desired initial values for these descriptors are defined in
186 1.1 cgd * local.h.
187 1.1 cgd */
188 1.1 cgd short SHIN; /* Current shell input (script) */
189 1.1 cgd short SHOUT; /* Shell output */
190 1.1 cgd short SHDIAG; /* Diagnostic output... shell errs go here */
191 1.1 cgd short OLDSTD; /* Old standard input (def for cmds) */
192 1.1 cgd
193 1.1 cgd /*
194 1.1 cgd * Error control
195 1.1 cgd *
196 1.1 cgd * Errors in scanning and parsing set up an error message to be printed
197 1.1 cgd * at the end and complete. Other errors always cause a reset.
198 1.1 cgd * Because of source commands and .cshrc we need nested error catches.
199 1.1 cgd */
200 1.1 cgd
201 1.1 cgd #include <setjmp.h>
202 1.1 cgd jmp_buf reslab;
203 1.1 cgd
204 1.1 cgd #define setexit() (setjmp(reslab))
205 1.1 cgd #define reset() longjmp(reslab, 1)
206 1.1 cgd /* Should use structure assignment here */
207 1.1 cgd #define getexit(a) bcopy((char *)reslab, ((char *)(a)), sizeof reslab)
208 1.1 cgd #define resexit(a) bcopy((char *)(a), (char *)reslab, sizeof reslab)
209 1.1 cgd
210 1.1 cgd Char *gointr; /* Label for an onintr transfer */
211 1.1 cgd
212 1.1 cgd #include <signal.h>
213 1.1 cgd sig_t parintr; /* Parents interrupt catch */
214 1.1 cgd sig_t parterm; /* Parents terminate catch */
215 1.1 cgd
216 1.1 cgd /*
217 1.1 cgd * Lexical definitions.
218 1.1 cgd *
219 1.1 cgd * All lexical space is allocated dynamically.
220 1.1 cgd * The eighth/sizteenth bit of characters is used to prevent recognition,
221 1.1 cgd * and eventually stripped.
222 1.1 cgd */
223 1.1 cgd #define META 0200
224 1.1 cgd #define ASCII 0177
225 1.1 cgd #ifdef SHORT_STRINGS
226 1.1 cgd #define CHAR 0377
227 1.1 cgd #define QUOTE 0100000 /* 16nth char bit used for 'ing */
228 1.1 cgd #define TRIM 0077777 /* Mask to strip quote bit */
229 1.1 cgd #else
230 1.1 cgd #define CHAR 0177
231 1.1 cgd #define QUOTE 0200 /* Eighth char bit used for 'ing */
232 1.1 cgd #define TRIM 0177 /* Mask to strip quote bit */
233 1.1 cgd #endif
234 1.1 cgd
235 1.1 cgd int AsciiOnly; /* If set only 7 bits is expected in characters */
236 1.1 cgd
237 1.1 cgd /*
238 1.1 cgd * Each level of input has a buffered input structure.
239 1.1 cgd * There are one or more blocks of buffered input for each level,
240 1.1 cgd * exactly one if the input is seekable and tell is available.
241 1.1 cgd * In other cases, the shell buffers enough blocks to keep all loops
242 1.1 cgd * in the buffer.
243 1.1 cgd */
244 1.1 cgd struct Bin {
245 1.1 cgd off_t Bfseekp; /* Seek pointer */
246 1.1 cgd off_t Bfbobp; /* Seekp of beginning of buffers */
247 1.1 cgd off_t Bfeobp; /* Seekp of end of buffers */
248 1.1 cgd short Bfblocks; /* Number of buffer blocks */
249 1.1 cgd Char **Bfbuf; /* The array of buffer blocks */
250 1.1 cgd } B;
251 1.1 cgd
252 1.1 cgd #define fseekp B.Bfseekp
253 1.1 cgd #define fbobp B.Bfbobp
254 1.1 cgd #define feobp B.Bfeobp
255 1.1 cgd #define fblocks B.Bfblocks
256 1.1 cgd #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.1 cgd off_t lineloc;
264 1.1 cgd
265 1.1 cgd bool 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.1 cgd 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.1 cgd #define DODOL 1
287 1.1 cgd #define DOEXCL 2
288 1.1 cgd #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.1 cgd 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.1 cgd * as needed during the semantics/exeuction pass (sh.sem.c).
305 1.1 cgd */
306 1.1 cgd struct command {
307 1.1 cgd short 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.1 cgd short 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.1 cgd 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.1 cgd 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.1 cgd #define t_dlef L.T_dlef
340 1.1 cgd #define t_dcar L.T_dcar
341 1.1 cgd #define t_drit R.T_drit
342 1.1 cgd #define t_dcdr R.T_dcdr
343 1.1 cgd Char **t_dcom; /* Command/argument vector */
344 1.1 cgd struct command *t_dspr; /* Pointer to ()'d subtree */
345 1.1 cgd short t_nice;
346 1.1 cgd };
347 1.1 cgd
348 1.1 cgd
349 1.1 cgd /*
350 1.1 cgd * The keywords for the parser
351 1.1 cgd */
352 1.1 cgd #define T_BREAK 0
353 1.1 cgd #define T_BRKSW 1
354 1.1 cgd #define T_CASE 2
355 1.1 cgd #define T_DEFAULT 3
356 1.1 cgd #define T_ELSE 4
357 1.1 cgd #define T_END 5
358 1.1 cgd #define T_ENDIF 6
359 1.1 cgd #define T_ENDSW 7
360 1.1 cgd #define T_EXIT 8
361 1.1 cgd #define T_FOREACH 9
362 1.1 cgd #define T_GOTO 10
363 1.1 cgd #define T_IF 11
364 1.1 cgd #define T_LABEL 12
365 1.1 cgd #define T_LET 13
366 1.1 cgd #define T_SET 14
367 1.1 cgd #define T_SWITCH 15
368 1.1 cgd #define T_TEST 16
369 1.1 cgd #define T_THEN 17
370 1.1 cgd #define T_WHILE 18
371 1.1 cgd
372 1.1 cgd /*
373 1.1 cgd * Structure defining the existing while/foreach loops at this
374 1.1 cgd * source level. Loops are implemented by seeking back in the
375 1.1 cgd * input. For foreach (fe), the word list is attached here.
376 1.1 cgd */
377 1.1 cgd struct whyle {
378 1.1 cgd off_t w_start; /* Point to restart loop */
379 1.1 cgd off_t w_end; /* End of loop (0 if unknown) */
380 1.1 cgd Char **w_fe, **w_fe0; /* Current/initial wordlist for fe */
381 1.1 cgd Char *w_fename; /* Name for fe */
382 1.1 cgd struct whyle *w_next; /* Next (more outer) loop */
383 1.1 cgd } *whyles;
384 1.1 cgd
385 1.1 cgd /*
386 1.1 cgd * Variable structure
387 1.1 cgd *
388 1.1 cgd * Aliases and variables are stored in AVL balanced binary trees.
389 1.1 cgd */
390 1.1 cgd struct varent {
391 1.1 cgd Char **vec; /* Array of words which is the value */
392 1.1 cgd Char *v_name; /* Name of variable/alias */
393 1.1 cgd struct varent *v_link[3]; /* The links, see below */
394 1.1 cgd int v_bal; /* Balance factor */
395 1.1 cgd } shvhed, aliases;
396 1.1 cgd
397 1.1 cgd #define v_left v_link[0]
398 1.1 cgd #define v_right v_link[1]
399 1.1 cgd #define v_parent v_link[2]
400 1.1 cgd
401 1.1 cgd struct varent *adrof1();
402 1.1 cgd
403 1.1 cgd #define adrof(v) adrof1(v, &shvhed)
404 1.1 cgd #define value(v) value1(v, &shvhed)
405 1.1 cgd
406 1.1 cgd /*
407 1.1 cgd * The following are for interfacing redo substitution in
408 1.1 cgd * aliases to the lexical routines.
409 1.1 cgd */
410 1.1 cgd struct wordent *alhistp; /* Argument list (first) */
411 1.1 cgd struct wordent *alhistt; /* Node after last in arg list */
412 1.1 cgd Char **alvec; /* The (remnants of) alias vector */
413 1.1 cgd
414 1.1 cgd /*
415 1.1 cgd * Filename/command name expansion variables
416 1.1 cgd */
417 1.1 cgd short gflag; /* After tglob -> is globbing needed? */
418 1.1 cgd
419 1.1 cgd #define MAXVARLEN 30 /* Maximum number of char in a variable name */
420 1.1 cgd
421 1.1 cgd /*
422 1.1 cgd * Variables for filename expansion
423 1.1 cgd */
424 1.1 cgd extern Char **gargv; /* Pointer to the (stack) arglist */
425 1.1 cgd extern long gargc; /* Number args in gargv */
426 1.1 cgd
427 1.1 cgd /*
428 1.1 cgd * Variables for command expansion.
429 1.1 cgd */
430 1.1 cgd extern Char **pargv; /* Pointer to the argv list space */
431 1.1 cgd extern long pargc; /* Count of arguments in pargv */
432 1.1 cgd Char *pargs; /* Pointer to start current word */
433 1.1 cgd long pnleft; /* Number of chars left in pargs */
434 1.1 cgd Char *pargcp; /* Current index into pargs */
435 1.1 cgd
436 1.1 cgd /*
437 1.1 cgd * History list
438 1.1 cgd *
439 1.1 cgd * Each history list entry contains an embedded wordlist
440 1.1 cgd * from the scanner, a number for the event, and a reference count
441 1.1 cgd * to aid in discarding old entries.
442 1.1 cgd *
443 1.1 cgd * Essentially "invisible" entries are put on the history list
444 1.1 cgd * when history substitution includes modifiers, and thrown away
445 1.1 cgd * at the next discarding since their event numbers are very negative.
446 1.1 cgd */
447 1.1 cgd struct Hist {
448 1.1 cgd struct wordent Hlex;
449 1.1 cgd int Hnum;
450 1.1 cgd int Href;
451 1.1 cgd long Htime;
452 1.1 cgd struct Hist *Hnext;
453 1.1 cgd } Histlist;
454 1.1 cgd
455 1.1 cgd struct wordent paraml; /* Current lexical word list */
456 1.1 cgd int eventno; /* Next events number */
457 1.1 cgd int lastev; /* Last event reference (default) */
458 1.1 cgd
459 1.1 cgd Char HIST; /* history invocation character */
460 1.1 cgd Char HISTSUB; /* auto-substitute character */
461 1.1 cgd
462 1.1 cgd /*
463 1.1 cgd * strings.h:
464 1.1 cgd */
465 1.1 cgd #ifndef SHORT_STRINGS
466 1.1 cgd #define Strchr(a, b) strchr(a, b)
467 1.1 cgd #define Strrchr(a, b) strrchr(a, b)
468 1.1 cgd #define Strcat(a, b) strcat(a, b)
469 1.1 cgd #define Strncat(a, b, c) strncat(a, b, c)
470 1.1 cgd #define Strcpy(a, b) strcpy(a, b)
471 1.1 cgd #define Strncpy(a, b, c) strncpy(a, b, c)
472 1.1 cgd #define Strlen(a) strlen(a)
473 1.1 cgd #define Strcmp(a, b) strcmp(a, b)
474 1.1 cgd #define Strncmp(a, b, c) strncmp(a, b, c)
475 1.1 cgd
476 1.1 cgd #define Strspl(a, b) strspl(a, b)
477 1.1 cgd #define Strsave(a) strsave(a)
478 1.1 cgd #define Strend(a) strend(a)
479 1.1 cgd #define Strstr(a, b) strstr(a, b)
480 1.1 cgd
481 1.1 cgd #define str2short(a) (a)
482 1.1 cgd #define blk2short(a) saveblk(a)
483 1.1 cgd #define short2blk(a) saveblk(a)
484 1.1 cgd #define short2str(a) (a)
485 1.1 cgd #define short2qstr(a) (a)
486 1.1 cgd #else
487 1.1 cgd #define Strchr(a, b) s_strchr(a, b)
488 1.1 cgd #define Strrchr(a, b) s_strrchr(a, b)
489 1.1 cgd #define Strcat(a, b) s_strcat(a, b)
490 1.1 cgd #define Strncat(a, b, c) s_strncat(a, b, c)
491 1.1 cgd #define Strcpy(a, b) s_strcpy(a, b)
492 1.1 cgd #define Strncpy(a, b, c) s_strncpy(a, b, c)
493 1.1 cgd #define Strlen(a) s_strlen(a)
494 1.1 cgd #define Strcmp(a, b) s_strcmp(a, b)
495 1.1 cgd #define Strncmp(a, b, c) s_strncmp(a, b, c)
496 1.1 cgd
497 1.1 cgd #define Strspl(a, b) s_strspl(a, b)
498 1.1 cgd #define Strsave(a) s_strsave(a)
499 1.1 cgd #define Strend(a) s_strend(a)
500 1.1 cgd #define Strstr(a, b) s_strstr(a, b)
501 1.1 cgd #endif
502 1.1 cgd
503 1.1 cgd /*
504 1.1 cgd * setname is a macro to save space (see sh.err.c)
505 1.1 cgd */
506 1.1 cgd char *bname;
507 1.1 cgd
508 1.1 cgd #define setname(a) (bname = (a))
509 1.1 cgd
510 1.1 cgd Char *Vsav;
511 1.1 cgd Char *Vdp;
512 1.1 cgd Char *Vexpath;
513 1.1 cgd char **Vt;
514 1.1 cgd
515 1.1 cgd Char **evalvec;
516 1.1 cgd Char *evalp;
517 1.1 cgd
518 1.1 cgd extern struct mesg {
519 1.1 cgd char *iname; /* name from /usr/include */
520 1.1 cgd char *pname; /* print name */
521 1.1 cgd } mesg[];
522 1.1 cgd
523 1.1 cgd /* word_chars is set by default to WORD_CHARS but can be overridden by
524 1.1 cgd the worchars variable--if unset, reverts to WORD_CHARS */
525 1.1 cgd
526 1.1 cgd Char *word_chars;
527 1.1 cgd
528 1.1 cgd #define WORD_CHARS "*?_-.[]~=" /* default chars besides alnums in words */
529 1.1 cgd
530 1.1 cgd Char *STR_SHELLPATH;
531 1.1 cgd
532 1.1 cgd #include <paths.h>
533 1.1 cgd #ifdef _PATH_BSHELL
534 1.1 cgd Char *STR_BSHELL;
535 1.1 cgd #endif
536 1.1 cgd Char *STR_WORD_CHARS;
537 1.1 cgd Char **STR_environ;
538