annotate src/flac-1.2.1/include/share/getopt.h @ 94:d278df1123f9

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