10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2013Smj162486 * Common Development and Distribution License (the "License"). 6*2013Smj162486 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*2013Smj162486 /* 22*2013Smj162486 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*2013Smj162486 * Use is subject to license terms. 24*2013Smj162486 */ 25*2013Smj162486 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 26*2013Smj162486 /* All Rights Reserved */ 270Sstevel@tonic-gate 28*2013Smj162486 #pragma ident "%Z%%M% %I% %E% SMI" 290Sstevel@tonic-gate 30*2013Smj162486 #ifndef _MODE_H 31*2013Smj162486 #define _MODE_H 32*2013Smj162486 330Sstevel@tonic-gate /* 340Sstevel@tonic-gate * UNIX shell 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate 370Sstevel@tonic-gate #include <unistd.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef pdp11 400Sstevel@tonic-gate typedef char BOOL; 410Sstevel@tonic-gate #else 420Sstevel@tonic-gate typedef short BOOL; 430Sstevel@tonic-gate #endif 440Sstevel@tonic-gate 450Sstevel@tonic-gate #define BYTESPERWORD (sizeof (char *)) 46*2013Smj162486 #define ALIGNSIZ (sizeof (double)) 47*2013Smj162486 #define NIL ((char *)0) 480Sstevel@tonic-gate 490Sstevel@tonic-gate 50*2013Smj162486 /* 51*2013Smj162486 * the following nonsense is required 520Sstevel@tonic-gate * because casts turn an Lvalue 530Sstevel@tonic-gate * into an Rvalue so two cheats 540Sstevel@tonic-gate * are necessary, one for each context. 550Sstevel@tonic-gate */ 560Sstevel@tonic-gate #define Rcheat(a) ((int)(a)) 570Sstevel@tonic-gate 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* address puns for storage allocation */ 600Sstevel@tonic-gate typedef union 610Sstevel@tonic-gate { 620Sstevel@tonic-gate struct forknod *_forkptr; 630Sstevel@tonic-gate struct comnod *_comptr; 640Sstevel@tonic-gate struct fndnod *_fndptr; 650Sstevel@tonic-gate struct parnod *_parptr; 660Sstevel@tonic-gate struct ifnod *_ifptr; 670Sstevel@tonic-gate struct whnod *_whptr; 680Sstevel@tonic-gate struct fornod *_forptr; 690Sstevel@tonic-gate struct lstnod *_lstptr; 700Sstevel@tonic-gate struct blk *_blkptr; 710Sstevel@tonic-gate struct namnod *_namptr; 720Sstevel@tonic-gate char *_bytptr; 730Sstevel@tonic-gate } address; 740Sstevel@tonic-gate 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* heap storage */ 770Sstevel@tonic-gate struct blk 780Sstevel@tonic-gate { 790Sstevel@tonic-gate struct blk *word; 80*2013Smj162486 char pad[ALIGNSIZ - sizeof (struct blk *)]; 810Sstevel@tonic-gate }; 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * largefile converson hack note. 850Sstevel@tonic-gate * the shell uses the *fnxt and *fend pointers when 860Sstevel@tonic-gate * parsing a script. However, it was also using the 870Sstevel@tonic-gate * difference between them when doing lseeks. Because 880Sstevel@tonic-gate * that doesn't work in the largefile world, I have 890Sstevel@tonic-gate * added a parallel set of offset counters that need to 900Sstevel@tonic-gate * be updated whenever the "buffer" offsets the shell 910Sstevel@tonic-gate * uses get changed. Most of this code is in word.c. 920Sstevel@tonic-gate * If you change it, have fun... 930Sstevel@tonic-gate */ 940Sstevel@tonic-gate 950Sstevel@tonic-gate #define BUFFERSIZE 128 960Sstevel@tonic-gate struct fileblk 970Sstevel@tonic-gate { 980Sstevel@tonic-gate int fdes; 990Sstevel@tonic-gate unsigned flin; 1000Sstevel@tonic-gate BOOL feof; 1010Sstevel@tonic-gate unsigned char fsiz; 1020Sstevel@tonic-gate unsigned char *fnxt; 1030Sstevel@tonic-gate unsigned char *fend; 1040Sstevel@tonic-gate off_t nxtoff; /* file offset */ 1050Sstevel@tonic-gate off_t endoff; /* file offset */ 1060Sstevel@tonic-gate unsigned char **feval; 1070Sstevel@tonic-gate struct fileblk *fstak; 1080Sstevel@tonic-gate unsigned char fbuf[BUFFERSIZE]; 1090Sstevel@tonic-gate }; 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate struct tempblk 1120Sstevel@tonic-gate { 1130Sstevel@tonic-gate int fdes; 1140Sstevel@tonic-gate struct tempblk *fstak; 1150Sstevel@tonic-gate }; 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* for files not used with file descriptors */ 1190Sstevel@tonic-gate struct filehdr 1200Sstevel@tonic-gate { 1210Sstevel@tonic-gate int fdes; 1220Sstevel@tonic-gate unsigned flin; 1230Sstevel@tonic-gate BOOL feof; 1240Sstevel@tonic-gate unsigned char fsiz; 1250Sstevel@tonic-gate unsigned char *fnxt; 1260Sstevel@tonic-gate unsigned char *fend; 1270Sstevel@tonic-gate off_t nxtoff; /* file offset */ 1280Sstevel@tonic-gate off_t endoff; /* file offset */ 1290Sstevel@tonic-gate unsigned char **feval; 1300Sstevel@tonic-gate struct fileblk *fstak; 1310Sstevel@tonic-gate unsigned char _fbuf[1]; 1320Sstevel@tonic-gate }; 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate struct sysnod 1350Sstevel@tonic-gate { 1360Sstevel@tonic-gate char *sysnam; 1370Sstevel@tonic-gate int sysval; 1380Sstevel@tonic-gate }; 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* this node is a proforma for those that follow */ 1410Sstevel@tonic-gate struct trenod 1420Sstevel@tonic-gate { 1430Sstevel@tonic-gate int tretyp; 1440Sstevel@tonic-gate struct ionod *treio; 1450Sstevel@tonic-gate }; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* dummy for access only */ 1480Sstevel@tonic-gate struct argnod 1490Sstevel@tonic-gate { 1500Sstevel@tonic-gate struct argnod *argnxt; 1510Sstevel@tonic-gate unsigned char argval[1]; 1520Sstevel@tonic-gate }; 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate struct dolnod 1550Sstevel@tonic-gate { 1560Sstevel@tonic-gate struct dolnod *dolnxt; 1570Sstevel@tonic-gate int doluse; 1580Sstevel@tonic-gate unsigned char **dolarg; 1590Sstevel@tonic-gate }; 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate struct forknod 1620Sstevel@tonic-gate { 1630Sstevel@tonic-gate int forktyp; 1640Sstevel@tonic-gate struct ionod *forkio; 1650Sstevel@tonic-gate struct trenod *forktre; 1660Sstevel@tonic-gate }; 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate struct comnod 1690Sstevel@tonic-gate { 1700Sstevel@tonic-gate int comtyp; 1710Sstevel@tonic-gate struct ionod *comio; 1720Sstevel@tonic-gate struct argnod *comarg; 1730Sstevel@tonic-gate struct argnod *comset; 1740Sstevel@tonic-gate }; 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate struct fndnod 1770Sstevel@tonic-gate { 1780Sstevel@tonic-gate int fndtyp; 1790Sstevel@tonic-gate unsigned char *fndnam; 1800Sstevel@tonic-gate struct trenod *fndval; 1810Sstevel@tonic-gate }; 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate struct ifnod 1840Sstevel@tonic-gate { 1850Sstevel@tonic-gate int iftyp; 1860Sstevel@tonic-gate struct trenod *iftre; 1870Sstevel@tonic-gate struct trenod *thtre; 1880Sstevel@tonic-gate struct trenod *eltre; 1890Sstevel@tonic-gate }; 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate struct whnod 1920Sstevel@tonic-gate { 1930Sstevel@tonic-gate int whtyp; 1940Sstevel@tonic-gate struct trenod *whtre; 1950Sstevel@tonic-gate struct trenod *dotre; 1960Sstevel@tonic-gate }; 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate struct fornod 1990Sstevel@tonic-gate { 2000Sstevel@tonic-gate int fortyp; 2010Sstevel@tonic-gate struct trenod *fortre; 2020Sstevel@tonic-gate unsigned char *fornam; 2030Sstevel@tonic-gate struct comnod *forlst; 2040Sstevel@tonic-gate }; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate struct swnod 2070Sstevel@tonic-gate { 2080Sstevel@tonic-gate int swtyp; 2090Sstevel@tonic-gate unsigned char *swarg; 2100Sstevel@tonic-gate struct regnod *swlst; 2110Sstevel@tonic-gate }; 2120Sstevel@tonic-gate 2130Sstevel@tonic-gate struct regnod 2140Sstevel@tonic-gate { 2150Sstevel@tonic-gate struct argnod *regptr; 2160Sstevel@tonic-gate struct trenod *regcom; 2170Sstevel@tonic-gate struct regnod *regnxt; 2180Sstevel@tonic-gate }; 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate struct parnod 2210Sstevel@tonic-gate { 2220Sstevel@tonic-gate int partyp; 2230Sstevel@tonic-gate struct trenod *partre; 2240Sstevel@tonic-gate }; 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate struct lstnod 2270Sstevel@tonic-gate { 2280Sstevel@tonic-gate int lsttyp; 2290Sstevel@tonic-gate struct trenod *lstlef; 2300Sstevel@tonic-gate struct trenod *lstrit; 2310Sstevel@tonic-gate }; 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate struct ionod 2340Sstevel@tonic-gate { 2350Sstevel@tonic-gate int iofile; 2360Sstevel@tonic-gate char *ioname; 2370Sstevel@tonic-gate char *iolink; 2380Sstevel@tonic-gate struct ionod *ionxt; 2390Sstevel@tonic-gate struct ionod *iolst; 2400Sstevel@tonic-gate }; 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate struct fdsave 2430Sstevel@tonic-gate { 2440Sstevel@tonic-gate int org_fd; 2450Sstevel@tonic-gate int dup_fd; 2460Sstevel@tonic-gate }; 2470Sstevel@tonic-gate 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate #define fndptr(x) ((struct fndnod *)x) 2500Sstevel@tonic-gate #define comptr(x) ((struct comnod *)x) 2510Sstevel@tonic-gate #define forkptr(x) ((struct forknod *)x) 2520Sstevel@tonic-gate #define parptr(x) ((struct parnod *)x) 2530Sstevel@tonic-gate #define lstptr(x) ((struct lstnod *)x) 2540Sstevel@tonic-gate #define forptr(x) ((struct fornod *)x) 2550Sstevel@tonic-gate #define whptr(x) ((struct whnod *)x) 2560Sstevel@tonic-gate #define ifptr(x) ((struct ifnod *)x) 2570Sstevel@tonic-gate #define swptr(x) ((struct swnod *)x) 258*2013Smj162486 259*2013Smj162486 #endif /* _MODE_H */ 260