| 1 | /* Internal declarations for getopt.
 | 
|---|
| 2 |    Copyright (C) 1989-1994,1996-1999,2001,2003,2004
 | 
|---|
| 3 |    Free Software Foundation, Inc.
 | 
|---|
| 4 |    This file is part of the GNU C Library.
 | 
|---|
| 5 | 
 | 
|---|
| 6 |    The GNU C Library is free software; you can redistribute it and/or
 | 
|---|
| 7 |    modify it under the terms of the GNU Lesser General Public
 | 
|---|
| 8 |    License as published by the Free Software Foundation; either
 | 
|---|
| 9 |    version 2.1 of the License, or (at your option) any later version.
 | 
|---|
| 10 | 
 | 
|---|
| 11 |    The GNU C Library is distributed in the hope that it will be useful,
 | 
|---|
| 12 |    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 13 |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
|---|
| 14 |    Lesser General Public License for more details.
 | 
|---|
| 15 | 
 | 
|---|
| 16 |    You should have received a copy of the GNU Lesser General Public
 | 
|---|
| 17 |    License along with the GNU C Library; if not, write to the Free
 | 
|---|
| 18 |    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 | 
|---|
| 19 |    02111-1307 USA.  */
 | 
|---|
| 20 | 
 | 
|---|
| 21 | #ifndef _GETOPT_INT_H
 | 
|---|
| 22 | #define _GETOPT_INT_H   1
 | 
|---|
| 23 | 
 | 
|---|
| 24 | extern int _getopt_internal (int ___argc, char *const *___argv,
 | 
|---|
| 25 |                              const char *__shortopts,
 | 
|---|
| 26 |                              const struct option *__longopts, int *__longind,
 | 
|---|
| 27 |                              int __long_only);
 | 
|---|
| 28 | 
 | 
|---|
| 29 |  | 
|---|
| 30 | 
 | 
|---|
| 31 | /* Reentrant versions which can handle parsing multiple argument
 | 
|---|
| 32 |    vectors at the same time.  */
 | 
|---|
| 33 | 
 | 
|---|
| 34 | /* Data type for reentrant functions.  */
 | 
|---|
| 35 | struct _getopt_data
 | 
|---|
| 36 | {
 | 
|---|
| 37 |   /* These have exactly the same meaning as the corresponding global
 | 
|---|
| 38 |      variables, except that they are used for the reentrant
 | 
|---|
| 39 |      versions of getopt.  */
 | 
|---|
| 40 |   int optind;
 | 
|---|
| 41 |   int opterr;
 | 
|---|
| 42 |   int optopt;
 | 
|---|
| 43 |   char *optarg;
 | 
|---|
| 44 | 
 | 
|---|
| 45 |   /* Internal members.  */
 | 
|---|
| 46 | 
 | 
|---|
| 47 |   /* True if the internal members have been initialized.  */
 | 
|---|
| 48 |   int __initialized;
 | 
|---|
| 49 | 
 | 
|---|
| 50 |   /* The next char to be scanned in the option-element
 | 
|---|
| 51 |      in which the last option character we returned was found.
 | 
|---|
| 52 |      This allows us to pick up the scan where we left off.
 | 
|---|
| 53 | 
 | 
|---|
| 54 |      If this is zero, or a null string, it means resume the scan
 | 
|---|
| 55 |      by advancing to the next ARGV-element.  */
 | 
|---|
| 56 |   char *__nextchar;
 | 
|---|
| 57 | 
 | 
|---|
| 58 |   /* Describe how to deal with options that follow non-option ARGV-elements.
 | 
|---|
| 59 | 
 | 
|---|
| 60 |      If the caller did not specify anything,
 | 
|---|
| 61 |      the default is REQUIRE_ORDER if the environment variable
 | 
|---|
| 62 |      POSIXLY_CORRECT is defined, PERMUTE otherwise.
 | 
|---|
| 63 | 
 | 
|---|
| 64 |      REQUIRE_ORDER means don't recognize them as options;
 | 
|---|
| 65 |      stop option processing when the first non-option is seen.
 | 
|---|
| 66 |      This is what Unix does.
 | 
|---|
| 67 |      This mode of operation is selected by either setting the environment
 | 
|---|
| 68 |      variable POSIXLY_CORRECT, or using `+' as the first character
 | 
|---|
| 69 |      of the list of option characters.
 | 
|---|
| 70 | 
 | 
|---|
| 71 |      PERMUTE is the default.  We permute the contents of ARGV as we
 | 
|---|
| 72 |      scan, so that eventually all the non-options are at the end.
 | 
|---|
| 73 |      This allows options to be given in any order, even with programs
 | 
|---|
| 74 |      that were not written to expect this.
 | 
|---|
| 75 | 
 | 
|---|
| 76 |      RETURN_IN_ORDER is an option available to programs that were
 | 
|---|
| 77 |      written to expect options and other ARGV-elements in any order
 | 
|---|
| 78 |      and that care about the ordering of the two.  We describe each
 | 
|---|
| 79 |      non-option ARGV-element as if it were the argument of an option
 | 
|---|
| 80 |      with character code 1.  Using `-' as the first character of the
 | 
|---|
| 81 |      list of option characters selects this mode of operation.
 | 
|---|
| 82 | 
 | 
|---|
| 83 |      The special argument `--' forces an end of option-scanning regardless
 | 
|---|
| 84 |      of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
 | 
|---|
| 85 |      `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
 | 
|---|
| 86 | 
 | 
|---|
| 87 |   enum
 | 
|---|
| 88 |     {
 | 
|---|
| 89 |       REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
 | 
|---|
| 90 |     } __ordering;
 | 
|---|
| 91 | 
 | 
|---|
| 92 |   /* If the POSIXLY_CORRECT environment variable is set.  */
 | 
|---|
| 93 |   int __posixly_correct;
 | 
|---|
| 94 | 
 | 
|---|
| 95 | 
 | 
|---|
| 96 |   /* Handle permutation of arguments.  */
 | 
|---|
| 97 | 
 | 
|---|
| 98 |   /* Describe the part of ARGV that contains non-options that have
 | 
|---|
| 99 |      been skipped.  `first_nonopt' is the index in ARGV of the first
 | 
|---|
| 100 |      of them; `last_nonopt' is the index after the last of them.  */
 | 
|---|
| 101 | 
 | 
|---|
| 102 |   int __first_nonopt;
 | 
|---|
| 103 |   int __last_nonopt;
 | 
|---|
| 104 | 
 | 
|---|
| 105 | #if defined _LIBC && defined USE_NONOPTION_FLAGS
 | 
|---|
| 106 |   int __nonoption_flags_max_len;
 | 
|---|
| 107 |   int __nonoption_flags_len;
 | 
|---|
| 108 | # endif
 | 
|---|
| 109 | };
 | 
|---|
| 110 | 
 | 
|---|
| 111 | /* The initializer is necessary to set OPTIND and OPTERR to their
 | 
|---|
| 112 |    default values and to clear the initialization flag.  */
 | 
|---|
| 113 | #define _GETOPT_DATA_INITIALIZER        { 1, 1 }
 | 
|---|
| 114 | 
 | 
|---|
| 115 | extern int _getopt_internal_r (int ___argc, char *const *___argv,
 | 
|---|
| 116 |                                const char *__shortopts,
 | 
|---|
| 117 |                                const struct option *__longopts, int *__longind,
 | 
|---|
| 118 |                                int __long_only, struct _getopt_data *__data);
 | 
|---|
| 119 | 
 | 
|---|
| 120 | extern int _getopt_long_r (int ___argc, char *const *___argv,
 | 
|---|
| 121 |                            const char *__shortopts,
 | 
|---|
| 122 |                            const struct option *__longopts, int *__longind,
 | 
|---|
| 123 |                            struct _getopt_data *__data);
 | 
|---|
| 124 | 
 | 
|---|
| 125 | extern int _getopt_long_only_r (int ___argc, char *const *___argv,
 | 
|---|
| 126 |                                 const char *__shortopts,
 | 
|---|
| 127 |                                 const struct option *__longopts,
 | 
|---|
| 128 |                                 int *__longind,
 | 
|---|
| 129 |                                 struct _getopt_data *__data);
 | 
|---|
| 130 | 
 | 
|---|
| 131 | #endif /* getopt_int.h */
 | 
|---|