dvi2bitmap dvi2bitmap1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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