17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 539e7390aSna195498 * Common Development and Distribution License (the "License"). 639e7390aSna195498 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate 227c478bd9Sstevel@tonic-gate /* 23*d6b882a9SNobutomo Nakano * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27965005c8Schin /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28965005c8Schin /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _DEFS_H 317c478bd9Sstevel@tonic-gate #define _DEFS_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * UNIX shell 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* execute flags */ 427c478bd9Sstevel@tonic-gate #define XEC_EXECED 01 437c478bd9Sstevel@tonic-gate #define XEC_LINKED 02 447c478bd9Sstevel@tonic-gate #define XEC_NOSTOP 04 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* endjobs flags */ 477c478bd9Sstevel@tonic-gate #define JOB_STOPPED 01 487c478bd9Sstevel@tonic-gate #define JOB_RUNNING 02 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* error exits from various parts of shell */ 517c478bd9Sstevel@tonic-gate #define ERROR 1 527c478bd9Sstevel@tonic-gate #define SYNBAD 2 537c478bd9Sstevel@tonic-gate #define SIGFAIL 2000 547c478bd9Sstevel@tonic-gate #define SIGFLG 0200 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* command tree */ 577c478bd9Sstevel@tonic-gate #define FPIN 0x0100 587c478bd9Sstevel@tonic-gate #define FPOU 0x0200 597c478bd9Sstevel@tonic-gate #define FAMP 0x0400 607c478bd9Sstevel@tonic-gate #define COMMSK 0x00F0 61*d6b882a9SNobutomo Nakano #define CNTMSK 0x000F /* this bit fields no longer used */ 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #define TCOM 0x0000 647c478bd9Sstevel@tonic-gate #define TPAR 0x0010 657c478bd9Sstevel@tonic-gate #define TFIL 0x0020 667c478bd9Sstevel@tonic-gate #define TLST 0x0030 677c478bd9Sstevel@tonic-gate #define TIF 0x0040 687c478bd9Sstevel@tonic-gate #define TWH 0x0050 697c478bd9Sstevel@tonic-gate #define TUN 0x0060 707c478bd9Sstevel@tonic-gate #define TSW 0x0070 717c478bd9Sstevel@tonic-gate #define TAND 0x0080 727c478bd9Sstevel@tonic-gate #define TORF 0x0090 737c478bd9Sstevel@tonic-gate #define TFORK 0x00A0 747c478bd9Sstevel@tonic-gate #define TFOR 0x00B0 757c478bd9Sstevel@tonic-gate #define TFND 0x00C0 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* execute table */ 787c478bd9Sstevel@tonic-gate #define SYSSET 1 797c478bd9Sstevel@tonic-gate #define SYSCD 2 807c478bd9Sstevel@tonic-gate #define SYSEXEC 3 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate #ifdef RES /* include login code */ 837c478bd9Sstevel@tonic-gate #define SYSLOGIN 4 847c478bd9Sstevel@tonic-gate #else 857c478bd9Sstevel@tonic-gate #define SYSNEWGRP 4 867c478bd9Sstevel@tonic-gate #endif 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #define SYSTRAP 5 897c478bd9Sstevel@tonic-gate #define SYSEXIT 6 907c478bd9Sstevel@tonic-gate #define SYSSHFT 7 917c478bd9Sstevel@tonic-gate #define SYSWAIT 8 927c478bd9Sstevel@tonic-gate #define SYSCONT 9 937c478bd9Sstevel@tonic-gate #define SYSBREAK 10 947c478bd9Sstevel@tonic-gate #define SYSEVAL 11 957c478bd9Sstevel@tonic-gate #define SYSDOT 12 967c478bd9Sstevel@tonic-gate #define SYSRDONLY 13 977c478bd9Sstevel@tonic-gate #define SYSTIMES 14 987c478bd9Sstevel@tonic-gate #define SYSXPORT 15 997c478bd9Sstevel@tonic-gate #define SYSNULL 16 1007c478bd9Sstevel@tonic-gate #define SYSREAD 17 1017c478bd9Sstevel@tonic-gate #define SYSTST 18 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate #ifndef RES /* exclude umask code */ 1047c478bd9Sstevel@tonic-gate #define SYSUMASK 20 1057c478bd9Sstevel@tonic-gate #define SYSULIMIT 21 1067c478bd9Sstevel@tonic-gate #endif 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define SYSECHO 22 1097c478bd9Sstevel@tonic-gate #define SYSHASH 23 1107c478bd9Sstevel@tonic-gate #define SYSPWD 24 1117c478bd9Sstevel@tonic-gate #define SYSRETURN 25 1127c478bd9Sstevel@tonic-gate #define SYSUNS 26 1137c478bd9Sstevel@tonic-gate #define SYSMEM 27 1147c478bd9Sstevel@tonic-gate #define SYSTYPE 28 1157c478bd9Sstevel@tonic-gate #define SYSGETOPT 29 1167c478bd9Sstevel@tonic-gate #define SYSJOBS 30 1177c478bd9Sstevel@tonic-gate #define SYSFGBG 31 1187c478bd9Sstevel@tonic-gate #define SYSKILL 32 1197c478bd9Sstevel@tonic-gate #define SYSSUSP 33 1207c478bd9Sstevel@tonic-gate #define SYSSTOP 34 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* used for input and output of shell */ 1237c478bd9Sstevel@tonic-gate #define INIO 19 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* io nodes */ 1267c478bd9Sstevel@tonic-gate #define USERIO 10 1277c478bd9Sstevel@tonic-gate #define IOUFD 15 1281573d361Snakanon #define IODOC 0x0010 1291573d361Snakanon #define IOPUT 0x0020 1301573d361Snakanon #define IOAPP 0x0040 1311573d361Snakanon #define IOMOV 0x0080 1321573d361Snakanon #define IORDW 0x0100 1331573d361Snakanon #define IOSTRIP 0x0200 1341573d361Snakanon #define IODOC_SUBST 0x0400 1357c478bd9Sstevel@tonic-gate #define INPIPE 0 1367c478bd9Sstevel@tonic-gate #define OTPIPE 1 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* arg list terminator */ 1397c478bd9Sstevel@tonic-gate #define ENDARGS 0 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate #include <unistd.h> 1427c478bd9Sstevel@tonic-gate #include "mac.h" 1437c478bd9Sstevel@tonic-gate #include "mode.h" 1447c478bd9Sstevel@tonic-gate #include "name.h" 1457c478bd9Sstevel@tonic-gate #include <signal.h> 1467c478bd9Sstevel@tonic-gate #include <sys/types.h> 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* id's */ 1497c478bd9Sstevel@tonic-gate extern pid_t mypid; 1507c478bd9Sstevel@tonic-gate extern pid_t mypgid; 1517c478bd9Sstevel@tonic-gate extern pid_t mysid; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* getopt */ 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate extern int optind; 1567c478bd9Sstevel@tonic-gate extern int opterr; 1577c478bd9Sstevel@tonic-gate extern int _sp; 1587c478bd9Sstevel@tonic-gate extern char *optarg; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* use sh-private versions of memory allocation routines */ 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate #define alloc malloc 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate /* result type declarations */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate extern int handle(); 1687c478bd9Sstevel@tonic-gate extern void chktrap(); 169965005c8Schin extern void done(int) 170965005c8Schin __NORETURN; 1717c478bd9Sstevel@tonic-gate extern void sh_free(); 1727c478bd9Sstevel@tonic-gate extern unsigned char *make(); 1737c478bd9Sstevel@tonic-gate extern unsigned char *movstr(); 1747c478bd9Sstevel@tonic-gate extern unsigned char *movstrn(); 1757c478bd9Sstevel@tonic-gate extern unsigned char *cwdget(); 1767c478bd9Sstevel@tonic-gate extern struct trenod *cmd(); 1777c478bd9Sstevel@tonic-gate extern struct trenod *makefork(); 1787c478bd9Sstevel@tonic-gate extern struct namnod *lookup(); 1797c478bd9Sstevel@tonic-gate extern struct namnod *findnam(); 1807c478bd9Sstevel@tonic-gate extern struct dolnod *useargs(); 1817c478bd9Sstevel@tonic-gate extern float expr(); 1827c478bd9Sstevel@tonic-gate extern unsigned char *catpath(); 1837c478bd9Sstevel@tonic-gate extern unsigned char *getpath(); 1847c478bd9Sstevel@tonic-gate extern unsigned char *nextpath(); 1857c478bd9Sstevel@tonic-gate extern unsigned char **scan(); 1867c478bd9Sstevel@tonic-gate extern unsigned char *mactrim(); 1877c478bd9Sstevel@tonic-gate extern unsigned char *macro(); 188965005c8Schin extern void exname(struct namnod *); 189965005c8Schin extern void printnam(struct namnod *); 190965005c8Schin extern void printro(struct namnod *); 191965005c8Schin extern void printexp(struct namnod *); 1927c478bd9Sstevel@tonic-gate extern unsigned int readwc(); 1937c478bd9Sstevel@tonic-gate extern unsigned int nextwc(); 1947c478bd9Sstevel@tonic-gate extern unsigned char skipc(); 1957c478bd9Sstevel@tonic-gate extern unsigned char **local_setenv(); 1967c478bd9Sstevel@tonic-gate extern time_t time(); 197965005c8Schin extern void exitsh(int) 198965005c8Schin __NORETURN; 19939e7390aSna195498 extern void failed_real(unsigned char *, const char *, unsigned char *) 20039e7390aSna195498 __NORETURN; 20139e7390aSna195498 extern void error(const char *) __NORETURN; 202965005c8Schin extern void prf(); 203965005c8Schin extern void assign(struct namnod *, unsigned char *); 204965005c8Schin extern void setmode(int); 205965005c8Schin extern void trim(unsigned char *); 206965005c8Schin extern void preacct(unsigned char *); 207*d6b882a9SNobutomo Nakano extern void addblok(unsigned int); 208*d6b882a9SNobutomo Nakano extern void freetree(struct trenod *); 209965005c8Schin 210965005c8Schin 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #define attrib(n, f) (n->namflg |= f) 2137c478bd9Sstevel@tonic-gate #define round(a, b) (((int)(((char *)(a)+b)-1))&~((b)-1)) 2147c478bd9Sstevel@tonic-gate #define closepipe(x) (close(x[INPIPE]), close(x[OTPIPE])) 2157c478bd9Sstevel@tonic-gate #define eq(a, b) (cf(a, b) == 0) 2167c478bd9Sstevel@tonic-gate #define max(a, b) ((a) > (b)?(a):(b)) 2177c478bd9Sstevel@tonic-gate #define assert(x) 21839e7390aSna195498 #define _gettext(s) (unsigned char *)gettext(s) 21939e7390aSna195498 22039e7390aSna195498 /* 22139e7390aSna195498 * macros using failed_real(). Only s2 is gettext'd with both functions. 22239e7390aSna195498 */ 22339e7390aSna195498 #define failed(s1, s2) failed_real(s1, s2, NULL) 22439e7390aSna195498 #define bfailed(s1, s2, s3) failed_real(s1, s2, s3) 22539e7390aSna195498 22639e7390aSna195498 /* 22739e7390aSna195498 * macros using failure_real(). s1 and s2 is gettext'd with gfailure(), but 22839e7390aSna195498 * only s2 is gettext'd with failure(). 22939e7390aSna195498 */ 23039e7390aSna195498 #define failure(s1, s2) failure_real(s1, s2, 0) 23139e7390aSna195498 #define gfailure(s1, s2) failure_real(s1, s2, 1) 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate /* temp files and io */ 2347c478bd9Sstevel@tonic-gate extern int output; 2357c478bd9Sstevel@tonic-gate extern int ioset; 2367c478bd9Sstevel@tonic-gate extern struct ionod *iotemp; /* files to be deleted sometime */ 2377c478bd9Sstevel@tonic-gate extern struct ionod *fiotemp; /* function files to be deleted sometime */ 2387c478bd9Sstevel@tonic-gate extern struct ionod *iopend; /* documents waiting to be read at NL */ 2397c478bd9Sstevel@tonic-gate extern struct fdsave fdmap[]; 2407c478bd9Sstevel@tonic-gate extern int savpipe; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate /* substitution */ 2437c478bd9Sstevel@tonic-gate extern int dolc; 2447c478bd9Sstevel@tonic-gate extern unsigned char **dolv; 2457c478bd9Sstevel@tonic-gate extern struct dolnod *argfor; 2467c478bd9Sstevel@tonic-gate extern struct argnod *gchain; 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate /* stak stuff */ 2497c478bd9Sstevel@tonic-gate #include "stak.h" 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate /* 2527c478bd9Sstevel@tonic-gate * If non-ANSI C, make const go away. We bring it back 2537c478bd9Sstevel@tonic-gate * at the end of the file to avoid side-effects. 2547c478bd9Sstevel@tonic-gate */ 2557c478bd9Sstevel@tonic-gate #ifndef __STDC__ 2567c478bd9Sstevel@tonic-gate #define const 2577c478bd9Sstevel@tonic-gate #endif 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate /* string constants */ 2607c478bd9Sstevel@tonic-gate extern const char atline[]; 2617c478bd9Sstevel@tonic-gate extern const char readmsg[]; 2627c478bd9Sstevel@tonic-gate extern const char colon[]; 2637c478bd9Sstevel@tonic-gate extern const char minus[]; 2647c478bd9Sstevel@tonic-gate extern const char nullstr[]; 2657c478bd9Sstevel@tonic-gate extern const char sptbnl[]; 2667c478bd9Sstevel@tonic-gate extern const char unexpected[]; 2677c478bd9Sstevel@tonic-gate extern const char endoffile[]; 2687c478bd9Sstevel@tonic-gate extern const char synmsg[]; 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate /* name tree and words */ 2717c478bd9Sstevel@tonic-gate extern const struct sysnod reserved[]; 2727c478bd9Sstevel@tonic-gate extern const int no_reserved; 2737c478bd9Sstevel@tonic-gate extern const struct sysnod commands[]; 2747c478bd9Sstevel@tonic-gate extern const int no_commands; 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate extern int wdval; 2777c478bd9Sstevel@tonic-gate extern int wdnum; 2787c478bd9Sstevel@tonic-gate extern int fndef; 2797c478bd9Sstevel@tonic-gate extern int nohash; 2807c478bd9Sstevel@tonic-gate extern struct argnod *wdarg; 2817c478bd9Sstevel@tonic-gate extern int wdset; 2827c478bd9Sstevel@tonic-gate extern BOOL reserv; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate /* prompting */ 2857c478bd9Sstevel@tonic-gate extern const char stdprompt[]; 2867c478bd9Sstevel@tonic-gate extern const char supprompt[]; 2877c478bd9Sstevel@tonic-gate extern const char profile[]; 2887c478bd9Sstevel@tonic-gate extern const char sysprofile[]; 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate /* locale testing */ 2917c478bd9Sstevel@tonic-gate extern const char localedir[]; 2927c478bd9Sstevel@tonic-gate extern int localedir_exists; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate /* built in names */ 2957c478bd9Sstevel@tonic-gate extern struct namnod fngnod; 2967c478bd9Sstevel@tonic-gate extern struct namnod cdpnod; 2977c478bd9Sstevel@tonic-gate extern struct namnod ifsnod; 2987c478bd9Sstevel@tonic-gate extern struct namnod homenod; 2997c478bd9Sstevel@tonic-gate extern struct namnod mailnod; 3007c478bd9Sstevel@tonic-gate extern struct namnod pathnod; 3017c478bd9Sstevel@tonic-gate extern struct namnod ps1nod; 3027c478bd9Sstevel@tonic-gate extern struct namnod ps2nod; 3037c478bd9Sstevel@tonic-gate extern struct namnod mchknod; 3047c478bd9Sstevel@tonic-gate extern struct namnod acctnod; 3057c478bd9Sstevel@tonic-gate extern struct namnod mailpnod; 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate /* special names */ 3087c478bd9Sstevel@tonic-gate extern unsigned char flagadr[]; 3097c478bd9Sstevel@tonic-gate extern unsigned char *pcsadr; 3107c478bd9Sstevel@tonic-gate extern unsigned char *pidadr; 3117c478bd9Sstevel@tonic-gate extern unsigned char *cmdadr; 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* names always present */ 3147c478bd9Sstevel@tonic-gate extern const char defpath[]; 3157c478bd9Sstevel@tonic-gate extern const char mailname[]; 3167c478bd9Sstevel@tonic-gate extern const char homename[]; 3177c478bd9Sstevel@tonic-gate extern const char pathname[]; 3187c478bd9Sstevel@tonic-gate extern const char cdpname[]; 3197c478bd9Sstevel@tonic-gate extern const char ifsname[]; 3207c478bd9Sstevel@tonic-gate extern const char ps1name[]; 3217c478bd9Sstevel@tonic-gate extern const char ps2name[]; 3227c478bd9Sstevel@tonic-gate extern const char mchkname[]; 3237c478bd9Sstevel@tonic-gate extern const char acctname[]; 3247c478bd9Sstevel@tonic-gate extern const char mailpname[]; 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* transput */ 3277c478bd9Sstevel@tonic-gate extern unsigned char tmpout[]; 328965005c8Schin extern int tmpout_offset; 329965005c8Schin extern unsigned int serial; 3307c478bd9Sstevel@tonic-gate 331965005c8Schin /* 332965005c8Schin * allow plenty of room for size for temp file name: 333965005c8Schin * "/tmp/sh"(7) + <pid> (<=6) + <unsigned int #> (<=10) + \0 (1) 334965005c8Schin */ 335965005c8Schin #define TMPOUTSZ 32 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate extern struct fileblk *standin; 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate #define input (standin->fdes) 3407c478bd9Sstevel@tonic-gate #define eof (standin->feof) 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate extern int peekc; 3437c478bd9Sstevel@tonic-gate extern int peekn; 3447c478bd9Sstevel@tonic-gate extern unsigned char *comdiv; 3457c478bd9Sstevel@tonic-gate extern 3467c478bd9Sstevel@tonic-gate #ifdef __STDC__ 3477c478bd9Sstevel@tonic-gate const 3487c478bd9Sstevel@tonic-gate #endif 3497c478bd9Sstevel@tonic-gate char devnull[]; 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate /* flags */ 3527c478bd9Sstevel@tonic-gate #define noexec 01 3537c478bd9Sstevel@tonic-gate #define sysflg 01 3547c478bd9Sstevel@tonic-gate #define intflg 02 3557c478bd9Sstevel@tonic-gate #define prompt 04 3567c478bd9Sstevel@tonic-gate #define setflg 010 3577c478bd9Sstevel@tonic-gate #define errflg 020 3587c478bd9Sstevel@tonic-gate #define ttyflg 040 3597c478bd9Sstevel@tonic-gate #define forked 0100 3607c478bd9Sstevel@tonic-gate #define oneflg 0200 3617c478bd9Sstevel@tonic-gate #define rshflg 0400 3627c478bd9Sstevel@tonic-gate #define subsh 01000 3637c478bd9Sstevel@tonic-gate #define stdflg 02000 3647c478bd9Sstevel@tonic-gate #define STDFLG 's' 3657c478bd9Sstevel@tonic-gate #define execpr 04000 3667c478bd9Sstevel@tonic-gate #define readpr 010000 3677c478bd9Sstevel@tonic-gate #define keyflg 020000 3687c478bd9Sstevel@tonic-gate #define hashflg 040000 3697c478bd9Sstevel@tonic-gate #define nofngflg 0200000 3707c478bd9Sstevel@tonic-gate #define exportflg 0400000 3717c478bd9Sstevel@tonic-gate #define monitorflg 01000000 3727c478bd9Sstevel@tonic-gate #define jcflg 02000000 3737c478bd9Sstevel@tonic-gate #define privflg 04000000 3747c478bd9Sstevel@tonic-gate #define forcexit 010000000 3757c478bd9Sstevel@tonic-gate #define jcoff 020000000 3767c478bd9Sstevel@tonic-gate #define pfshflg 040000000 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate extern long flags; 3797c478bd9Sstevel@tonic-gate extern int rwait; /* flags read waiting */ 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate /* error exits from various parts of shell */ 3827c478bd9Sstevel@tonic-gate #include <setjmp.h> 3837c478bd9Sstevel@tonic-gate extern jmp_buf subshell; 3847c478bd9Sstevel@tonic-gate extern jmp_buf errshell; 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* fault handling */ 3877c478bd9Sstevel@tonic-gate #include "brkincr.h" 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate extern unsigned brkincr; 3907c478bd9Sstevel@tonic-gate #define MINTRAP 0 3917c478bd9Sstevel@tonic-gate #define MAXTRAP NSIG 3927c478bd9Sstevel@tonic-gate 3937c478bd9Sstevel@tonic-gate #define TRAPSET 2 3947c478bd9Sstevel@tonic-gate #define SIGSET 4 3957c478bd9Sstevel@tonic-gate #define SIGMOD 8 3967c478bd9Sstevel@tonic-gate #define SIGIGN 16 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate extern BOOL trapnote; 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate /* name tree and words */ 4017c478bd9Sstevel@tonic-gate extern unsigned char **environ; 4027c478bd9Sstevel@tonic-gate extern unsigned char numbuf[]; 4037c478bd9Sstevel@tonic-gate extern const char export[]; 4047c478bd9Sstevel@tonic-gate extern const char duperr[]; 4057c478bd9Sstevel@tonic-gate extern const char readonly[]; 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate /* execflgs */ 4087c478bd9Sstevel@tonic-gate extern int exitval; 4097c478bd9Sstevel@tonic-gate extern int retval; 4107c478bd9Sstevel@tonic-gate extern BOOL execbrk; 4117c478bd9Sstevel@tonic-gate extern int loopcnt; 4127c478bd9Sstevel@tonic-gate extern int breakcnt; 4137c478bd9Sstevel@tonic-gate extern int funcnt; 4147c478bd9Sstevel@tonic-gate extern int tried_to_exit; 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* messages */ 4177c478bd9Sstevel@tonic-gate extern const char mailmsg[]; 4187c478bd9Sstevel@tonic-gate extern const char coredump[]; 4197c478bd9Sstevel@tonic-gate extern const char badopt[]; 4207c478bd9Sstevel@tonic-gate extern const char badparam[]; 4217c478bd9Sstevel@tonic-gate extern const char unset[]; 4227c478bd9Sstevel@tonic-gate extern const char badsub[]; 4237c478bd9Sstevel@tonic-gate extern const char nospace[]; 4247c478bd9Sstevel@tonic-gate extern const char nostack[]; 4257c478bd9Sstevel@tonic-gate extern const char notfound[]; 4267c478bd9Sstevel@tonic-gate extern const char badtrap[]; 4277c478bd9Sstevel@tonic-gate extern const char baddir[]; 4287c478bd9Sstevel@tonic-gate extern const char badshift[]; 4297c478bd9Sstevel@tonic-gate extern const char restricted[]; 4307c478bd9Sstevel@tonic-gate extern const char execpmsg[]; 4317c478bd9Sstevel@tonic-gate extern const char notid[]; 4327c478bd9Sstevel@tonic-gate extern const char badulimit[]; 4337c478bd9Sstevel@tonic-gate extern const char ulimit[]; 4347c478bd9Sstevel@tonic-gate extern const char wtfailed[]; 4357c478bd9Sstevel@tonic-gate extern const char badcreate[]; 4367c478bd9Sstevel@tonic-gate extern const char nofork[]; 4377c478bd9Sstevel@tonic-gate extern const char noswap[]; 4387c478bd9Sstevel@tonic-gate extern const char piperr[]; 4397c478bd9Sstevel@tonic-gate extern const char badopen[]; 4407c478bd9Sstevel@tonic-gate extern const char badnum[]; 4417c478bd9Sstevel@tonic-gate extern const char badsig[]; 4427c478bd9Sstevel@tonic-gate extern const char badid[]; 4437c478bd9Sstevel@tonic-gate extern const char arglist[]; 4447c478bd9Sstevel@tonic-gate extern const char txtbsy[]; 4457c478bd9Sstevel@tonic-gate extern const char toobig[]; 4467c478bd9Sstevel@tonic-gate extern const char badexec[]; 4477c478bd9Sstevel@tonic-gate extern const char badfile[]; 4487c478bd9Sstevel@tonic-gate extern const char badreturn[]; 4497c478bd9Sstevel@tonic-gate extern const char badexport[]; 4507c478bd9Sstevel@tonic-gate extern const char badunset[]; 4517c478bd9Sstevel@tonic-gate extern const char nohome[]; 4527c478bd9Sstevel@tonic-gate extern const char badperm[]; 4537c478bd9Sstevel@tonic-gate extern const char mssgargn[]; 4547c478bd9Sstevel@tonic-gate extern const char libacc[]; 4557c478bd9Sstevel@tonic-gate extern const char libbad[]; 4567c478bd9Sstevel@tonic-gate extern const char libscn[]; 4577c478bd9Sstevel@tonic-gate extern const char libmax[]; 4587c478bd9Sstevel@tonic-gate extern const char emultihop[]; 4597c478bd9Sstevel@tonic-gate extern const char nulldir[]; 4607c478bd9Sstevel@tonic-gate extern const char enotdir[]; 4617c478bd9Sstevel@tonic-gate extern const char enoent[]; 4627c478bd9Sstevel@tonic-gate extern const char eacces[]; 4637c478bd9Sstevel@tonic-gate extern const char enolink[]; 4647c478bd9Sstevel@tonic-gate extern const char exited[]; 4657c478bd9Sstevel@tonic-gate extern const char running[]; 4667c478bd9Sstevel@tonic-gate extern const char ambiguous[]; 4677c478bd9Sstevel@tonic-gate extern const char nosuchjob[]; 4687c478bd9Sstevel@tonic-gate extern const char nosuchpid[]; 4697c478bd9Sstevel@tonic-gate extern const char nosuchpgid[]; 4707c478bd9Sstevel@tonic-gate extern const char usage[]; 4717c478bd9Sstevel@tonic-gate extern const char nojc[]; 4727c478bd9Sstevel@tonic-gate extern const char killuse[]; 4737c478bd9Sstevel@tonic-gate extern const char jobsuse[]; 4747c478bd9Sstevel@tonic-gate extern const char stopuse[]; 4757c478bd9Sstevel@tonic-gate extern const char ulimuse[]; 4767c478bd9Sstevel@tonic-gate extern const char nocurjob[]; 4777c478bd9Sstevel@tonic-gate extern const char loginsh[]; 4787c478bd9Sstevel@tonic-gate extern const char jobsstopped[]; 4797c478bd9Sstevel@tonic-gate extern const char jobsrunning[]; 48039e7390aSna195498 extern const char nlorsemi[]; 48139e7390aSna195498 extern const char signalnum[]; 48239e7390aSna195498 extern const char badpwd[]; 48339e7390aSna195498 extern const char badlocale[]; 48439e7390aSna195498 extern const char nobracket[]; 48539e7390aSna195498 extern const char noparen[]; 48639e7390aSna195498 extern const char noarg[]; 4877c478bd9Sstevel@tonic-gate 4887c478bd9Sstevel@tonic-gate /* 'builtin' error messages */ 4897c478bd9Sstevel@tonic-gate 4907c478bd9Sstevel@tonic-gate extern const char btest[]; 4917c478bd9Sstevel@tonic-gate extern const char badop[]; 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate #ifndef __STDC__ 4947c478bd9Sstevel@tonic-gate #undef const /* bring back const */ 4957c478bd9Sstevel@tonic-gate #endif 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate /* fork constant */ 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate #define FORKLIM 32 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate extern address end[]; 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gate #include "ctype.h" 5047c478bd9Sstevel@tonic-gate #include <ctype.h> 5057c478bd9Sstevel@tonic-gate #include <locale.h> 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate extern int eflag; 5087c478bd9Sstevel@tonic-gate extern int ucb_builtins; 5097c478bd9Sstevel@tonic-gate 5107c478bd9Sstevel@tonic-gate /* 5117c478bd9Sstevel@tonic-gate * Find out if it is time to go away. 5127c478bd9Sstevel@tonic-gate * `trapnote' is set to SIGSET when fault is seen and 5137c478bd9Sstevel@tonic-gate * no trap has been set. 5147c478bd9Sstevel@tonic-gate */ 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate #define sigchk() if (trapnote & SIGSET) \ 5177c478bd9Sstevel@tonic-gate exitsh(exitval ? exitval : SIGFAIL) 5187c478bd9Sstevel@tonic-gate 5197c478bd9Sstevel@tonic-gate #define exitset() retval = exitval 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate /* Multibyte characters */ 5227c478bd9Sstevel@tonic-gate unsigned char *readw(); 5237c478bd9Sstevel@tonic-gate #include <stdlib.h> 5247c478bd9Sstevel@tonic-gate #include <limits.h> 5257c478bd9Sstevel@tonic-gate #define MULTI_BYTE_MAX MB_LEN_MAX 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5297c478bd9Sstevel@tonic-gate } 5307c478bd9Sstevel@tonic-gate #endif 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate #endif /* _DEFS_H */ 533