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