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 | This program is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | This program 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
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License along
|
---|
17 | with this program; if not, write to the Free Software Foundation,
|
---|
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
---|
19 |
|
---|
20 | #ifndef _GETOPT_INT_H
|
---|
21 | #define _GETOPT_INT_H 1
|
---|
22 |
|
---|
23 | extern int _getopt_internal (int ___argc, char **___argv,
|
---|
24 | const char *__shortopts,
|
---|
25 | const struct option *__longopts, int *__longind,
|
---|
26 | int __long_only, int __posixly_correct);
|
---|
27 |
|
---|
28 | |
---|
29 |
|
---|
30 | /* Reentrant versions which can handle parsing multiple argument
|
---|
31 | vectors at the same time. */
|
---|
32 |
|
---|
33 | /* Data type for reentrant functions. */
|
---|
34 | struct _getopt_data
|
---|
35 | {
|
---|
36 | /* These have exactly the same meaning as the corresponding global
|
---|
37 | variables, except that they are used for the reentrant
|
---|
38 | versions of getopt. */
|
---|
39 | int optind;
|
---|
40 | int opterr;
|
---|
41 | int optopt;
|
---|
42 | char *optarg;
|
---|
43 |
|
---|
44 | /* Internal members. */
|
---|
45 |
|
---|
46 | /* True if the internal members have been initialized. */
|
---|
47 | int __initialized;
|
---|
48 |
|
---|
49 | /* The next char to be scanned in the option-element
|
---|
50 | in which the last option character we returned was found.
|
---|
51 | This allows us to pick up the scan where we left off.
|
---|
52 |
|
---|
53 | If this is zero, or a null string, it means resume the scan
|
---|
54 | by advancing to the next ARGV-element. */
|
---|
55 | char *__nextchar;
|
---|
56 |
|
---|
57 | /* Describe how to deal with options that follow non-option ARGV-elements.
|
---|
58 |
|
---|
59 | If the caller did not specify anything,
|
---|
60 | the default is REQUIRE_ORDER if the environment variable
|
---|
61 | POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
---|
62 |
|
---|
63 | REQUIRE_ORDER means don't recognize them as options;
|
---|
64 | stop option processing when the first non-option is seen.
|
---|
65 | This is what Unix does.
|
---|
66 | This mode of operation is selected by either setting the environment
|
---|
67 | variable POSIXLY_CORRECT, or using `+' as the first character
|
---|
68 | of the list of option characters, or by calling getopt.
|
---|
69 |
|
---|
70 | PERMUTE is the default. We permute the contents of ARGV as we
|
---|
71 | scan, so that eventually all the non-options are at the end.
|
---|
72 | This allows options to be given in any order, even with programs
|
---|
73 | that were not written to expect this.
|
---|
74 |
|
---|
75 | RETURN_IN_ORDER is an option available to programs that were
|
---|
76 | written to expect options and other ARGV-elements in any order
|
---|
77 | and that care about the ordering of the two. We describe each
|
---|
78 | non-option ARGV-element as if it were the argument of an option
|
---|
79 | with character code 1. Using `-' as the first character of the
|
---|
80 | list of option characters selects this mode of operation.
|
---|
81 |
|
---|
82 | The special argument `--' forces an end of option-scanning regardless
|
---|
83 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
---|
84 | `--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
---|
85 |
|
---|
86 | enum
|
---|
87 | {
|
---|
88 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
---|
89 | } __ordering;
|
---|
90 |
|
---|
91 | /* If the POSIXLY_CORRECT environment variable is set
|
---|
92 | or getopt was called. */
|
---|
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 **___argv,
|
---|
116 | const char *__shortopts,
|
---|
117 | const struct option *__longopts, int *__longind,
|
---|
118 | int __long_only, int __posixly_correct,
|
---|
119 | struct _getopt_data *__data);
|
---|
120 |
|
---|
121 | extern int _getopt_long_r (int ___argc, char **___argv,
|
---|
122 | const char *__shortopts,
|
---|
123 | const struct option *__longopts, int *__longind,
|
---|
124 | struct _getopt_data *__data);
|
---|
125 |
|
---|
126 | extern int _getopt_long_only_r (int ___argc, char **___argv,
|
---|
127 | const char *__shortopts,
|
---|
128 | const struct option *__longopts,
|
---|
129 | int *__longind,
|
---|
130 | struct _getopt_data *__data);
|
---|
131 |
|
---|
132 | #endif /* getopt_int.h */
|
---|