Debian Codegraph @

src/gnu_getopt.h

raw symbols SCIP
1 /* Declarations for getopt.
2 Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000, 2001,
3 2002, 2003
4 Free Software Foundation, Inc.
5
6 NOTE: The canonical source of this file is maintained with the GNU C Library.
7 Bugs can be reported to [email protected].
8
9 This program is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2, or (at your option) any
12 later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 USA. */
23
24 #ifndef _GNU_GETOPT_H
25 #define _GNU_GETOPT_H 1
26
27 #ifndef __GETOPT_LONG_H__
28 #define __GETOPT_LONG_H__ 1
29
30 /* We only use getopt_long(), not getopt(), so we don't need a fully
31 prototyped declaration of getopt(). This forces the prototype for getopt()
32 to be compatible with all systems. Solaris in particular seems to have a
33 prototype for getopt() in unistd.h which conflicts with the one in this
34 file if we don't do this. */
35
36 #undef HAVE_DECL_GETOPT
37 #define HAVE_DECL_GETOPT 1
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /* For communication from `getopt' to the caller.
44 When `getopt' finds an option that takes an argument,
45 the argument value is returned here.
46 Also, when `ordering' is RETURN_IN_ORDER,
47 each non-option ARGV-element is returned here. */
48
49 extern char *optarg;
50
51 /* Index in ARGV of the next element to be scanned.
52 This is used for communication to and from the caller
53 and for communication between successive calls to `getopt'.
54
55 On entry to `getopt', zero means this is the first call; initialize.
56
57 When `getopt' returns -1, this is the index of the first of the
58 non-option elements that the caller should itself scan.
59
60 Otherwise, `optind' communicates from one call to the next
61 how much of ARGV has been scanned so far. */
62
63 extern int optind;
64
65 /* Callers store zero here to inhibit the error message `getopt' prints
66 for unrecognized options. */
67
68 extern int opterr;
69
70 /* Set to an option character which was unrecognized. */
71
72 extern int optopt;
73
74 /* Describe the long-named options requested by the application.
75 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
76 of `struct option' terminated by an element containing a name which is
77 zero.
78
79 The field `has_arg' is:
80 no_argument (or 0) if the option does not take an argument,
81 required_argument (or 1) if the option requires an argument,
82 optional_argument (or 2) if the option takes an optional argument.
83
84 If the field `flag' is not NULL, it points to a variable that is set
85 to the value given in the field `val' when the option is found, but
86 left unchanged if the option is not found.
87
88 To have a long-named option do something other than set an `int' to
89 a compiled-in constant, such as set a value from `optarg', set the
90 option's `flag' field to zero and its `val' field to a nonzero
91 value (the equivalent single-letter option character, if there is
92 one). For long options that have a zero `flag' field, `getopt'
93 returns the contents of the `val' field. */
94
95 struct option
96 {
97 #if defined (__STDC__) && __STDC__
98 const char *name;
99 #else
100 char *name;
101 #endif
102 /* has_arg can't be an enum because some compilers complain about
103 type mismatches in all the code that assumes it is an int. */
104 int has_arg;
105 int *flag;
106 int val;
107 };
108
109 /* Names for the values of the `has_arg' field of `struct option'. */
110
111 #define no_argument 0
112 #define required_argument 1
113 #define optional_argument 2
114
115 #if defined (__STDC__) && __STDC__
116 /* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
117 undefined, we haven't run the autoconf check so provide the
118 declaration without arguments. If it is 0, we checked and failed
119 to find the declaration so provide a fully prototyped one. If it
120 is 1, we found it so don't provide any declaration at all. */
121 #if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT)
122 /* Many other libraries have conflicting prototypes for getopt, with
123 differences in the consts, in stdlib.h. To avoid compilation
124 errors, only prototype getopt for the GNU C library. */
125 extern int getopt (int argc, char *const *argv, const char *shortopts);
126 #else /* not __GNU_LIBRARY__ */
127 # if !defined (HAVE_DECL_GETOPT)
128 extern int getopt ();
129 # endif
130 #endif /* __GNU_LIBRARY__ */
131 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
132 const struct option *longopts, int *longind);
133 extern int getopt_long_only (int argc, char *const *argv,
134 const char *shortopts,
135 const struct option *longopts, int *longind);
136
137 /* Internal only. Users should not call this directly. */
138 extern int _getopt_internal (int argc, char *const *argv,
139 const char *shortopts,
140 const struct option *longopts, int *longind,
141 int long_only);
142 #else /* not __STDC__ */
143 extern int getopt ();
144 extern int getopt_long ();
145 extern int getopt_long_only ();
146
147 extern int _getopt_internal ();
148 #endif /* __STDC__ */
149
150 #ifdef __cplusplus
151 }
152 #endif
153
154 #endif /* __GETOPT_LONG_H__ */
155 #endif /* gnu_getopt.h */