1 /* This file is from getopt of glibc 2.2.2 2 * And it is modified for TiMidity++ support at 01/19, 2002 3 * by Masanao Izumo <mo@goice.co.jp>. 4 */ 5 6 /* Declarations for getopt. 7 Copyright (C) 1989,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc. 8 This file is part of the GNU C Library. 9 10 The GNU C Library is free software; you can redistribute it and/or 11 modify it under the terms of the GNU Library General Public License as 12 published by the Free Software Foundation; either version 2 of the 13 License, or (at your option) any later version. 14 15 The GNU C Library is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 Library General Public License for more details. 19 20 You should have received a copy of the GNU Library General Public 21 License along with the GNU C Library; see the file COPYING.LIB. If not, 22 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 Boston, MA 02111-1307, USA. */ 24 25 #ifndef __TMDY_GETOPT_H__ 26 #define __TMDY_GETOPT_H__ 27 28 #if defined(HAVE_UNISTD_H) && (!defined(__WATCOMC__) || defined(HAVE_GETOPT)) 29 /* getopt() declaration here */ 30 #include <unistd.h> 31 #else 32 33 /* For communication from `getopt' to the caller. 34 When `getopt' finds an option that takes an argument, 35 the argument value is returned here. 36 Also, when `ordering' is RETURN_IN_ORDER, 37 each non-option ARGV-element is returned here. */ 38 39 extern char *optarg; 40 41 /* Index in ARGV of the next element to be scanned. 42 This is used for communication to and from the caller 43 and for communication between successive calls to `getopt'. 44 45 On entry to `getopt', zero means this is the first call; initialize. 46 47 When `getopt' returns -1, this is the index of the first of the 48 non-option elements that the caller should itself scan. 49 50 Otherwise, `optind' communicates from one call to the next 51 how much of ARGV has been scanned so far. */ 52 53 extern int optind; 54 55 /* Callers store zero here to inhibit the error message `getopt' prints 56 for unrecognized options. */ 57 58 extern int opterr; 59 60 /* Set to an option character which was unrecognized. */ 61 62 extern int optopt; 63 64 extern int getopt (int __argc, char *const *__argv, const char *__shortopts); 65 66 #endif /* <unistd.h> */ 67 68 #ifdef HAVE_GETOPT_H 69 /* gtopt_long() declared here */ 70 #include <getopt.h> 71 72 #if __POCC__ 73 struct option { 74 const char *name; 75 int has_arg; 76 int *flag; 77 int val; 78 }; 79 # define no_argument 0 80 # define required_argument 1 81 # define optional_argument 2 82 #endif 83 84 #else 85 86 /* Describe the long-named options requested by the application. 87 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 88 of `struct option' terminated by an element containing a name which is 89 zero. 90 91 The field `has_arg' is: 92 no_argument (or 0) if the option does not take an argument, 93 required_argument (or 1) if the option requires an argument, 94 optional_argument (or 2) if the option takes an optional argument. 95 96 If the field `flag' is not NULL, it points to a variable that is set 97 to the value given in the field `val' when the option is found, but 98 left unchanged if the option is not found. 99 100 To have a long-named option do something other than set an `int' to 101 a compiled-in constant, such as set a value from `optarg', set the 102 option's `flag' field to zero and its `val' field to a nonzero 103 value (the equivalent single-letter option character, if there is 104 one). For long options that have a zero `flag' field, `getopt' 105 returns the contents of the `val' field. */ 106 107 struct option 108 { 109 const char *name; 110 /* has_arg can't be an enum because some compilers complain about 111 type mismatches in all the code that assumes it is an int. */ 112 int has_arg; 113 int *flag; 114 int val; 115 }; 116 117 118 /* Names for the values of the `has_arg' field of `struct option'. */ 119 120 # define no_argument 0 121 # define required_argument 1 122 # define optional_argument 2 123 124 125 126 /* Get definitions and prototypes for functions to process the 127 arguments in ARGV (ARGC of them, minus the program name) for 128 options given in OPTS. 129 130 Return the option character from OPTS just read. Return -1 when 131 there are no more options. For unrecognized options, or options 132 missing arguments, `optopt' is set to the option letter, and '?' is 133 returned. 134 135 The OPTS string is a list of characters which are recognized option 136 letters, optionally followed by colons, specifying that that letter 137 takes an argument, to be placed in `optarg'. 138 139 If a letter in OPTS is followed by two colons, its argument is 140 optional. This behavior is specific to the GNU `getopt'. 141 142 The argument `--' causes premature termination of argument 143 scanning, explicitly telling `getopt' that there are no more 144 options. 145 146 If OPTS begins with `--', then non-option arguments are treated as 147 arguments to the option '\0'. This behavior is specific to the GNU 148 `getopt'. */ 149 150 extern int getopt_long (int __argc, char *const *__argv, 151 const char *__shortopts, 152 const struct option *__longopts, int *__longind); 153 extern int getopt_long_only (int __argc, char *const *__argv, 154 const char *__shortopts, 155 const struct option *__longopts, int *__longind); 156 157 #endif /* <getopt.h> */ 158 159 #endif 160