diff options
Diffstat (limited to 'newlib/libc/include/getopt.h')
-rw-r--r-- | newlib/libc/include/getopt.h | 102 |
1 files changed, 25 insertions, 77 deletions
diff --git a/newlib/libc/include/getopt.h b/newlib/libc/include/getopt.h index 13cf99c5f..7179298ae 100644 --- a/newlib/libc/include/getopt.h +++ b/newlib/libc/include/getopt.h @@ -82,8 +82,6 @@ Gregory Pietsch's current e-mail address: gpietsch@comcast.net ****************************************************************************/ -/* This is a glibc-extension header file. */ - #ifndef GETOPT_H #define GETOPT_H @@ -91,60 +89,31 @@ gpietsch@comcast.net /* include files needed by this include file */ -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 +/* macros defined by this include file */ +#define NO_ARG 0 +#define REQUIRED_ARG 1 +#define OPTIONAL_ARG 2 + +/* types defined by this include file */ + +struct option +{ + char *name; /* the name of the long option */ + int has_arg; /* one of the above macros */ + int *flag; /* determines if getopt_long() returns a + * value for a long option; if it is + * non-NULL, 0 is returned as a function + * value and the value of val is stored in + * the area pointed to by flag. Otherwise, + * val is returned. */ + int val; /* determines the value to return if flag is + * NULL. */ +}; #ifdef __cplusplus extern "C" { - -#endif /* __cplusplus */ - -/* types defined by this include file */ - struct option - { - char *name; /* the name of the long option */ - int has_arg; /* one of the above macros */ - int *flag; /* determines if getopt_long() returns a - * value for a long option; if it is - * non-NULL, 0 is returned as a function - * value and the value of val is stored in - * the area pointed to by flag. Otherwise, - * val is returned. */ - int val; /* determines the value to return if flag is - * NULL. */ - - }; - -/* While getopt.h is a glibc extension, the following are newlib extensions. - * They are optionally included via the __need_getopt_newlib flag. */ - -#ifdef __need_getopt_newlib - - /* macros defined by this include file */ - #define NO_ARG no_argument - #define REQUIRED_ARG required_argument - #define OPTIONAL_ARG optional_argument - - /* The GETOPT_DATA_INITIALIZER macro is used to initialize a statically- - allocated variable of type struct getopt_data. */ - #define GETOPT_DATA_INITIALIZER {0,0,0,0,0} - - /* These #defines are to make accessing the reentrant functions easier. */ - #define getopt_r __getopt_r - #define getopt_long_r __getopt_long_r - #define getopt_long_only_r __getopt_long_only_r - - /* The getopt_data structure is for reentrancy. Its members are similar to - the externally-defined variables. */ - typedef struct getopt_data - { - char *optarg; - int optind, opterr, optopt, optwhere; - } getopt_data; - -#endif /* __need_getopt_newlib */ +#endif /* externally-defined variables */ extern char *optarg; @@ -153,35 +122,14 @@ extern "C" extern int optopt; /* function prototypes */ - int _EXFUN (getopt, - (int __argc, char *const __argv[], const char *__optstring)); - - int _EXFUN (getopt_long, - (int __argc, char *const __argv[], const char *__shortopts, - const struct option * __longopts, int *__longind)); - - int _EXFUN (getopt_long_only, - (int __argc, char *const __argv[], const char *__shortopts, - const struct option * __longopts, int *__longind)); - - int _EXFUN (__getopt_r, - (int __argc, char *const __argv[], const char *__optstring, - struct getopt_data * __data)); - - int _EXFUN (__getopt_long_r, - (int __argc, char *const __argv[], const char *__shortopts, - const struct option * __longopts, int *__longind, - struct getopt_data * __data)); - - int _EXFUN (__getopt_long_only_r, - (int __argc, char *const __argv[], const char *__shortopts, - const struct option * __longopts, int *__longind, - struct getopt_data * __data)); + int _EXFUN (getopt, (int __argc, char *const __argv[], const char *__optstring)); + int _EXFUN (getopt_long, (int __argc, char *const __argv[], const char *__shortopts, const struct option *__longopts, int *__longind)); + int _EXFUN (getopt_long_only, (int __argc, char *const __argv[], const char *__shortopts, const struct option *__longopts, int *__longind)); #ifdef __cplusplus }; -#endif /* __cplusplus */ +#endif #endif /* GETOPT_H */ |