options.h revision 20425
1193323Sed/*-
2193323Sed * Copyright (c) 1991, 1993
3193323Sed *	The Regents of the University of California.  All rights reserved.
4193323Sed *
5193323Sed * This code is derived from software contributed to Berkeley by
6193323Sed * Kenneth Almquist.
7193323Sed *
8193323Sed * Redistribution and use in source and binary forms, with or without
9193323Sed * modification, are permitted provided that the following conditions
10193323Sed * are met:
11193323Sed * 1. Redistributions of source code must retain the above copyright
12193323Sed *    notice, this list of conditions and the following disclaimer.
13193323Sed * 2. Redistributions in binary form must reproduce the above copyright
14193323Sed *    notice, this list of conditions and the following disclaimer in the
15193323Sed *    documentation and/or other materials provided with the distribution.
16193323Sed * 3. All advertising materials mentioning features or use of this software
17218893Sdim *    must display the following acknowledgement:
18218893Sdim *	This product includes software developed by the University of
19234353Sdim *	California, Berkeley and its contributors.
20193323Sed * 4. Neither the name of the University nor the names of its contributors
21193323Sed *    may be used to endorse or promote products derived from this software
22193323Sed *    without specific prior written permission.
23193323Sed *
24193323Sed * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25193323Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26193323Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27193323Sed * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28193323Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29193323Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30193323Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31198090Srdivacky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32198090Srdivacky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33198090Srdivacky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34198090Srdivacky * SUCH DAMAGE.
35198090Srdivacky *
36198090Srdivacky *	@(#)options.h	8.2 (Berkeley) 5/4/95
37193323Sed *	$Id: options.h,v 1.4 1996/10/29 03:12:49 steve Exp $
38193323Sed */
39193323Sed
40193323Sedstruct shparam {
41193323Sed	int nparam;		/* # of positional parameters (without $0) */
42193323Sed	unsigned char malloc;	/* if parameter list dynamically allocated */
43193323Sed	unsigned char reset;	/* if getopts has been reset */
44193323Sed	char **p;		/* parameter list */
45193323Sed	char **optnext;		/* next parameter to be processed by getopts */
46193323Sed	char *optptr;		/* used by getopts */
47193323Sed};
48193323Sed
49193323Sed
50193323Sed
51193323Sed#define eflag optlist[0].val
52193323Sed#define fflag optlist[1].val
53193323Sed#define Iflag optlist[2].val
54193323Sed#define iflag optlist[3].val
55193323Sed#define mflag optlist[4].val
56193323Sed#define nflag optlist[5].val
57193323Sed#define sflag optlist[6].val
58193323Sed#define xflag optlist[7].val
59193323Sed#define vflag optlist[8].val
60193323Sed#define Vflag optlist[9].val
61193323Sed#define	Eflag optlist[10].val
62193323Sed#define	Cflag optlist[11].val
63193323Sed#define	aflag optlist[12].val
64193323Sed#define	bflag optlist[13].val
65193323Sed#define	uflag optlist[14].val
66193323Sed#define	privileged optlist[15].val
67194612Sed
68198090Srdivacky#define NOPTS	16
69234353Sdim
70193323Sedstruct optent {
71193323Sed	const char *name;
72193323Sed	const char letter;
73193323Sed	char val;
74193323Sed};
75194612Sed
76198090Srdivacky#ifdef DEFINE_OPTIONS
77234353Sdimstruct optent optlist[NOPTS] = {
78193323Sed	{ "errexit",	'e',	0 },
79193323Sed	{ "noglob",	'f',	0 },
80193323Sed	{ "ignoreeof",	'I',	0 },
81193323Sed	{ "interactive",'i',	0 },
82193323Sed	{ "monitor",	'm',	0 },
83194612Sed	{ "noexec",	'n',	0 },
84198090Srdivacky	{ "stdin",	's',	0 },
85234353Sdim	{ "xtrace",	'x',	0 },
86193323Sed	{ "verbose",	'v',	0 },
87193323Sed	{ "vi",		'V',	0 },
88193323Sed	{ "emacs",	'E',	0 },
89193323Sed	{ "noclobber",	'C',	0 },
90193323Sed	{ "allexport",	'a',	0 },
91194612Sed	{ "notify",	'b',	0 },
92198090Srdivacky	{ "nounset",	'u',	0 },
93234353Sdim	{ "privileged",	'p',	0 },
94193323Sed};
95193323Sed#else
96193323Sedextern struct optent optlist[NOPTS];
97193323Sed#endif
98193323Sed
99193323Sed
100193323Sedextern char *minusc;		/* argument to -c option */
101193323Sedextern char *arg0;		/* $0 */
102193323Sedextern struct shparam shellparam;  /* $@ */
103193323Sedextern char **argptr;		/* argument list for builtin commands */
104193323Sedextern char *optarg;		/* set by nextopt */
105193323Sedextern char *optptr;		/* used by nextopt */
106193323Sed
107193323Sedvoid procargs __P((int, char **));
108193323Sedvoid optschanged __P((void));
109193323Sedvoid setparam __P((char **));
110193323Sedvoid freeparam __P((struct shparam *));
111193323Sedint shiftcmd __P((int, char **));
112193323Sedint setcmd __P((int, char **));
113193323Sedint getoptscmd __P((int, char **));
114193323Sedint nextopt __P((char *));
115void getoptsreset __P((const char *));
116