123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559 |
- #ifndef _ARGP_H
- #define _ARGP_H
- #include <stdio.h>
- #include <ctype.h>
- #include <getopt.h>
- #include <limits.h>
- #define __need_error_t
- #include <errno.h>
- #ifndef __error_t_defined
- typedef int error_t;
- # define __error_t_defined
- #endif
- __BEGIN_DECLS
- struct argp_option
- {
-
- const char *name;
-
- int key;
-
- const char *arg;
-
- int flags;
-
- const char *doc;
-
- int group;
- };
- #define OPTION_ARG_OPTIONAL 0x1
- #define OPTION_HIDDEN 0x2
- #define OPTION_ALIAS 0x4
- #define OPTION_DOC 0x8
- #define OPTION_NO_USAGE 0x10
- struct argp;
- struct argp_state;
- struct argp_child;
- typedef error_t (*argp_parser_t) (int __key, char *__arg,
- struct argp_state *__state);
- #define ARGP_ERR_UNKNOWN E2BIG
- #define ARGP_KEY_ARG 0
- #define ARGP_KEY_ARGS 0x1000006
- #define ARGP_KEY_END 0x1000001
- #define ARGP_KEY_NO_ARGS 0x1000002
- #define ARGP_KEY_INIT 0x1000003
- #define ARGP_KEY_FINI 0x1000007
- #define ARGP_KEY_SUCCESS 0x1000004
- #define ARGP_KEY_ERROR 0x1000005
- struct argp
- {
-
- const struct argp_option *options;
-
- argp_parser_t parser;
-
- const char *args_doc;
-
- const char *doc;
-
- const struct argp_child *children;
-
- char *(*help_filter) (int __key, const char *__text, void *__input);
-
- const char *argp_domain;
- };
- #define ARGP_KEY_HELP_PRE_DOC 0x2000001
- #define ARGP_KEY_HELP_POST_DOC 0x2000002
- #define ARGP_KEY_HELP_HEADER 0x2000003
- #define ARGP_KEY_HELP_EXTRA 0x2000004
- #define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
- #define ARGP_KEY_HELP_ARGS_DOC 0x2000006
- struct argp_child
- {
-
- const struct argp *argp;
-
- int flags;
-
- const char *header;
-
- int group;
- };
- struct argp_state
- {
-
- const struct argp *root_argp;
-
- int argc;
- char **argv;
-
- int next;
-
- unsigned flags;
-
- unsigned arg_num;
-
- int quoted;
-
- void *input;
-
- void **child_inputs;
-
- void *hook;
-
- char *name;
-
- FILE *err_stream;
- FILE *out_stream;
- void *pstate;
- };
- #define ARGP_PARSE_ARGV0 0x01
- #define ARGP_NO_ERRS 0x02
- #define ARGP_NO_ARGS 0x04
- #define ARGP_IN_ORDER 0x08
- #define ARGP_NO_HELP 0x10
- #define ARGP_NO_EXIT 0x20
- #define ARGP_LONG_ONLY 0x40
- #define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)
- extern error_t argp_parse (const struct argp *__restrict __argp,
- int __argc, char **__restrict __argv,
- unsigned __flags, int *__restrict __arg_index,
- void *__restrict __input);
- extern error_t __argp_parse (const struct argp *__restrict __argp,
- int __argc, char **__restrict __argv,
- unsigned __flags, int *__restrict __arg_index,
- void *__restrict __input);
- extern const char *argp_program_version;
- extern void (*argp_program_version_hook) (FILE *__restrict __stream,
- struct argp_state *__restrict
- __state);
- extern const char *argp_program_bug_address;
- extern error_t argp_err_exit_status;
- #define ARGP_HELP_USAGE 0x01
- #define ARGP_HELP_SHORT_USAGE 0x02
- #define ARGP_HELP_SEE 0x04
- #define ARGP_HELP_LONG 0x08
- #define ARGP_HELP_PRE_DOC 0x10
- #define ARGP_HELP_POST_DOC 0x20
- #define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)
- #define ARGP_HELP_BUG_ADDR 0x40
- #define ARGP_HELP_LONG_ONLY 0x80
- #define ARGP_HELP_EXIT_ERR 0x100
- #define ARGP_HELP_EXIT_OK 0x200
- #define ARGP_HELP_STD_ERR \
- (ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
- #define ARGP_HELP_STD_USAGE \
- (ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
- #define ARGP_HELP_STD_HELP \
- (ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
- | ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
- extern void argp_help (const struct argp *__restrict __argp,
- FILE *__restrict __stream,
- unsigned __flags, char *__restrict __name);
- extern void __argp_help (const struct argp *__restrict __argp,
- FILE *__restrict __stream, unsigned __flags,
- char *__name);
- extern void argp_state_help (const struct argp_state *__restrict __state,
- FILE *__restrict __stream,
- unsigned int __flags);
- extern void __argp_state_help (const struct argp_state *__restrict __state,
- FILE *__restrict __stream,
- unsigned int __flags);
- extern void argp_usage (const struct argp_state *__state);
- extern void __argp_usage (const struct argp_state *__state);
- extern void argp_error (const struct argp_state *__restrict __state,
- const char *__restrict __fmt, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
- extern void __argp_error (const struct argp_state *__restrict __state,
- const char *__restrict __fmt, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
- extern void argp_failure (const struct argp_state *__restrict __state,
- int __status, int __errnum,
- const char *__restrict __fmt, ...)
- __attribute__ ((__format__ (__printf__, 4, 5)));
- extern void __argp_failure (const struct argp_state *__restrict __state,
- int __status, int __errnum,
- const char *__restrict __fmt, ...)
- __attribute__ ((__format__ (__printf__, 4, 5)));
- extern int _option_is_short (const struct argp_option *__opt) __THROW;
- extern int __option_is_short (const struct argp_option *__opt) __THROW;
- extern int _option_is_end (const struct argp_option *__opt) __THROW;
- extern int __option_is_end (const struct argp_option *__opt) __THROW;
- extern void *_argp_input (const struct argp *__restrict __argp,
- const struct argp_state *__restrict __state)
- __THROW;
- extern void *__argp_input (const struct argp *__restrict __argp,
- const struct argp_state *__restrict __state)
- __THROW;
- #ifdef __USE_EXTERN_INLINES
- # if !_LIBC
- # define __argp_usage argp_usage
- # define __argp_state_help argp_state_help
- # define __option_is_short _option_is_short
- # define __option_is_end _option_is_end
- # endif
- # ifndef ARGP_EI
- # define ARGP_EI __extern_inline
- # endif
- ARGP_EI void
- __argp_usage (const struct argp_state *__state)
- {
- __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
- }
- ARGP_EI int
- __NTH (__option_is_short (const struct argp_option *__opt))
- {
- if (__opt->flags & OPTION_DOC)
- return 0;
- else
- {
- int __key = __opt->key;
- return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
- }
- }
- ARGP_EI int
- __NTH (__option_is_end (const struct argp_option *__opt))
- {
- return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
- }
- # if !_LIBC
- # undef __argp_usage
- # undef __argp_state_help
- # undef __option_is_short
- # undef __option_is_end
- # endif
- #endif
- __END_DECLS
- #endif
|