CMake: Keep existing options in LIBS when adding -lrt
[xz/debian.git] / lib / getopt_int.h
blob2dcb5538213d9f5d4739273c8d6521d879a3e513
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 /* Internal declarations for getopt.
4 Copyright (C) 1989-2023 Free Software Foundation, Inc.
5 This file is part of the GNU C Library and is also part of gnulib.
6 Patches to this file should be submitted to both projects.
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 The GNU C Library 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 GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library; if not, see
20 <https://www.gnu.org/licenses/>. */
22 #ifndef _GETOPT_INT_H
23 #define _GETOPT_INT_H 1
25 #include <getopt.h>
27 extern int _getopt_internal (int ___argc, char **___argv,
28 const char *__shortopts,
29 const struct option *__longopts, int *__longind,
30 int __long_only, int __posixly_correct);
33 /* Reentrant versions which can handle parsing multiple argument
34 vectors at the same time. */
36 /* Describe how to deal with options that follow non-option ARGV-elements.
38 REQUIRE_ORDER means don't recognize them as options; stop option
39 processing when the first non-option is seen. This is what POSIX
40 specifies should happen.
42 PERMUTE means permute the contents of ARGV as we scan, so that
43 eventually all the non-options are at the end. This allows options
44 to be given in any order, even with programs that were not written
45 to expect this.
47 RETURN_IN_ORDER is an option available to programs that were
48 written to expect options and other ARGV-elements in any order
49 and that care about the ordering of the two. We describe each
50 non-option ARGV-element as if it were the argument of an option
51 with character code 1.
53 The special argument '--' forces an end of option-scanning regardless
54 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
55 '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */
57 enum __ord
59 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
62 /* Data type for reentrant functions. */
63 struct _getopt_data
65 /* These have exactly the same meaning as the corresponding global
66 variables, except that they are used for the reentrant
67 versions of getopt. */
68 int optind;
69 int opterr;
70 int optopt;
71 char *optarg;
73 /* Internal members. */
75 /* True if the internal members have been initialized. */
76 int __initialized;
78 /* The next char to be scanned in the option-element
79 in which the last option character we returned was found.
80 This allows us to pick up the scan where we left off.
82 If this is zero, or a null string, it means resume the scan
83 by advancing to the next ARGV-element. */
84 char *__nextchar;
86 /* See __ord above. */
87 enum __ord __ordering;
89 /* Handle permutation of arguments. */
91 /* Describe the part of ARGV that contains non-options that have
92 been skipped. 'first_nonopt' is the index in ARGV of the first
93 of them; 'last_nonopt' is the index after the last of them. */
95 int __first_nonopt;
96 int __last_nonopt;
99 /* The initializer is necessary to set OPTIND and OPTERR to their
100 default values and to clear the initialization flag. */
101 #define _GETOPT_DATA_INITIALIZER { 1, 1 }
103 extern int _getopt_internal_r (int ___argc, char **___argv,
104 const char *__shortopts,
105 const struct option *__longopts, int *__longind,
106 int __long_only, struct _getopt_data *__data,
107 int __posixly_correct);
109 extern int _getopt_long_r (int ___argc, char **___argv,
110 const char *__shortopts,
111 const struct option *__longopts, int *__longind,
112 struct _getopt_data *__data);
114 extern int _getopt_long_only_r (int ___argc, char **___argv,
115 const char *__shortopts,
116 const struct option *__longopts,
117 int *__longind,
118 struct _getopt_data *__data);
120 #endif /* getopt_int.h */