1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate /* 27*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 28*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 29*7c478bd9Sstevel@tonic-gate */ 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifndef _DEFS_H 33*7c478bd9Sstevel@tonic-gate #define _DEFS_H 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 38*7c478bd9Sstevel@tonic-gate extern "C" { 39*7c478bd9Sstevel@tonic-gate #endif 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate /* 42*7c478bd9Sstevel@tonic-gate * UNIX shell 43*7c478bd9Sstevel@tonic-gate */ 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* execute flags */ 46*7c478bd9Sstevel@tonic-gate #define XEC_EXECED 01 47*7c478bd9Sstevel@tonic-gate #define XEC_LINKED 02 48*7c478bd9Sstevel@tonic-gate #define XEC_NOSTOP 04 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate /* endjobs flags */ 51*7c478bd9Sstevel@tonic-gate #define JOB_STOPPED 01 52*7c478bd9Sstevel@tonic-gate #define JOB_RUNNING 02 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* error exits from various parts of shell */ 55*7c478bd9Sstevel@tonic-gate #define ERROR 1 56*7c478bd9Sstevel@tonic-gate #define SYNBAD 2 57*7c478bd9Sstevel@tonic-gate #define SIGFAIL 2000 58*7c478bd9Sstevel@tonic-gate #define SIGFLG 0200 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* command tree */ 61*7c478bd9Sstevel@tonic-gate #define FPIN 0x0100 62*7c478bd9Sstevel@tonic-gate #define FPOU 0x0200 63*7c478bd9Sstevel@tonic-gate #define FAMP 0x0400 64*7c478bd9Sstevel@tonic-gate #define COMMSK 0x00F0 65*7c478bd9Sstevel@tonic-gate #define CNTMSK 0x000F 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate #define TCOM 0x0000 68*7c478bd9Sstevel@tonic-gate #define TPAR 0x0010 69*7c478bd9Sstevel@tonic-gate #define TFIL 0x0020 70*7c478bd9Sstevel@tonic-gate #define TLST 0x0030 71*7c478bd9Sstevel@tonic-gate #define TIF 0x0040 72*7c478bd9Sstevel@tonic-gate #define TWH 0x0050 73*7c478bd9Sstevel@tonic-gate #define TUN 0x0060 74*7c478bd9Sstevel@tonic-gate #define TSW 0x0070 75*7c478bd9Sstevel@tonic-gate #define TAND 0x0080 76*7c478bd9Sstevel@tonic-gate #define TORF 0x0090 77*7c478bd9Sstevel@tonic-gate #define TFORK 0x00A0 78*7c478bd9Sstevel@tonic-gate #define TFOR 0x00B0 79*7c478bd9Sstevel@tonic-gate #define TFND 0x00C0 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate /* execute table */ 82*7c478bd9Sstevel@tonic-gate #define SYSSET 1 83*7c478bd9Sstevel@tonic-gate #define SYSCD 2 84*7c478bd9Sstevel@tonic-gate #define SYSEXEC 3 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate #ifdef RES /* include login code */ 87*7c478bd9Sstevel@tonic-gate #define SYSLOGIN 4 88*7c478bd9Sstevel@tonic-gate #else 89*7c478bd9Sstevel@tonic-gate #define SYSNEWGRP 4 90*7c478bd9Sstevel@tonic-gate #endif 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate #define SYSTRAP 5 93*7c478bd9Sstevel@tonic-gate #define SYSEXIT 6 94*7c478bd9Sstevel@tonic-gate #define SYSSHFT 7 95*7c478bd9Sstevel@tonic-gate #define SYSWAIT 8 96*7c478bd9Sstevel@tonic-gate #define SYSCONT 9 97*7c478bd9Sstevel@tonic-gate #define SYSBREAK 10 98*7c478bd9Sstevel@tonic-gate #define SYSEVAL 11 99*7c478bd9Sstevel@tonic-gate #define SYSDOT 12 100*7c478bd9Sstevel@tonic-gate #define SYSRDONLY 13 101*7c478bd9Sstevel@tonic-gate #define SYSTIMES 14 102*7c478bd9Sstevel@tonic-gate #define SYSXPORT 15 103*7c478bd9Sstevel@tonic-gate #define SYSNULL 16 104*7c478bd9Sstevel@tonic-gate #define SYSREAD 17 105*7c478bd9Sstevel@tonic-gate #define SYSTST 18 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate #ifndef RES /* exclude umask code */ 108*7c478bd9Sstevel@tonic-gate #define SYSUMASK 20 109*7c478bd9Sstevel@tonic-gate #define SYSULIMIT 21 110*7c478bd9Sstevel@tonic-gate #endif 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate #define SYSECHO 22 113*7c478bd9Sstevel@tonic-gate #define SYSHASH 23 114*7c478bd9Sstevel@tonic-gate #define SYSPWD 24 115*7c478bd9Sstevel@tonic-gate #define SYSRETURN 25 116*7c478bd9Sstevel@tonic-gate #define SYSUNS 26 117*7c478bd9Sstevel@tonic-gate #define SYSMEM 27 118*7c478bd9Sstevel@tonic-gate #define SYSTYPE 28 119*7c478bd9Sstevel@tonic-gate #define SYSGETOPT 29 120*7c478bd9Sstevel@tonic-gate #define SYSJOBS 30 121*7c478bd9Sstevel@tonic-gate #define SYSFGBG 31 122*7c478bd9Sstevel@tonic-gate #define SYSKILL 32 123*7c478bd9Sstevel@tonic-gate #define SYSSUSP 33 124*7c478bd9Sstevel@tonic-gate #define SYSSTOP 34 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate /* used for input and output of shell */ 127*7c478bd9Sstevel@tonic-gate #define INIO 19 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate /* io nodes */ 130*7c478bd9Sstevel@tonic-gate #define USERIO 10 131*7c478bd9Sstevel@tonic-gate #define IOUFD 15 132*7c478bd9Sstevel@tonic-gate #define IODOC 16 133*7c478bd9Sstevel@tonic-gate #define IOPUT 32 134*7c478bd9Sstevel@tonic-gate #define IOAPP 64 135*7c478bd9Sstevel@tonic-gate #define IOMOV 128 136*7c478bd9Sstevel@tonic-gate #define IORDW 256 137*7c478bd9Sstevel@tonic-gate #define IOSTRIP 512 138*7c478bd9Sstevel@tonic-gate #define INPIPE 0 139*7c478bd9Sstevel@tonic-gate #define OTPIPE 1 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate /* arg list terminator */ 142*7c478bd9Sstevel@tonic-gate #define ENDARGS 0 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate #include <unistd.h> 145*7c478bd9Sstevel@tonic-gate #include "mac.h" 146*7c478bd9Sstevel@tonic-gate #include "mode.h" 147*7c478bd9Sstevel@tonic-gate #include "name.h" 148*7c478bd9Sstevel@tonic-gate #include <signal.h> 149*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate /* id's */ 152*7c478bd9Sstevel@tonic-gate extern pid_t mypid; 153*7c478bd9Sstevel@tonic-gate extern pid_t mypgid; 154*7c478bd9Sstevel@tonic-gate extern pid_t mysid; 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* getopt */ 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate extern int optind; 159*7c478bd9Sstevel@tonic-gate extern int opterr; 160*7c478bd9Sstevel@tonic-gate extern int _sp; 161*7c478bd9Sstevel@tonic-gate extern char *optarg; 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate /* use sh-private versions of memory allocation routines */ 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate #define alloc malloc 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate /* result type declarations */ 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate extern int handle(); 171*7c478bd9Sstevel@tonic-gate extern void chktrap(); 172*7c478bd9Sstevel@tonic-gate extern void done(); 173*7c478bd9Sstevel@tonic-gate extern void sh_free(); 174*7c478bd9Sstevel@tonic-gate extern unsigned char *make(); 175*7c478bd9Sstevel@tonic-gate extern unsigned char *movstr(); 176*7c478bd9Sstevel@tonic-gate extern unsigned char *movstrn(); 177*7c478bd9Sstevel@tonic-gate extern unsigned char *cwdget(); 178*7c478bd9Sstevel@tonic-gate extern struct trenod *cmd(); 179*7c478bd9Sstevel@tonic-gate extern struct trenod *makefork(); 180*7c478bd9Sstevel@tonic-gate extern struct namnod *lookup(); 181*7c478bd9Sstevel@tonic-gate extern struct namnod *findnam(); 182*7c478bd9Sstevel@tonic-gate extern struct dolnod *useargs(); 183*7c478bd9Sstevel@tonic-gate extern float expr(); 184*7c478bd9Sstevel@tonic-gate extern unsigned char *catpath(); 185*7c478bd9Sstevel@tonic-gate extern unsigned char *getpath(); 186*7c478bd9Sstevel@tonic-gate extern unsigned char *nextpath(); 187*7c478bd9Sstevel@tonic-gate extern unsigned char **scan(); 188*7c478bd9Sstevel@tonic-gate extern unsigned char *mactrim(); 189*7c478bd9Sstevel@tonic-gate extern unsigned char *macro(); 190*7c478bd9Sstevel@tonic-gate extern int exname(); 191*7c478bd9Sstevel@tonic-gate extern int printnam(); 192*7c478bd9Sstevel@tonic-gate extern int printro(); 193*7c478bd9Sstevel@tonic-gate extern int printexp(); 194*7c478bd9Sstevel@tonic-gate extern unsigned int readwc(); 195*7c478bd9Sstevel@tonic-gate extern unsigned int nextwc(); 196*7c478bd9Sstevel@tonic-gate extern unsigned char skipc(); 197*7c478bd9Sstevel@tonic-gate extern unsigned char **local_setenv(); 198*7c478bd9Sstevel@tonic-gate extern time_t time(); 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate #define attrib(n, f) (n->namflg |= f) 201*7c478bd9Sstevel@tonic-gate #define round(a, b) (((int)(((char *)(a)+b)-1))&~((b)-1)) 202*7c478bd9Sstevel@tonic-gate #define closepipe(x) (close(x[INPIPE]), close(x[OTPIPE])) 203*7c478bd9Sstevel@tonic-gate #define eq(a, b) (cf(a, b) == 0) 204*7c478bd9Sstevel@tonic-gate #define max(a, b) ((a) > (b)?(a):(b)) 205*7c478bd9Sstevel@tonic-gate #define assert(x) 206*7c478bd9Sstevel@tonic-gate 207*7c478bd9Sstevel@tonic-gate /* temp files and io */ 208*7c478bd9Sstevel@tonic-gate extern int output; 209*7c478bd9Sstevel@tonic-gate extern int ioset; 210*7c478bd9Sstevel@tonic-gate extern struct ionod *iotemp; /* files to be deleted sometime */ 211*7c478bd9Sstevel@tonic-gate extern struct ionod *fiotemp; /* function files to be deleted sometime */ 212*7c478bd9Sstevel@tonic-gate extern struct ionod *iopend; /* documents waiting to be read at NL */ 213*7c478bd9Sstevel@tonic-gate extern struct fdsave fdmap[]; 214*7c478bd9Sstevel@tonic-gate extern int savpipe; 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate /* substitution */ 217*7c478bd9Sstevel@tonic-gate extern int dolc; 218*7c478bd9Sstevel@tonic-gate extern unsigned char **dolv; 219*7c478bd9Sstevel@tonic-gate extern struct dolnod *argfor; 220*7c478bd9Sstevel@tonic-gate extern struct argnod *gchain; 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate /* stak stuff */ 223*7c478bd9Sstevel@tonic-gate #include "stak.h" 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate /* 226*7c478bd9Sstevel@tonic-gate * If non-ANSI C, make const go away. We bring it back 227*7c478bd9Sstevel@tonic-gate * at the end of the file to avoid side-effects. 228*7c478bd9Sstevel@tonic-gate */ 229*7c478bd9Sstevel@tonic-gate #ifndef __STDC__ 230*7c478bd9Sstevel@tonic-gate #define const 231*7c478bd9Sstevel@tonic-gate #endif 232*7c478bd9Sstevel@tonic-gate 233*7c478bd9Sstevel@tonic-gate /* string constants */ 234*7c478bd9Sstevel@tonic-gate extern const char atline[]; 235*7c478bd9Sstevel@tonic-gate extern const char readmsg[]; 236*7c478bd9Sstevel@tonic-gate extern const char colon[]; 237*7c478bd9Sstevel@tonic-gate extern const char minus[]; 238*7c478bd9Sstevel@tonic-gate extern const char nullstr[]; 239*7c478bd9Sstevel@tonic-gate extern const char sptbnl[]; 240*7c478bd9Sstevel@tonic-gate extern const char unexpected[]; 241*7c478bd9Sstevel@tonic-gate extern const char endoffile[]; 242*7c478bd9Sstevel@tonic-gate extern const char synmsg[]; 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate /* name tree and words */ 245*7c478bd9Sstevel@tonic-gate extern const struct sysnod reserved[]; 246*7c478bd9Sstevel@tonic-gate extern const int no_reserved; 247*7c478bd9Sstevel@tonic-gate extern const struct sysnod commands[]; 248*7c478bd9Sstevel@tonic-gate extern const int no_commands; 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate extern int wdval; 251*7c478bd9Sstevel@tonic-gate extern int wdnum; 252*7c478bd9Sstevel@tonic-gate extern int fndef; 253*7c478bd9Sstevel@tonic-gate extern int nohash; 254*7c478bd9Sstevel@tonic-gate extern struct argnod *wdarg; 255*7c478bd9Sstevel@tonic-gate extern int wdset; 256*7c478bd9Sstevel@tonic-gate extern BOOL reserv; 257*7c478bd9Sstevel@tonic-gate 258*7c478bd9Sstevel@tonic-gate /* prompting */ 259*7c478bd9Sstevel@tonic-gate extern const char stdprompt[]; 260*7c478bd9Sstevel@tonic-gate extern const char supprompt[]; 261*7c478bd9Sstevel@tonic-gate extern const char profile[]; 262*7c478bd9Sstevel@tonic-gate extern const char sysprofile[]; 263*7c478bd9Sstevel@tonic-gate 264*7c478bd9Sstevel@tonic-gate /* locale testing */ 265*7c478bd9Sstevel@tonic-gate extern const char localedir[]; 266*7c478bd9Sstevel@tonic-gate extern int localedir_exists; 267*7c478bd9Sstevel@tonic-gate 268*7c478bd9Sstevel@tonic-gate /* built in names */ 269*7c478bd9Sstevel@tonic-gate extern struct namnod fngnod; 270*7c478bd9Sstevel@tonic-gate extern struct namnod cdpnod; 271*7c478bd9Sstevel@tonic-gate extern struct namnod ifsnod; 272*7c478bd9Sstevel@tonic-gate extern struct namnod homenod; 273*7c478bd9Sstevel@tonic-gate extern struct namnod mailnod; 274*7c478bd9Sstevel@tonic-gate extern struct namnod pathnod; 275*7c478bd9Sstevel@tonic-gate extern struct namnod ps1nod; 276*7c478bd9Sstevel@tonic-gate extern struct namnod ps2nod; 277*7c478bd9Sstevel@tonic-gate extern struct namnod mchknod; 278*7c478bd9Sstevel@tonic-gate extern struct namnod acctnod; 279*7c478bd9Sstevel@tonic-gate extern struct namnod mailpnod; 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate /* special names */ 282*7c478bd9Sstevel@tonic-gate extern unsigned char flagadr[]; 283*7c478bd9Sstevel@tonic-gate extern unsigned char *pcsadr; 284*7c478bd9Sstevel@tonic-gate extern unsigned char *pidadr; 285*7c478bd9Sstevel@tonic-gate extern unsigned char *cmdadr; 286*7c478bd9Sstevel@tonic-gate 287*7c478bd9Sstevel@tonic-gate /* names always present */ 288*7c478bd9Sstevel@tonic-gate extern const char defpath[]; 289*7c478bd9Sstevel@tonic-gate extern const char mailname[]; 290*7c478bd9Sstevel@tonic-gate extern const char homename[]; 291*7c478bd9Sstevel@tonic-gate extern const char pathname[]; 292*7c478bd9Sstevel@tonic-gate extern const char cdpname[]; 293*7c478bd9Sstevel@tonic-gate extern const char ifsname[]; 294*7c478bd9Sstevel@tonic-gate extern const char ps1name[]; 295*7c478bd9Sstevel@tonic-gate extern const char ps2name[]; 296*7c478bd9Sstevel@tonic-gate extern const char mchkname[]; 297*7c478bd9Sstevel@tonic-gate extern const char acctname[]; 298*7c478bd9Sstevel@tonic-gate extern const char mailpname[]; 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate /* transput */ 301*7c478bd9Sstevel@tonic-gate extern unsigned char tmpout[]; 302*7c478bd9Sstevel@tonic-gate extern unsigned char *tmpname; 303*7c478bd9Sstevel@tonic-gate extern int serial; 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate #define TMPNAM 7 306*7c478bd9Sstevel@tonic-gate 307*7c478bd9Sstevel@tonic-gate extern struct fileblk *standin; 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate #define input (standin->fdes) 310*7c478bd9Sstevel@tonic-gate #define eof (standin->feof) 311*7c478bd9Sstevel@tonic-gate 312*7c478bd9Sstevel@tonic-gate extern int peekc; 313*7c478bd9Sstevel@tonic-gate extern int peekn; 314*7c478bd9Sstevel@tonic-gate extern unsigned char *comdiv; 315*7c478bd9Sstevel@tonic-gate extern 316*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 317*7c478bd9Sstevel@tonic-gate const 318*7c478bd9Sstevel@tonic-gate #endif 319*7c478bd9Sstevel@tonic-gate char devnull[]; 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate /* flags */ 322*7c478bd9Sstevel@tonic-gate #define noexec 01 323*7c478bd9Sstevel@tonic-gate #define sysflg 01 324*7c478bd9Sstevel@tonic-gate #define intflg 02 325*7c478bd9Sstevel@tonic-gate #define prompt 04 326*7c478bd9Sstevel@tonic-gate #define setflg 010 327*7c478bd9Sstevel@tonic-gate #define errflg 020 328*7c478bd9Sstevel@tonic-gate #define ttyflg 040 329*7c478bd9Sstevel@tonic-gate #define forked 0100 330*7c478bd9Sstevel@tonic-gate #define oneflg 0200 331*7c478bd9Sstevel@tonic-gate #define rshflg 0400 332*7c478bd9Sstevel@tonic-gate #define subsh 01000 333*7c478bd9Sstevel@tonic-gate #define stdflg 02000 334*7c478bd9Sstevel@tonic-gate #define STDFLG 's' 335*7c478bd9Sstevel@tonic-gate #define execpr 04000 336*7c478bd9Sstevel@tonic-gate #define readpr 010000 337*7c478bd9Sstevel@tonic-gate #define keyflg 020000 338*7c478bd9Sstevel@tonic-gate #define hashflg 040000 339*7c478bd9Sstevel@tonic-gate #define nofngflg 0200000 340*7c478bd9Sstevel@tonic-gate #define exportflg 0400000 341*7c478bd9Sstevel@tonic-gate #define monitorflg 01000000 342*7c478bd9Sstevel@tonic-gate #define jcflg 02000000 343*7c478bd9Sstevel@tonic-gate #define privflg 04000000 344*7c478bd9Sstevel@tonic-gate #define forcexit 010000000 345*7c478bd9Sstevel@tonic-gate #define jcoff 020000000 346*7c478bd9Sstevel@tonic-gate #define pfshflg 040000000 347*7c478bd9Sstevel@tonic-gate 348*7c478bd9Sstevel@tonic-gate extern long flags; 349*7c478bd9Sstevel@tonic-gate extern int rwait; /* flags read waiting */ 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate /* error exits from various parts of shell */ 352*7c478bd9Sstevel@tonic-gate #include <setjmp.h> 353*7c478bd9Sstevel@tonic-gate extern jmp_buf subshell; 354*7c478bd9Sstevel@tonic-gate extern jmp_buf errshell; 355*7c478bd9Sstevel@tonic-gate 356*7c478bd9Sstevel@tonic-gate /* fault handling */ 357*7c478bd9Sstevel@tonic-gate #include "brkincr.h" 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate extern unsigned brkincr; 360*7c478bd9Sstevel@tonic-gate #define MINTRAP 0 361*7c478bd9Sstevel@tonic-gate #define MAXTRAP NSIG 362*7c478bd9Sstevel@tonic-gate 363*7c478bd9Sstevel@tonic-gate #define TRAPSET 2 364*7c478bd9Sstevel@tonic-gate #define SIGSET 4 365*7c478bd9Sstevel@tonic-gate #define SIGMOD 8 366*7c478bd9Sstevel@tonic-gate #define SIGIGN 16 367*7c478bd9Sstevel@tonic-gate 368*7c478bd9Sstevel@tonic-gate extern BOOL trapnote; 369*7c478bd9Sstevel@tonic-gate 370*7c478bd9Sstevel@tonic-gate /* name tree and words */ 371*7c478bd9Sstevel@tonic-gate extern unsigned char **environ; 372*7c478bd9Sstevel@tonic-gate extern unsigned char numbuf[]; 373*7c478bd9Sstevel@tonic-gate extern const char export[]; 374*7c478bd9Sstevel@tonic-gate extern const char duperr[]; 375*7c478bd9Sstevel@tonic-gate extern const char readonly[]; 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate /* execflgs */ 378*7c478bd9Sstevel@tonic-gate extern int exitval; 379*7c478bd9Sstevel@tonic-gate extern int retval; 380*7c478bd9Sstevel@tonic-gate extern BOOL execbrk; 381*7c478bd9Sstevel@tonic-gate extern int loopcnt; 382*7c478bd9Sstevel@tonic-gate extern int breakcnt; 383*7c478bd9Sstevel@tonic-gate extern int funcnt; 384*7c478bd9Sstevel@tonic-gate extern int tried_to_exit; 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate /* messages */ 387*7c478bd9Sstevel@tonic-gate extern const char mailmsg[]; 388*7c478bd9Sstevel@tonic-gate extern const char coredump[]; 389*7c478bd9Sstevel@tonic-gate extern const char badopt[]; 390*7c478bd9Sstevel@tonic-gate extern const char badparam[]; 391*7c478bd9Sstevel@tonic-gate extern const char unset[]; 392*7c478bd9Sstevel@tonic-gate extern const char badsub[]; 393*7c478bd9Sstevel@tonic-gate extern const char nospace[]; 394*7c478bd9Sstevel@tonic-gate extern const char nostack[]; 395*7c478bd9Sstevel@tonic-gate extern const char notfound[]; 396*7c478bd9Sstevel@tonic-gate extern const char badtrap[]; 397*7c478bd9Sstevel@tonic-gate extern const char baddir[]; 398*7c478bd9Sstevel@tonic-gate extern const char badshift[]; 399*7c478bd9Sstevel@tonic-gate extern const char restricted[]; 400*7c478bd9Sstevel@tonic-gate extern const char execpmsg[]; 401*7c478bd9Sstevel@tonic-gate extern const char notid[]; 402*7c478bd9Sstevel@tonic-gate extern const char badulimit[]; 403*7c478bd9Sstevel@tonic-gate extern const char badresource[]; 404*7c478bd9Sstevel@tonic-gate extern const char badscale[]; 405*7c478bd9Sstevel@tonic-gate extern const char ulimit[]; 406*7c478bd9Sstevel@tonic-gate extern const char wtfailed[]; 407*7c478bd9Sstevel@tonic-gate extern const char badcreate[]; 408*7c478bd9Sstevel@tonic-gate extern const char nofork[]; 409*7c478bd9Sstevel@tonic-gate extern const char noswap[]; 410*7c478bd9Sstevel@tonic-gate extern const char piperr[]; 411*7c478bd9Sstevel@tonic-gate extern const char badopen[]; 412*7c478bd9Sstevel@tonic-gate extern const char badnum[]; 413*7c478bd9Sstevel@tonic-gate extern const char badsig[]; 414*7c478bd9Sstevel@tonic-gate extern const char badid[]; 415*7c478bd9Sstevel@tonic-gate extern const char arglist[]; 416*7c478bd9Sstevel@tonic-gate extern const char txtbsy[]; 417*7c478bd9Sstevel@tonic-gate extern const char toobig[]; 418*7c478bd9Sstevel@tonic-gate extern const char badexec[]; 419*7c478bd9Sstevel@tonic-gate extern const char badfile[]; 420*7c478bd9Sstevel@tonic-gate extern const char badreturn[]; 421*7c478bd9Sstevel@tonic-gate extern const char badexport[]; 422*7c478bd9Sstevel@tonic-gate extern const char badunset[]; 423*7c478bd9Sstevel@tonic-gate extern const char nohome[]; 424*7c478bd9Sstevel@tonic-gate extern const char badperm[]; 425*7c478bd9Sstevel@tonic-gate extern const char mssgargn[]; 426*7c478bd9Sstevel@tonic-gate extern const char libacc[]; 427*7c478bd9Sstevel@tonic-gate extern const char libbad[]; 428*7c478bd9Sstevel@tonic-gate extern const char libscn[]; 429*7c478bd9Sstevel@tonic-gate extern const char libmax[]; 430*7c478bd9Sstevel@tonic-gate extern const char emultihop[]; 431*7c478bd9Sstevel@tonic-gate extern const char nulldir[]; 432*7c478bd9Sstevel@tonic-gate extern const char enotdir[]; 433*7c478bd9Sstevel@tonic-gate extern const char enoent[]; 434*7c478bd9Sstevel@tonic-gate extern const char eacces[]; 435*7c478bd9Sstevel@tonic-gate extern const char enolink[]; 436*7c478bd9Sstevel@tonic-gate extern const char exited[]; 437*7c478bd9Sstevel@tonic-gate extern const char running[]; 438*7c478bd9Sstevel@tonic-gate extern const char ambiguous[]; 439*7c478bd9Sstevel@tonic-gate extern const char nosuchjob[]; 440*7c478bd9Sstevel@tonic-gate extern const char nosuchpid[]; 441*7c478bd9Sstevel@tonic-gate extern const char nosuchpgid[]; 442*7c478bd9Sstevel@tonic-gate extern const char usage[]; 443*7c478bd9Sstevel@tonic-gate extern const char nojc[]; 444*7c478bd9Sstevel@tonic-gate extern const char killuse[]; 445*7c478bd9Sstevel@tonic-gate extern const char jobsuse[]; 446*7c478bd9Sstevel@tonic-gate extern const char stopuse[]; 447*7c478bd9Sstevel@tonic-gate extern const char ulimuse[]; 448*7c478bd9Sstevel@tonic-gate extern const char nocurjob[]; 449*7c478bd9Sstevel@tonic-gate extern const char loginsh[]; 450*7c478bd9Sstevel@tonic-gate extern const char jobsstopped[]; 451*7c478bd9Sstevel@tonic-gate extern const char jobsrunning[]; 452*7c478bd9Sstevel@tonic-gate 453*7c478bd9Sstevel@tonic-gate /* 'builtin' error messages */ 454*7c478bd9Sstevel@tonic-gate 455*7c478bd9Sstevel@tonic-gate extern const char btest[]; 456*7c478bd9Sstevel@tonic-gate extern const char badop[]; 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate #ifndef __STDC__ 459*7c478bd9Sstevel@tonic-gate #undef const /* bring back const */ 460*7c478bd9Sstevel@tonic-gate #endif 461*7c478bd9Sstevel@tonic-gate 462*7c478bd9Sstevel@tonic-gate /* fork constant */ 463*7c478bd9Sstevel@tonic-gate 464*7c478bd9Sstevel@tonic-gate #define FORKLIM 32 465*7c478bd9Sstevel@tonic-gate 466*7c478bd9Sstevel@tonic-gate extern address end[]; 467*7c478bd9Sstevel@tonic-gate 468*7c478bd9Sstevel@tonic-gate #include "ctype.h" 469*7c478bd9Sstevel@tonic-gate #include <ctype.h> 470*7c478bd9Sstevel@tonic-gate #include <locale.h> 471*7c478bd9Sstevel@tonic-gate 472*7c478bd9Sstevel@tonic-gate extern int eflag; 473*7c478bd9Sstevel@tonic-gate extern int ucb_builtins; 474*7c478bd9Sstevel@tonic-gate 475*7c478bd9Sstevel@tonic-gate /* 476*7c478bd9Sstevel@tonic-gate * Find out if it is time to go away. 477*7c478bd9Sstevel@tonic-gate * `trapnote' is set to SIGSET when fault is seen and 478*7c478bd9Sstevel@tonic-gate * no trap has been set. 479*7c478bd9Sstevel@tonic-gate */ 480*7c478bd9Sstevel@tonic-gate 481*7c478bd9Sstevel@tonic-gate #define sigchk() if (trapnote & SIGSET) \ 482*7c478bd9Sstevel@tonic-gate exitsh(exitval ? exitval : SIGFAIL) 483*7c478bd9Sstevel@tonic-gate 484*7c478bd9Sstevel@tonic-gate #define exitset() retval = exitval 485*7c478bd9Sstevel@tonic-gate 486*7c478bd9Sstevel@tonic-gate /* Multibyte characters */ 487*7c478bd9Sstevel@tonic-gate void setwidth(); 488*7c478bd9Sstevel@tonic-gate unsigned char *readw(); 489*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 490*7c478bd9Sstevel@tonic-gate #include <limits.h> 491*7c478bd9Sstevel@tonic-gate #define MULTI_BYTE_MAX MB_LEN_MAX 492*7c478bd9Sstevel@tonic-gate 493*7c478bd9Sstevel@tonic-gate 494*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 495*7c478bd9Sstevel@tonic-gate } 496*7c478bd9Sstevel@tonic-gate #endif 497*7c478bd9Sstevel@tonic-gate 498*7c478bd9Sstevel@tonic-gate #endif /* _DEFS_H */ 499