| 1 |
/* getopt (GNU extensions) gnulib wrapper header. |
| 2 |
Copyright (C) 1989-2024 Free Software Foundation, Inc. |
| 3 |
This file is part of gnulib. |
| 4 |
Unlike most of the getopt implementation, it is NOT shared |
| 5 |
with the GNU C Library. |
| 6 |
|
| 7 |
This file is free software: you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU Lesser General Public License as |
| 9 |
published by the Free Software Foundation; either version 2.1 of the |
| 10 |
License, or (at your option) any later version. |
| 11 |
|
| 12 |
This file is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU Lesser General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU Lesser General Public License |
| 18 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 19 |
|
| 20 |
#ifndef _GETOPT_PFX_EXT_H |
| 21 |
#define _GETOPT_PFX_EXT_H 1 |
| 22 |
|
| 23 |
/* This header should not be used directly; include getopt.h instead. |
| 24 |
It does not have a protective #error, because the guard macro for |
| 25 |
getopt.h in gnulib is not fixed. */ |
| 26 |
|
| 27 |
/* Standalone applications should #define __GETOPT_PREFIX to an |
| 28 |
identifier that prefixes the external functions and variables |
| 29 |
defined in getopt-core.h and getopt-ext.h. Systematically |
| 30 |
rename identifiers so that they do not collide with the system |
| 31 |
functions and variables. Renaming avoids problems with some |
| 32 |
compilers and linkers. */ |
| 33 |
#ifdef __GETOPT_PREFIX |
| 34 |
# ifndef __GETOPT_ID |
| 35 |
# define __GETOPT_CONCAT(x, y) x ## y |
| 36 |
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) |
| 37 |
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) |
| 38 |
# endif |
| 39 |
# undef getopt_long |
| 40 |
# undef getopt_long_only |
| 41 |
# undef option |
| 42 |
# undef _getopt_internal |
| 43 |
# define getopt_long __GETOPT_ID (getopt_long) |
| 44 |
# define getopt_long_only __GETOPT_ID (getopt_long_only) |
| 45 |
# define option __GETOPT_ID (option) |
| 46 |
# define _getopt_internal __GETOPT_ID (getopt_internal) |
| 47 |
|
| 48 |
/* The system's getopt.h may have already included getopt-ext.h to |
| 49 |
declare the unprefixed identifiers. Undef _GETOPT_EXT_H so that |
| 50 |
getopt-ext.h declares them with prefixes. */ |
| 51 |
# undef _GETOPT_EXT_H |
| 52 |
#endif |
| 53 |
|
| 54 |
/* Standalone applications get correct prototypes for getopt_long and |
| 55 |
getopt_long_only; they declare "char **argv". For backward |
| 56 |
compatibility with old applications, if __GETOPT_PREFIX is not |
| 57 |
defined, we supply GNU-libc-compatible, but incorrect, prototypes |
| 58 |
using "char *const *argv". (GNU libc is stuck with the incorrect |
| 59 |
prototypes, as they are baked into older versions of LSB.) */ |
| 60 |
#ifndef __getopt_argv_const |
| 61 |
# if defined __GETOPT_PREFIX |
| 62 |
# define __getopt_argv_const /* empty */ |
| 63 |
# else |
| 64 |
# define __getopt_argv_const const |
| 65 |
# endif |
| 66 |
#endif |
| 67 |
|
| 68 |
#include <getopt-ext.h> |
| 69 |
|
| 70 |
#endif /* _GETOPT_PFX_EXT_H */ |