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