xref: /csrg-svn/bin/sh/options.h (revision 69272)
147136Sbostic /*-
260698Sbostic  * Copyright (c) 1991, 1993
360698Sbostic  *	The Regents of the University of California.  All rights reserved.
447136Sbostic  *
547136Sbostic  * This code is derived from software contributed to Berkeley by
647136Sbostic  * Kenneth Almquist.
747136Sbostic  *
847136Sbostic  * %sccs.include.redist.c%
947136Sbostic  *
10*69272Schristos  *	@(#)options.h	8.2 (Berkeley) 05/04/95
1147136Sbostic  */
1247136Sbostic 
1347136Sbostic struct shparam {
1447136Sbostic 	int nparam;	/* number of positional parameters (without $0) */
1547136Sbostic 	char malloc;	/* true if parameter list dynamicly allocated */
1647136Sbostic 	char **p;		/* parameter list */
1747136Sbostic 	char **optnext;	/* next parameter to be processed by getopts */
1847136Sbostic 	char *optptr;	/* used by getopts */
1947136Sbostic };
2047136Sbostic 
2147136Sbostic 
2247136Sbostic 
2355229Smarc #define eflag optlist[0].val
2455229Smarc #define fflag optlist[1].val
2555229Smarc #define Iflag optlist[2].val
2655229Smarc #define iflag optlist[3].val
2755229Smarc #define mflag optlist[4].val
2855229Smarc #define nflag optlist[5].val
2955229Smarc #define sflag optlist[6].val
3055229Smarc #define xflag optlist[7].val
3155229Smarc #define vflag optlist[8].val
3255229Smarc #define Vflag optlist[9].val
3355229Smarc #define	Eflag optlist[10].val
3455229Smarc #define	Cflag optlist[11].val
3555229Smarc #define	aflag optlist[12].val
3655229Smarc #define	bflag optlist[13].val
3755229Smarc #define	uflag optlist[14].val
3847136Sbostic 
3955229Smarc #define NOPTS	15
4047136Sbostic 
4155229Smarc struct optent {
4255229Smarc 	const char *name;
4355229Smarc 	const char letter;
4455229Smarc 	char val;
4555229Smarc };
4655229Smarc 
4747136Sbostic #ifdef DEFINE_OPTIONS
4855229Smarc struct optent optlist[NOPTS] = {
49*69272Schristos 	{ "errexit",	'e',	0 },
50*69272Schristos 	{ "noglob",	'f',	0 },
51*69272Schristos 	{ "ignoreeof",	'I',	0 },
52*69272Schristos 	{ "interactive",'i',	0 },
53*69272Schristos 	{ "monitor",	'm',	0 },
54*69272Schristos 	{ "noexec",	'n',	0 },
55*69272Schristos 	{ "stdin",	's',	0 },
56*69272Schristos 	{ "xtrace",	'x',	0 },
57*69272Schristos 	{ "verbose",	'v',	0 },
58*69272Schristos 	{ "vi",		'V',	0 },
59*69272Schristos 	{ "emacs",	'E',	0 },
60*69272Schristos 	{ "noclobber",	'C',	0 },
61*69272Schristos 	{ "allexport",	'a',	0 },
62*69272Schristos 	{ "notify",	'b',	0 },
63*69272Schristos 	{ "nounset",	'u',	0 },
6455229Smarc };
6547136Sbostic #else
6655229Smarc extern struct optent optlist[NOPTS];
6747136Sbostic #endif
6847136Sbostic 
6947136Sbostic 
7047136Sbostic extern char *minusc;		/* argument to -c option */
7147136Sbostic extern char *arg0;		/* $0 */
7247136Sbostic extern struct shparam shellparam;  /* $@ */
7347136Sbostic extern char **argptr;		/* argument list for builtin commands */
7447136Sbostic extern char *optarg;		/* set by nextopt */
7547136Sbostic extern char *optptr;		/* used by nextopt */
7647136Sbostic 
77*69272Schristos void procargs __P((int, char **));
78*69272Schristos void optschanged __P((void));
79*69272Schristos void setparam __P((char **));
80*69272Schristos void freeparam __P((struct shparam *));
81*69272Schristos int shiftcmd __P((int, char **));
82*69272Schristos int setcmd __P((int, char **));
83*69272Schristos int getoptscmd __P((int, char **));
84*69272Schristos int nextopt __P((char *));
85