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