1 /* Declarations for getopt.
\r
2 Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
\r
4 This program is free software; you can redistribute it and/or modify it
\r
5 under the terms of the GNU General Public License as published by the
\r
6 Free Software Foundation; either version 2, or (at your option) any
\r
9 This program is distributed in the hope that it will be useful,
\r
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 GNU General Public License for more details.
\r
14 You should have received a copy of the GNU General Public License
\r
15 along with this program; if not, write to the Free Software
\r
16 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
\r
25 /* For communication from `getopt' to the caller.
\r
26 When `getopt' finds an option that takes an argument,
\r
27 the argument value is returned here.
\r
28 Also, when `ordering' is RETURN_IN_ORDER,
\r
29 each non-option ARGV-element is returned here. */
\r
31 extern char *optarg;
\r
33 /* Index in ARGV of the next element to be scanned.
\r
34 This is used for communication to and from the caller
\r
35 and for communication between successive calls to `getopt'.
\r
37 On entry to `getopt', zero means this is the first call; initialize.
\r
39 When `getopt' returns EOF, this is the index of the first of the
\r
40 non-option elements that the caller should itself scan.
\r
42 Otherwise, `optind' communicates from one call to the next
\r
43 how much of ARGV has been scanned so far. */
\r
47 /* Callers store zero here to inhibit the error message `getopt' prints
\r
48 for unrecognized options. */
\r
52 /* Set to an option character which was unrecognized. */
\r
56 /* Describe the long-named options requested by the application.
\r
57 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
\r
58 of `struct option' terminated by an element containing a name which is
\r
61 The field `has_arg' is:
\r
62 no_argument (or 0) if the option does not take an argument,
\r
63 required_argument (or 1) if the option requires an argument,
\r
64 optional_argument (or 2) if the option takes an optional argument.
\r
66 If the field `flag' is not NULL, it points to a variable that is set
\r
67 to the value given in the field `val' when the option is found, but
\r
68 left unchanged if the option is not found.
\r
70 To have a long-named option do something other than set an `int' to
\r
71 a compiled-in constant, such as set a value from `optarg', set the
\r
72 option's `flag' field to zero and its `val' field to a nonzero
\r
73 value (the equivalent single-letter option character, if there is
\r
74 one). For long options that have a zero `flag' field, `getopt'
\r
75 returns the contents of the `val' field. */
\r
84 /* has_arg can't be an enum because some compilers complain about
\r
85 type mismatches in all the code that assumes it is an int. */
\r
91 /* Names for the values of the `has_arg' field of `struct option'. */
\r
93 #define no_argument 0
\r
94 #define required_argument 1
\r
95 #define optional_argument 2
\r
98 #if defined(__GNU_LIBRARY__)
\r
99 /* Many other libraries have conflicting prototypes for getopt, with
\r
100 differences in the consts, in stdlib.h. To avoid compilation
\r
101 errors, only prototype getopt for the GNU C library. */
\r
102 extern int getopt (int argc, char *const *argv, const char *shortopts);
\r
103 #else /* not __GNU_LIBRARY__ */
\r
104 extern int getopt ();
\r
105 #endif /* not __GNU_LIBRARY__ */
\r
106 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
\r
107 const struct option *longopts, int *longind);
\r
108 extern int getopt_long_only (int argc, char *const *argv,
\r
109 const char *shortopts,
\r
110 const struct option *longopts, int *longind);
\r
112 /* Internal only. Users should not call this directly. */
\r
113 extern int _getopt_internal (int argc, char *const *argv,
\r
114 const char *shortopts,
\r
115 const struct option *longopts, int *longind,
\r
117 #else /* not __STDC__ */
\r
118 extern int getopt ();
\r
119 extern int getopt_long ();
\r
120 extern int getopt_long_only ();
\r
122 extern int _getopt_internal ();
\r
123 #endif /* not __STDC__ */
\r
129 #endif /* _GETOPT_H */
\r