options.h revision 90111
11556Srgrimes/*-
21556Srgrimes * Copyright (c) 1991, 1993
31556Srgrimes *	The Regents of the University of California.  All rights reserved.
41556Srgrimes *
51556Srgrimes * This code is derived from software contributed to Berkeley by
61556Srgrimes * Kenneth Almquist.
71556Srgrimes *
81556Srgrimes * Redistribution and use in source and binary forms, with or without
91556Srgrimes * modification, are permitted provided that the following conditions
101556Srgrimes * are met:
111556Srgrimes * 1. Redistributions of source code must retain the above copyright
121556Srgrimes *    notice, this list of conditions and the following disclaimer.
131556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141556Srgrimes *    notice, this list of conditions and the following disclaimer in the
151556Srgrimes *    documentation and/or other materials provided with the distribution.
161556Srgrimes * 3. All advertising materials mentioning features or use of this software
171556Srgrimes *    must display the following acknowledgement:
181556Srgrimes *	This product includes software developed by the University of
191556Srgrimes *	California, Berkeley and its contributors.
201556Srgrimes * 4. Neither the name of the University nor the names of its contributors
211556Srgrimes *    may be used to endorse or promote products derived from this software
221556Srgrimes *    without specific prior written permission.
231556Srgrimes *
241556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271556Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341556Srgrimes * SUCH DAMAGE.
351556Srgrimes *
3617987Speter *	@(#)options.h	8.2 (Berkeley) 5/4/95
3750471Speter * $FreeBSD: head/bin/sh/options.h 90111 2002-02-02 06:50:57Z imp $
381556Srgrimes */
391556Srgrimes
401556Srgrimesstruct shparam {
4120425Ssteve	int nparam;		/* # of positional parameters (without $0) */
4220425Ssteve	unsigned char malloc;	/* if parameter list dynamically allocated */
4320425Ssteve	unsigned char reset;	/* if getopts has been reset */
441556Srgrimes	char **p;		/* parameter list */
4520425Ssteve	char **optnext;		/* next parameter to be processed by getopts */
4620425Ssteve	char *optptr;		/* used by getopts */
471556Srgrimes};
481556Srgrimes
491556Srgrimes
501556Srgrimes
511556Srgrimes#define eflag optlist[0].val
521556Srgrimes#define fflag optlist[1].val
531556Srgrimes#define Iflag optlist[2].val
541556Srgrimes#define iflag optlist[3].val
551556Srgrimes#define mflag optlist[4].val
561556Srgrimes#define nflag optlist[5].val
571556Srgrimes#define sflag optlist[6].val
581556Srgrimes#define xflag optlist[7].val
591556Srgrimes#define vflag optlist[8].val
601556Srgrimes#define Vflag optlist[9].val
611556Srgrimes#define	Eflag optlist[10].val
621556Srgrimes#define	Cflag optlist[11].val
631556Srgrimes#define	aflag optlist[12].val
641556Srgrimes#define	bflag optlist[13].val
651556Srgrimes#define	uflag optlist[14].val
6619240Ssteve#define	privileged optlist[15].val
6745221Scracauer#define	Tflag optlist[16].val
681556Srgrimes
6945221Scracauer#define NOPTS	17
701556Srgrimes
711556Srgrimesstruct optent {
721556Srgrimes	const char *name;
731556Srgrimes	const char letter;
741556Srgrimes	char val;
751556Srgrimes};
761556Srgrimes
771556Srgrimes#ifdef DEFINE_OPTIONS
781556Srgrimesstruct optent optlist[NOPTS] = {
7917987Speter	{ "errexit",	'e',	0 },
8017987Speter	{ "noglob",	'f',	0 },
8117987Speter	{ "ignoreeof",	'I',	0 },
8217987Speter	{ "interactive",'i',	0 },
8317987Speter	{ "monitor",	'm',	0 },
8417987Speter	{ "noexec",	'n',	0 },
8517987Speter	{ "stdin",	's',	0 },
8617987Speter	{ "xtrace",	'x',	0 },
8717987Speter	{ "verbose",	'v',	0 },
8817987Speter	{ "vi",		'V',	0 },
8917987Speter	{ "emacs",	'E',	0 },
9017987Speter	{ "noclobber",	'C',	0 },
9117987Speter	{ "allexport",	'a',	0 },
9217987Speter	{ "notify",	'b',	0 },
9317987Speter	{ "nounset",	'u',	0 },
9419240Ssteve	{ "privileged",	'p',	0 },
9545221Scracauer	{ "trapsasync",	'T',	0 },
961556Srgrimes};
971556Srgrimes#else
981556Srgrimesextern struct optent optlist[NOPTS];
991556Srgrimes#endif
1001556Srgrimes
1011556Srgrimes
1021556Srgrimesextern char *minusc;		/* argument to -c option */
1031556Srgrimesextern char *arg0;		/* $0 */
1041556Srgrimesextern struct shparam shellparam;  /* $@ */
1051556Srgrimesextern char **argptr;		/* argument list for builtin commands */
10659436Scracauerextern char *shoptarg;		/* set by nextopt */
1071556Srgrimesextern char *optptr;		/* used by nextopt */
1081556Srgrimes
10990111Simpvoid procargs(int, char **);
11090111Simpvoid optschanged(void);
11190111Simpvoid setparam(char **);
11290111Simpvoid freeparam(struct shparam *);
11390111Simpint shiftcmd(int, char **);
11490111Simpint setcmd(int, char **);
11590111Simpint getoptscmd(int, char **);
11690111Simpint nextopt(char *);
11790111Simpvoid getoptsreset(const char *);
118