diff options
Diffstat (limited to '')
-rw-r--r-- | tools/gpgconf.c | 74 |
1 files changed, 50 insertions, 24 deletions
diff --git a/tools/gpgconf.c b/tools/gpgconf.c index 6f4c1fbbb..f261a2c0a 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -33,12 +33,16 @@ enum cmd_and_opt_values aNull = 0, oDryRun = 'n', oOutput = 'o', - oQuiet = 'q', + oQuiet = 'q', oVerbose = 'v', + oComponent = 'c', oNoVerbose = 500, oHomedir, - - aDummy + + aListComponents, + aListOptions, + aChangeOptions, + }; @@ -47,16 +51,19 @@ static ARGPARSE_OPTS opts[] = { { 300, NULL, 0, N_("@Commands:\n ") }, + { aListComponents, "list-components", 256, N_("list all components") }, + { aListOptions, "list-options", 256, N_("|COMPONENT|list options") }, + { aChangeOptions, "change-options", 256, N_("|COMPONENT|change options") }, + { 301, NULL, 0, N_("@\nOptions:\n ") }, - { oOutput, "output", 2, N_("use as output file")}, + { oOutput, "output", 2, N_("use as output file") }, { oVerbose, "verbose", 0, N_("verbose") }, - { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, + { oQuiet, "quiet", 0, N_("quiet") }, { oDryRun, "dry-run", 0, N_("do not make any changes") }, - + /* hidden options */ { oNoVerbose, "no-verbose", 0, "@"}, - { oHomedir, "homedir", 2, "@" }, /* defaults to "~/.gnupg" */ {0} }; @@ -124,16 +131,6 @@ main (int argc, char **argv) i18n_init(); - /* Setup the default homedir. */ -#ifdef __MINGW32__ - opt.homedir = read_w32_registry_string ( NULL, - "Software\\GNU\\GnuPG", "HomeDir" ); -#else - opt.homedir = getenv ("GNUPGHOME"); -#endif - if (!opt.homedir || !*opt.homedir ) - opt.homedir = GNUPG_DEFAULT_HOMEDIR; - /* Patrse the command line. */ pargs.argc = &argc; pargs.argv = &argv; @@ -143,14 +140,17 @@ main (int argc, char **argv) switch (pargs.r_opt) { case oOutput: opt.outfile = pargs.r.ret_str; break; - - case oQuiet: opt.quiet = 1; break; + case oQuiet: opt.quiet = 1; break; case oDryRun: opt.dry_run = 1; break; case oVerbose: opt.verbose++; break; case oNoVerbose: opt.verbose = 0; break; - case oHomedir: opt.homedir = pargs.r.ret_str; break; - case aDummy: break; + case aListComponents: + case aListOptions: + case aChangeOptions: + cmd = pargs.r_opt; + break; + default: pargs.err = 2; break; } } @@ -158,14 +158,40 @@ main (int argc, char **argv) if (log_get_errorcount (0)) exit (2); - fname = argc? *argv : NULL; + fname = argc ? *argv : NULL; switch (cmd) { + case aListComponents: default: - /* List all standard options. */ - gpgconf_list_standard_options (); + /* List all components. */ + gc_component_list_components (stdout); break; + + case aListOptions: + case aChangeOptions: + if (!fname) + { + fputs (N_("usage: gpgconf [options] "), stderr); + fputs (N_("Need one component argument"), stderr); + putc ('\n',stderr); + exit (2); + } + else + { + int idx = gc_component_find (fname); + if (idx < 0) + { + fputs (N_("Component not found"), stderr); + putc ('\n', stderr); + exit (1); + } + gc_component_retrieve_options (idx); + if (cmd == aListOptions) + gc_component_list_options (idx, stdout); + else + gc_component_change_options (idx, stdin); + } } return 0; |