annotate src/sdl/getopt.h @ 68:86093f2ce7d1

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