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