1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/*	$NetBSD: options.h,v 1.17 2003/08/07 09:05:36 agc Exp $	*/
2dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
3dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/*-
4dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Copyright (c) 1991, 1993
5dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *	The Regents of the University of California.  All rights reserved.
6dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
7dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * This code is derived from software contributed to Berkeley by
8dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Kenneth Almquist.
9dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
10dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Redistribution and use in source and binary forms, with or without
11dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * modification, are permitted provided that the following conditions
12dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * are met:
13dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * 1. Redistributions of source code must retain the above copyright
14dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
15dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright
16dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    notice, this list of conditions and the following disclaimer in the
17dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    documentation and/or other materials provided with the distribution.
18dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * 3. Neither the name of the University nor the names of its contributors
19dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    may be used to endorse or promote products derived from this software
20dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    without specific prior written permission.
21dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
22dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * SUCH DAMAGE.
33dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
34dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *	@(#)options.h	8.2 (Berkeley) 5/4/95
35dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project */
36dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
37dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectstruct shparam {
38dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	int nparam;		/* # of positional parameters (without $0) */
39dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	unsigned char malloc;	/* if parameter list dynamically allocated */
40dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	unsigned char reset;	/* if getopts has been reset */
41dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	char **p;		/* parameter list */
42dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	char **optnext;		/* next parameter to be processed by getopts */
43dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	char *optptr;		/* used by getopts */
44dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project};
45dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
46dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
47dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectstruct optent {
48dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	const char *name;		/* for set -o <name> */
49dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	const char letter;		/* set [+/-]<letter> and $- */
50dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	const char opt_set;		/* mutually exclusive option set */
51dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	char val;			/* value of <letter>flag */
52dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project};
53dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
54dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* Those marked [U] are required by posix, but have no effect! */
55dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
56dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#ifdef DEFINE_OPTIONS
57dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define DEF_OPTS(name, letter, opt_set) {name, letter, opt_set, 0},
58dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectstruct optent optlist[] = {
59dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#else
60dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define DEF_OPTS(name, letter, opt_set)
61dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif
62dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define DEF_OPT(name,letter) DEF_OPTS(name, letter, 0)
63dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
64dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "errexit",	'e' )	/* exit on error */
65dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define eflag optlist[0].val
66dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "noglob",	'f' )	/* no pathname expansion */
67dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define fflag optlist[1].val
68dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "ignoreeof",	'I' )	/* do not exit on EOF */
69dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define Iflag optlist[2].val
70dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "interactive",'i' )	/* interactive shell */
71dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define iflag optlist[3].val
72dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "monitor",	'm' )	/* job control */
73dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define mflag optlist[4].val
74dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "noexec",	'n' )	/* [U] do not exec commands */
75dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define nflag optlist[5].val
76dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "stdin",	's' )	/* read from stdin */
77dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define sflag optlist[6].val
78dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "xtrace",	'x' )	/* trace after expansion */
79dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define xflag optlist[7].val
80dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "verbose",	'v' )	/* trace read input */
81dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define vflag optlist[8].val
82dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPTS( "vi",		'V', 'V' )	/* vi style editing */
83dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define Vflag optlist[9].val
84dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPTS( "emacs",	'E', 'V' )	/* emacs style editing */
85dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	Eflag optlist[10].val
86dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "noclobber",	'C' )	/* do not overwrite files with > */
87dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	Cflag optlist[11].val
88dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "allexport",	'a' )	/* export all variables */
89dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	aflag optlist[12].val
90dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "notify",	'b' )	/* [U] report completion of background jobs */
91dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	bflag optlist[13].val
92dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "nounset",	'u' )	/* error expansion of unset variables */
93dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	uflag optlist[14].val
94dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "quietprofile", 'q' )
95dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	qflag optlist[15].val
96dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "nolog",	0 )	/* [U] no functon defs in command history */
97dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	nolog optlist[16].val
98dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "cdprint",	0 )	/* always print result of cd */
99dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	cdprint optlist[17].val
100dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#ifdef DEBUG
101dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectDEF_OPT( "debug",	0 )	/* enable debug prints */
102dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define	debug optlist[18].val
103dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif
104dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
105dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#ifdef DEFINE_OPTIONS
106dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project	{ 0, 0, 0, 0 },
107dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project};
108dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define NOPTS (sizeof optlist / sizeof optlist[0] - 1)
109dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectint sizeof_optlist = sizeof optlist;
110dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#else
111dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern struct optent optlist[];
112dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern int sizeof_optlist;
113dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif
114dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
115dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
116dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern char *minusc;		/* argument to -c option */
117dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern char *arg0;		/* $0 */
118dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern struct shparam shellparam;  /* $@ */
119dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern char **argptr;		/* argument list for builtin commands */
120dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern char *optionarg;		/* set by nextopt */
121dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectextern char *optptr;		/* used by nextopt */
122dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
123dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid procargs(int, char **);
124dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid optschanged(void);
125dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid setparam(char **);
126dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid freeparam(volatile struct shparam *);
127dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectint shiftcmd(int, char **);
128dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectint setcmd(int, char **);
129dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectint getoptscmd(int, char **);
130dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectint nextopt(const char *);
131dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid getoptsreset(const char *);