diff options
author | Werner Koch <[email protected]> | 2020-02-21 19:28:47 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-02-21 19:28:47 +0000 |
commit | 3bc004decd289810bc1b6ad6fb8f47e45c770ce6 (patch) | |
tree | f6e161cc838bfaacbfc647ff5f68ed04d977105f /agent | |
parent | Use gpgrt's new option parser for gpgc, gpgsm, and gpg-agent. (diff) | |
download | gnupg-3bc004decd289810bc1b6ad6fb8f47e45c770ce6.tar.gz gnupg-3bc004decd289810bc1b6ad6fb8f47e45c770ce6.zip |
Use gpgrt's new option parser for the tools.
* agent/preset-passphrase.c: Switch to the new option parser.
* agent/protect-tool.c: Ditto.
* kbx/kbxutil.c: Ditto.
* tools/gpg-card.c: Ditto.
* tools/gpg-check-pattern.c: Ditto.
* tools/gpg-connect-agent.c: Ditto.
* tools/gpg-pair-tool.c: Ditto.
* tools/gpg-wks-client.c: Ditto.
* tools/gpg-wks-server.c: Ditto.
* tools/gpgconf.c: Ditto.
* tools/gpgsplit.c: Ditto.
* tools/gpgtar.c: Ditto.
--
This is another part of changes. A followup patch will address the
remaining daemons.
GnuPG-bug-id: 4788
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent')
-rw-r--r-- | agent/preset-passphrase.c | 21 | ||||
-rw-r--r-- | agent/protect-tool.c | 21 |
2 files changed, 22 insertions, 20 deletions
diff --git a/agent/preset-passphrase.c b/agent/preset-passphrase.c index 496cee73d..df6da00e3 100644 --- a/agent/preset-passphrase.c +++ b/agent/preset-passphrase.c @@ -15,12 +15,10 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: GPL-3.0-or-later */ #include <config.h> -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS #include <stdio.h> #include <stdlib.h> @@ -52,7 +50,6 @@ #include "../common/i18n.h" #include "../common/sysutils.h" #include "../common/init.h" -#include "../common/argparse.h" /* temporary hack. */ enum cmd_and_opt_values @@ -72,7 +69,7 @@ aTest }; static const char *opt_passphrase; -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { { 301, NULL, 0, N_("@Options:\n ") }, @@ -93,9 +90,11 @@ my_strusage (int level) const char *p; switch (level) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "gpg-preset-passphrase (@GNUPG@)"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; @@ -207,12 +206,12 @@ forget_passphrase (const char *keygrip) int main (int argc, char **argv) { - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; int cmd = 0; const char *keygrip = NULL; early_system_init (); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); log_set_prefix ("gpg-preset-passphrase", GPGRT_LOG_WITH_PREFIX); /* Make sure that our subsystems are ready. */ @@ -221,8 +220,8 @@ main (int argc, char **argv) pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1; /* (do not remove the args) */ - while (arg_parse (&pargs, opts) ) + pargs.flags= ARGPARSE_FLAG_KEEP; + while (gpgrt_argparse (NULL, &pargs, opts)) { switch (pargs.r_opt) { @@ -236,13 +235,15 @@ main (int argc, char **argv) default : pargs.err = 2; break; } } + gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */ + if (log_get_errorcount(0)) exit(2); if (argc == 1) keygrip = *argv; else - usage (1); + gpgrt_usage (1); /* Tell simple-pwquery about the standard socket name. */ { diff --git a/agent/protect-tool.c b/agent/protect-tool.c index 798c50e78..31256695e 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -15,12 +15,10 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: GPL-3.0-or-later */ #include <config.h> -/* We don't want to have the macros from gpgrt here until we have - * completely replaced this module by the one from gpgrt. */ -#undef GPGRT_ENABLE_ARGPARSE_MACROS #include <stdio.h> #include <stdlib.h> @@ -46,7 +44,6 @@ #include "../common/get-passphrase.h" #include "../common/sysutils.h" #include "../common/init.h" -#include "../common/argparse.h" /* temporary hack. */ enum cmd_and_opt_values @@ -106,7 +103,7 @@ static char *get_passphrase (int promptno); static void release_passphrase (char *pw); -static ARGPARSE_OPTS opts[] = { +static gpgrt_opt_t opts[] = { ARGPARSE_group (300, N_("@Commands:\n ")), ARGPARSE_c (oProtect, "protect", "protect a private key"), @@ -148,9 +145,11 @@ my_strusage (int level) const char *p; switch (level) { + case 9: p = "GPL-3.0-or-later"; break; case 11: p = "gpg-protect-tool (" GNUPG_NAME ")"; break; case 13: p = VERSION; break; + case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break; case 17: p = PRINTABLE_OS_NAME; break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; @@ -556,13 +555,13 @@ show_keygrip (const char *fname) int main (int argc, char **argv ) { - ARGPARSE_ARGS pargs; + gpgrt_argparse_t pargs; int cmd = 0; const char *fname; ctrl_t ctrl; early_system_init (); - set_strusage (my_strusage); + gpgrt_set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); log_set_prefix ("gpg-protect-tool", GPGRT_LOG_WITH_PREFIX); @@ -575,8 +574,8 @@ main (int argc, char **argv ) pargs.argc = &argc; pargs.argv = &argv; - pargs.flags= 1; /* (do not remove the args) */ - while (arg_parse (&pargs, opts) ) + pargs.flags= ARGPARSE_FLAG_KEEP; + while (gpgrt_argparse (NULL, &pargs, opts)) { switch (pargs.r_opt) { @@ -606,6 +605,8 @@ main (int argc, char **argv ) default: pargs.err = ARGPARSE_PRINT_ERROR; break; } } + gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */ + if (log_get_errorcount (0)) exit (2); @@ -613,7 +614,7 @@ main (int argc, char **argv ) if (argc == 1) fname = *argv; else if (argc > 1) - usage (1); + gpgrt_usage (1); /* Allocate an CTRL object. An empty object should be sufficient. */ ctrl = xtrycalloc (1, sizeof *ctrl); |