]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/ext/flac/share/getopt.h
wwww
[16.git] / src / lib / doslib / ext / flac / share / getopt.h
1 /*
2         NOTE:
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
10
11         In the meantime I have munged the global symbols and removed gates
12         around code, while at the same time trying to touch the original as
13         little as possible.
14 */
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.
18
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.
23
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.
28
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.  */
33
34 #ifndef SHARE__GETOPT_H
35 #define SHARE__GETOPT_H
36
37 /*[JEC] was:#ifndef __need_getopt*/
38 /*[JEC] was:# define _GETOPT_H 1*/
39 /*[JEC] was:#endif*/
40
41 #ifdef  __cplusplus
42 extern "C" {
43 #endif
44
45 /* For communication from `share__getopt' to the caller.
46    When `share__getopt' finds an option that takes an argument,
47    the argument value is returned here.
48    Also, when `ordering' is RETURN_IN_ORDER,
49    each non-option ARGV-element is returned here.  */
50
51 extern char *share__optarg;
52
53 /* Index in ARGV of the next element to be scanned.
54    This is used for communication to and from the caller
55    and for communication between successive calls to `share__getopt'.
56
57    On entry to `share__getopt', zero means this is the first call; initialize.
58
59    When `share__getopt' returns -1, this is the index of the first of the
60    non-option elements that the caller should itself scan.
61
62    Otherwise, `share__optind' communicates from one call to the next
63    how much of ARGV has been scanned so far.  */
64
65 extern int share__optind;
66
67 /* Callers store zero here to inhibit the error message `share__getopt' prints
68    for unrecognized options.  */
69
70 extern int share__opterr;
71
72 /* Set to an option character which was unrecognized.  */
73
74 extern int share__optopt;
75
76 /*[JEC] was:#ifndef __need_getopt */
77 /* Describe the long-named options requested by the application.
78    The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector
79    of `struct share__option' terminated by an element containing a name which is
80    zero.
81
82    The field `has_arg' is:
83    share__no_argument           (or 0) if the option does not take an argument,
84    share__required_argument     (or 1) if the option requires an argument,
85    share__optional_argument     (or 2) if the option takes an optional argument.
86
87    If the field `flag' is not NULL, it points to a variable that is set
88    to the value given in the field `val' when the option is found, but
89    left unchanged if the option is not found.
90
91    To have a long-named option do something other than set an `int' to
92    a compiled-in constant, such as set a value from `share__optarg', set the
93    option's `flag' field to zero and its `val' field to a nonzero
94    value (the equivalent single-letter option character, if there is
95    one).  For long options that have a zero `flag' field, `share__getopt'
96    returns the contents of the `val' field.  */
97
98 struct share__option
99 {
100 # if defined __STDC__ && __STDC__
101   const char *name;
102 # else
103   char *name;
104 # endif
105   /* has_arg can't be an enum because some compilers complain about
106      type mismatches in all the code that assumes it is an int.  */
107   int has_arg;
108   int *flag;
109   int val;
110 };
111
112 /* Names for the values of the `has_arg' field of `struct share__option'.  */
113
114 # define share__no_argument             0
115 # define share__required_argument       1
116 # define share__optional_argument       2
117 /*[JEC] was:#endif*/    /* need getopt */
118
119
120 /* Get definitions and prototypes for functions to process the
121    arguments in ARGV (ARGC of them, minus the program name) for
122    options given in OPTS.
123
124    Return the option character from OPTS just read.  Return -1 when
125    there are no more options.  For unrecognized options, or options
126    missing arguments, `share__optopt' is set to the option letter, and '?' is
127    returned.
128
129    The OPTS string is a list of characters which are recognized option
130    letters, optionally followed by colons, specifying that that letter
131    takes an argument, to be placed in `share__optarg'.
132
133    If a letter in OPTS is followed by two colons, its argument is
134    optional.  This behavior is specific to the GNU `share__getopt'.
135
136    The argument `--' causes premature termination of argument
137    scanning, explicitly telling `share__getopt' that there are no more
138    options.
139
140    If OPTS begins with `--', then non-option arguments are treated as
141    arguments to the option '\0'.  This behavior is specific to the GNU
142    `share__getopt'.  */
143
144 /*[JEC] was:#if defined __STDC__ && __STDC__*/
145 /*[JEC] was:# ifdef __GNU_LIBRARY__*/
146 /* Many other libraries have conflicting prototypes for getopt, with
147    differences in the consts, in stdlib.h.  To avoid compilation
148    errors, only prototype getopt for the GNU C library.  */
149 extern int share__getopt (int argc, char *const *argv, const char *shortopts);
150 /*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */
151 /*[JEC] was:extern int getopt ();*/
152 /*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */
153
154 /*[JEC] was:# ifndef __need_getopt*/
155 extern int share__getopt_long (int argc, char *const *argv, const char *shortopts,
156                         const struct share__option *longopts, int *longind);
157 extern int share__getopt_long_only (int argc, char *const *argv,
158                              const char *shortopts,
159                              const struct share__option *longopts, int *longind);
160
161 /* Internal only.  Users should not call this directly.  */
162 extern int share___getopt_internal (int argc, char *const *argv,
163                              const char *shortopts,
164                              const struct share__option *longopts, int *longind,
165                              int long_only);
166 /*[JEC] was:# endif*/
167 /*[JEC] was:#else*/ /* not __STDC__ */
168 /*[JEC] was:extern int getopt ();*/
169 /*[JEC] was:# ifndef __need_getopt*/
170 /*[JEC] was:extern int getopt_long ();*/
171 /*[JEC] was:extern int getopt_long_only ();*/
172
173 /*[JEC] was:extern int _getopt_internal ();*/
174 /*[JEC] was:# endif*/
175 /*[JEC] was:#endif*/ /* __STDC__ */
176
177 #ifdef  __cplusplus
178 }
179 #endif
180
181 /* Make sure we later can get all the definitions and declarations.  */
182 /*[JEC] was:#undef __need_getopt*/
183
184 #endif /* getopt.h */