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