xref: /original-bsd/bin/sh/options.h (revision b3c06cab)
1 /*-
2  * Copyright (c) 1991, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Kenneth Almquist.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)options.h	8.2 (Berkeley) 05/04/95
11  */
12 
13 struct shparam {
14 	int nparam;	/* number of positional parameters (without $0) */
15 	char malloc;	/* true if parameter list dynamicly allocated */
16 	char **p;		/* parameter list */
17 	char **optnext;	/* next parameter to be processed by getopts */
18 	char *optptr;	/* used by getopts */
19 };
20 
21 
22 
23 #define eflag optlist[0].val
24 #define fflag optlist[1].val
25 #define Iflag optlist[2].val
26 #define iflag optlist[3].val
27 #define mflag optlist[4].val
28 #define nflag optlist[5].val
29 #define sflag optlist[6].val
30 #define xflag optlist[7].val
31 #define vflag optlist[8].val
32 #define Vflag optlist[9].val
33 #define	Eflag optlist[10].val
34 #define	Cflag optlist[11].val
35 #define	aflag optlist[12].val
36 #define	bflag optlist[13].val
37 #define	uflag optlist[14].val
38 
39 #define NOPTS	15
40 
41 struct optent {
42 	const char *name;
43 	const char letter;
44 	char val;
45 };
46 
47 #ifdef DEFINE_OPTIONS
48 struct optent optlist[NOPTS] = {
49 	{ "errexit",	'e',	0 },
50 	{ "noglob",	'f',	0 },
51 	{ "ignoreeof",	'I',	0 },
52 	{ "interactive",'i',	0 },
53 	{ "monitor",	'm',	0 },
54 	{ "noexec",	'n',	0 },
55 	{ "stdin",	's',	0 },
56 	{ "xtrace",	'x',	0 },
57 	{ "verbose",	'v',	0 },
58 	{ "vi",		'V',	0 },
59 	{ "emacs",	'E',	0 },
60 	{ "noclobber",	'C',	0 },
61 	{ "allexport",	'a',	0 },
62 	{ "notify",	'b',	0 },
63 	{ "nounset",	'u',	0 },
64 };
65 #else
66 extern struct optent optlist[NOPTS];
67 #endif
68 
69 
70 extern char *minusc;		/* argument to -c option */
71 extern char *arg0;		/* $0 */
72 extern struct shparam shellparam;  /* $@ */
73 extern char **argptr;		/* argument list for builtin commands */
74 extern char *optarg;		/* set by nextopt */
75 extern char *optptr;		/* used by nextopt */
76 
77 void procargs __P((int, char **));
78 void optschanged __P((void));
79 void setparam __P((char **));
80 void freeparam __P((struct shparam *));
81 int shiftcmd __P((int, char **));
82 int setcmd __P((int, char **));
83 int getoptscmd __P((int, char **));
84 int nextopt __P((char *));
85