aboutsummaryrefslogtreecommitdiffstats
path: root/common/argparse.h
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2017-07-18 16:08:25 +0000
committerMarcus Brinkmann <[email protected]>2017-07-18 16:08:25 +0000
commitf17862d47d184d7f6ef883778cf63801365599a0 (patch)
treeaaa3c994a5b616e113ab1037142dcf9a07382aef /common/argparse.h
parentgpgscm,w32: Fix testing for absolute paths. (diff)
downloadgnupg-f17862d47d184d7f6ef883778cf63801365599a0.tar.gz
gnupg-f17862d47d184d7f6ef883778cf63801365599a0.zip
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 <[email protected]> GnuPG-bug-id: 1747
Diffstat (limited to '')
-rw-r--r--common/argparse.h14
1 files changed, 13 insertions, 1 deletions
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. */