Another fix for LIST not showing some elements after error.
[pwmd.git] / src / getopt_long.h
blob062a77c3f4424b442d1d28591dfbee04f0d8a67d
2 /* Declarations for getopt.
3 Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 This file was modified slightly by Ian Lance Taylor, November 1992,
20 for Taylor UUCP, and again in June, 1995. */
22 #ifndef _GETOPT_H
23 #define _GETOPT_H 1
25 #ifdef __cplusplus
26 extern "C"
28 #endif
30 /* Ian Lance Taylor <ian@airs.com> added the following defines for
31 Taylor UUCP. This avoids reported conflicts with system getopt
32 definitions. */
33 #define getopt gnu_getopt
34 #define optarg gnu_optarg
35 #define optind gnu_optind
36 #define opterr gnu_opterr
38 /* For communication from `getopt' to the caller.
39 When `getopt' finds an option that takes an argument,
40 the argument value is returned here.
41 Also, when `ordering' is RETURN_IN_ORDER,
42 each non-option ARGV-element is returned here. */
44 extern char *optarg;
46 /* Index in ARGV of the next element to be scanned.
47 This is used for communication to and from the caller
48 and for communication between successive calls to `getopt'.
50 On entry to `getopt', zero means this is the first call; initialize.
52 When `getopt' returns EOF, this is the index of the first of the
53 non-option elements that the caller should itself scan.
55 Otherwise, `optind' communicates from one call to the next
56 how much of ARGV has been scanned so far. */
58 extern int optind;
60 /* Callers store zero here to inhibit the error message `getopt' prints
61 for unrecognized options. */
63 extern int opterr;
65 /* Describe the long-named options requested by the application.
66 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
67 of `struct option' terminated by an element containing a name which is
68 zero.
70 The field `has_arg' is:
71 no_argument (or 0) if the option does not take an argument,
72 required_argument (or 1) if the option requires an argument,
73 optional_argument (or 2) if the option takes an optional argument.
75 If the field `flag' is not NULL, it points to a variable that is set
76 to the value given in the field `val' when the option is found, but
77 left unchanged if the option is not found.
79 To have a long-named option do something other than set an `int' to
80 a compiled-in constant, such as set a value from `optarg', set the
81 option's `flag' field to zero and its `val' field to a nonzero
82 value (the equivalent single-letter option character, if there is
83 one). For long options that have a zero `flag' field, `getopt'
84 returns the contents of the `val' field. */
86 struct option
88 const char *name;
89 /* has_arg can't be an enum because some compilers complain about type
90 * mismatches in all the code that assumes it is an int. */
91 int has_arg;
92 int *flag;
93 int val;
96 /* Names for the values of the `has_arg' field of `struct option'. */
98 enum _argtype
100 no_argument,
101 required_argument,
102 optional_argument
105 #ifndef P
107 /* On some systems, <stdio.h> includes getopt.h before P is defined by
108 uucp.h, and the -I arguments cause this version of getopt.h to be
109 included. Work around that here. */
110 #define P(x) ()
111 #define UNDEFINE_P
112 #endif
114 extern int getopt P ((int argc, char *const *argv, const char *shortopts));
115 extern int getopt_long
116 P ((int argc, char *const *argv, const char *shortopts,
117 const struct option * longopts, int *longind));
118 extern int getopt_long_only
119 P ((int argc, char *const *argv, const char *shortopts,
120 const struct option * longopts, int *longind));
122 /* Internal only. Users should not call this directly. */
123 extern int _getopt_internal
124 P ((int argc, char *const *argv, const char *shortopts,
125 const struct option * longopts, int *longind, int long_only));
127 #ifdef UNDEFINE_P
128 #undef P
129 #undef UNDEFINE_P
130 #endif
132 #ifdef __cplusplus
134 #endif
136 #endif /* _GETOPT_H */