new signals make read's restarted, thus must setjmp/longjmp to get
[unix-history] / usr / src / old / sh / defs.h
CommitLineData
22674779 1/* defs.h 4.2 83/06/10 */
92b4c148
KM
2
3#
4/*
5 * UNIX shell
6 */
7
8/* error exits from various parts of shell */
9#define ERROR 1
10#define SYNBAD 2
11#define SIGFAIL 3
12#define SIGFLG 0200
13
14/* command tree */
15#define FPRS 020
16#define FINT 040
17#define FAMP 0100
18#define FPIN 0400
19#define FPOU 01000
20#define FPCL 02000
21#define FCMD 04000
22#define COMMSK 017
23
24#define TCOM 0
25#define TPAR 1
26#define TFIL 2
27#define TLST 3
28#define TIF 4
29#define TWH 5
30#define TUN 6
31#define TSW 7
32#define TAND 8
33#define TORF 9
34#define TFORK 10
35#define TFOR 11
36
37/* execute table */
38#define SYSSET 1
39#define SYSCD 2
40#define SYSEXEC 3
41#define SYSLOGIN 4
42#define SYSTRAP 5
43#define SYSEXIT 6
44#define SYSSHFT 7
45#define SYSWAIT 8
46#define SYSCONT 9
47#define SYSBREAK 10
48#define SYSEVAL 11
49#define SYSDOT 12
50#define SYSRDONLY 13
51#define SYSTIMES 14
52#define SYSXPORT 15
53#define SYSNULL 16
54#define SYSREAD 17
55#define SYSTST 18
56#define SYSUMASK 19
57
58/* used for input and output of shell */
59#define INIO 10
60#define OTIO 11
61
62/*io nodes*/
63#define USERIO 10
64#define IOUFD 15
65#define IODOC 16
66#define IOPUT 32
67#define IOAPP 64
68#define IOMOV 128
69#define IORDW 256
70#define INPIPE 0
71#define OTPIPE 1
72
73/* arg list terminator */
74#define ENDARGS 0
75
76#include "mac.h"
77#include "mode.h"
78#include "name.h"
79
80
81/* result type declarations */
82#define alloc malloc
83ADDRESS alloc();
84VOID addblok();
85STRING make();
86STRING movstr();
87TREPTR cmd();
88TREPTR makefork();
89NAMPTR lookup();
90VOID setname();
91VOID setargs();
92DOLPTR useargs();
93REAL expr();
94STRING catpath();
95STRING getpath();
96STRING *scan();
97STRING mactrim();
98STRING macro();
99STRING execs();
100VOID await();
101VOID post();
102STRING copyto();
103VOID exname();
104STRING staknam();
105VOID printnam();
106VOID printflg();
107VOID prs();
108VOID prc();
109VOID getenv();
110STRING *setenv();
111
112#define attrib(n,f) (n->namflg |= f)
113#define round(a,b) (((int)((ADR(a)+b)-1))&~((b)-1))
114#define closepipe(x) (close(x[INPIPE]), close(x[OTPIPE]))
115#define eq(a,b) (cf(a,b)==0)
116#define max(a,b) ((a)>(b)?(a):(b))
117#define assert(x) ;
118
119/* temp files and io */
120UFD output;
121INT ioset;
122IOPTR iotemp; /* files to be deleted sometime */
123IOPTR iopend; /* documents waiting to be read at NL */
124
125/* substitution */
126INT dolc;
127STRING *dolv;
128DOLPTR argfor;
129ARGPTR gchain;
130
131/* stack */
132#define BLK(x) ((BLKPTR)(x))
133#define BYT(x) ((BYTPTR)(x))
134#define STK(x) ((STKPTR)(x))
135#define ADR(x) ((char*)(x))
136
137/* stak stuff */
138#include "stak.h"
139
140/* string constants */
141MSG atline;
142MSG readmsg;
143MSG colon;
144MSG minus;
145MSG nullstr;
146MSG sptbnl;
147MSG unexpected;
148MSG endoffile;
149MSG synmsg;
150
151/* name tree and words */
152SYSTAB reserved;
153INT wdval;
154INT wdnum;
155ARGPTR wdarg;
156INT wdset;
157BOOL reserv;
158
159/* prompting */
160MSG stdprompt;
161MSG supprompt;
162MSG profile;
163
164/* built in names */
165NAMNOD fngnod;
166NAMNOD ifsnod;
167NAMNOD homenod;
168NAMNOD mailnod;
169NAMNOD pathnod;
170NAMNOD ps1nod;
171NAMNOD ps2nod;
172
173/* special names */
174MSG flagadr;
175STRING cmdadr;
176STRING exitadr;
177STRING dolladr;
178STRING pcsadr;
179STRING pidadr;
180
181MSG defpath;
182
183/* names always present */
184MSG mailname;
185MSG homename;
186MSG pathname;
187MSG fngname;
188MSG ifsname;
189MSG ps1name;
190MSG ps2name;
191
192/* transput */
193CHAR tmpout[];
194STRING tmpnam;
195INT serial;
196#define TMPNAM 7
197FILE standin;
198#define input (standin->fdes)
199#define eof (standin->feof)
200INT peekc;
201STRING comdiv;
202MSG devnull;
203
204/* flags */
205#define noexec 01
206#define intflg 02
207#define prompt 04
208#define setflg 010
209#define errflg 020
210#define ttyflg 040
211#define forked 0100
212#define oneflg 0200
213#define rshflg 0400
214#define waiting 01000
215#define stdflg 02000
216#define execpr 04000
217#define readpr 010000
218#define keyflg 020000
219INT flags;
220
221/* error exits from various parts of shell */
222#include <setjmp.h>
223jmp_buf subshell;
224jmp_buf errshell;
22674779 225jmp_buf INTbuf;
92b4c148
KM
226
227/* fault handling */
228#include "brkincr.h"
229POS brkincr;
230
231#define MINTRAP 0
232#define MAXTRAP 17
233
234#define INTR 2
235#define QUIT 3
236#define MEMF 11
237#define ALARM 14
238#define KILL 15
239#define TRAPSET 2
240#define SIGSET 4
241#define SIGMOD 8
242
243VOID fault();
244BOOL trapnote;
245STRING trapcom[];
246BOOL trapflg[];
22674779 247BOOL trapjmp[];
92b4c148
KM
248
249/* name tree and words */
250STRING *environ;
251CHAR numbuf[];
252MSG export;
253MSG readonly;
254
255/* execflgs */
256INT exitval;
257BOOL execbrk;
258INT loopcnt;
259INT breakcnt;
260
261/* messages */
262MSG mailmsg;
263MSG coredump;
264MSG badopt;
265MSG badparam;
266MSG badsub;
267MSG nospace;
268MSG notfound;
269MSG badtrap;
270MSG baddir;
271MSG badshift;
272MSG illegal;
273MSG restricted;
274MSG execpmsg;
275MSG notid;
276MSG wtfailed;
277MSG badcreate;
278MSG piperr;
279MSG badopen;
280MSG badnum;
281MSG arglist;
282MSG txtbsy;
283MSG toobig;
284MSG badexec;
285MSG notfound;
286MSG badfile;
287
288address end[];
289
290#include "ctype.h"
291