From b1790f4cc71f14422255bbfba78e91f037e035dd Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sun, 31 Oct 2021 17:44:08 +0100 Subject: argparse: Add support to read values from the Windows Registry. * src/argparse.c (struct variable_s): New. (struct _gpgrt_argparse_internal_s): New fields expand, if_cond, if_active and vartbl. (deinitialize): Free vartbl. (initialize): Clear new vars. (get_var): New. (substitute_vars): New. (set_variable): New. (handle_meta_if): New. (handle_meta_let): New. (handle_meta_getenv): New. (handle_meta_echo): Re-implement in terms of variabale substitution. (handle_meta_expand): New. (handle_metacmd): Add new meta commands. (_gpgrt_argparse): Expand values if enabled. (_gpgrt_argparse): Take care of conditions. (_gpgrt_argparser): Reset some state at the end of a file. * tests/etc/t-argparse.conf: Adjust for changed system variables. * tests/t-argparse.c (my_strusage): Add a value for a version test. (main): Add new option "street". * tests/t-argparse.conf: A couple if additions for the new conditions. -- The whole thing is actually only for here for doing this [let tkey HKLM\Foo\Bar\GnuPG:trusted-key-1] [if $tkey] trusted-key $tkey [fi] But we are hackers and tend to make things more complicated^Wflexible. Documentation will be done eventually. Signed-off-by: Werner Koch --- tests/t-argparse.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/t-argparse.c') diff --git a/tests/t-argparse.c b/tests/t-argparse.c index 8ba5841..4d24e5f 100644 --- a/tests/t-argparse.c +++ b/tests/t-argparse.c @@ -39,6 +39,7 @@ static struct { int myopt; int echo; int a_long_one; + char *street; } opt; @@ -53,6 +54,7 @@ my_strusage (int level) case 9: p = "LGPL-2.1-or-later"; break; case 11: p = "t-argparse"; break; + case 13: p = "6.42.17-beta99"; break; default: p = NULL; } @@ -74,7 +76,7 @@ main (int argc, char **argv) ARGPARSE_o_s('c', "cross-ref", "cross-reference erzeugen\n" ), /* Note that on a non-utf8 terminal the ß might garble the output. */ ARGPARSE_header("extra-options", "List of extra options"), - ARGPARSE_s_n('s', "street","|Straße|set the name of the street to Straße"), + ARGPARSE_s_s('s', "street","|Straße|set the name of the street to Straße"), ARGPARSE_o_i('m', "my-option", 0), ARGPARSE_o_i('M', "not-my-option", 0), ARGPARSE_s_n(500, "a-long-option", 0 ), @@ -135,6 +137,7 @@ main (int argc, char **argv) case 'c': opt.crf = pargs.r_type? pargs.r.ret_str:"a.crf"; break; case 'm': opt.myopt = pargs.r_type? pargs.r.ret_int : 1; break; case 'M': opt.myopt = 0; break; + case 's': opt.street = pargs.r.ret_str; break; case 500: opt.a_long_one++; break; default : pargs.err = ARGPARSE_PRINT_WARNING; any_warn = 1; break; } @@ -151,6 +154,8 @@ main (int argc, char **argv) printf (" outfile='%s'\n", opt.outfile ); if (opt.crf) printf (" crffile='%s'\n", opt.crf ); + if (opt.street) + printf (" street='%s'\n", opt.street ); if (opt.myopt) printf (" myopt=%d\n", opt.myopt ); if (opt.a_long_one) -- cgit v1.2.3