Build: Fix a typo in autogen.sh
[xz/debian.git] / lib / getopt-ext.h
blob006037ba86478dbbb8f77d3fd103af86817ba33b
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 /* Declarations for getopt (GNU extensions).
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_EXT_H
23 #define _GETOPT_EXT_H 1
25 /* This header should not be used directly; include getopt.h instead.
26 Unlike most bits headers, it does not have a protective #error,
27 because the guard macro for getopt.h in gnulib is not fixed. */
29 __BEGIN_DECLS
31 /* Describe the long-named options requested by the application.
32 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
33 of 'struct option' terminated by an element containing a name which is
34 zero.
36 The field 'has_arg' is:
37 no_argument (or 0) if the option does not take an argument,
38 required_argument (or 1) if the option requires an argument,
39 optional_argument (or 2) if the option takes an optional argument.
41 If the field 'flag' is not NULL, it points to a variable that is set
42 to the value given in the field 'val' when the option is found, but
43 left unchanged if the option is not found.
45 To have a long-named option do something other than set an 'int' to
46 a compiled-in constant, such as set a value from 'optarg', set the
47 option's 'flag' field to zero and its 'val' field to a nonzero
48 value (the equivalent single-letter option character, if there is
49 one). For long options that have a zero 'flag' field, 'getopt'
50 returns the contents of the 'val' field. */
52 struct option
54 const char *name;
55 /* has_arg can't be an enum because some compilers complain about
56 type mismatches in all the code that assumes it is an int. */
57 int has_arg;
58 int *flag;
59 int val;
62 /* Names for the values of the 'has_arg' field of 'struct option'. */
64 #define no_argument 0
65 #define required_argument 1
66 #define optional_argument 2
68 extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
69 const char *__shortopts,
70 const struct option *__longopts, int *__longind)
71 __THROW _GL_ARG_NONNULL ((2, 3));
72 extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
73 const char *__shortopts,
74 const struct option *__longopts, int *__longind)
75 __THROW _GL_ARG_NONNULL ((2, 3));
77 __END_DECLS
79 #endif /* _GETOPT_EXT_H */