summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/gpg-card.c17
-rw-r--r--tools/gpg-check-pattern.c20
-rw-r--r--tools/gpg-connect-agent.c19
-rw-r--r--tools/gpg-pair-tool.c11
-rw-r--r--tools/gpg-wks-client.c26
-rw-r--r--tools/gpg-wks-server.c25
-rw-r--r--tools/gpgconf.c24
-rw-r--r--tools/gpgsplit.c22
-rw-r--r--tools/gpgtar.c36
9 files changed, 103 insertions, 97 deletions
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index 1967d4915..0ed6f81a0 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -19,9 +19,6 @@
*/
#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>
#include <string.h>
@@ -44,7 +41,6 @@
#include "../common/ttyio.h"
#include "../common/server-help.h"
#include "../common/openpgpdefs.h"
-#include "../common/argparse.h" /* temporary hack. */
#include "gpg-card.h"
@@ -82,7 +78,7 @@ enum opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
ARGPARSE_group (301, ("@\nOptions:\n ")),
ARGPARSE_s_n (oVerbose, "verbose", ("verbose")),
@@ -154,9 +150,11 @@ my_strusage( int level )
switch (level)
{
+ case 9: p = "GPL-3.0-or-later"; break;
case 11: p = "gpg-card"; break;
case 12: p = "@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;
@@ -193,9 +191,9 @@ set_opt_session_env (const char *name, const char *value)
/* Command line parsing. */
static void
-parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
+parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
{
- while (optfile_parse (NULL, NULL, NULL, pargs, popts))
+ while (gpgrt_argparse (NULL, pargs, popts))
{
switch (pargs->r_opt)
{
@@ -242,13 +240,13 @@ int
main (int argc, char **argv)
{
gpg_error_t err;
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
char **command_list = NULL;
int cmdidx;
char *command;
gnupg_reopen_std ("gpg-card");
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
gnupg_rl_initialize ();
log_set_prefix ("gpg-card", GPGRT_LOG_WITH_PREFIX);
@@ -272,6 +270,7 @@ main (int argc, char **argv)
pargs.argv = &argv;
pargs.flags = ARGPARSE_FLAG_KEEP;
parse_arguments (&pargs, opts);
+ gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */
if (log_get_errorcount (0))
exit (2);
diff --git a/tools/gpg-check-pattern.c b/tools/gpg-check-pattern.c
index be1832217..115e6b07b 100644
--- a/tools/gpg-check-pattern.c
+++ b/tools/gpg-check-pattern.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>
@@ -47,7 +45,6 @@
#include "../common/i18n.h"
#include "../common/sysutils.h"
#include "../common/init.h"
-#include "../common/argparse.h" /* temporary hack. */
enum cmd_and_opt_values
@@ -68,7 +65,7 @@ enum cmd_and_opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
{ 301, NULL, 0, N_("@Options:\n ") },
@@ -137,9 +134,11 @@ my_strusage (int level)
const char *p;
switch (level)
{
+ case 9: p = "GPL-3.0-or-later"; break;
case 11: p = "gpg-check-pattern (@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;
@@ -161,13 +160,13 @@ my_strusage (int level)
int
main (int argc, char **argv )
{
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
char *raw_pattern;
size_t raw_pattern_length;
pattern_t *patternarray;
early_system_init ();
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
log_set_prefix ("gpg-check-pattern", GPGRT_LOG_WITH_PREFIX);
@@ -180,8 +179,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)
{
@@ -193,11 +192,12 @@ 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)
- usage (1);
+ gpgrt_usage (1);
/* We read the entire pattern file into our memory and parse it
using a separate function. This allows us to eventual do the
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index ae044dcc4..12b0d8686 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -16,13 +16,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>
#include <string.h>
@@ -34,7 +31,6 @@
#include "../common/i18n.h"
#include "../common/util.h"
-#include "../common/argparse.h" /* temporary hack. */
#include "../common/asshelp.h"
#include "../common/sysutils.h"
#include "../common/membuf.h"
@@ -77,7 +73,7 @@ enum cmd_and_opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
ARGPARSE_group (301, N_("@\nOptions:\n ")),
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
@@ -205,9 +201,11 @@ my_strusage( int level )
switch (level)
{
+ case 9: p = "GPL-3.0-or-later"; break;
case 11: p = "@GPG@-connect-agent (@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;
@@ -1158,7 +1156,7 @@ help_cmd_p (const char *line)
int
main (int argc, char **argv)
{
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
int no_more_options = 0;
assuan_context_t ctx;
char *line, *p;
@@ -1183,7 +1181,7 @@ main (int argc, char **argv)
early_system_init ();
gnupg_rl_initialize ();
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
log_set_prefix ("gpg-connect-agent", GPGRT_LOG_WITH_PREFIX);
/* Make sure that our subsystems are ready. */
@@ -1199,8 +1197,8 @@ main (int argc, char **argv)
/* Parse the command line. */
pargs.argc = &argc;
pargs.argv = &argv;
- pargs.flags = 1; /* Do not remove the args. */
- while (!no_more_options && optfile_parse (NULL, NULL, NULL, &pargs, opts))
+ pargs.flags = ARGPARSE_FLAG_KEEP;
+ while (!no_more_options && gpgrt_argparse (NULL, &pargs, opts))
{
switch (pargs.r_opt)
{
@@ -1230,6 +1228,7 @@ 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);
diff --git a/tools/gpg-pair-tool.c b/tools/gpg-pair-tool.c
index a41d99031..25fa074c8 100644
--- a/tools/gpg-pair-tool.c
+++ b/tools/gpg-pair-tool.c
@@ -15,6 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
*/
/* Protocol:
@@ -120,9 +121,7 @@
*/
#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>
#include <string.h>
@@ -138,8 +137,6 @@
#include "../common/sysutils.h"
#include "../common/init.h"
#include "../common/name-value.h"
-#include "../common/argparse.h" /* temporary hack. */
-
/* Constants to identify the commands and options. */
enum cmd_and_opt_values
@@ -292,7 +289,8 @@ my_strusage( int level )
static void
wrong_args (const char *text)
{
- es_fprintf (es_stderr, _("usage: %s [options] %s\n"), strusage (11), text);
+ es_fprintf (es_stderr, _("usage: %s [options] %s\n"),
+ gpgrt_strusage (11), text);
exit (2);
}
@@ -416,6 +414,7 @@ main (int argc, char **argv)
default: pargs.err = ARGPARSE_PRINT_WARNING; break;
}
}
+ gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */
/* Print a warning if an argument looks like an option. */
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c
index 8c13be7e2..5f765d3c1 100644
--- a/tools/gpg-wks-client.c
+++ b/tools/gpg-wks-client.c
@@ -16,12 +16,11 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1-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>
#include <string.h>
@@ -44,7 +43,6 @@
#include "mime-maker.h"
#include "send-mail.h"
#include "gpg-wks.h"
-#include "../common/argparse.h" /* temporary hack. */
/* Constants to identify the commands and options. */
@@ -80,7 +78,7 @@ enum cmd_and_opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
ARGPARSE_group (300, ("@Commands:\n ")),
ARGPARSE_c (aSupported, "supported",
@@ -163,9 +161,11 @@ my_strusage( int level )
switch (level)
{
+ case 9: p = "LGPL-2.1-or-later"; break;
case 11: p = "gpg-wks-client"; break;
case 12: p = "@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;
@@ -187,7 +187,8 @@ my_strusage( int level )
static void
wrong_args (const char *text)
{
- es_fprintf (es_stderr, _("usage: %s [options] %s\n"), strusage (11), text);
+ es_fprintf (es_stderr, _("usage: %s [options] %s\n"),
+ gpgrt_strusage (11), text);
exit (2);
}
@@ -195,12 +196,12 @@ wrong_args (const char *text)
/* Command line parsing. */
static enum cmd_and_opt_values
-parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
+parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
{
enum cmd_and_opt_values cmd = 0;
int no_more_options = 0;
- while (!no_more_options && optfile_parse (NULL, NULL, NULL, pargs, popts))
+ while (!no_more_options && gpgrt_argparse (NULL, pargs, popts))
{
switch (pargs->r_opt)
{
@@ -248,7 +249,7 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
cmd = pargs->r_opt;
break;
- default: pargs->err = 2; break;
+ default: pargs->err = ARGPARSE_PRINT_ERROR; break;
}
}
@@ -262,11 +263,11 @@ int
main (int argc, char **argv)
{
gpg_error_t err, delayed_err;
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
enum cmd_and_opt_values cmd;
gnupg_reopen_std ("gpg-wks-client");
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
log_set_prefix ("gpg-wks-client", GPGRT_LOG_WITH_PREFIX);
/* Make sure that our subsystems are ready. */
@@ -281,6 +282,7 @@ main (int argc, char **argv)
pargs.argv = &argv;
pargs.flags = ARGPARSE_FLAG_KEEP;
cmd = parse_arguments (&pargs, opts);
+ gpgrt_argparse (NULL, &pargs, NULL);
if (log_get_errorcount (0))
exit (2);
@@ -426,7 +428,7 @@ main (int argc, char **argv)
break;
default:
- usage (1);
+ gpgrt_usage (1);
err = 0;
break;
}
diff --git a/tools/gpg-wks-server.c b/tools/gpg-wks-server.c
index bd0dfd641..967572581 100644
--- a/tools/gpg-wks-server.c
+++ b/tools/gpg-wks-server.c
@@ -16,6 +16,7 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
*/
/* The Web Key Service I-D defines an update protocol to store a
@@ -24,9 +25,7 @@
*/
#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>
#include <string.h>
@@ -48,7 +47,6 @@
#include "mime-maker.h"
#include "send-mail.h"
#include "gpg-wks.h"
-#include "../common/argparse.h" /* temporary hack. */
/* The time we wait for a confirmation response. */
@@ -87,7 +85,7 @@ enum cmd_and_opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
ARGPARSE_group (300, ("@Commands:\n ")),
ARGPARSE_c (aReceive, "receive",
@@ -176,9 +174,11 @@ my_strusage( int level )
switch (level)
{
+ case 9: p = "LGPL-2.1-or-later"; break;
case 11: p = "gpg-wks-server"; break;
case 12: p = "@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;
@@ -200,7 +200,7 @@ my_strusage( int level )
static void
wrong_args (const char *text)
{
- es_fprintf (es_stderr, "usage: %s [options] %s\n", strusage (11), text);
+ es_fprintf (es_stderr, "usage: %s [options] %s\n", gpgrt_strusage (11), text);
exit (2);
}
@@ -208,12 +208,12 @@ wrong_args (const char *text)
/* Command line parsing. */
static enum cmd_and_opt_values
-parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
+parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
{
enum cmd_and_opt_values cmd = 0;
int no_more_options = 0;
- while (!no_more_options && optfile_parse (NULL, NULL, NULL, pargs, popts))
+ while (!no_more_options && gpgrt_argparse (NULL, pargs, popts))
{
switch (pargs->r_opt)
{
@@ -262,7 +262,7 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
cmd = pargs->r_opt;
break;
- default: pargs->err = 2; break;
+ default: pargs->err = ARGPARSE_PRINT_ERROR; break;
}
}
@@ -276,11 +276,11 @@ int
main (int argc, char **argv)
{
gpg_error_t err, firsterr;
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
enum cmd_and_opt_values cmd;
gnupg_reopen_std ("gpg-wks-server");
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
log_set_prefix ("gpg-wks-server", GPGRT_LOG_WITH_PREFIX);
/* Make sure that our subsystems are ready. */
@@ -291,6 +291,7 @@ main (int argc, char **argv)
pargs.argv = &argv;
pargs.flags = ARGPARSE_FLAG_KEEP;
cmd = parse_arguments (&pargs, opts);
+ gpgrt_argparse (NULL, &pargs, NULL);
if (log_get_errorcount (0))
exit (2);
@@ -420,7 +421,7 @@ main (int argc, char **argv)
break;
default:
- usage (1);
+ gpgrt_usage (1);
err = gpg_error (GPG_ERR_BUG);
break;
}
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index a6094400b..14137ddcd 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -16,12 +16,11 @@
*
* 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 <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -34,7 +33,6 @@
#include "../common/sysutils.h"
#include "../common/init.h"
#include "../common/status.h"
-#include "../common/argparse.h" /* temporary hack. */
/* Constants to identify the commands and options. */
@@ -74,7 +72,7 @@ enum cmd_and_opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] =
+static gpgrt_opt_t opts[] =
{
{ 300, NULL, 0, N_("@Commands:\n ") },
@@ -133,9 +131,11 @@ my_strusage( int level )
switch (level)
{
+ case 9: p = "GPL-3.0-or-later"; break;
case 11: p = "@GPGCONF@ (@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;
@@ -541,7 +541,7 @@ int
main (int argc, char **argv)
{
gpg_error_t err;
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
const char *fname;
int no_more_options = 0;
enum cmd_and_opt_values cmd = 0;
@@ -550,7 +550,7 @@ main (int argc, char **argv)
early_system_init ();
gnupg_reopen_std (GPGCONF_NAME);
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
log_set_prefix (GPGCONF_NAME, GPGRT_LOG_WITH_PREFIX);
/* Make sure that our subsystems are ready. */
@@ -561,17 +561,15 @@ main (int argc, char **argv)
/* Parse the command line. */
pargs.argc = &argc;
pargs.argv = &argv;
- pargs.flags = 1; /* Do not remove the args. */
- while (!no_more_options && optfile_parse (NULL, NULL, NULL, &pargs, opts))
+ pargs.flags = ARGPARSE_FLAG_KEEP;
+ while (!no_more_options && gpgrt_argparse (NULL, &pargs, opts))
{
switch (pargs.r_opt)
{
case oOutput: opt.outfile = pargs.r.ret_str; break;
case oQuiet: opt.quiet = 1; break;
case oDryRun: opt.dry_run = 1; break;
- case oRuntime:
- opt.runtime = 1;
- break;
+ case oRuntime: opt.runtime = 1; break;
case oVerbose: opt.verbose++; break;
case oNoVerbose: opt.verbose = 0; break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
@@ -605,6 +603,8 @@ main (int argc, char **argv)
}
}
+ gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */
+
if (log_get_errorcount (0))
gpgconf_failure (GPG_ERR_USER_2);
diff --git a/tools/gpgsplit.c b/tools/gpgsplit.c
index 8b65c89c5..7257b63e1 100644
--- a/tools/gpgsplit.c
+++ b/tools/gpgsplit.c
@@ -15,12 +15,11 @@
*
* 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 <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -42,7 +41,6 @@
#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h"
#include "../common/openpgpdefs.h"
-#include "../common/argparse.h" /* temporary hack. */
#ifdef HAVE_BZIP2
# include <bzlib.h>
@@ -70,7 +68,7 @@ enum cmd_and_opt_values {
};
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
{ 301, NULL, 0, "@Options:\n " },
@@ -90,9 +88,11 @@ my_strusage (int level)
const char *p;
switch (level)
{
+ case 9: p = "GPL-3.0-or-later"; break;
case 11: p = "gpgsplit (@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;
@@ -115,19 +115,22 @@ my_strusage (int level)
int
main (int argc, char **argv)
{
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
#ifdef HAVE_DOSISH_SYSTEM
setmode( fileno(stdin), O_BINARY );
setmode( fileno(stdout), O_BINARY );
#endif
log_set_prefix ("gpgsplit", GPGRT_LOG_WITH_PREFIX);
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
+ /* Register our string mapper with gpgrt. Usually done in
+ * init_common_subsystems, but we don't need that here. */
+ gpgrt_set_fixed_string_mapper (map_static_macro_string);
pargs.argc = &argc;
pargs.argv = &argv;
- pargs.flags= 1; /* do not remove the args */
- while (optfile_parse( NULL, NULL, NULL, &pargs, opts))
+ pargs.flags= ARGPARSE_FLAG_KEEP;
+ while (gpgrt_argparse (NULL, &pargs, opts))
{
switch (pargs.r_opt)
{
@@ -139,6 +142,7 @@ main (int argc, char **argv)
default : pargs.err = 2; break;
}
}
+ gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */
if (log_get_errorcount(0))
g10_exit (2);
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index 363510ecf..680ed3ddd 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -15,6 +15,7 @@
*
* 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
*/
/* GnuPG comes with a shell script gpg-zip which creates archive files
@@ -27,9 +28,7 @@
gpg. So here we go. */
#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 <ctype.h>
#include <errno.h>
#include <stdio.h>
@@ -44,7 +43,6 @@
#include "../common/openpgpdefs.h"
#include "../common/init.h"
#include "../common/strlist.h"
-#include "../common/argparse.h" /* temporary hack. */
#include "gpgtar.h"
@@ -88,7 +86,7 @@ enum cmd_and_opt_values
/* The list of commands and options. */
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
ARGPARSE_group (300, N_("@Commands:\n ")),
ARGPARSE_c (aCreate, "create", N_("create an archive")),
@@ -130,7 +128,7 @@ static ARGPARSE_OPTS opts[] = {
/* The list of commands and options for tar that we understand. */
-static ARGPARSE_OPTS tar_opts[] = {
+static gpgrt_opt_t tar_opts[] = {
ARGPARSE_s_s (oDirectory, "directory",
N_("|DIRECTORY|extract files into DIRECTORY")),
ARGPARSE_s_s (oFilesFrom, "files-from",
@@ -158,9 +156,11 @@ my_strusage( int level )
switch (level)
{
+ case 9: p = "GPL-3.0-or-later"; break;
case 11: p = "@GPGTAR@ (@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;
@@ -307,11 +307,11 @@ shell_parse_argv (const char *s, int *r_argc, char ***r_argv)
/* Command line parsing. */
static void
-parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
+parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
{
int no_more_options = 0;
- while (!no_more_options && optfile_parse (NULL, NULL, NULL, pargs, popts))
+ while (!no_more_options && gpgrt_argparse (NULL, pargs, popts))
{
switch (pargs->r_opt)
{
@@ -381,7 +381,7 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
}
break;
- case oTarArgs:;
+ case oTarArgs:
{
int tar_argc;
char **tar_argv;
@@ -391,11 +391,12 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
pargs->r.ret_str);
else
{
- ARGPARSE_ARGS tar_args;
+ gpgrt_argparse_t tar_args;
tar_args.argc = &tar_argc;
tar_args.argv = &tar_argv;
tar_args.flags = ARGPARSE_FLAG_ARG0;
parse_arguments (&tar_args, tar_opts);
+ gpgrt_argparse (NULL, &tar_args, NULL);
if (tar_args.err)
log_error ("unsupported tar arguments '%s'\n",
pargs->r.ret_str);
@@ -420,23 +421,24 @@ main (int argc, char **argv)
{
gpg_error_t err;
const char *fname;
- ARGPARSE_ARGS pargs;
-
- assert (sizeof (struct ustar_raw_header) == 512);
+ gpgrt_argparse_t pargs;
gnupg_reopen_std (GPGTAR_NAME);
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
log_set_prefix (GPGTAR_NAME, GPGRT_LOG_WITH_PREFIX);
/* Make sure that our subsystems are ready. */
i18n_init();
init_common_subsystems (&argc, &argv);
+ log_assert (sizeof (struct ustar_raw_header) == 512);
+
/* Parse the command line. */
pargs.argc = &argc;
pargs.argv = &argv;
pargs.flags = ARGPARSE_FLAG_KEEP;
parse_arguments (&pargs, opts);
+ gpgrt_argparse (NULL, &pargs, NULL);
if ((files_from && !null_names) || (!files_from && null_names))
log_error ("--files-from and --null may only be used in conjunction\n");
@@ -466,7 +468,7 @@ main (int argc, char **argv)
{
case aList:
if (argc > 1)
- usage (1);
+ gpgrt_usage (1);
fname = argc ? *argv : NULL;
if (opt.filename)
log_info ("note: ignoring option --set-filename\n");
@@ -482,7 +484,7 @@ main (int argc, char **argv)
case aSignEncrypt:
if ((!argc && !null_names)
|| (argc && null_names))
- usage (1);
+ gpgrt_usage (1);
if (opt.filename)
log_info ("note: ignoring option --set-filename\n");
err = gpgtar_create (null_names? NULL :argv,
@@ -495,7 +497,7 @@ main (int argc, char **argv)
case aDecrypt:
if (argc != 1)
- usage (1);
+ gpgrt_usage (1);
if (opt.outfile)
log_info ("note: ignoring option --output\n");
if (files_from)