xref: /freebsd/bin/sh/options.h (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1991, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Kenneth Almquist.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	@(#)options.h	8.2 (Berkeley) 5/4/95
35  */
36 
37 struct shparam {
38 	int nparam;		/* # of positional parameters (without $0) */
39 	unsigned char malloc;	/* if parameter list dynamically allocated */
40 	unsigned char reset;	/* if getopts has been reset */
41 	char **p;		/* parameter list */
42 	char **optp;		/* parameter list for getopts */
43 	char **optnext;		/* next parameter to be processed by getopts */
44 	char *optptr;		/* used by getopts */
45 };
46 
47 
48 
49 #define eflag optval[0]
50 #define fflag optval[1]
51 #define Iflag optval[2]
52 #define iflag optval[3]
53 #define mflag optval[4]
54 #define nflag optval[5]
55 #define sflag optval[6]
56 #define xflag optval[7]
57 #define vflag optval[8]
58 #define Vflag optval[9]
59 #define	Eflag optval[10]
60 #define	Cflag optval[11]
61 #define	aflag optval[12]
62 #define	bflag optval[13]
63 #define	uflag optval[14]
64 #define	privileged optval[15]
65 #define	Tflag optval[16]
66 #define	Pflag optval[17]
67 #define	hflag optval[18]
68 #define	nologflag optval[19]
69 #define	pipefailflag optval[20]
70 #define	verifyflag optval[21]
71 
72 #define NSHORTOPTS	19
73 #define NOPTS		22
74 
75 extern char optval[NOPTS];
76 extern const char optletter[NSHORTOPTS];
77 #ifdef DEFINE_OPTIONS
78 char optval[NOPTS];
79 const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
80 static const unsigned char optname[] =
81 	"\007errexit"
82 	"\006noglob"
83 	"\011ignoreeof"
84 	"\013interactive"
85 	"\007monitor"
86 	"\006noexec"
87 	"\005stdin"
88 	"\006xtrace"
89 	"\007verbose"
90 	"\002vi"
91 	"\005emacs"
92 	"\011noclobber"
93 	"\011allexport"
94 	"\006notify"
95 	"\007nounset"
96 	"\012privileged"
97 	"\012trapsasync"
98 	"\010physical"
99 	"\010trackall"
100 	"\005nolog"
101 	"\010pipefail"
102 	"\006verify"
103 ;
104 #endif
105 
106 
107 extern char *minusc;		/* argument to -c option */
108 extern char *arg0;		/* $0 */
109 extern struct shparam shellparam;  /* $@ */
110 extern char **argptr;		/* argument list for builtin commands */
111 extern char *shoptarg;		/* set by nextopt */
112 extern char *nextopt_optptr;	/* used by nextopt */
113 
114 void procargs(int, char **);
115 void optschanged(void);
116 void freeparam(struct shparam *);
117 int nextopt(const char *);
118 void getoptsreset(const char *);
119