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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
---|
19 | |
---|
20 | #ifndef _GETOPT_INT_H |
---|
21 | #define _GETOPT_INT_H 1 |
---|
22 | |
---|
23 | extern int _getopt_internal ( |
---|
24 | int ___argc, |
---|
25 | char *const *___argv, |
---|
26 | const char *__shortopts, |
---|
27 | const struct option *__longopts, |
---|
28 | int *__longind, |
---|
29 | int __long_only |
---|
30 | ); |
---|
31 | |
---|
32 | |
---|
33 | /* Reentrant versions which can handle parsing multiple argument |
---|
34 | vectors at the same time. */ |
---|
35 | |
---|
36 | /* Data type for reentrant functions. */ |
---|
37 | struct _getopt_data |
---|
38 | { |
---|
39 | /* These have exactly the same meaning as the corresponding global |
---|
40 | variables, except that they are used for the reentrant |
---|
41 | versions of getopt. */ |
---|
42 | int optind; |
---|
43 | int opterr; |
---|
44 | int optopt; |
---|
45 | char *optarg; |
---|
46 | |
---|
47 | /* Internal members. */ |
---|
48 | |
---|
49 | /* True if the internal members have been initialized. */ |
---|
50 | int __initialized; |
---|
51 | |
---|
52 | /* The next char to be scanned in the option-element |
---|
53 | in which the last option character we returned was found. |
---|
54 | This allows us to pick up the scan where we left off. |
---|
55 | |
---|
56 | If this is zero, or a null string, it means resume the scan |
---|
57 | by advancing to the next ARGV-element. */ |
---|
58 | char *__nextchar; |
---|
59 | |
---|
60 | /* Describe how to deal with options that follow non-option ARGV-elements. |
---|
61 | |
---|
62 | If the caller did not specify anything, |
---|
63 | the default is REQUIRE_ORDER if the environment variable |
---|
64 | POSIXLY_CORRECT is defined, PERMUTE otherwise. |
---|
65 | |
---|
66 | REQUIRE_ORDER means don't recognize them as options; |
---|
67 | stop option processing when the first non-option is seen. |
---|
68 | This is what Unix does. |
---|
69 | This mode of operation is selected by either setting the environment |
---|
70 | variable POSIXLY_CORRECT, or using `+' as the first character |
---|
71 | of the list of option characters. |
---|
72 | |
---|
73 | PERMUTE is the default. We permute the contents of ARGV as we |
---|
74 | scan, so that eventually all the non-options are at the end. |
---|
75 | This allows options to be given in any order, even with programs |
---|
76 | that were not written to expect this. |
---|
77 | |
---|
78 | RETURN_IN_ORDER is an option available to programs that were |
---|
79 | written to expect options and other ARGV-elements in any order |
---|
80 | and that care about the ordering of the two. We describe each |
---|
81 | non-option ARGV-element as if it were the argument of an option |
---|
82 | with character code 1. Using `-' as the first character of the |
---|
83 | list of option characters selects this mode of operation. |
---|
84 | |
---|
85 | The special argument `--' forces an end of option-scanning regardless |
---|
86 | of the value of `ordering'. In the case of RETURN_IN_ORDER, only |
---|
87 | `--' can cause `getopt' to return -1 with `optind' != ARGC. */ |
---|
88 | |
---|
89 | enum |
---|
90 | { |
---|
91 | REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER |
---|
92 | } __ordering; |
---|
93 | |
---|
94 | /* If the POSIXLY_CORRECT environment variable is set. */ |
---|
95 | int __posixly_correct; |
---|
96 | |
---|
97 | |
---|
98 | /* Handle permutation of arguments. */ |
---|
99 | |
---|
100 | /* Describe the part of ARGV that contains non-options that have |
---|
101 | been skipped. `first_nonopt' is the index in ARGV of the first |
---|
102 | of them; `last_nonopt' is the index after the last of them. */ |
---|
103 | |
---|
104 | int __first_nonopt; |
---|
105 | int __last_nonopt; |
---|
106 | |
---|
107 | #if defined _LIBC && defined USE_NONOPTION_FLAGS |
---|
108 | int __nonoption_flags_max_len; |
---|
109 | int __nonoption_flags_len; |
---|
110 | # endif |
---|
111 | }; |
---|
112 | |
---|
113 | /* The initializer is necessary to set OPTIND and OPTERR to their |
---|
114 | default values and to clear the initialization flag. */ |
---|
115 | #define _GETOPT_DATA_INITIALIZER { 1, 1 } |
---|
116 | |
---|
117 | extern int _getopt_internal_r ( |
---|
118 | int ___argc, |
---|
119 | char *const *___argv, |
---|
120 | const char *__shortopts, |
---|
121 | const struct option *__longopts, |
---|
122 | int *__longind, |
---|
123 | int __long_only, |
---|
124 | struct _getopt_data *__data |
---|
125 | ); |
---|
126 | |
---|
127 | extern int _getopt_long_r ( |
---|
128 | int ___argc, |
---|
129 | char *const *___argv, |
---|
130 | const char *__shortopts, |
---|
131 | const struct option *__longopts, |
---|
132 | int *__longind, |
---|
133 | struct _getopt_data *__data |
---|
134 | ); |
---|
135 | |
---|
136 | extern int _getopt_long_only_r ( |
---|
137 | int ___argc, |
---|
138 | char *const *___argv, |
---|
139 | const char *__shortopts, |
---|
140 | const struct option *__longopts, |
---|
141 | int *__longind, |
---|
142 | struct _getopt_data *__data |
---|
143 | ); |
---|
144 | |
---|
145 | #endif /* getopt_int.h */ |
---|