3 I cannot get the vanilla getopt code to work (i.e. compile only what
4 is needed and not duplicate symbols found in the standard library)
5 on all the platforms that FLAC supports. In particular the gating
6 of code with the ELIDE_CODE #define is not accurate enough on systems
7 that are POSIX but not glibc. If someone has a patch that works on
8 GNU/Linux, Darwin, AND Solaris please submit it on the project page:
9 http://sourceforge.net/projects/flac
11 In the meantime I have munged the global symbols and remove gates
12 around code, while at the same time trying to touch the original as
15 /* Declarations for getopt.
16 Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
17 This file is part of the GNU C Library.
19 The GNU C Library is free software; you can redistribute it and/or
20 modify it under the terms of the GNU Library General Public License as
21 published by the Free Software Foundation; either version 2 of the
22 License, or (at your option) any later version.
24 The GNU C Library is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 Library General Public License for more details.
29 You should have received a copy of the GNU Library General Public
30 License along with the GNU C Library; see the file COPYING.LIB. If not,
31 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
32 Boston, MA 02111-1307, USA. */
34 #ifndef FLAC__SHARE__GETOPT_H
35 #define FLAC__SHARE__GETOPT_H
37 #if defined(FLAC__NO_DLL) || defined(unix) || defined(__CYGWIN__) || defined(__CYGWIN32__)
42 #ifdef GETOPT_API_EXPORTS
43 #define GETOPT_API _declspec(dllexport)
45 #define GETOPT_API _declspec(dllimport)
46 #define __LIBNAME__ "getopt.lib"
47 #pragma comment(lib, __LIBNAME__)
54 /*[JEC] was:#ifndef __need_getopt*/
55 /*[JEC] was:# define _GETOPT_H 1*/
62 /* For communication from `FLAC__share__getopt' to the caller.
63 When `FLAC__share__getopt' finds an option that takes an argument,
64 the argument value is returned here.
65 Also, when `ordering' is RETURN_IN_ORDER,
66 each non-option ARGV-element is returned here. */
68 GETOPT_API extern char *FLAC__share__optarg;
70 /* Index in ARGV of the next element to be scanned.
71 This is used for communication to and from the caller
72 and for communication between successive calls to `FLAC__share__getopt'.
74 On entry to `FLAC__share__getopt', zero means this is the first call; initialize.
76 When `FLAC__share__getopt' returns -1, this is the index of the first of the
77 non-option elements that the caller should itself scan.
79 Otherwise, `FLAC__share__optind' communicates from one call to the next
80 how much of ARGV has been scanned so far. */
82 GETOPT_API extern int FLAC__share__optind;
84 /* Callers store zero here to inhibit the error message `FLAC__share__getopt' prints
85 for unrecognized options. */
87 GETOPT_API extern int FLAC__share__opterr;
89 /* Set to an option character which was unrecognized. */
91 GETOPT_API extern int FLAC__share__optopt;
93 /*[JEC] was:#ifndef __need_getopt */
94 /* Describe the long-named options requested by the application.
95 The LONG_OPTIONS argument to FLAC__share__getopt_long or FLAC__share__getopt_long_only is a vector
96 of `struct FLAC__share__option' terminated by an element containing a name which is
99 The field `has_arg' is:
100 FLAC__share__no_argument (or 0) if the option does not take an argument,
101 FLAC__share__required_argument (or 1) if the option requires an argument,
102 FLAC__share__optional_argument (or 2) if the option takes an optional argument.
104 If the field `flag' is not NULL, it points to a variable that is set
105 to the value given in the field `val' when the option is found, but
106 left unchanged if the option is not found.
108 To have a long-named option do something other than set an `int' to
109 a compiled-in constant, such as set a value from `FLAC__share__optarg', set the
110 option's `flag' field to zero and its `val' field to a nonzero
111 value (the equivalent single-letter option character, if there is
112 one). For long options that have a zero `flag' field, `FLAC__share__getopt'
113 returns the contents of the `val' field. */
115 struct FLAC__share__option
117 # if defined __STDC__ && __STDC__
122 /* has_arg can't be an enum because some compilers complain about
123 type mismatches in all the code that assumes it is an int. */
129 /* Names for the values of the `has_arg' field of `struct FLAC__share__option'. */
131 # define FLAC__share__no_argument 0
132 # define FLAC__share__required_argument 1
133 # define FLAC__share__optional_argument 2
134 /*[JEC] was:#endif*/ /* need getopt */
137 /* Get definitions and prototypes for functions to process the
138 arguments in ARGV (ARGC of them, minus the program name) for
139 options given in OPTS.
141 Return the option character from OPTS just read. Return -1 when
142 there are no more options. For unrecognized options, or options
143 missing arguments, `FLAC__share__optopt' is set to the option letter, and '?' is
146 The OPTS string is a list of characters which are recognized option
147 letters, optionally followed by colons, specifying that that letter
148 takes an argument, to be placed in `FLAC__share__optarg'.
150 If a letter in OPTS is followed by two colons, its argument is
151 optional. This behavior is specific to the GNU `FLAC__share__getopt'.
153 The argument `--' causes premature termination of argument
154 scanning, explicitly telling `FLAC__share__getopt' that there are no more
157 If OPTS begins with `--', then non-option arguments are treated as
158 arguments to the option '\0'. This behavior is specific to the GNU
159 `FLAC__share__getopt'. */
161 /*[JEC] was:#if defined __STDC__ && __STDC__*/
162 /*[JEC] was:# ifdef __GNU_LIBRARY__*/
163 /* Many other libraries have conflicting prototypes for getopt, with
164 differences in the consts, in stdlib.h. To avoid compilation
165 errors, only prototype getopt for the GNU C library. */
166 GETOPT_API extern int FLAC__share__getopt (int __argc, char *const *__argv, const char *__shortopts);
167 /*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */
168 /*[JEC] was:extern int getopt ();*/
169 /*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */
171 /*[JEC] was:# ifndef __need_getopt*/
172 GETOPT_API extern int FLAC__share__getopt_long (int __argc, char *const *__argv, const char *__shortopts,
173 const struct FLAC__share__option *__longopts, int *__longind);
174 GETOPT_API extern int FLAC__share__getopt_long_only (int __argc, char *const *__argv,
175 const char *__shortopts,
176 const struct FLAC__share__option *__longopts, int *__longind);
178 /* Internal only. Users should not call this directly. */
179 GETOPT_API extern int FLAC__share___getopt_internal (int __argc, char *const *__argv,
180 const char *__shortopts,
181 const struct FLAC__share__option *__longopts, int *__longind,
183 /*[JEC] was:# endif*/
184 /*[JEC] was:#else*/ /* not __STDC__ */
185 /*[JEC] was:extern int getopt ();*/
186 /*[JEC] was:# ifndef __need_getopt*/
187 /*[JEC] was:extern int getopt_long ();*/
188 /*[JEC] was:extern int getopt_long_only ();*/
190 /*[JEC] was:extern int _getopt_internal ();*/
191 /*[JEC] was:# endif*/
192 /*[JEC] was:#endif*/ /* __STDC__ */
198 /* Make sure we later can get all the definitions and declarations. */
199 /*[JEC] was:#undef __need_getopt*/
201 #endif /* getopt.h */