/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1985 AT&T * All Rights Reserved * * Include file for test.c */ #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */ /* error exits from various parts of shell */ #define ERROR 1 #define SYNBAD 2 #define SIGFAIL 2000 #define SIGFLG 0200 /* command tree */ #define FPRS 0x0100 #define FINT 0x0200 #define FAMP 0x0400 #define FPIN 0x0800 #define FPOU 0x1000 #define FPCL 0x2000 #define FCMD 0x4000 #define COMMSK 0x00F0 #define CNTMSK 0x000F #define TCOM 0x0000 #define TPAR 0x0010 #define TFIL 0x0020 #define TLST 0x0030 #define TIF 0x0040 #define TWH 0x0050 #define TUN 0x0060 #define TSW 0x0070 #define TAND 0x0080 #define TORF 0x0090 #define TFORK 0x00A0 #define TFOR 0x00B0 #define TFND 0x00C0 /* execute table */ #define SYSSET 1 #define SYSCD 2 #define SYSEXEC 3 #ifdef RES /* include login code */ #define SYSLOGIN 4 #else #define SYSNEWGRP 4 #endif #define SYSTRAP 5 #define SYSEXIT 6 #define SYSSHFT 7 #define SYSWAIT 8 #define SYSCONT 9 #define SYSBREAK 10 #define SYSEVAL 11 #define SYSDOT 12 #define SYSRDONLY 13 #define SYSTIMES 14 #define SYSXPORT 15 #define SYSNULL 16 #define SYSREAD 17 #define SYSTST 18 #ifndef RES /* exclude umask code */ #define SYSUMASK 20 #define SYSULIMIT 21 #endif #define SYSECHO 22 #define SYSHASH 23 #define SYSPWD 24 #define SYSRETURN 25 #define SYSUNS 26 #define SYSMEM 27 #define SYSTYPE 28 /* used for input and output of shell */ #define INIO 19 /*io nodes*/ #define USERIO 10 #define IOUFD 15 #define IODOC 16 #define IOPUT 32 #define IOAPP 64 #define IOMOV 128 #define IORDW 256 #define IOSTRIP 512 #define INPIPE 0 #define OTPIPE 1 /* arg list terminator */ #define ENDARGS 0 /* * begin: mac.h */ #define TRUE (-1) #define FALSE 0 #define LOBYTE 0377 #define STRIP 0177 #define QUOTE 0200 #define EOF 0 #define NL '\n' #define SP ' ' #define LQ '`' #define RQ '\'' #define MINUS '-' #define COLON ':' #define TAB '\t' #define MAX(a,b) ((a)>(b)?(a):(b)) #define blank() prc(SP) #define tab() prc(TAB) #define newline() prc(NL) /* * end: mac.h */ /* * begin: mode.h */ #ifdef pdp11 typedef char BOOL; #else typedef short BOOL; #endif #define BYTESPERWORD (sizeof (char *)) #define NIL ((char*)0) /* the following nonsense is required * because casts turn an Lvalue * into an Rvalue so two cheats * are necessary, one for each context. NOT USED -- generates warnings -- REMOVED abs 9/22/88 union { int _cheat;}; #define Lcheat(a) ((a)._cheat) #define Rcheat(a) ((int)(a)) */ /* address puns for storage allocation */ typedef union { struct forknod *_forkptr; struct comnod *_comptr; struct fndnod *_fndptr; struct parnod *_parptr; struct ifnod *_ifptr; struct whnod *_whptr; struct fornod *_forptr; struct lstnod *_lstptr; struct blk *_blkptr; struct namnod *_namptr; char *_bytptr; } address; /* heap storage */ struct blk { struct blk *word; }; #define BUFSIZ 1024 struct fileblk { int fdes; unsigned flin; BOOL feof; unsigned char fsiz; char *fnxt; char *fend; char **feval; struct fileblk *fstak; char fbuf[BUFSIZ]; }; struct tempblk { int fdes; struct tempblk *fstak; }; /* for files not used with file descriptors */ struct filehdr { int fdes; unsigned flin; BOOL feof; unsigned char fsiz; char *fnxt; char *fend; char **feval; struct fileblk *fstak; char _fbuf[1]; }; struct sysnod { char *sysnam; int sysval; }; /* this node is a proforma for those that follow */ struct trenod { int tretyp; struct ionod *treio; }; /* dummy for access only */ struct argnod { struct argnod *argnxt; char argval[1]; }; struct dolnod { struct dolnod *dolnxt; int doluse; char *dolarg[1]; }; struct forknod { int forktyp; struct ionod *forkio; struct trenod *forktre; }; struct comnod { int comtyp; struct ionod *comio; struct argnod *comarg; struct argnod *comset; }; struct fndnod { int fndtyp; char *fndnam; struct trenod *fndval; }; struct ifnod { int iftyp; struct trenod *iftre; struct trenod *thtre; struct trenod *eltre; }; struct whnod { int whtyp; struct trenod *whtre; struct trenod *dotre; }; struct fornod { int fortyp; struct trenod *fortre; char *fornam; struct comnod *forlst; }; struct swnod { int swtyp; char *swarg; struct regnod *swlst; }; struct regnod { struct argnod *regptr; struct trenod *regcom; struct regnod *regnxt; }; struct parnod { int partyp; struct trenod *partre; }; struct lstnod { int lsttyp; struct trenod *lstlef; struct trenod *lstrit; }; struct ionod { int iofile; char *ioname; char *iolink; struct ionod *ionxt; struct ionod *iolst; }; struct fdsave { int org_fd; int dup_fd; }; #define fndptr(x) ((struct fndnod *)x) #define comptr(x) ((struct comnod *)x) #define forkptr(x) ((struct forknod *)x) #define parptr(x) ((struct parnod *)x) #define lstptr(x) ((struct lstnod *)x) #define forptr(x) ((struct fornod *)x) #define whptr(x) ((struct whnod *)x) #define ifptr(x) ((struct ifnod *)x) #define swptr(x) ((struct swnod *)x) /* * end: mode.h */ /* * begin: name.h */ #define N_ENVCHG 0020 #define N_RDONLY 0010 #define N_EXPORT 0004 #define N_ENVNAM 0002 #define N_FUNCTN 0001 #define N_DEFAULT 0 struct namnod { struct namnod *namlft; struct namnod *namrgt; char *namid; char *namval; char *namenv; int namflg; }; /* * end: name.h */ #include /* error catching */ /* extern int errno; EFT abs k16 */ /* result type declarations */ #define alloc malloc /* wish.h includes malloc.h extern char *alloc();*/ extern char *make(); extern char *movstr(); extern char *movstrn(); extern struct trenod *cmd(); extern struct trenod *makefork(); extern struct namnod *lookup(); extern struct namnod *findnam(); extern struct dolnod *useargs(); extern float expr(); extern char *catpath(); extern char *getpath(); extern char *nextpath(); extern char **scan(); extern char *mactrim(); extern char *macro(); extern char *execs(); extern char *copyto(); extern int exname(); extern char *staknam(); extern int printnam(); extern int printro(); extern int printexp(); extern char **setenv(); extern time_t time(); /* EFT abs k16 */ #define attrib(n,f) (n->namflg |= f) #define round(a,b) (((int)(((char *)(a)+b)-1))&~((b)-1)) #define closepipe(x) (close(x[INPIPE]), close(x[OTPIPE])) #define eq(a,b) (cf(a,b)==0) #define assert(x) ; /* temp files and io */ extern int output; extern int ioset; extern struct ionod *iotemp; /* files to be deleted sometime */ extern struct ionod *fiotemp; /* function files to be deleted sometime */ extern struct ionod *iopend; /* documents waiting to be read at NL */ extern struct fdsave fdmap[]; /* substitution */ extern int dolc; extern char **dolv; extern struct dolnod *argfor; extern struct argnod *gchain; /* * begin: stak.h */ /* To use stack as temporary workspace across * possible storage allocation (eg name lookup) * a) get ptr from `relstak' * b) can now use `pushstak' * c) then reset with `setstak' * d) `absstak' gives real address if needed */ #define relstak() (staktop-stakbot) /* NOT USED--Rcheat commented out above. abs 9/22/88 #define absstak(x) (stakbot+Rcheat(x)) #define setstak(x) (staktop=absstak(x)) */ #define pushstak(c) (*staktop++=(c)) #define zerostak() (*staktop=0) /* Used to address an item left on the top of * the stack (very temporary) */ #define curstak() (staktop) /* `usestak' before `pushstak' then `fixstak' * These routines are safe against heap * being allocated. */ #define usestak() {locstak();} /* for local use only since it hands * out a real address for the stack top */ extern char *locstak(); /* Will allocate the item being used and return its * address (safe now). */ #define fixstak() endstak(staktop) /* For use after `locstak' to hand back * new stack top and then allocate item */ extern char *endstak(); /* Copy a string onto the stack and * allocate the space. */ extern char *cpystak(); /* Allocate given ammount of stack space */ extern char *getstak(); /* A chain of ptrs of stack blocks that * have become covered by heap allocation. * `tdystak' will return them to the heap. */ extern struct blk *stakbsy; /* Base of the entire stack */ extern char *stakbas; /* Top of entire stack */ extern char *brkend; /* Base of current item */ extern char *stakbot; /* Top of current item */ extern char *staktop; /* Used with tdystak */ extern char *savstak(); /* * end: stak.h */ /* string constants */ extern char atline[]; extern char readmsg[]; extern char colon[]; extern char minus[]; extern char nullstr[]; extern char sptbnl[]; extern char unexpected[]; extern char endoffile[]; /* name tree and words */ extern struct sysnod reserved[]; extern int no_reserved; extern struct sysnod commands[]; extern int no_commands; extern int wdval; extern int wdnum; extern int fndef; extern int nohash; extern struct argnod *wdarg; extern int wdset; extern BOOL reserv; /* prompting */ extern char stdprompt[]; extern char supprompt[]; extern char profile[]; extern char sysprofile[]; /* built in names */ extern struct namnod fngnod; extern struct namnod cdpnod; extern struct namnod ifsnod; extern struct namnod homenod; extern struct namnod mailnod; extern struct namnod pathnod; extern struct namnod ps1nod; extern struct namnod ps2nod; extern struct namnod mchknod; extern struct namnod acctnod; extern struct namnod mailpnod; /* special names */ extern char flagadr[]; extern char *pcsadr; extern char *pidadr; extern char *cmdadr; extern char defpath[]; /* names always present */ extern char mailname[]; extern char homename[]; extern char pathname[]; extern char cdpname[]; extern char ifsname[]; extern char ps1name[]; extern char ps2name[]; extern char mchkname[]; extern char acctname[]; extern char mailpname[]; /* transput */ extern char tmpout[]; extern int serial; #define TMPNAM 7 extern struct fileblk *standin; #define input (standin->fdes) #define eof (standin->feof) extern int peekc; extern int peekn; extern char *comdiv; extern char devnull[]; /* flags */ #define noexec 01 #define sysflg 01 #define intflg 02 #define prompt 04 #define setflg 010 #define errflg 020 #define ttyflg 040 #define forked 0100 #define oneflg 0200 #define rshflg 0400 #define waiting 01000 #define stdflg 02000 #define STDFLG 's' #define execpr 04000 #define readpr 010000 #define keyflg 020000 #define hashflg 040000 #define nofngflg 0200000 #define exportflg 0400000 extern long flags; extern int rwait; /* flags read waiting */ /* error exits from various parts of shell */ #include extern jmp_buf subshell; extern jmp_buf errshell; /* fault handling */ /* * begin: brkincr.h */ #define BRKINCR 01000 #define BRKMAX 04000 /* * end: brkincr.h */ extern unsigned brkincr; #define MINTRAP 0 #define MAXTRAP 20 #define TRAPSET 2 #define SIGSET 4 #define SIGMOD 8 #define SIGCAUGHT 16 extern int fault(); extern BOOL trapnote; extern char *trapcom[]; extern BOOL trapflg[]; /* name tree and words */ extern char **environ; extern char numbuf[]; extern char export[]; extern char duperr[]; extern char readonly[]; /* execflgs */ extern int exitval; extern int retval; extern BOOL execbrk; extern int loopcnt; extern int breakcnt; extern int funcnt; /* messages */ extern char mailmsg[]; extern char coredump[]; extern char badopt[]; extern char badparam[]; extern char unset[]; extern char badsub[]; extern char nospace[]; extern char nostack[]; extern char notfound[]; extern char badtrap[]; extern char baddir[]; extern char badshift[]; extern char restricted[]; extern char execpmsg[]; extern char notid[]; extern char badulimit[]; extern char wtfailed[]; extern char badcreate[]; extern char nofork[]; extern char noswap[]; extern char piperr[]; extern char badopen[]; extern char badnum[]; extern char arglist[]; extern char txtbsy[]; extern char toobig[]; extern char badexec[]; extern char badfile[]; extern char badreturn[]; extern char badexport[]; extern char badunset[]; extern char nohome[]; extern char badperm[]; /* 'builtin' error messages */ extern char btest[]; extern char badop[]; /* fork constant */ #define FORKLIM 32 extern address end[]; #include "ctype.h" extern int wasintr; /* used to tell if break or delete is hit * while executing a wait */ extern int eflag; /* * Find out if it is time to go away. * `trapnote' is set to SIGSET when fault is seen and * no trap has been set. */ #define sigchk() if (trapnote & SIGSET) \ exitsh(exitval ? exitval : SIGFAIL) #define exitset() retval = exitval