From f17862d47d184d7f6ef883778cf63801365599a0 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 18 Jul 2017 18:08:25 +0200 Subject: common: Allow abbreviations of standard options. * argparse.h (ARGPARSE_SHORTOPT_HELP, ARGPARSE_SHORTOPT_VERSION, ARGPARSE_SHORTOPT_WARRANTY, ARGPARSE_SHORTOPT_DUMP_OPTIONS): New macros. (ARGPARSE_end): Add some placeholders for standard options. * argparse.c (arg_parse): Fill in missing standard options so default machinery works. Check for standard options in new way. Do not write out standard options for --dump-options. Signed-off-by: Marcus Brinkmann GnuPG-bug-id: 1747 --- common/argparse.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'common/argparse.h') diff --git a/common/argparse.h b/common/argparse.h index d75b49fbd..cdd18d9a2 100644 --- a/common/argparse.h +++ b/common/argparse.h @@ -71,6 +71,12 @@ typedef struct const char *description; /* Optional option description. */ } ARGPARSE_OPTS; +/* Short options. */ +#define ARGPARSE_SHORTOPT_HELP 32768 +#define ARGPARSE_SHORTOPT_VERSION 32769 +#define ARGPARSE_SHORTOPT_WARRANTY 32770 +#define ARGPARSE_SHORTOPT_DUMP_OPTIONS 32771 + /* Global flags (ARGPARSE_ARGS). */ #define ARGPARSE_FLAG_KEEP 1 /* Do not remove options form argv. */ @@ -169,7 +175,13 @@ typedef struct #define ARGPARSE_group(s,d) \ { (s), NULL, 0, (d) } -#define ARGPARSE_end() { 0, NULL, 0, NULL } +/* Placeholder options for help, version, warranty and dump-options. See arg_parse(). */ +#define ARGPARSE_end() \ + { 0, NULL, 0, NULL }, \ + { 0, NULL, 0, NULL }, \ + { 0, NULL, 0, NULL }, \ + { 0, NULL, 0, NULL }, \ + { 0, NULL, 0, NULL } /* Other constants. */ -- cgit v1.2.3