diff options
author | Werner Koch <wk@gnupg.org> | 2020-03-02 16:53:20 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-03-02 16:53:20 +0100 |
commit | d3661d81e9aafae75680164ede7322cf3d7b6804 (patch) | |
tree | 0384134cc8b8b4741ae294d231753fe674b8c451 /tests | |
parent | 2d1969ab465bad62f73a7c24ddc8bb490ff9fd40 (diff) | |
download | libgpg-error-d3661d81e9aafae75680164ede7322cf3d7b6804.tar.gz |
core: Allow returning of attributes from gpgrt_argparser.
* src/gpg-error.h.in (ARGPARSE_FLAG_WITHATTR): New.
(ARGPARSE_ATTR_FORCE): New.
(ARGPARSE_ATTR_IGNORE): New.
(ARGPARSE_TYPE_MASK): Moved from argparse.c to here.
* src/argparse.c: Always use macros for constants.
(_gpgrt_argparse): Handle ARGPARSE_FLAG_WITHATTR.
(arg_parse): Ditto.
* tests/t-argparse.c (main): Add commented test case.
--
This is a ABI compatible hack to allow the ignore and force attributes
as well as to return which option has been ignored in a user file or
on the command line.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/t-argparse.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/t-argparse.c b/tests/t-argparse.c index 46b7258..80da5ac 100644 --- a/tests/t-argparse.c +++ b/tests/t-argparse.c @@ -86,6 +86,7 @@ main (int argc, char **argv) | ARGPARSE_FLAG_SYS | ARGPARSE_FLAG_USER /* | ARGPARSE_FLAG_VERBOSE */ + /* | ARGPARSE_FLAG_WITHATTR */ ) }; int i; const char *srcdir; @@ -104,7 +105,16 @@ main (int argc, char **argv) while (gpgrt_argparser (&pargs, opts, PGM".conf")) { - /* printf ("got option %d\n", pargs.r_opt); */ + /* printf ("got option %3d type %0x04x\n", pargs.r_opt, pargs.r_type); */ + /* if (pargs.r_type & (ARGPARSE_ATTR_IGNORE|ARGPARSE_ATTR_FORCE)) */ + /* printf ("attributes:%s%s\n", */ + /* (pargs.r_type & ARGPARSE_ATTR_IGNORE)? " ignore":"", */ + /* (pargs.r_type & ARGPARSE_ATTR_FORCE)? " force":""); */ + /* if (pargs.r_type & ARGPARSE_OPT_IGNORE) */ + /* { */ + /* printf ("ignored\n"); */ + /* continue; */ + /* } */ switch (pargs.r_opt) { case ARGPARSE_CONFFILE: |