xref: /csrg-svn/old/sh/mode.h (revision 34082)
1*34082Sbostic /*	mode.h	4.2	88/04/24	*/
26697Smckusick 
36697Smckusick #
46697Smckusick /*
56697Smckusick  *	UNIX shell
66697Smckusick  */
76697Smckusick 
86697Smckusick 
96697Smckusick #define BYTESPERWORD	(sizeof(char *))
106697Smckusick 
116697Smckusick TYPE char	CHAR;
126697Smckusick TYPE char	BOOL;
136697Smckusick TYPE int	UFD;
146697Smckusick TYPE int	INT;
156697Smckusick TYPE float	REAL;
166697Smckusick TYPE char	*ADDRESS;
176697Smckusick TYPE long int	L_INT;
186697Smckusick TYPE int	VOID;
196697Smckusick TYPE unsigned	POS;
206697Smckusick TYPE char	*STRING;
216697Smckusick TYPE char	MSG[];
226697Smckusick TYPE int	PIPE[];
236697Smckusick TYPE char	*STKPTR;
246697Smckusick TYPE char	*BYTPTR;
256697Smckusick 
266697Smckusick STRUCT stat	STATBUF;	/* defined in /usr/sys/stat.h */
276697Smckusick STRUCT blk	*BLKPTR;
286697Smckusick STRUCT fileblk	FILEBLK;
296697Smckusick STRUCT filehdr	FILEHDR;
306697Smckusick STRUCT fileblk	*FILE;
31*34082Sbostic UNION  trenod	*TREPTR;
326697Smckusick STRUCT forknod	*FORKPTR;
336697Smckusick STRUCT comnod	*COMPTR;
346697Smckusick STRUCT swnod	*SWPTR;
356697Smckusick STRUCT regnod	*REGPTR;
366697Smckusick STRUCT parnod	*PARPTR;
376697Smckusick STRUCT ifnod	*IFPTR;
386697Smckusick STRUCT whnod	*WHPTR;
396697Smckusick STRUCT fornod	*FORPTR;
406697Smckusick STRUCT lstnod	*LSTPTR;
416697Smckusick STRUCT argnod	*ARGPTR;
426697Smckusick STRUCT dolnod	*DOLPTR;
436697Smckusick STRUCT ionod	*IOPTR;
446697Smckusick STRUCT namnod	NAMNOD;
456697Smckusick STRUCT namnod	*NAMPTR;
466697Smckusick STRUCT sysnod	SYSNOD;
476697Smckusick STRUCT sysnod	*SYSPTR;
486697Smckusick STRUCT sysnod	SYSTAB[];
496697Smckusick #define NIL	((char*)0)
506697Smckusick 
516697Smckusick 
526697Smckusick /* the following nonsense is required
536697Smckusick  * because casts turn an Lvalue
546697Smckusick  * into an Rvalue so two cheats
556697Smckusick  * are necessary, one for each context.
566697Smckusick  */
57*34082Sbostic /* union { int _cheat;}; */
58*34082Sbostic /* #define Lcheat(a)	((a)._cheat) */
59*34082Sbostic #define Lcheat(a)	(*(int *)&(a))
60*34082Sbostic #define Rcheat(a)	( (int  ) (a))
616697Smckusick 
626697Smckusick 
636697Smckusick /* address puns for storage allocation */
646697Smckusick UNION {
656697Smckusick 	FORKPTR	_forkptr;
666697Smckusick 	COMPTR	_comptr;
676697Smckusick 	PARPTR	_parptr;
686697Smckusick 	IFPTR	_ifptr;
696697Smckusick 	WHPTR	_whptr;
706697Smckusick 	FORPTR	_forptr;
716697Smckusick 	LSTPTR	_lstptr;
726697Smckusick 	BLKPTR	_blkptr;
736697Smckusick 	NAMPTR	_namptr;
746697Smckusick 	BYTPTR	_bytptr;
756697Smckusick 	}	address;
766697Smckusick 
776697Smckusick 
786697Smckusick /* for functions that do not return values */
796697Smckusick /*
806697Smckusick struct void {INT vvvvvvvv;};
816697Smckusick */
826697Smckusick 
836697Smckusick 
846697Smckusick /* heap storage */
856697Smckusick struct blk {
866697Smckusick 	BLKPTR	word;
876697Smckusick };
886697Smckusick 
896697Smckusick #define	BUFSIZ	64
906697Smckusick struct fileblk {
916697Smckusick 	UFD	fdes;
926697Smckusick 	POS	flin;
936697Smckusick 	BOOL	feof;
946697Smckusick 	CHAR	fsiz;
956697Smckusick 	STRING	fnxt;
966697Smckusick 	STRING	fend;
976697Smckusick 	STRING	*feval;
986697Smckusick 	FILE	fstak;
996697Smckusick 	CHAR	fbuf[BUFSIZ];
1006697Smckusick };
1016697Smckusick 
1026697Smckusick /* for files not used with file descriptors */
1036697Smckusick struct filehdr {
1046697Smckusick 	UFD	fdes;
1056697Smckusick 	POS	flin;
1066697Smckusick 	BOOL	feof;
1076697Smckusick 	CHAR	fsiz;
1086697Smckusick 	STRING	fnxt;
1096697Smckusick 	STRING	fend;
1106697Smckusick 	STRING	*feval;
1116697Smckusick 	FILE	fstak;
1126697Smckusick 	CHAR	_fbuf[1];
1136697Smckusick };
1146697Smckusick 
1156697Smckusick struct sysnod {
1166697Smckusick 	STRING	sysnam;
1176697Smckusick 	INT	sysval;
1186697Smckusick };
1196697Smckusick 
1206697Smckusick /* dummy for access only */
1216697Smckusick struct argnod {
1226697Smckusick 	ARGPTR	argnxt;
1236697Smckusick 	CHAR	argval[1];
1246697Smckusick };
1256697Smckusick 
1266697Smckusick struct dolnod {
1276697Smckusick 	DOLPTR	dolnxt;
1286697Smckusick 	INT	doluse;
1296697Smckusick 	CHAR	dolarg[1];
1306697Smckusick };
1316697Smckusick 
1326697Smckusick struct forknod {
1336697Smckusick 	INT	forktyp;
1346697Smckusick 	IOPTR	forkio;
1356697Smckusick 	TREPTR	forktre;
1366697Smckusick };
1376697Smckusick 
1386697Smckusick struct comnod {
1396697Smckusick 	INT	comtyp;
1406697Smckusick 	IOPTR	comio;
1416697Smckusick 	ARGPTR	comarg;
1426697Smckusick 	ARGPTR	comset;
1436697Smckusick };
1446697Smckusick 
1456697Smckusick struct ifnod {
1466697Smckusick 	INT	iftyp;
1476697Smckusick 	TREPTR	iftre;
1486697Smckusick 	TREPTR	thtre;
1496697Smckusick 	TREPTR	eltre;
1506697Smckusick };
1516697Smckusick 
1526697Smckusick struct whnod {
1536697Smckusick 	INT	whtyp;
1546697Smckusick 	TREPTR	whtre;
1556697Smckusick 	TREPTR	dotre;
1566697Smckusick };
1576697Smckusick 
1586697Smckusick struct fornod {
1596697Smckusick 	INT	fortyp;
1606697Smckusick 	TREPTR	fortre;
1616697Smckusick 	STRING	fornam;
1626697Smckusick 	COMPTR	forlst;
1636697Smckusick };
1646697Smckusick 
1656697Smckusick struct swnod {
1666697Smckusick 	INT	swtyp;
1676697Smckusick 	STRING	swarg;
1686697Smckusick 	REGPTR	swlst;
1696697Smckusick };
1706697Smckusick 
1716697Smckusick struct regnod {
1726697Smckusick 	ARGPTR	regptr;
1736697Smckusick 	TREPTR	regcom;
1746697Smckusick 	REGPTR	regnxt;
1756697Smckusick };
1766697Smckusick 
1776697Smckusick struct parnod {
1786697Smckusick 	INT	partyp;
1796697Smckusick 	TREPTR	partre;
1806697Smckusick };
1816697Smckusick 
1826697Smckusick struct lstnod {
1836697Smckusick 	INT	lsttyp;
1846697Smckusick 	TREPTR	lstlef;
1856697Smckusick 	TREPTR	lstrit;
1866697Smckusick };
1876697Smckusick 
1886697Smckusick struct ionod {
1896697Smckusick 	INT	iofile;
1906697Smckusick 	STRING	ioname;
1916697Smckusick 	IOPTR	ionxt;
1926697Smckusick 	IOPTR	iolst;
1936697Smckusick };
1946697Smckusick 
1956697Smckusick #define	FORKTYPE	(sizeof(struct forknod))
1966697Smckusick #define	COMTYPE		(sizeof(struct comnod))
1976697Smckusick #define	IFTYPE		(sizeof(struct ifnod))
1986697Smckusick #define	WHTYPE		(sizeof(struct whnod))
1996697Smckusick #define	FORTYPE		(sizeof(struct fornod))
2006697Smckusick #define	SWTYPE		(sizeof(struct swnod))
2016697Smckusick #define	REGTYPE		(sizeof(struct regnod))
2026697Smckusick #define	PARTYPE		(sizeof(struct parnod))
2036697Smckusick #define	LSTTYPE		(sizeof(struct lstnod))
2046697Smckusick #define	IOTYPE		(sizeof(struct ionod))
205*34082Sbostic 
206*34082Sbostic /* this node is a proforma for those that precede it */
207*34082Sbostic union trenod {
208*34082Sbostic 	INT	tretyp;
209*34082Sbostic 	struct { INT dummyy; IOPTR treio;} treio;
210*34082Sbostic 	struct forknod	forknod;
211*34082Sbostic 	struct comnod	comnod;
212*34082Sbostic 	struct ifnod	ifnod;
213*34082Sbostic 	struct whnod	whnod;
214*34082Sbostic 	struct fornod	fornod;
215*34082Sbostic 	struct swnod	swnod;
216*34082Sbostic 	struct lstnod	lstnod;
217*34082Sbostic 	struct parnod	parnod;
218*34082Sbostic };
219