xref: /titanic_50/usr/src/cmd/sh/mode.h (revision 0b46ffbad80838700776674f5dea3ad9b16dd6e4)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0b46ffbaSmj162486  * Common Development and Distribution License (the "License").
6*0b46ffbaSmj162486  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*0b46ffbaSmj162486 /*
22*0b46ffbaSmj162486  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*0b46ffbaSmj162486  * Use is subject to license terms.
24*0b46ffbaSmj162486  */
257c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
267c478bd9Sstevel@tonic-gate /* All Rights Reserved */
277c478bd9Sstevel@tonic-gate 
28*0b46ffbaSmj162486 #pragma ident	"%Z%%M%	%I%	%E% SMI"
297c478bd9Sstevel@tonic-gate 
30*0b46ffbaSmj162486 #ifndef _MODE_H
31*0b46ffbaSmj162486 #define	_MODE_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  *	UNIX shell
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <unistd.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef pdp11
407c478bd9Sstevel@tonic-gate typedef char BOOL;
417c478bd9Sstevel@tonic-gate #else
427c478bd9Sstevel@tonic-gate typedef short BOOL;
437c478bd9Sstevel@tonic-gate #endif
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #define	BYTESPERWORD	(sizeof (char *))
46*0b46ffbaSmj162486 #define	ALIGNSIZ	(sizeof (double))
477c478bd9Sstevel@tonic-gate #define	NIL	((char *)0)
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate 
50*0b46ffbaSmj162486 /*
51*0b46ffbaSmj162486  * the following nonsense is required
527c478bd9Sstevel@tonic-gate  * because casts turn an Lvalue
537c478bd9Sstevel@tonic-gate  * into an Rvalue so two cheats
547c478bd9Sstevel@tonic-gate  * are necessary, one for each context.
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate #define	Rcheat(a)	((int)(a))
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /* address puns for storage allocation */
607c478bd9Sstevel@tonic-gate typedef union
617c478bd9Sstevel@tonic-gate {
627c478bd9Sstevel@tonic-gate 	struct forknod	*_forkptr;
637c478bd9Sstevel@tonic-gate 	struct comnod	*_comptr;
647c478bd9Sstevel@tonic-gate 	struct fndnod	*_fndptr;
657c478bd9Sstevel@tonic-gate 	struct parnod	*_parptr;
667c478bd9Sstevel@tonic-gate 	struct ifnod	*_ifptr;
677c478bd9Sstevel@tonic-gate 	struct whnod	*_whptr;
687c478bd9Sstevel@tonic-gate 	struct fornod	*_forptr;
697c478bd9Sstevel@tonic-gate 	struct lstnod	*_lstptr;
707c478bd9Sstevel@tonic-gate 	struct blk	*_blkptr;
717c478bd9Sstevel@tonic-gate 	struct namnod	*_namptr;
727c478bd9Sstevel@tonic-gate 	char	*_bytptr;
737c478bd9Sstevel@tonic-gate } address;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /* heap storage */
777c478bd9Sstevel@tonic-gate struct blk
787c478bd9Sstevel@tonic-gate {
797c478bd9Sstevel@tonic-gate 	struct blk	*word;
80*0b46ffbaSmj162486 	char		pad[ALIGNSIZ - sizeof (struct blk *)];
817c478bd9Sstevel@tonic-gate };
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * largefile converson hack note.
857c478bd9Sstevel@tonic-gate  * the shell uses the *fnxt and *fend pointers when
867c478bd9Sstevel@tonic-gate  * parsing a script. However, it was also using the
877c478bd9Sstevel@tonic-gate  * difference between them when doing lseeks. Because
887c478bd9Sstevel@tonic-gate  * that doesn't work in the largefile world, I have
897c478bd9Sstevel@tonic-gate  * added a parallel set of offset counters that need to
907c478bd9Sstevel@tonic-gate  * be updated whenever the "buffer" offsets the shell
917c478bd9Sstevel@tonic-gate  * uses get changed. Most of this code is in word.c.
927c478bd9Sstevel@tonic-gate  * If you change it, have fun...
937c478bd9Sstevel@tonic-gate  */
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate #define	BUFFERSIZE	128
967c478bd9Sstevel@tonic-gate struct fileblk
977c478bd9Sstevel@tonic-gate {
987c478bd9Sstevel@tonic-gate 	int	fdes;
997c478bd9Sstevel@tonic-gate 	unsigned flin;
1007c478bd9Sstevel@tonic-gate 	BOOL	feof;
1017c478bd9Sstevel@tonic-gate 	unsigned char	fsiz;
1027c478bd9Sstevel@tonic-gate 	unsigned char	*fnxt;
1037c478bd9Sstevel@tonic-gate 	unsigned char	*fend;
1047c478bd9Sstevel@tonic-gate 	off_t		nxtoff;		/* file offset */
1057c478bd9Sstevel@tonic-gate 	off_t		endoff;		/* file offset */
1067c478bd9Sstevel@tonic-gate 	unsigned char	**feval;
1077c478bd9Sstevel@tonic-gate 	struct fileblk	*fstak;
1087c478bd9Sstevel@tonic-gate 	unsigned char	fbuf[BUFFERSIZE];
1097c478bd9Sstevel@tonic-gate };
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate struct tempblk
1127c478bd9Sstevel@tonic-gate {
1137c478bd9Sstevel@tonic-gate 	int fdes;
1147c478bd9Sstevel@tonic-gate 	struct tempblk *fstak;
1157c478bd9Sstevel@tonic-gate };
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /* for files not used with file descriptors */
1197c478bd9Sstevel@tonic-gate struct filehdr
1207c478bd9Sstevel@tonic-gate {
1217c478bd9Sstevel@tonic-gate 	int	fdes;
1227c478bd9Sstevel@tonic-gate 	unsigned	flin;
1237c478bd9Sstevel@tonic-gate 	BOOL	feof;
1247c478bd9Sstevel@tonic-gate 	unsigned char	fsiz;
1257c478bd9Sstevel@tonic-gate 	unsigned char	*fnxt;
1267c478bd9Sstevel@tonic-gate 	unsigned char	*fend;
1277c478bd9Sstevel@tonic-gate 	off_t		nxtoff;		/* file offset */
1287c478bd9Sstevel@tonic-gate 	off_t		endoff;		/* file offset */
1297c478bd9Sstevel@tonic-gate 	unsigned char	**feval;
1307c478bd9Sstevel@tonic-gate 	struct fileblk	*fstak;
1317c478bd9Sstevel@tonic-gate 	unsigned char	_fbuf[1];
1327c478bd9Sstevel@tonic-gate };
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate struct sysnod
1357c478bd9Sstevel@tonic-gate {
1367c478bd9Sstevel@tonic-gate 	char	*sysnam;
1377c478bd9Sstevel@tonic-gate 	int	sysval;
1387c478bd9Sstevel@tonic-gate };
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /* this node is a proforma for those that follow */
1417c478bd9Sstevel@tonic-gate struct trenod
1427c478bd9Sstevel@tonic-gate {
1437c478bd9Sstevel@tonic-gate 	int	tretyp;
1447c478bd9Sstevel@tonic-gate 	struct ionod	*treio;
1457c478bd9Sstevel@tonic-gate };
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /* dummy for access only */
1487c478bd9Sstevel@tonic-gate struct argnod
1497c478bd9Sstevel@tonic-gate {
1507c478bd9Sstevel@tonic-gate 	struct argnod	*argnxt;
1517c478bd9Sstevel@tonic-gate 	unsigned char	argval[1];
1527c478bd9Sstevel@tonic-gate };
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate struct dolnod
1557c478bd9Sstevel@tonic-gate {
1567c478bd9Sstevel@tonic-gate 	struct dolnod	*dolnxt;
1577c478bd9Sstevel@tonic-gate 	int	doluse;
1587c478bd9Sstevel@tonic-gate 	unsigned char	**dolarg;
1597c478bd9Sstevel@tonic-gate };
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate struct forknod
1627c478bd9Sstevel@tonic-gate {
1637c478bd9Sstevel@tonic-gate 	int	forktyp;
1647c478bd9Sstevel@tonic-gate 	struct ionod	*forkio;
1657c478bd9Sstevel@tonic-gate 	struct trenod	*forktre;
1667c478bd9Sstevel@tonic-gate };
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate struct comnod
1697c478bd9Sstevel@tonic-gate {
1707c478bd9Sstevel@tonic-gate 	int	comtyp;
1717c478bd9Sstevel@tonic-gate 	struct ionod	*comio;
1727c478bd9Sstevel@tonic-gate 	struct argnod	*comarg;
1737c478bd9Sstevel@tonic-gate 	struct argnod	*comset;
1747c478bd9Sstevel@tonic-gate };
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate struct fndnod
1777c478bd9Sstevel@tonic-gate {
1787c478bd9Sstevel@tonic-gate 	int 	fndtyp;
1797c478bd9Sstevel@tonic-gate 	unsigned char	*fndnam;
1807c478bd9Sstevel@tonic-gate 	struct trenod	*fndval;
1817c478bd9Sstevel@tonic-gate };
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate struct ifnod
1847c478bd9Sstevel@tonic-gate {
1857c478bd9Sstevel@tonic-gate 	int	iftyp;
1867c478bd9Sstevel@tonic-gate 	struct trenod	*iftre;
1877c478bd9Sstevel@tonic-gate 	struct trenod	*thtre;
1887c478bd9Sstevel@tonic-gate 	struct trenod	*eltre;
1897c478bd9Sstevel@tonic-gate };
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate struct whnod
1927c478bd9Sstevel@tonic-gate {
1937c478bd9Sstevel@tonic-gate 	int	whtyp;
1947c478bd9Sstevel@tonic-gate 	struct trenod	*whtre;
1957c478bd9Sstevel@tonic-gate 	struct trenod	*dotre;
1967c478bd9Sstevel@tonic-gate };
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate struct fornod
1997c478bd9Sstevel@tonic-gate {
2007c478bd9Sstevel@tonic-gate 	int	fortyp;
2017c478bd9Sstevel@tonic-gate 	struct trenod	*fortre;
2027c478bd9Sstevel@tonic-gate 	unsigned char	*fornam;
2037c478bd9Sstevel@tonic-gate 	struct comnod	*forlst;
2047c478bd9Sstevel@tonic-gate };
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate struct swnod
2077c478bd9Sstevel@tonic-gate {
2087c478bd9Sstevel@tonic-gate 	int	swtyp;
2097c478bd9Sstevel@tonic-gate 	unsigned char *swarg;
2107c478bd9Sstevel@tonic-gate 	struct regnod	*swlst;
2117c478bd9Sstevel@tonic-gate };
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate struct regnod
2147c478bd9Sstevel@tonic-gate {
2157c478bd9Sstevel@tonic-gate 	struct argnod	*regptr;
2167c478bd9Sstevel@tonic-gate 	struct trenod	*regcom;
2177c478bd9Sstevel@tonic-gate 	struct regnod	*regnxt;
2187c478bd9Sstevel@tonic-gate };
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate struct parnod
2217c478bd9Sstevel@tonic-gate {
2227c478bd9Sstevel@tonic-gate 	int	partyp;
2237c478bd9Sstevel@tonic-gate 	struct trenod	*partre;
2247c478bd9Sstevel@tonic-gate };
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate struct lstnod
2277c478bd9Sstevel@tonic-gate {
2287c478bd9Sstevel@tonic-gate 	int	lsttyp;
2297c478bd9Sstevel@tonic-gate 	struct trenod	*lstlef;
2307c478bd9Sstevel@tonic-gate 	struct trenod	*lstrit;
2317c478bd9Sstevel@tonic-gate };
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate struct ionod
2347c478bd9Sstevel@tonic-gate {
2357c478bd9Sstevel@tonic-gate 	int	iofile;
2367c478bd9Sstevel@tonic-gate 	char	*ioname;
2377c478bd9Sstevel@tonic-gate 	char	*iolink;
2387c478bd9Sstevel@tonic-gate 	struct ionod	*ionxt;
2397c478bd9Sstevel@tonic-gate 	struct ionod	*iolst;
2407c478bd9Sstevel@tonic-gate };
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate struct fdsave
2437c478bd9Sstevel@tonic-gate {
2447c478bd9Sstevel@tonic-gate 	int org_fd;
2457c478bd9Sstevel@tonic-gate 	int dup_fd;
2467c478bd9Sstevel@tonic-gate };
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate #define		fndptr(x)	((struct fndnod *)x)
2507c478bd9Sstevel@tonic-gate #define		comptr(x)	((struct comnod *)x)
2517c478bd9Sstevel@tonic-gate #define		forkptr(x)	((struct forknod *)x)
2527c478bd9Sstevel@tonic-gate #define		parptr(x)	((struct parnod *)x)
2537c478bd9Sstevel@tonic-gate #define		lstptr(x)	((struct lstnod *)x)
2547c478bd9Sstevel@tonic-gate #define		forptr(x)	((struct fornod *)x)
2557c478bd9Sstevel@tonic-gate #define		whptr(x)	((struct whnod *)x)
2567c478bd9Sstevel@tonic-gate #define		ifptr(x)	((struct ifnod *)x)
2577c478bd9Sstevel@tonic-gate #define		swptr(x)	((struct swnod *)x)
258*0b46ffbaSmj162486 
259*0b46ffbaSmj162486 #endif /* _MODE_H */
260