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 52013Smj162486 * Common Development and Distribution License (the "License"). 62013Smj162486 * 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 */ 212013Smj162486 /* 22*9369SNobutomo.Nakano@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 232013Smj162486 * Use is subject to license terms. 242013Smj162486 */ 252013Smj162486 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 262013Smj162486 /* All Rights Reserved */ 270Sstevel@tonic-gate 282013Smj162486 #ifndef _MODE_H 292013Smj162486 #define _MODE_H 302013Smj162486 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * UNIX shell 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <unistd.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef pdp11 380Sstevel@tonic-gate typedef char BOOL; 390Sstevel@tonic-gate #else 400Sstevel@tonic-gate typedef short BOOL; 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate 430Sstevel@tonic-gate #define BYTESPERWORD (sizeof (char *)) 442013Smj162486 #define ALIGNSIZ (sizeof (double)) 452013Smj162486 #define NIL ((char *)0) 460Sstevel@tonic-gate 470Sstevel@tonic-gate 482013Smj162486 /* 492013Smj162486 * the following nonsense is required 500Sstevel@tonic-gate * because casts turn an Lvalue 510Sstevel@tonic-gate * into an Rvalue so two cheats 520Sstevel@tonic-gate * are necessary, one for each context. 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate #define Rcheat(a) ((int)(a)) 550Sstevel@tonic-gate 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* address puns for storage allocation */ 580Sstevel@tonic-gate typedef union 590Sstevel@tonic-gate { 600Sstevel@tonic-gate struct forknod *_forkptr; 610Sstevel@tonic-gate struct comnod *_comptr; 620Sstevel@tonic-gate struct fndnod *_fndptr; 630Sstevel@tonic-gate struct parnod *_parptr; 640Sstevel@tonic-gate struct ifnod *_ifptr; 650Sstevel@tonic-gate struct whnod *_whptr; 660Sstevel@tonic-gate struct fornod *_forptr; 670Sstevel@tonic-gate struct lstnod *_lstptr; 680Sstevel@tonic-gate struct blk *_blkptr; 690Sstevel@tonic-gate struct namnod *_namptr; 700Sstevel@tonic-gate char *_bytptr; 710Sstevel@tonic-gate } address; 720Sstevel@tonic-gate 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* heap storage */ 750Sstevel@tonic-gate struct blk 760Sstevel@tonic-gate { 770Sstevel@tonic-gate struct blk *word; 782013Smj162486 char pad[ALIGNSIZ - sizeof (struct blk *)]; 790Sstevel@tonic-gate }; 800Sstevel@tonic-gate 810Sstevel@tonic-gate /* 820Sstevel@tonic-gate * largefile converson hack note. 830Sstevel@tonic-gate * the shell uses the *fnxt and *fend pointers when 840Sstevel@tonic-gate * parsing a script. However, it was also using the 850Sstevel@tonic-gate * difference between them when doing lseeks. Because 860Sstevel@tonic-gate * that doesn't work in the largefile world, I have 870Sstevel@tonic-gate * added a parallel set of offset counters that need to 880Sstevel@tonic-gate * be updated whenever the "buffer" offsets the shell 890Sstevel@tonic-gate * uses get changed. Most of this code is in word.c. 900Sstevel@tonic-gate * If you change it, have fun... 910Sstevel@tonic-gate */ 920Sstevel@tonic-gate 930Sstevel@tonic-gate #define BUFFERSIZE 128 940Sstevel@tonic-gate struct fileblk 950Sstevel@tonic-gate { 960Sstevel@tonic-gate int fdes; 970Sstevel@tonic-gate unsigned flin; 980Sstevel@tonic-gate BOOL feof; 990Sstevel@tonic-gate unsigned char fsiz; 1000Sstevel@tonic-gate unsigned char *fnxt; 1010Sstevel@tonic-gate unsigned char *fend; 1020Sstevel@tonic-gate off_t nxtoff; /* file offset */ 1030Sstevel@tonic-gate off_t endoff; /* file offset */ 1040Sstevel@tonic-gate unsigned char **feval; 1050Sstevel@tonic-gate struct fileblk *fstak; 1060Sstevel@tonic-gate unsigned char fbuf[BUFFERSIZE]; 1070Sstevel@tonic-gate }; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate struct tempblk 1100Sstevel@tonic-gate { 1110Sstevel@tonic-gate int fdes; 1120Sstevel@tonic-gate struct tempblk *fstak; 1130Sstevel@tonic-gate }; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* for files not used with file descriptors */ 1170Sstevel@tonic-gate struct filehdr 1180Sstevel@tonic-gate { 1190Sstevel@tonic-gate int fdes; 1200Sstevel@tonic-gate unsigned flin; 1210Sstevel@tonic-gate BOOL feof; 1220Sstevel@tonic-gate unsigned char fsiz; 1230Sstevel@tonic-gate unsigned char *fnxt; 1240Sstevel@tonic-gate unsigned char *fend; 1250Sstevel@tonic-gate off_t nxtoff; /* file offset */ 1260Sstevel@tonic-gate off_t endoff; /* file offset */ 1270Sstevel@tonic-gate unsigned char **feval; 1280Sstevel@tonic-gate struct fileblk *fstak; 1290Sstevel@tonic-gate unsigned char _fbuf[1]; 1300Sstevel@tonic-gate }; 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate struct sysnod 1330Sstevel@tonic-gate { 1340Sstevel@tonic-gate char *sysnam; 1350Sstevel@tonic-gate int sysval; 1360Sstevel@tonic-gate }; 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate /* this node is a proforma for those that follow */ 1390Sstevel@tonic-gate struct trenod 1400Sstevel@tonic-gate { 1410Sstevel@tonic-gate int tretyp; 1420Sstevel@tonic-gate struct ionod *treio; 1430Sstevel@tonic-gate }; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* dummy for access only */ 1460Sstevel@tonic-gate struct argnod 1470Sstevel@tonic-gate { 1480Sstevel@tonic-gate struct argnod *argnxt; 1490Sstevel@tonic-gate unsigned char argval[1]; 1500Sstevel@tonic-gate }; 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate struct dolnod 1530Sstevel@tonic-gate { 1540Sstevel@tonic-gate struct dolnod *dolnxt; 1550Sstevel@tonic-gate int doluse; 1560Sstevel@tonic-gate unsigned char **dolarg; 1570Sstevel@tonic-gate }; 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate struct forknod 1600Sstevel@tonic-gate { 1610Sstevel@tonic-gate int forktyp; 1620Sstevel@tonic-gate struct ionod *forkio; 1630Sstevel@tonic-gate struct trenod *forktre; 1640Sstevel@tonic-gate }; 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate struct comnod 1670Sstevel@tonic-gate { 1680Sstevel@tonic-gate int comtyp; 1690Sstevel@tonic-gate struct ionod *comio; 1700Sstevel@tonic-gate struct argnod *comarg; 1710Sstevel@tonic-gate struct argnod *comset; 1720Sstevel@tonic-gate }; 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate struct fndnod 1750Sstevel@tonic-gate { 1760Sstevel@tonic-gate int fndtyp; 1770Sstevel@tonic-gate unsigned char *fndnam; 1780Sstevel@tonic-gate struct trenod *fndval; 179*9369SNobutomo.Nakano@Sun.COM int fndref; 1800Sstevel@tonic-gate }; 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate struct ifnod 1830Sstevel@tonic-gate { 1840Sstevel@tonic-gate int iftyp; 1850Sstevel@tonic-gate struct trenod *iftre; 1860Sstevel@tonic-gate struct trenod *thtre; 1870Sstevel@tonic-gate struct trenod *eltre; 1880Sstevel@tonic-gate }; 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate struct whnod 1910Sstevel@tonic-gate { 1920Sstevel@tonic-gate int whtyp; 1930Sstevel@tonic-gate struct trenod *whtre; 1940Sstevel@tonic-gate struct trenod *dotre; 1950Sstevel@tonic-gate }; 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate struct fornod 1980Sstevel@tonic-gate { 1990Sstevel@tonic-gate int fortyp; 2000Sstevel@tonic-gate struct trenod *fortre; 2010Sstevel@tonic-gate unsigned char *fornam; 2020Sstevel@tonic-gate struct comnod *forlst; 2030Sstevel@tonic-gate }; 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate struct swnod 2060Sstevel@tonic-gate { 2070Sstevel@tonic-gate int swtyp; 2080Sstevel@tonic-gate unsigned char *swarg; 2090Sstevel@tonic-gate struct regnod *swlst; 2100Sstevel@tonic-gate }; 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate struct regnod 2130Sstevel@tonic-gate { 2140Sstevel@tonic-gate struct argnod *regptr; 2150Sstevel@tonic-gate struct trenod *regcom; 2160Sstevel@tonic-gate struct regnod *regnxt; 2170Sstevel@tonic-gate }; 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate struct parnod 2200Sstevel@tonic-gate { 2210Sstevel@tonic-gate int partyp; 2220Sstevel@tonic-gate struct trenod *partre; 2230Sstevel@tonic-gate }; 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate struct lstnod 2260Sstevel@tonic-gate { 2270Sstevel@tonic-gate int lsttyp; 2280Sstevel@tonic-gate struct trenod *lstlef; 2290Sstevel@tonic-gate struct trenod *lstrit; 2300Sstevel@tonic-gate }; 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate struct ionod 2330Sstevel@tonic-gate { 2340Sstevel@tonic-gate int iofile; 2350Sstevel@tonic-gate char *ioname; 2360Sstevel@tonic-gate char *iolink; 2370Sstevel@tonic-gate struct ionod *ionxt; 2380Sstevel@tonic-gate struct ionod *iolst; 2390Sstevel@tonic-gate }; 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate struct fdsave 2420Sstevel@tonic-gate { 2430Sstevel@tonic-gate int org_fd; 2440Sstevel@tonic-gate int dup_fd; 2450Sstevel@tonic-gate }; 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate 2480Sstevel@tonic-gate #define fndptr(x) ((struct fndnod *)x) 2490Sstevel@tonic-gate #define comptr(x) ((struct comnod *)x) 2500Sstevel@tonic-gate #define forkptr(x) ((struct forknod *)x) 2510Sstevel@tonic-gate #define parptr(x) ((struct parnod *)x) 2520Sstevel@tonic-gate #define lstptr(x) ((struct lstnod *)x) 2530Sstevel@tonic-gate #define forptr(x) ((struct fornod *)x) 2540Sstevel@tonic-gate #define whptr(x) ((struct whnod *)x) 2550Sstevel@tonic-gate #define ifptr(x) ((struct ifnod *)x) 2560Sstevel@tonic-gate #define swptr(x) ((struct swnod *)x) 2572013Smj162486 2582013Smj162486 #endif /* _MODE_H */ 259