options.h revision 1556
1139825Simp/*- 250565Sphk * Copyright (c) 1991, 1993 350565Sphk * The Regents of the University of California. All rights reserved. 450565Sphk * 550565Sphk * This code is derived from software contributed to Berkeley by 650565Sphk * Kenneth Almquist. 750565Sphk * 850565Sphk * Redistribution and use in source and binary forms, with or without 950565Sphk * modification, are permitted provided that the following conditions 1050565Sphk * are met: 1150565Sphk * 1. Redistributions of source code must retain the above copyright 1250565Sphk * notice, this list of conditions and the following disclaimer. 1350565Sphk * 2. Redistributions in binary form must reproduce the above copyright 1450565Sphk * notice, this list of conditions and the following disclaimer in the 1550565Sphk * documentation and/or other materials provided with the distribution. 1694182Sphk * 3. All advertising materials mentioning features or use of this software 17274732Smav * must display the following acknowledgement: 1894182Sphk * This product includes software developed by the University of 1994182Sphk * California, Berkeley and its contributors. 2050565Sphk * 4. Neither the name of the University nor the names of its contributors 21110119Sphk * may be used to endorse or promote products derived from this software 22110119Sphk * without specific prior written permission. 23110119Sphk * 24110119Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25103675Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2650565Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2794182Sphk * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2894182Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29210365Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30210365Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31210365Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32210365Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33210365Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3494282Sphk * SUCH DAMAGE. 3594282Sphk * 36210365Strasz * @(#)options.h 8.1 (Berkeley) 5/31/93 37210365Strasz */ 3894282Sphk 39210365Straszstruct shparam { 4094282Sphk int nparam; /* number of positional parameters (without $0) */ 4194282Sphk char malloc; /* true if parameter list dynamicly allocated */ 42210365Strasz char **p; /* parameter list */ 43210365Strasz char **optnext; /* next parameter to be processed by getopts */ 44210365Strasz char *optptr; /* used by getopts */ 4594282Sphk}; 4694282Sphk 4794282Sphk 4894282Sphk 49210365Strasz#define eflag optlist[0].val 50210365Strasz#define fflag optlist[1].val 5194282Sphk#define Iflag optlist[2].val 5294282Sphk#define iflag optlist[3].val 5394282Sphk#define mflag optlist[4].val 5494282Sphk#define nflag optlist[5].val 5594282Sphk#define sflag optlist[6].val 56210365Strasz#define xflag optlist[7].val 57210365Strasz#define vflag optlist[8].val 5894282Sphk#define Vflag optlist[9].val 5994282Sphk#define Eflag optlist[10].val 6094282Sphk#define Cflag optlist[11].val 6194282Sphk#define aflag optlist[12].val 62210365Strasz#define bflag optlist[13].val 63210365Strasz#define uflag optlist[14].val 6494287Sphk 6594287Sphk#define NOPTS 15 6694287Sphk 6794287Sphkstruct optent { 6894287Sphk const char *name; 6994287Sphk const char letter; 70169284Spjd char val; 71210365Strasz}; 72169284Spjd 73169284Spjd#ifdef DEFINE_OPTIONS 74169284Spjdstruct optent optlist[NOPTS] = { 75169284Spjd "errexit", 'e', 0, 76210365Strasz "noglob", 'f', 0, 77169284Spjd "ignoreeof", 'I', 0, 78169284Spjd "interactive", 'i', 0, 79169284Spjd "monitor", 'm', 0, 80169284Spjd "noexec", 'n', 0, 81169284Spjd "stdin", 's', 0, 82210226Strasz "xtrace", 'x', 0, 83169284Spjd "verbose", 'v', 0, 84169284Spjd "vi", 'V', 0, 85169284Spjd "emacs", 'E', 0, 86169284Spjd "noclobber", 'C', 0, 87169284Spjd "allexport", 'a', 0, 88169284Spjd "notify", 'b', 0, 89169284Spjd "nounset", 'u', 0, 90169284Spjd}; 91169284Spjd#else 92169284Spjdextern struct optent optlist[NOPTS]; 93169284Spjd#endif 94169284Spjd 95169284Spjd 96169284Spjdextern char *minusc; /* argument to -c option */ 97169284Spjdextern char *arg0; /* $0 */ 98169284Spjdextern struct shparam shellparam; /* $@ */ 99169284Spjdextern char **argptr; /* argument list for builtin commands */ 100169284Spjdextern char *optarg; /* set by nextopt */ 101169284Spjdextern char *optptr; /* used by nextopt */ 102210365Strasz 103210365Strasz 104182843Slulf#ifdef __STDC__ 105182843Slulfvoid procargs(int, char **); 106182843Slulfvoid setparam(char **); 107182843Slulfvoid freeparam(struct shparam *); 108210365Straszint nextopt(char *); 109210365Strasz#else 110200934Smavvoid procargs(); 111210365Straszvoid setparam(); 112200934Smavvoid freeparam(); 113200934Smavint nextopt(); 114210365Strasz#endif 115210365Strasz