summaryrefslogtreecommitdiffstats
path: root/gl/getopt_int.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/getopt_int.h')
-rw-r--r--gl/getopt_int.h91
1 files changed, 37 insertions, 54 deletions
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index a6e4b9ea..4d9e24be 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -1,30 +1,31 @@
1/* Internal declarations for getopt. 1/* Internal declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software 2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 Foundation, Inc. 3 This file is part of the GNU C Library and is also part of gnulib.
4 This file is part of the GNU C Library. 4 Patches to this file should be submitted to both projects.
5 5
6 This program is free software: you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3 of the License, or 8 License as published by the Free Software Foundation; either
9 (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 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 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifndef _GETOPT_INT_H 20#ifndef _GETOPT_INT_H
20#define _GETOPT_INT_H 1 21#define _GETOPT_INT_H 1
21 22
22#include <getopt.h> 23#include <getopt.h>
23 24
24extern int _getopt_internal (int ___argc, char **___argv, 25extern int _getopt_internal (int ___argc, char **___argv,
25 const char *__shortopts, 26 const char *__shortopts,
26 const struct option *__longopts, int *__longind, 27 const struct option *__longopts, int *__longind,
27 int __long_only, int __posixly_correct); 28 int __long_only, int __posixly_correct);
28 29
29 30
30/* Reentrant versions which can handle parsing multiple argument 31/* Reentrant versions which can handle parsing multiple argument
@@ -32,28 +33,20 @@ extern int _getopt_internal (int ___argc, char **___argv,
32 33
33/* Describe how to deal with options that follow non-option ARGV-elements. 34/* Describe how to deal with options that follow non-option ARGV-elements.
34 35
35 If the caller did not specify anything, 36 REQUIRE_ORDER means don't recognize them as options; stop option
36 the default is REQUIRE_ORDER if the environment variable 37 processing when the first non-option is seen. This is what POSIX
37 POSIXLY_CORRECT is defined, PERMUTE otherwise. 38 specifies should happen.
38 39
39 REQUIRE_ORDER means don't recognize them as options; 40 PERMUTE means permute the contents of ARGV as we scan, so that
40 stop option processing when the first non-option is seen. 41 eventually all the non-options are at the end. This allows options
41 This is what Unix does. 42 to be given in any order, even with programs that were not written
42 This mode of operation is selected by either setting the environment 43 to expect this.
43 variable POSIXLY_CORRECT, or using '+' as the first character
44 of the list of option characters, or by calling getopt.
45
46 PERMUTE is the default. We permute the contents of ARGV as we
47 scan, so that eventually all the non-options are at the end.
48 This allows options to be given in any order, even with programs
49 that were not written to expect this.
50 44
51 RETURN_IN_ORDER is an option available to programs that were 45 RETURN_IN_ORDER is an option available to programs that were
52 written to expect options and other ARGV-elements in any order 46 written to expect options and other ARGV-elements in any order
53 and that care about the ordering of the two. We describe each 47 and that care about the ordering of the two. We describe each
54 non-option ARGV-element as if it were the argument of an option 48 non-option ARGV-element as if it were the argument of an option
55 with character code 1. Using '-' as the first character of the 49 with character code 1.
56 list of option characters selects this mode of operation.
57 50
58 The special argument '--' forces an end of option-scanning regardless 51 The special argument '--' forces an end of option-scanning regardless
59 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only 52 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
@@ -91,11 +84,6 @@ struct _getopt_data
91 /* See __ord above. */ 84 /* See __ord above. */
92 enum __ord __ordering; 85 enum __ord __ordering;
93 86
94 /* If the POSIXLY_CORRECT environment variable is set
95 or getopt was called. */
96 int __posixly_correct;
97
98
99 /* Handle permutation of arguments. */ 87 /* Handle permutation of arguments. */
100 88
101 /* Describe the part of ARGV that contains non-options that have 89 /* Describe the part of ARGV that contains non-options that have
@@ -104,32 +92,27 @@ struct _getopt_data
104 92
105 int __first_nonopt; 93 int __first_nonopt;
106 int __last_nonopt; 94 int __last_nonopt;
107
108#if defined _LIBC && defined USE_NONOPTION_FLAGS
109 int __nonoption_flags_max_len;
110 int __nonoption_flags_len;
111#endif
112}; 95};
113 96
114/* The initializer is necessary to set OPTIND and OPTERR to their 97/* The initializer is necessary to set OPTIND and OPTERR to their
115 default values and to clear the initialization flag. */ 98 default values and to clear the initialization flag. */
116#define _GETOPT_DATA_INITIALIZER { 1, 1 } 99#define _GETOPT_DATA_INITIALIZER { 1, 1 }
117 100
118extern int _getopt_internal_r (int ___argc, char **___argv, 101extern int _getopt_internal_r (int ___argc, char **___argv,
119 const char *__shortopts, 102 const char *__shortopts,
120 const struct option *__longopts, int *__longind, 103 const struct option *__longopts, int *__longind,
121 int __long_only, struct _getopt_data *__data, 104 int __long_only, struct _getopt_data *__data,
122 int __posixly_correct); 105 int __posixly_correct);
123 106
124extern int _getopt_long_r (int ___argc, char **___argv, 107extern int _getopt_long_r (int ___argc, char **___argv,
125 const char *__shortopts, 108 const char *__shortopts,
126 const struct option *__longopts, int *__longind, 109 const struct option *__longopts, int *__longind,
127 struct _getopt_data *__data); 110 struct _getopt_data *__data);
128 111
129extern int _getopt_long_only_r (int ___argc, char **___argv, 112extern int _getopt_long_only_r (int ___argc, char **___argv,
130 const char *__shortopts, 113 const char *__shortopts,
131 const struct option *__longopts, 114 const struct option *__longopts,
132 int *__longind, 115 int *__longind,
133 struct _getopt_data *__data); 116 struct _getopt_data *__data);
134 117
135#endif /* getopt_int.h */ 118#endif /* getopt_int.h */