xref: /onnv-gate/usr/src/cmd/sh/mode.h (revision 0)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright (c) 1996, by Sun Microsystems, Inc.
28*0Sstevel@tonic-gate  * All rights reserved.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.8.1.2	*/
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  *	UNIX shell
34*0Sstevel@tonic-gate  */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <unistd.h>
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #ifdef pdp11
39*0Sstevel@tonic-gate typedef char BOOL;
40*0Sstevel@tonic-gate #else
41*0Sstevel@tonic-gate typedef short BOOL;
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #define	BYTESPERWORD	(sizeof (char *))
45*0Sstevel@tonic-gate #define	NIL	((char*)0)
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate /* the following nonsense is required
49*0Sstevel@tonic-gate  * because casts turn an Lvalue
50*0Sstevel@tonic-gate  * into an Rvalue so two cheats
51*0Sstevel@tonic-gate  * are necessary, one for each context.
52*0Sstevel@tonic-gate  */
53*0Sstevel@tonic-gate #define	Rcheat(a)	((int)(a))
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate /* address puns for storage allocation */
57*0Sstevel@tonic-gate typedef union
58*0Sstevel@tonic-gate {
59*0Sstevel@tonic-gate 	struct forknod	*_forkptr;
60*0Sstevel@tonic-gate 	struct comnod	*_comptr;
61*0Sstevel@tonic-gate 	struct fndnod	*_fndptr;
62*0Sstevel@tonic-gate 	struct parnod	*_parptr;
63*0Sstevel@tonic-gate 	struct ifnod	*_ifptr;
64*0Sstevel@tonic-gate 	struct whnod	*_whptr;
65*0Sstevel@tonic-gate 	struct fornod	*_forptr;
66*0Sstevel@tonic-gate 	struct lstnod	*_lstptr;
67*0Sstevel@tonic-gate 	struct blk	*_blkptr;
68*0Sstevel@tonic-gate 	struct namnod	*_namptr;
69*0Sstevel@tonic-gate 	char	*_bytptr;
70*0Sstevel@tonic-gate } address;
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate /* heap storage */
74*0Sstevel@tonic-gate struct blk
75*0Sstevel@tonic-gate {
76*0Sstevel@tonic-gate 	struct blk	*word;
77*0Sstevel@tonic-gate };
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate /*
80*0Sstevel@tonic-gate  * largefile converson hack note.
81*0Sstevel@tonic-gate  * the shell uses the *fnxt and *fend pointers when
82*0Sstevel@tonic-gate  * parsing a script. However, it was also using the
83*0Sstevel@tonic-gate  * difference between them when doing lseeks. Because
84*0Sstevel@tonic-gate  * that doesn't work in the largefile world, I have
85*0Sstevel@tonic-gate  * added a parallel set of offset counters that need to
86*0Sstevel@tonic-gate  * be updated whenever the "buffer" offsets the shell
87*0Sstevel@tonic-gate  * uses get changed. Most of this code is in word.c.
88*0Sstevel@tonic-gate  * If you change it, have fun...
89*0Sstevel@tonic-gate  */
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate #define	BUFFERSIZE	128
92*0Sstevel@tonic-gate struct fileblk
93*0Sstevel@tonic-gate {
94*0Sstevel@tonic-gate 	int	fdes;
95*0Sstevel@tonic-gate 	unsigned flin;
96*0Sstevel@tonic-gate 	BOOL	feof;
97*0Sstevel@tonic-gate 	unsigned char	fsiz;
98*0Sstevel@tonic-gate 	unsigned char	*fnxt;
99*0Sstevel@tonic-gate 	unsigned char	*fend;
100*0Sstevel@tonic-gate 	off_t		nxtoff;		/* file offset */
101*0Sstevel@tonic-gate 	off_t		endoff;		/* file offset */
102*0Sstevel@tonic-gate 	unsigned char	**feval;
103*0Sstevel@tonic-gate 	struct fileblk	*fstak;
104*0Sstevel@tonic-gate 	unsigned char	fbuf[BUFFERSIZE];
105*0Sstevel@tonic-gate };
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate struct tempblk
108*0Sstevel@tonic-gate {
109*0Sstevel@tonic-gate 	int fdes;
110*0Sstevel@tonic-gate 	struct tempblk *fstak;
111*0Sstevel@tonic-gate };
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate /* for files not used with file descriptors */
115*0Sstevel@tonic-gate struct filehdr
116*0Sstevel@tonic-gate {
117*0Sstevel@tonic-gate 	int	fdes;
118*0Sstevel@tonic-gate 	unsigned	flin;
119*0Sstevel@tonic-gate 	BOOL	feof;
120*0Sstevel@tonic-gate 	unsigned char	fsiz;
121*0Sstevel@tonic-gate 	unsigned char	*fnxt;
122*0Sstevel@tonic-gate 	unsigned char	*fend;
123*0Sstevel@tonic-gate 	off_t		nxtoff;		/* file offset */
124*0Sstevel@tonic-gate 	off_t		endoff;		/* file offset */
125*0Sstevel@tonic-gate 	unsigned char	**feval;
126*0Sstevel@tonic-gate 	struct fileblk	*fstak;
127*0Sstevel@tonic-gate 	unsigned char	_fbuf[1];
128*0Sstevel@tonic-gate };
129*0Sstevel@tonic-gate 
130*0Sstevel@tonic-gate struct sysnod
131*0Sstevel@tonic-gate {
132*0Sstevel@tonic-gate 	char	*sysnam;
133*0Sstevel@tonic-gate 	int	sysval;
134*0Sstevel@tonic-gate };
135*0Sstevel@tonic-gate 
136*0Sstevel@tonic-gate /* this node is a proforma for those that follow */
137*0Sstevel@tonic-gate struct trenod
138*0Sstevel@tonic-gate {
139*0Sstevel@tonic-gate 	int	tretyp;
140*0Sstevel@tonic-gate 	struct ionod	*treio;
141*0Sstevel@tonic-gate };
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate /* dummy for access only */
144*0Sstevel@tonic-gate struct argnod
145*0Sstevel@tonic-gate {
146*0Sstevel@tonic-gate 	struct argnod	*argnxt;
147*0Sstevel@tonic-gate 	unsigned char	argval[1];
148*0Sstevel@tonic-gate };
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate struct dolnod
151*0Sstevel@tonic-gate {
152*0Sstevel@tonic-gate 	struct dolnod	*dolnxt;
153*0Sstevel@tonic-gate 	int	doluse;
154*0Sstevel@tonic-gate 	unsigned char	**dolarg;
155*0Sstevel@tonic-gate };
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate struct forknod
158*0Sstevel@tonic-gate {
159*0Sstevel@tonic-gate 	int	forktyp;
160*0Sstevel@tonic-gate 	struct ionod	*forkio;
161*0Sstevel@tonic-gate 	struct trenod	*forktre;
162*0Sstevel@tonic-gate };
163*0Sstevel@tonic-gate 
164*0Sstevel@tonic-gate struct comnod
165*0Sstevel@tonic-gate {
166*0Sstevel@tonic-gate 	int	comtyp;
167*0Sstevel@tonic-gate 	struct ionod	*comio;
168*0Sstevel@tonic-gate 	struct argnod	*comarg;
169*0Sstevel@tonic-gate 	struct argnod	*comset;
170*0Sstevel@tonic-gate };
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate struct fndnod
173*0Sstevel@tonic-gate {
174*0Sstevel@tonic-gate 	int 	fndtyp;
175*0Sstevel@tonic-gate 	unsigned char	*fndnam;
176*0Sstevel@tonic-gate 	struct trenod	*fndval;
177*0Sstevel@tonic-gate };
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate struct ifnod
180*0Sstevel@tonic-gate {
181*0Sstevel@tonic-gate 	int	iftyp;
182*0Sstevel@tonic-gate 	struct trenod	*iftre;
183*0Sstevel@tonic-gate 	struct trenod	*thtre;
184*0Sstevel@tonic-gate 	struct trenod	*eltre;
185*0Sstevel@tonic-gate };
186*0Sstevel@tonic-gate 
187*0Sstevel@tonic-gate struct whnod
188*0Sstevel@tonic-gate {
189*0Sstevel@tonic-gate 	int	whtyp;
190*0Sstevel@tonic-gate 	struct trenod	*whtre;
191*0Sstevel@tonic-gate 	struct trenod	*dotre;
192*0Sstevel@tonic-gate };
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate struct fornod
195*0Sstevel@tonic-gate {
196*0Sstevel@tonic-gate 	int	fortyp;
197*0Sstevel@tonic-gate 	struct trenod	*fortre;
198*0Sstevel@tonic-gate 	unsigned char	*fornam;
199*0Sstevel@tonic-gate 	struct comnod	*forlst;
200*0Sstevel@tonic-gate };
201*0Sstevel@tonic-gate 
202*0Sstevel@tonic-gate struct swnod
203*0Sstevel@tonic-gate {
204*0Sstevel@tonic-gate 	int	swtyp;
205*0Sstevel@tonic-gate 	unsigned char *swarg;
206*0Sstevel@tonic-gate 	struct regnod	*swlst;
207*0Sstevel@tonic-gate };
208*0Sstevel@tonic-gate 
209*0Sstevel@tonic-gate struct regnod
210*0Sstevel@tonic-gate {
211*0Sstevel@tonic-gate 	struct argnod	*regptr;
212*0Sstevel@tonic-gate 	struct trenod	*regcom;
213*0Sstevel@tonic-gate 	struct regnod	*regnxt;
214*0Sstevel@tonic-gate };
215*0Sstevel@tonic-gate 
216*0Sstevel@tonic-gate struct parnod
217*0Sstevel@tonic-gate {
218*0Sstevel@tonic-gate 	int	partyp;
219*0Sstevel@tonic-gate 	struct trenod	*partre;
220*0Sstevel@tonic-gate };
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate struct lstnod
223*0Sstevel@tonic-gate {
224*0Sstevel@tonic-gate 	int	lsttyp;
225*0Sstevel@tonic-gate 	struct trenod	*lstlef;
226*0Sstevel@tonic-gate 	struct trenod	*lstrit;
227*0Sstevel@tonic-gate };
228*0Sstevel@tonic-gate 
229*0Sstevel@tonic-gate struct ionod
230*0Sstevel@tonic-gate {
231*0Sstevel@tonic-gate 	int	iofile;
232*0Sstevel@tonic-gate 	char	*ioname;
233*0Sstevel@tonic-gate 	char	*iolink;
234*0Sstevel@tonic-gate 	struct ionod	*ionxt;
235*0Sstevel@tonic-gate 	struct ionod	*iolst;
236*0Sstevel@tonic-gate };
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate struct fdsave
239*0Sstevel@tonic-gate {
240*0Sstevel@tonic-gate 	int org_fd;
241*0Sstevel@tonic-gate 	int dup_fd;
242*0Sstevel@tonic-gate };
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate #define		fndptr(x)	((struct fndnod *)x)
246*0Sstevel@tonic-gate #define		comptr(x)	((struct comnod *)x)
247*0Sstevel@tonic-gate #define		forkptr(x)	((struct forknod *)x)
248*0Sstevel@tonic-gate #define		parptr(x)	((struct parnod *)x)
249*0Sstevel@tonic-gate #define		lstptr(x)	((struct lstnod *)x)
250*0Sstevel@tonic-gate #define		forptr(x)	((struct fornod *)x)
251*0Sstevel@tonic-gate #define		whptr(x)	((struct whnod *)x)
252*0Sstevel@tonic-gate #define		ifptr(x)	((struct ifnod *)x)
253*0Sstevel@tonic-gate #define		swptr(x)	((struct swnod *)x)
254