Add gpgme_get_dirinfo.

* src/dirinfo.c (gpgme_get_dirinfo): New.
* tests/t-engine-info.c (main): Print results from that function.
This commit is contained in:
Werner Koch 2014-04-10 11:47:19 +02:00
parent b788c36ec0
commit 77931a9a14
7 changed files with 89 additions and 4 deletions

5
NEWS
View File

@ -5,10 +5,13 @@ Noteworthy changes in version 1.5.0 (unreleased)
located via the envvar PATH. All configuration options to set the located via the envvar PATH. All configuration options to set the
name of the engines for configure run are removed. name of the engines for configure run are removed.
* If GPGME find the gpgconf binary it defaults to using gpg2 or * If GPGME finds the gpgconf binary it defaults to using gpg2 or
whatever gpgconf tells as name for the OpenPGP engine. If gpgconf whatever gpgconf tells as name for the OpenPGP engine. If gpgconf
is not found, GPGME looks for an engine named "gpg". is not found, GPGME looks for an engine named "gpg".
* Interface changes relative to the 1.4.3 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_get_dirinfo NEW.
Noteworthy changes in version 1.4.3 (2013-08-12) Noteworthy changes in version 1.4.3 (2013-08-12)

View File

@ -878,6 +878,41 @@ allocated string describing the protocol @var{protocol}, or
@section Engine Version Check @section Engine Version Check
@cindex version check, of the engines @cindex version check, of the engines
@deftypefun @w{const char *} gpgme_get_dirinfo (@w{cons char *@var{what}})
The function @code{gpgme_get_dirinfo} returns a statically allocated
string with the value associated to @var{what}. The returned values
are the defaults and won't change even after
@code{gpgme_set_engine_info} has been used to configure a different
engine. @code{NULL} is returned if no value is available. Commonly
supported values for @var{what} are:
@table @code
@item homedir
Return the default home directory.
@item agent-socket
Return the name of the socket to connect to the gpg-agent.
@item uiserver-socket
Return the name of the socket to connect to the user interface server.
@item gpgconf-name
Return the file name of the engine configuration tool.
@item gpg-name
Return the file name of the OpenPGP engine.
@item gpgsm-name
Return the file name of the CMS engine.
@item g13-name
Return the name of the file container encryption engine.
@end table
@end deftypefun
@deftypefun gpgme_error_t gpgme_engine_check_version (@w{gpgme_protocol_t @var{protocol}}) @deftypefun gpgme_error_t gpgme_engine_check_version (@w{gpgme_protocol_t @var{protocol}})
The function @code{gpgme_engine_check_version} verifies that the The function @code{gpgme_engine_check_version} verifies that the
engine implementing the protocol @var{PROTOCOL} is installed in the engine implementing the protocol @var{PROTOCOL} is installed in the
@ -916,7 +951,8 @@ reserved for future use, so always check before you use it.
@item const char *home_dir @item const char *home_dir
This is a string holding the directory name of the crypto engine's This is a string holding the directory name of the crypto engine's
configuration directory. If it is @code{NULL}, then the default configuration directory. If it is @code{NULL}, then the default
directory is used. directory is used. See @code{gpgme_get_dirinfo} on how to get the
default directory.
@item const char *version @item const char *version
This is a string containing the version number of the crypto engine. This is a string containing the version number of the crypto engine.

View File

@ -357,3 +357,28 @@ _gpgme_get_basename (const char *name)
return s+1; return s+1;
return name; return name;
} }
/* Return default values for various directories and file names. */
const char *
gpgme_get_dirinfo (const char *what)
{
if (!what)
return NULL;
else if (!strcmp (what, "homedir"))
return get_gpgconf_item (WANT_HOMEDIR);
else if (!strcmp (what, "agent-socket"))
return get_gpgconf_item (WANT_AGENT_SOCKET);
else if (!strcmp (what, "uiserver-socket"))
return get_gpgconf_item (WANT_UISRV_SOCKET);
else if (!strcmp (what, "gpgconf-name"))
return get_gpgconf_item (WANT_GPGCONF_NAME);
else if (!strcmp (what, "gpg-name"))
return get_gpgconf_item (WANT_GPG_NAME);
else if (!strcmp (what, "gpgsm-name"))
return get_gpgconf_item (WANT_GPGSM_NAME);
else if (!strcmp (what, "g13-name"))
return get_gpgconf_item (WANT_G13_NAME);
else
return NULL;
}

View File

@ -213,5 +213,7 @@ EXPORTS
gpgme_data_identify @161 gpgme_data_identify @161
gpgme_get_dirinfo @162
; END ; END

View File

@ -2090,6 +2090,9 @@ const char *gpgme_check_version_internal (const char *req_version,
gpgme_check_version_internal (req_version, \ gpgme_check_version_internal (req_version, \
offsetof (struct _gpgme_signature, validity)) offsetof (struct _gpgme_signature, validity))
/* Return the default values for various directories. */
const char *gpgme_get_dirinfo (const char *what);
/* Get the information about the configured and installed engines. A /* Get the information about the configured and installed engines. A
pointer to the first engine in the statically allocated linked list pointer to the first engine in the statically allocated linked list
is returned in *INFO. If an error occurs, it is returned. The is returned in *INFO. If an error occurs, it is returned. The

View File

@ -87,6 +87,8 @@ GPGME_1.1 {
gpgme_set_pinentry_mode; gpgme_set_pinentry_mode;
gpgme_get_pinentry_mode; gpgme_get_pinentry_mode;
gpgme_get_dirinfo;
}; };

View File

@ -109,12 +109,26 @@ main (int argc, char **argv )
} }
gpgme_check_version (NULL); gpgme_check_version (NULL);
{
const char *keys[] = {"homedir", "agent-socket", "uiserver-socket",
"gpgconf-name", "gpg-name", "gpgsm-name",
"g13-name", NULL };
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);
}
err = gpgme_get_engine_info (&info); err = gpgme_get_engine_info (&info);
fail_if_err (err); fail_if_err (err);
for (; info; info = info->next) for (; info; info = info->next)
fprintf (stdout, "protocol=%d engine='%s' v='%s' (min='%s')\n", fprintf (stdout, "protocol=%d engine='%s' v='%s' (min='%s') home='%s'\n",
info->protocol, info->file_name, info->version, info->req_version); info->protocol, info->file_name, info->version, info->req_version,
info->home_dir? info->home_dir : "[default]");
return 0; return 0;
} }