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