diff options
Diffstat (limited to 'lib/gnugetopt.h')
-rw-r--r-- | lib/gnugetopt.h | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/lib/gnugetopt.h b/lib/gnugetopt.h index a1b8dd6..31a693e 100644 --- a/lib/gnugetopt.h +++ b/lib/gnugetopt.h @@ -20,7 +20,7 @@ #ifndef _GETOPT_H #ifndef __need_getopt -# define _GETOPT_H 1 +#define _GETOPT_H 1 #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used @@ -31,7 +31,7 @@ if it's from glibc. (Why ctype.h? It's guaranteed to exist and it doesn't flood the namespace with stuff the way some other headers do.) */ #if !defined __GNU_LIBRARY__ -# include <ctype.h> +#include <ctype.h> #endif #ifdef __cplusplus @@ -44,7 +44,7 @@ extern "C" { Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -extern char *optarg; + extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -58,16 +58,16 @@ extern char *optarg; Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ -extern int optind; + extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ -extern int opterr; + extern int opterr; /* Set to an option character which was unrecognized. */ -extern int optopt; + extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. @@ -91,27 +91,25 @@ extern int optopt; one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ -struct option -{ -# if (defined __STDC__ && __STDC__) || defined __cplusplus - const char *name; -# else - char *name; -# endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; + struct option { +#if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +#else + char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; + }; /* Names for the values of the `has_arg' field of `struct option'. */ -# define no_argument 0 -# define required_argument 1 -# define optional_argument 2 -#endif /* need getopt */ - +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 +#endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for @@ -138,43 +136,44 @@ struct option `getopt'. */ #if (defined __STDC__ && __STDC__) || defined __cplusplus -# ifdef __GNU_LIBRARY__ +#ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ -extern int getopt (int __argc, char *const *__argv, const char *__shortopts); -# else /* not __GNU_LIBRARY__ */ -extern int getopt (); -# endif /* __GNU_LIBRARY__ */ - -# ifndef __need_getopt -extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, - const struct option *__longopts, int *__longind); -extern int getopt_long_only (int __argc, char *const *__argv, - const char *__shortopts, - const struct option *__longopts, int *__longind); + extern int getopt(int __argc, char *const *__argv, + const char *__shortopts); +#else /* not __GNU_LIBRARY__ */ + extern int getopt(); +#endif /* __GNU_LIBRARY__ */ + +#ifndef __need_getopt + extern int getopt_long(int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); + extern int getopt_long_only(int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, + int *__longind); /* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int __argc, char *const *__argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only); -# endif -#else /* not __STDC__ */ -extern int getopt (); -# ifndef __need_getopt -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -# endif -#endif /* __STDC__ */ + extern int _getopt_internal(int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, + int *__longind, int __long_only); +#endif +#else /* not __STDC__ */ + extern int getopt(); +#ifndef __need_getopt + extern int getopt_long(); + extern int getopt_long_only(); + + extern int _getopt_internal(); +#endif +#endif /* __STDC__ */ #ifdef __cplusplus } #endif - /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt - -#endif /* getopt.h */ +#endif /* getopt.h */ |