1
/* Declarations for getopt.
2
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
4
This program is free software; you can redistribute it and/or modify it
5
under the terms of the GNU General Public License as published by the
6
Free Software Foundation; either version 2, or (at your option) any
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
18
/* Modified for use with hexcurse by Blake Matheny <matheny@dbaseiv.net> */
28
#define APPLY_OPTVAR_REPLACEMENTS 1
35
/* For communication from `getopt' to the caller.
36
When `getopt' finds an option that takes an argument,
37
the argument value is returned here.
38
Also, when `ordering' is RETURN_IN_ORDER,
39
each non-option ARGV-element is returned here. */
43
/* Index in ARGV of the next element to be scanned.
44
This is used for communication to and from the caller
45
and for communication between successive calls to `getopt'.
47
On entry to `getopt', zero means this is the first call; initialize.
49
When `getopt' returns EOF, this is the index of the first of the
50
non-option elements that the caller should itself scan.
52
Otherwise, `optind' communicates from one call to the next
53
how much of ARGV has been scanned so far. */
57
/* Callers store zero here to inhibit the error message `getopt' prints
58
for unrecognized options. */
62
/* Set to an option character which was unrecognized. */
66
/* Describe the long-named options requested by the application.
67
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
68
of `struct option' terminated by an element containing a name which is
71
The field `has_arg' is:
72
no_argument (or 0) if the option does not take an argument,
73
required_argument (or 1) if the option requires an argument,
74
optional_argument (or 2) if the option takes an optional argument.
76
If the field `flag' is not NULL, it points to a variable that is set
77
to the value given in the field `val' when the option is found, but
78
left unchanged if the option is not found.
80
To have a long-named option do something other than set an `int' to
81
a compiled-in constant, such as set a value from `optarg', set the
82
option's `flag' field to zero and its `val' field to a nonzero
83
value (the equivalent single-letter option character, if there is
84
one). For long options that have a zero `flag' field, `getopt'
85
returns the contents of the `val' field. */
94
/* has_arg can't be an enum because some compilers complain about
95
type mismatches in all the code that assumes it is an int. */
101
/* Names for the values of the `has_arg' field of `struct option'. */
103
#define no_argument 0
104
#define required_argument 1
105
#define optional_argument 2
108
#if 0 /* we do not use getopt */
109
#if defined(__GNU_LIBRARY__)
110
/* Many other libraries have conflicting prototypes for getopt, with
111
differences in the consts, in stdlib.h. To avoid compilation
112
errors, only prototype getopt for the GNU C library. */
113
extern int getopt (int argc, char *const *argv, const char *shortopts);
114
#else /* not __GNU_LIBRARY__ */
115
extern int getopt ();
116
#endif /* not __GNU_LIBRARY__ */
117
#endif /* we do not use getopt */
118
#ifdef APPLY_OPTVAR_REPLACEMENTS
119
extern char *get_optarg (void);
120
extern int get_opterr (void);
121
extern int get_optind (void);
122
extern int get_optopt (void);
123
extern int inc_optind (void);
124
#endif /* APPLY_OPTVAR_REPLACEMENTS */
125
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
126
const struct option *longopts, int *longind);
127
extern int getopt_long_only (int argc, char *const *argv,
128
const char *shortopts,
129
const struct option *longopts, int *longind);
131
/* Internal only. Users should not call this directly. */
132
extern int _getopt_internal (int argc, char *const *argv,
133
const char *shortopts,
134
const struct option *longopts, int *longind,
136
#else /* not __STDC__ */
137
#ifdef APPLY_OPTVAR_REPLACEMENTS
138
extern char *get_optarg ();
139
extern int get_opterr ();
140
extern int get_optind ();
141
extern int get_optopt ();
142
extern int inc_optind ();
143
#endif /* APPLY_OPTVAR_REPLACEMENTS */
144
extern int getopt ();
145
extern int getopt_long ();
146
extern int getopt_long_only ();
148
extern int _getopt_internal ();
149
#endif /* not __STDC__ */
151
#ifdef APPLY_OPTVAR_REPLACEMENTS
152
#define optind get_optind ()
153
#define optarg get_optarg ()
154
#define opterr get_opterr ()
155
#define optopt get_optopt ()
156
#else /* APPLY_OPTVAR_REPLACEMENTS */
157
#define inc_optind() (optind ++)
158
#define get_optind() (optind)
159
#define get_optarg() (optarg)
160
#define get_opterr() (opterr)
161
#define get_optopt() (optopt)
162
#endif /* APPLY_OPTVAR_REPLACEMENTS */
168
#endif /* _GETOPT_H */