summaryrefslogtreecommitdiffstats
path: root/gl/getopt.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/getopt.in.h')
-rw-r--r--gl/getopt.in.h70
1 files changed, 47 insertions, 23 deletions
diff --git a/gl/getopt.in.h b/gl/getopt.in.h
index d2d3e6e..57a8e89 100644
--- a/gl/getopt.in.h
+++ b/gl/getopt.in.h
@@ -1,6 +1,6 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007 2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2010 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
@@ -16,24 +16,42 @@
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#ifndef _GETOPT_H 19#ifndef _GL_GETOPT_H
20
21#if __GNUC__ >= 3
22@PRAGMA_SYSTEM_HEADER@
23#endif
24
25/* The include_next requires a split double-inclusion guard. We must
26 also inform the replacement unistd.h to not recursively use
27 <getopt.h>; our definitions will be present soon enough. */
28#if @HAVE_GETOPT_H@
29# define _GL_SYSTEM_GETOPT
30# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
31# undef _GL_SYSTEM_GETOPT
32#endif
33
34#ifndef _GL_GETOPT_H
20 35
21#ifndef __need_getopt 36#ifndef __need_getopt
22# define _GETOPT_H 1 37# define _GL_GETOPT_H 1
23#endif 38#endif
24 39
25/* Standalone applications should #define __GETOPT_PREFIX to an 40/* Standalone applications should #define __GETOPT_PREFIX to an
26 identifier that prefixes the external functions and variables 41 identifier that prefixes the external functions and variables
27 defined in this header. When this happens, include the 42 defined in this header. When this happens, include the
28 headers that might declare getopt so that they will not cause 43 headers that might declare getopt so that they will not cause
29 confusion if included after this file. Then systematically rename 44 confusion if included after this file (if the system had <getopt.h>,
45 we have already included it). Then systematically rename
30 identifiers so that they do not collide with the system functions 46 identifiers so that they do not collide with the system functions
31 and variables. Renaming avoids problems with some compilers and 47 and variables. Renaming avoids problems with some compilers and
32 linkers. */ 48 linkers. */
33#if defined __GETOPT_PREFIX && !defined __need_getopt 49#if defined __GETOPT_PREFIX && !defined __need_getopt
34# include <stdlib.h> 50# if !@HAVE_GETOPT_H@
35# include <stdio.h> 51# include <stdlib.h>
36# include <unistd.h> 52# include <stdio.h>
53# include <unistd.h>
54# endif
37# undef __need_getopt 55# undef __need_getopt
38# undef getopt 56# undef getopt
39# undef getopt_long 57# undef getopt_long
@@ -42,6 +60,7 @@
42# undef opterr 60# undef opterr
43# undef optind 61# undef optind
44# undef optopt 62# undef optopt
63# undef option
45# define __GETOPT_CONCAT(x, y) x ## y 64# define __GETOPT_CONCAT(x, y) x ## y
46# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) 65# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
47# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) 66# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
@@ -52,6 +71,8 @@
52# define opterr __GETOPT_ID (opterr) 71# define opterr __GETOPT_ID (opterr)
53# define optind __GETOPT_ID (optind) 72# define optind __GETOPT_ID (optind)
54# define optopt __GETOPT_ID (optopt) 73# define optopt __GETOPT_ID (optopt)
74# define option __GETOPT_ID (option)
75# define _getopt_internal __GETOPT_ID (getopt_internal)
55#endif 76#endif
56 77
57/* Standalone applications get correct prototypes for getopt_long and 78/* Standalone applications get correct prototypes for getopt_long and
@@ -94,12 +115,14 @@
94# define __GNUC_PREREQ(maj, min) (0) 115# define __GNUC_PREREQ(maj, min) (0)
95# endif 116# endif
96# if defined __cplusplus && __GNUC_PREREQ (2,8) 117# if defined __cplusplus && __GNUC_PREREQ (2,8)
97# define __THROW throw () 118# define __THROW throw ()
98# else 119# else
99# define __THROW 120# define __THROW
100# endif 121# endif
101#endif 122#endif
102 123
124/* The definition of _GL_ARG_NONNULL is copied here. */
125
103#ifdef __cplusplus 126#ifdef __cplusplus
104extern "C" { 127extern "C" {
105#endif 128#endif
@@ -142,9 +165,9 @@ extern int optopt;
142 zero. 165 zero.
143 166
144 The field `has_arg' is: 167 The field `has_arg' is:
145 no_argument (or 0) if the option does not take an argument, 168 no_argument (or 0) if the option does not take an argument,
146 required_argument (or 1) if the option requires an argument, 169 required_argument (or 1) if the option requires an argument,
147 optional_argument (or 2) if the option takes an optional argument. 170 optional_argument (or 2) if the option takes an optional argument.
148 171
149 If the field `flag' is not NULL, it points to a variable that is set 172 If the field `flag' is not NULL, it points to a variable that is set
150 to the value given in the field `val' when the option is found, but 173 to the value given in the field `val' when the option is found, but
@@ -169,10 +192,10 @@ struct option
169 192
170/* Names for the values of the `has_arg' field of `struct option'. */ 193/* Names for the values of the `has_arg' field of `struct option'. */
171 194
172# define no_argument 0 195# define no_argument 0
173# define required_argument 1 196# define required_argument 1
174# define optional_argument 2 197# define optional_argument 2
175#endif /* need getopt */ 198#endif /* need getopt */
176 199
177 200
178/* Get definitions and prototypes for functions to process the 201/* Get definitions and prototypes for functions to process the
@@ -201,17 +224,17 @@ struct option
201 the environment, then do not permute arguments. */ 224 the environment, then do not permute arguments. */
202 225
203extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) 226extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
204 __THROW; 227 __THROW _GL_ARG_NONNULL ((2, 3));
205 228
206#ifndef __need_getopt 229#ifndef __need_getopt
207extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, 230extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
208 const char *__shortopts, 231 const char *__shortopts,
209 const struct option *__longopts, int *__longind) 232 const struct option *__longopts, int *__longind)
210 __THROW; 233 __THROW _GL_ARG_NONNULL ((2, 3));
211extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, 234extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
212 const char *__shortopts, 235 const char *__shortopts,
213 const struct option *__longopts, int *__longind) 236 const struct option *__longopts, int *__longind)
214 __THROW; 237 __THROW _GL_ARG_NONNULL ((2, 3));
215 238
216#endif 239#endif
217 240
@@ -223,3 +246,4 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
223#undef __need_getopt 246#undef __need_getopt
224 247
225#endif /* getopt.h */ 248#endif /* getopt.h */
249#endif /* getopt.h */