xref: /original-bsd/old/sh/defs.h (revision b288febc)
1 /*	defs.h	4.5	89/05/08	*/
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
83 ADDRESS		alloc();
84 VOID		addblok();
85 STRING		make();
86 STRING		movstr();
87 TREPTR		cmd();
88 TREPTR		makefork();
89 NAMPTR		lookup();
90 VOID		setname();
91 VOID		setargs();
92 DOLPTR		useargs();
93 REAL		expr();
94 STRING		catpath();
95 STRING		getpath();
96 STRING		*scan();
97 STRING		mactrim();
98 STRING		macro();
99 STRING		execs();
100 VOID		await();
101 VOID		post();
102 STRING		copyto();
103 VOID		exname();
104 STRING		staknam();
105 VOID		printnam();
106 VOID		printflg();
107 VOID		prs();
108 VOID		prc();
109 VOID		setupenv();
110 STRING		*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 */
120 UFD		output;
121 INT		ioset;
122 IOPTR		iotemp;		/* files to be deleted sometime */
123 IOPTR		iopend;		/* documents waiting to be read at NL */
124 
125 /* substitution */
126 INT		dolc;
127 STRING		*dolv;
128 DOLPTR		argfor;
129 ARGPTR		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 */
141 MSG		atline;
142 MSG		readmsg;
143 MSG		colon;
144 MSG		minus;
145 MSG		nullstr;
146 MSG		sptbnl;
147 MSG		unexpected;
148 MSG		endoffile;
149 MSG		synmsg;
150 
151 /* name tree and words */
152 SYSTAB		reserved;
153 INT		wdval;
154 INT		wdnum;
155 ARGPTR		wdarg;
156 INT		wdset;
157 BOOL		reserv;
158 
159 /* prompting */
160 MSG		stdprompt;
161 MSG		supprompt;
162 MSG		profile;
163 
164 /* built in names */
165 NAMNOD		fngnod;
166 NAMNOD		ifsnod;
167 NAMNOD		homenod;
168 NAMNOD		mailnod;
169 NAMNOD		pathnod;
170 NAMNOD		ps1nod;
171 NAMNOD		ps2nod;
172 
173 /* special names */
174 MSG		flagadr;
175 STRING		cmdadr;
176 STRING		exitadr;
177 STRING		dolladr;
178 STRING		pcsadr;
179 STRING		pidadr;
180 
181 /* names always present */
182 MSG		mailname;
183 MSG		homename;
184 MSG		pathname;
185 MSG		fngname;
186 MSG		ifsname;
187 MSG		ps1name;
188 MSG		ps2name;
189 
190 /* transput */
191 CHAR		tmpout[];
192 STRING		tmpnam;
193 INT		serial;
194 #define		TMPNAM 7
195 FILE		standin;
196 #define input	(standin->fdes)
197 #define eof	(standin->feof)
198 INT		peekc;
199 STRING		comdiv;
200 MSG		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
217 #define		batchflg	040000
218 INT		flags;
219 
220 /* error exits from various parts of shell */
221 #include	<setjmp.h>
222 jmp_buf		subshell;
223 jmp_buf		errshell;
224 jmp_buf		INTbuf;
225 
226 /* fault handling */
227 #include	"brkincr.h"
228 POS		brkincr;
229 
230 #define MINTRAP	0
231 #define MAXTRAP	32
232 
233 #define INTR	2
234 #define QUIT	3
235 #define MEMF	11
236 #define ALARM	14
237 #define KILL	15
238 #define TRAPSET	2
239 #define SIGSET	4
240 #define SIGMOD	8
241 
242 VOID		fault();
243 BOOL		trapnote;
244 STRING		trapcom[];
245 BOOL		trapflg[];
246 BOOL		trapjmp[];
247 
248 /* name tree and words */
249 STRING		*environ;
250 CHAR		numbuf[];
251 MSG		export;
252 MSG		readonly;
253 
254 /* execflgs */
255 INT		exitval;
256 BOOL		execbrk;
257 INT		loopcnt;
258 INT		breakcnt;
259 
260 /* messages */
261 MSG		mailmsg;
262 MSG		coredump;
263 MSG		badopt;
264 MSG		badparam;
265 MSG		badsub;
266 MSG		nospace;
267 MSG		notfound;
268 MSG		badtrap;
269 MSG		baddir;
270 MSG		badshift;
271 MSG		illegal;
272 MSG		restricted;
273 MSG		execpmsg;
274 MSG		notid;
275 MSG		wtfailed;
276 MSG		badcreate;
277 MSG		piperr;
278 MSG		badopen;
279 MSG		badnum;
280 MSG		arglist;
281 MSG		txtbsy;
282 MSG		toobig;
283 MSG		badexec;
284 MSG		notfound;
285 MSG		badfile;
286 
287 address	end[];
288 
289 #include	"ctype.h"
290 
291