annotate src/flac-1.2.1/include/share/getopt.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 05aa0afa9217
children
rev   line source
Chris@1 1 /*
Chris@1 2 NOTE:
Chris@1 3 I cannot get the vanilla getopt code to work (i.e. compile only what
Chris@1 4 is needed and not duplicate symbols found in the standard library)
Chris@1 5 on all the platforms that FLAC supports. In particular the gating
Chris@1 6 of code with the ELIDE_CODE #define is not accurate enough on systems
Chris@1 7 that are POSIX but not glibc. If someone has a patch that works on
Chris@1 8 GNU/Linux, Darwin, AND Solaris please submit it on the project page:
Chris@1 9 http://sourceforge.net/projects/flac
Chris@1 10
Chris@1 11 In the meantime I have munged the global symbols and removed gates
Chris@1 12 around code, while at the same time trying to touch the original as
Chris@1 13 little as possible.
Chris@1 14 */
Chris@1 15 /* Declarations for getopt.
Chris@1 16 Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
Chris@1 17 This file is part of the GNU C Library.
Chris@1 18
Chris@1 19 The GNU C Library is free software; you can redistribute it and/or
Chris@1 20 modify it under the terms of the GNU Library General Public License as
Chris@1 21 published by the Free Software Foundation; either version 2 of the
Chris@1 22 License, or (at your option) any later version.
Chris@1 23
Chris@1 24 The GNU C Library is distributed in the hope that it will be useful,
Chris@1 25 but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1 26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@1 27 Library General Public License for more details.
Chris@1 28
Chris@1 29 You should have received a copy of the GNU Library General Public
Chris@1 30 License along with the GNU C Library; see the file COPYING.LIB. If not,
Chris@1 31 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Chris@1 32 Boston, MA 02111-1307, USA. */
Chris@1 33
Chris@1 34 #ifndef SHARE__GETOPT_H
Chris@1 35 #define SHARE__GETOPT_H
Chris@1 36
Chris@1 37 /*[JEC] was:#ifndef __need_getopt*/
Chris@1 38 /*[JEC] was:# define _GETOPT_H 1*/
Chris@1 39 /*[JEC] was:#endif*/
Chris@1 40
Chris@1 41 #ifdef __cplusplus
Chris@1 42 extern "C" {
Chris@1 43 #endif
Chris@1 44
Chris@1 45 /* For communication from `share__getopt' to the caller.
Chris@1 46 When `share__getopt' finds an option that takes an argument,
Chris@1 47 the argument value is returned here.
Chris@1 48 Also, when `ordering' is RETURN_IN_ORDER,
Chris@1 49 each non-option ARGV-element is returned here. */
Chris@1 50
Chris@1 51 extern char *share__optarg;
Chris@1 52
Chris@1 53 /* Index in ARGV of the next element to be scanned.
Chris@1 54 This is used for communication to and from the caller
Chris@1 55 and for communication between successive calls to `share__getopt'.
Chris@1 56
Chris@1 57 On entry to `share__getopt', zero means this is the first call; initialize.
Chris@1 58
Chris@1 59 When `share__getopt' returns -1, this is the index of the first of the
Chris@1 60 non-option elements that the caller should itself scan.
Chris@1 61
Chris@1 62 Otherwise, `share__optind' communicates from one call to the next
Chris@1 63 how much of ARGV has been scanned so far. */
Chris@1 64
Chris@1 65 extern int share__optind;
Chris@1 66
Chris@1 67 /* Callers store zero here to inhibit the error message `share__getopt' prints
Chris@1 68 for unrecognized options. */
Chris@1 69
Chris@1 70 extern int share__opterr;
Chris@1 71
Chris@1 72 /* Set to an option character which was unrecognized. */
Chris@1 73
Chris@1 74 extern int share__optopt;
Chris@1 75
Chris@1 76 /*[JEC] was:#ifndef __need_getopt */
Chris@1 77 /* Describe the long-named options requested by the application.
Chris@1 78 The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector
Chris@1 79 of `struct share__option' terminated by an element containing a name which is
Chris@1 80 zero.
Chris@1 81
Chris@1 82 The field `has_arg' is:
Chris@1 83 share__no_argument (or 0) if the option does not take an argument,
Chris@1 84 share__required_argument (or 1) if the option requires an argument,
Chris@1 85 share__optional_argument (or 2) if the option takes an optional argument.
Chris@1 86
Chris@1 87 If the field `flag' is not NULL, it points to a variable that is set
Chris@1 88 to the value given in the field `val' when the option is found, but
Chris@1 89 left unchanged if the option is not found.
Chris@1 90
Chris@1 91 To have a long-named option do something other than set an `int' to
Chris@1 92 a compiled-in constant, such as set a value from `share__optarg', set the
Chris@1 93 option's `flag' field to zero and its `val' field to a nonzero
Chris@1 94 value (the equivalent single-letter option character, if there is
Chris@1 95 one). For long options that have a zero `flag' field, `share__getopt'
Chris@1 96 returns the contents of the `val' field. */
Chris@1 97
Chris@1 98 struct share__option
Chris@1 99 {
Chris@1 100 # if defined __STDC__ && __STDC__
Chris@1 101 const char *name;
Chris@1 102 # else
Chris@1 103 char *name;
Chris@1 104 # endif
Chris@1 105 /* has_arg can't be an enum because some compilers complain about
Chris@1 106 type mismatches in all the code that assumes it is an int. */
Chris@1 107 int has_arg;
Chris@1 108 int *flag;
Chris@1 109 int val;
Chris@1 110 };
Chris@1 111
Chris@1 112 /* Names for the values of the `has_arg' field of `struct share__option'. */
Chris@1 113
Chris@1 114 # define share__no_argument 0
Chris@1 115 # define share__required_argument 1
Chris@1 116 # define share__optional_argument 2
Chris@1 117 /*[JEC] was:#endif*/ /* need getopt */
Chris@1 118
Chris@1 119
Chris@1 120 /* Get definitions and prototypes for functions to process the
Chris@1 121 arguments in ARGV (ARGC of them, minus the program name) for
Chris@1 122 options given in OPTS.
Chris@1 123
Chris@1 124 Return the option character from OPTS just read. Return -1 when
Chris@1 125 there are no more options. For unrecognized options, or options
Chris@1 126 missing arguments, `share__optopt' is set to the option letter, and '?' is
Chris@1 127 returned.
Chris@1 128
Chris@1 129 The OPTS string is a list of characters which are recognized option
Chris@1 130 letters, optionally followed by colons, specifying that that letter
Chris@1 131 takes an argument, to be placed in `share__optarg'.
Chris@1 132
Chris@1 133 If a letter in OPTS is followed by two colons, its argument is
Chris@1 134 optional. This behavior is specific to the GNU `share__getopt'.
Chris@1 135
Chris@1 136 The argument `--' causes premature termination of argument
Chris@1 137 scanning, explicitly telling `share__getopt' that there are no more
Chris@1 138 options.
Chris@1 139
Chris@1 140 If OPTS begins with `--', then non-option arguments are treated as
Chris@1 141 arguments to the option '\0'. This behavior is specific to the GNU
Chris@1 142 `share__getopt'. */
Chris@1 143
Chris@1 144 /*[JEC] was:#if defined __STDC__ && __STDC__*/
Chris@1 145 /*[JEC] was:# ifdef __GNU_LIBRARY__*/
Chris@1 146 /* Many other libraries have conflicting prototypes for getopt, with
Chris@1 147 differences in the consts, in stdlib.h. To avoid compilation
Chris@1 148 errors, only prototype getopt for the GNU C library. */
Chris@1 149 extern int share__getopt (int argc, char *const *argv, const char *shortopts);
Chris@1 150 /*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */
Chris@1 151 /*[JEC] was:extern int getopt ();*/
Chris@1 152 /*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */
Chris@1 153
Chris@1 154 /*[JEC] was:# ifndef __need_getopt*/
Chris@1 155 extern int share__getopt_long (int argc, char *const *argv, const char *shortopts,
Chris@1 156 const struct share__option *longopts, int *longind);
Chris@1 157 extern int share__getopt_long_only (int argc, char *const *argv,
Chris@1 158 const char *shortopts,
Chris@1 159 const struct share__option *longopts, int *longind);
Chris@1 160
Chris@1 161 /* Internal only. Users should not call this directly. */
Chris@1 162 extern int share___getopt_internal (int argc, char *const *argv,
Chris@1 163 const char *shortopts,
Chris@1 164 const struct share__option *longopts, int *longind,
Chris@1 165 int long_only);
Chris@1 166 /*[JEC] was:# endif*/
Chris@1 167 /*[JEC] was:#else*/ /* not __STDC__ */
Chris@1 168 /*[JEC] was:extern int getopt ();*/
Chris@1 169 /*[JEC] was:# ifndef __need_getopt*/
Chris@1 170 /*[JEC] was:extern int getopt_long ();*/
Chris@1 171 /*[JEC] was:extern int getopt_long_only ();*/
Chris@1 172
Chris@1 173 /*[JEC] was:extern int _getopt_internal ();*/
Chris@1 174 /*[JEC] was:# endif*/
Chris@1 175 /*[JEC] was:#endif*/ /* __STDC__ */
Chris@1 176
Chris@1 177 #ifdef __cplusplus
Chris@1 178 }
Chris@1 179 #endif
Chris@1 180
Chris@1 181 /* Make sure we later can get all the definitions and declarations. */
Chris@1 182 /*[JEC] was:#undef __need_getopt*/
Chris@1 183
Chris@1 184 #endif /* getopt.h */