2003-01-30 11:54:23 +00:00
|
|
|
|
/* t-engine-info.c - Regression test for gpgme_get_engine_info.
|
2018-11-16 12:27:33 +00:00
|
|
|
|
* Copyright (C) 2003, 2004, 2007 g10 Code GmbH
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GPGME.
|
|
|
|
|
*
|
|
|
|
|
* GPGME is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GPGME is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this program; if not, see <https://gnu.org/licenses/>.
|
|
|
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
|
*/
|
2003-01-30 11:54:23 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <gpgme.h>
|
|
|
|
|
|
2014-01-06 16:16:52 +00:00
|
|
|
|
#define PGM "t-engine-info"
|
|
|
|
|
|
|
|
|
|
static int verbose;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-01-30 11:54:23 +00:00
|
|
|
|
|
|
|
|
|
#define fail_if_err(err) \
|
|
|
|
|
do \
|
|
|
|
|
{ \
|
|
|
|
|
if (err) \
|
|
|
|
|
{ \
|
2003-05-18 20:45:24 +00:00
|
|
|
|
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
2003-01-30 11:54:23 +00:00
|
|
|
|
__FILE__, __LINE__, gpgme_strerror (err)); \
|
|
|
|
|
exit (1); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
while (0)
|
|
|
|
|
|
|
|
|
|
|
2012-09-25 13:29:49 +00:00
|
|
|
|
int
|
2003-01-30 11:54:23 +00:00
|
|
|
|
main (int argc, char **argv )
|
|
|
|
|
{
|
2014-01-06 16:16:52 +00:00
|
|
|
|
int last_argc = -1;
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_engine_info_t info;
|
|
|
|
|
gpgme_error_t err;
|
2003-01-30 11:54:23 +00:00
|
|
|
|
|
2014-01-06 16:16:52 +00:00
|
|
|
|
if (argc)
|
|
|
|
|
{ argc--; argv++; }
|
|
|
|
|
|
|
|
|
|
while (argc && last_argc != argc )
|
|
|
|
|
{
|
|
|
|
|
last_argc = argc;
|
|
|
|
|
if (!strcmp (*argv, "--"))
|
|
|
|
|
{
|
|
|
|
|
argc--; argv++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (*argv, "--help"))
|
|
|
|
|
{
|
|
|
|
|
fputs ("usage: " PGM " [options]\n"
|
|
|
|
|
"Options:\n"
|
|
|
|
|
" --set-global-flag KEY VALUE\n",
|
|
|
|
|
stdout);
|
|
|
|
|
exit (0);
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (*argv, "--verbose"))
|
|
|
|
|
{
|
|
|
|
|
verbose++;
|
|
|
|
|
argc--; argv++;
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (*argv, "--set-global-flag"))
|
|
|
|
|
{
|
|
|
|
|
argc--; argv++;
|
|
|
|
|
if (argc < 2)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, PGM ": not enough arguments for option\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
if (gpgme_set_global_flag (argv[0], argv[1]))
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, PGM ": gpgme_set_global_flag failed\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
argc--; argv++;
|
|
|
|
|
argc--; argv++;
|
|
|
|
|
}
|
|
|
|
|
else if (!strncmp (*argv, "--", 2))
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, PGM ": unknown option '%s'\n", *argv);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (argc)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, PGM ": unexpected arguments\n");
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-24 14:07:31 +00:00
|
|
|
|
gpgme_check_version (NULL);
|
2014-04-10 09:47:19 +00:00
|
|
|
|
|
|
|
|
|
{
|
core: Add new items for gpgme_get_dirinfo.
* src/dirinfo.c (WANT_SYSCONFDIR, WANT_LIBEXECDIR, WANT_LIBDIR): New.
(WANT_DATADIR, WANT_LCOALEDIR, WANT_AGENT_SSH_SOCKET): New
(WANT_DIRMNGR_SOCKET): New.
(dirinfo): Add fields 'sysconfdir', 'bindir', 'libexecdir', 'libdir',
'datadir', 'localedir', 'agent_ssh_socket', and 'dirmngr_socket'.
(parse_output): Set these fields.
(get_gpgconf_item): Return them.
(gpgme_get_dirinfo): Likewise.
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-22 14:57:51 +00:00
|
|
|
|
const char *keys[] = {"homedir",
|
|
|
|
|
"sysconfdir",
|
|
|
|
|
"bindir",
|
|
|
|
|
"libexecdir",
|
|
|
|
|
"libdir",
|
|
|
|
|
"datadir",
|
|
|
|
|
"localedir",
|
2021-09-22 08:18:30 +00:00
|
|
|
|
"socketdir",
|
core: Add new items for gpgme_get_dirinfo.
* src/dirinfo.c (WANT_SYSCONFDIR, WANT_LIBEXECDIR, WANT_LIBDIR): New.
(WANT_DATADIR, WANT_LCOALEDIR, WANT_AGENT_SSH_SOCKET): New
(WANT_DIRMNGR_SOCKET): New.
(dirinfo): Add fields 'sysconfdir', 'bindir', 'libexecdir', 'libdir',
'datadir', 'localedir', 'agent_ssh_socket', and 'dirmngr_socket'.
(parse_output): Set these fields.
(get_gpgconf_item): Return them.
(gpgme_get_dirinfo): Likewise.
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-22 14:57:51 +00:00
|
|
|
|
"agent-socket",
|
|
|
|
|
"agent-ssh-socket",
|
|
|
|
|
"dirmngr-socket",
|
|
|
|
|
"uiserver-socket",
|
|
|
|
|
"gpgconf-name",
|
|
|
|
|
"gpg-name",
|
|
|
|
|
"gpgsm-name",
|
2017-03-21 10:16:16 +00:00
|
|
|
|
"g13-name",
|
|
|
|
|
"gpg-wks-client-name",
|
|
|
|
|
NULL };
|
2014-04-10 09:47:19 +00:00
|
|
|
|
const char *s;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i=0; keys[i]; i++)
|
|
|
|
|
if ((s = gpgme_get_dirinfo (keys[i])))
|
|
|
|
|
fprintf (stderr, "dirinfo: %s='%s'\n", keys[i], s);
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-30 11:54:23 +00:00
|
|
|
|
err = gpgme_get_engine_info (&info);
|
|
|
|
|
fail_if_err (err);
|
|
|
|
|
|
2013-12-27 15:08:20 +00:00
|
|
|
|
for (; info; info = info->next)
|
2014-04-10 09:47:19 +00:00
|
|
|
|
fprintf (stdout, "protocol=%d engine='%s' v='%s' (min='%s') home='%s'\n",
|
|
|
|
|
info->protocol, info->file_name, info->version, info->req_version,
|
|
|
|
|
info->home_dir? info->home_dir : "[default]");
|
2003-01-30 11:54:23 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|