aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/dirmngr-client.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-02-21 20:45:13 +0000
committerWerner Koch <[email protected]>2020-02-21 20:45:13 +0000
commitba463128ce65a0f347643f7246a8e097c5be19f1 (patch)
tree682da0a88444811b099f162dc77d2f4b2b0ba5d9 /dirmngr/dirmngr-client.c
parentUse gpgrt's new option parser for the tools. (diff)
downloadgnupg-ba463128ce65a0f347643f7246a8e097c5be19f1.tar.gz
gnupg-ba463128ce65a0f347643f7246a8e097c5be19f1.zip
Use gpgrt's new option parser for the remaining daemons.
* scd/scdaemon.c: Switch to the new option parser and enable a global conf file. * dirmngr/dirmngr.c: Ditto. * g13/g13.c: Ditto. * g13/g13-syshelp.c: Ditto. Do not force verbose mode. * dirmngr/dirmngr_ldap.c: Switch to the new option parser. * dirmngr/dirmngr-client.c: Switch to the new option parser. -- This finalizes the switch to the new option parser. What's left is to remove the old argparser code from common. g13-syshelp does not anymore default to --verbose because that can now be enabled in /etc/gnupg/g13-syshelp.conf. GnuPG-bug-id: 4788 Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--dirmngr/dirmngr-client.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/dirmngr/dirmngr-client.c b/dirmngr/dirmngr-client.c
index e0bc80fcf..1ea10a8ad 100644
--- a/dirmngr/dirmngr-client.c
+++ b/dirmngr/dirmngr-client.c
@@ -16,12 +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>
@@ -35,7 +33,6 @@
#include <assuan.h>
#include "../common/logging.h"
-#include "../common/argparse.h"
#include "../common/stringhelp.h"
#include "../common/mischelp.h"
#include "../common/strlist.h"
@@ -44,7 +41,6 @@
#include "../common/i18n.h"
#include "../common/util.h"
#include "../common/init.h"
-#include "../common/argparse.h" /* temporary hack. */
/* Constants for the options. */
@@ -69,7 +65,7 @@ enum
/* The list of options as used by the argparse.c code. */
-static ARGPARSE_OPTS opts[] = {
+static gpgrt_opt_t opts[] = {
{ oVerbose, "verbose", 0, N_("verbose") },
{ oQuiet, "quiet", 0, N_("be somewhat more quiet") },
{ oOCSP, "ocsp", 0, N_("use OCSP instead of CRLs") },
@@ -162,9 +158,11 @@ my_strusage (int level)
switch(level)
{
+ case 9: p = "GPL-3.0-or-later"; break;
case 11: p = "dirmngr-client (@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;
case 49: p = PACKAGE_BUGREPORT; break;
@@ -190,7 +188,7 @@ my_strusage (int level)
int
main (int argc, char **argv )
{
- ARGPARSE_ARGS pargs;
+ gpgrt_argparse_t pargs;
assuan_context_t ctx;
gpg_error_t err;
unsigned char *certbuf;
@@ -203,9 +201,12 @@ main (int argc, char **argv )
int cmd_squid_mode = 0;
early_system_init ();
- set_strusage (my_strusage);
+ gpgrt_set_strusage (my_strusage);
log_set_prefix ("dirmngr-client",
GPGRT_LOG_WITH_PREFIX);
+ /* 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);
/* For W32 we need to initialize the socket subsystem. Because we
don't use Pth we need to do this explicit. */
@@ -227,8 +228,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 (arg_parse (&pargs, opts) )
+ pargs.flags= ARGPARSE_FLAG_KEEP;
+ while (gpgrt_argparse (NULL, &pargs, opts))
{
switch (pargs.r_opt)
{
@@ -251,9 +252,11 @@ main (int argc, char **argv )
break;
case oForceDefaultResponder: opt.force_default_responder = 1; break;
- default : pargs.err = 2; break;
+ default : pargs.err = ARGPARSE_PRINT_ERROR; break;
}
}
+ gpgrt_argparse (NULL, &pargs, NULL);
+
if (log_get_errorcount (0))
exit (2);
@@ -262,14 +265,14 @@ main (int argc, char **argv )
else if (cmd_lookup || cmd_loadcrl)
{
if (!argc)
- usage (1);
+ gpgrt_usage (1);
err = 0;
}
else if (cmd_squid_mode)
{
err = 0;
if (argc)
- usage (1);
+ gpgrt_usage (1);
}
else if (!argc)
{
@@ -288,7 +291,7 @@ main (int argc, char **argv )
else
{
err = 0;
- usage (1);
+ gpgrt_usage (1);
}
if (log_get_errorcount (0))