]> git.saurik.com Git - apple/shell_cmds.git/blame - sh/options.h
shell_cmds-216.60.1.tar.gz
[apple/shell_cmds.git] / sh / options.h
CommitLineData
71aad674 1/*-
254f12f7
A
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
71aad674
A
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.
254f12f7 18 * 3. Neither the name of the University nor the names of its contributors
71aad674
A
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
254f12f7 35 * $FreeBSD: head/bin/sh/options.h 326025 2017-11-20 19:49:47Z pfg $
71aad674
A
36 */
37
38struct shparam {
39 int nparam; /* # of positional parameters (without $0) */
40 unsigned char malloc; /* if parameter list dynamically allocated */
41 unsigned char reset; /* if getopts has been reset */
42 char **p; /* parameter list */
43 char **optp; /* parameter list for getopts */
44 char **optnext; /* next parameter to be processed by getopts */
45 char *optptr; /* used by getopts */
46};
47
48
49
deb63bfb
A
50#define eflag optval[0]
51#define fflag optval[1]
52#define Iflag optval[2]
53#define iflag optval[3]
54#define mflag optval[4]
55#define nflag optval[5]
56#define sflag optval[6]
57#define xflag optval[7]
58#define vflag optval[8]
59#define Vflag optval[9]
60#define Eflag optval[10]
61#define Cflag optval[11]
62#define aflag optval[12]
63#define bflag optval[13]
64#define uflag optval[14]
65#define privileged optval[15]
66#define Tflag optval[16]
67#define Pflag optval[17]
68#define hflag optval[18]
69#define nologflag optval[19]
71aad674 70
deb63bfb
A
71#define NSHORTOPTS 19
72#define NOPTS 20
71aad674 73
deb63bfb
A
74extern char optval[NOPTS];
75extern const char optletter[NSHORTOPTS];
71aad674 76#ifdef DEFINE_OPTIONS
deb63bfb
A
77char optval[NOPTS];
78const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
79static const unsigned char optname[] =
80 "\007errexit"
81 "\006noglob"
82 "\011ignoreeof"
83 "\013interactive"
84 "\007monitor"
85 "\006noexec"
86 "\005stdin"
87 "\006xtrace"
88 "\007verbose"
89 "\002vi"
90 "\005emacs"
91 "\011noclobber"
92 "\011allexport"
93 "\006notify"
94 "\007nounset"
95 "\012privileged"
96 "\012trapsasync"
97 "\010physical"
98 "\010trackall"
99 "\005nolog"
100;
71aad674
A
101#endif
102
103
104extern char *minusc; /* argument to -c option */
105extern char *arg0; /* $0 */
106extern struct shparam shellparam; /* $@ */
107extern char **argptr; /* argument list for builtin commands */
108extern char *shoptarg; /* set by nextopt */
109extern char *nextopt_optptr; /* used by nextopt */
110
111void procargs(int, char **);
112void optschanged(void);
71aad674
A
113void freeparam(struct shparam *);
114int nextopt(const char *);
115void getoptsreset(const char *);