options.h revision 1556
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
17193323Sed *    must display the following acknowledgement:
18193323Sed *	This product includes software developed by the University of
19193323Sed *	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
26198090Srdivacky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27198090Srdivacky * 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)
31193323Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32193323Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33193323Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34193323Sed * SUCH DAMAGE.
35193323Sed *
36193323Sed *	@(#)options.h	8.1 (Berkeley) 5/31/93
37193323Sed */
38193323Sed
39193323Sedstruct shparam {
40193323Sed	int nparam;	/* number of positional parameters (without $0) */
41193323Sed	char malloc;	/* true if parameter list dynamicly allocated */
42193323Sed	char **p;		/* parameter list */
43193323Sed	char **optnext;	/* next parameter to be processed by getopts */
44193323Sed	char *optptr;	/* used by getopts */
45193323Sed};
46193323Sed
47193323Sed
48193323Sed
49193323Sed#define eflag optlist[0].val
50193323Sed#define fflag optlist[1].val
51193323Sed#define Iflag optlist[2].val
52193323Sed#define iflag optlist[3].val
53193323Sed#define mflag optlist[4].val
54193323Sed#define nflag optlist[5].val
55193323Sed#define sflag optlist[6].val
56193323Sed#define xflag optlist[7].val
57193323Sed#define vflag optlist[8].val
58193323Sed#define Vflag optlist[9].val
59193323Sed#define	Eflag optlist[10].val
60193323Sed#define	Cflag optlist[11].val
61193323Sed#define	aflag optlist[12].val
62193323Sed#define	bflag optlist[13].val
63193323Sed#define	uflag optlist[14].val
64193323Sed
65193323Sed#define NOPTS	15
66193323Sed
67193323Sedstruct optent {
68193323Sed	const char *name;
69193323Sed	const char letter;
70193323Sed	char val;
71193323Sed};
72193323Sed
73193323Sed#ifdef DEFINE_OPTIONS
74193323Sedstruct optent optlist[NOPTS] = {
75193323Sed	"errexit",	'e',	0,
76193323Sed	"noglob",	'f',	0,
77193323Sed	"ignoreeof",	'I',	0,
78193323Sed	"interactive",	'i',	0,
79193323Sed	"monitor",	'm',	0,
80193323Sed	"noexec",	'n',	0,
81202375Srdivacky	"stdin",	's',	0,
82193323Sed	"xtrace",	'x',	0,
83193323Sed	"verbose",	'v',	0,
84193323Sed	"vi",		'V',	0,
85193323Sed	"emacs",	'E',	0,
86193323Sed	"noclobber",	'C',	0,
87193323Sed	"allexport",	'a',	0,
88193323Sed	"notify",	'b',	0,
89202375Srdivacky	"nounset",	'u',	0,
90193323Sed};
91193323Sed#else
92202375Srdivackyextern struct optent optlist[NOPTS];
93202375Srdivacky#endif
94202375Srdivacky
95193323Sed
96193323Sedextern char *minusc;		/* argument to -c option */
97193323Sedextern char *arg0;		/* $0 */
98193323Sedextern struct shparam shellparam;  /* $@ */
99198892Srdivackyextern char **argptr;		/* argument list for builtin commands */
100212904Sdimextern char *optarg;		/* set by nextopt */
101212904Sdimextern char *optptr;		/* used by nextopt */
102193323Sed
103212904Sdim
104212904Sdim#ifdef __STDC__
105193323Sedvoid procargs(int, char **);
106212904Sdimvoid setparam(char **);
107193323Sedvoid freeparam(struct shparam *);
108193323Sedint nextopt(char *);
109193323Sed#else
110193323Sedvoid procargs();
111193323Sedvoid setparam();
112193323Sedvoid freeparam();
113193323Sedint nextopt();
114193323Sed#endif
115193323Sed