aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-04-10 09:47:19 +0000
committerWerner Koch <[email protected]>2014-04-10 09:48:20 +0000
commit77931a9a1468b0cfbaafd4153867d90764a6d258 (patch)
tree4d04e5b7d055b6bf1f8b931bc573603cd805ad65
parentRemove compiler warning from test (diff)
downloadgpgme-77931a9a1468b0cfbaafd4153867d90764a6d258.tar.gz
gpgme-77931a9a1468b0cfbaafd4153867d90764a6d258.zip
Add gpgme_get_dirinfo.
* src/dirinfo.c (gpgme_get_dirinfo): New. * tests/t-engine-info.c (main): Print results from that function.
-rw-r--r--NEWS5
-rw-r--r--doc/gpgme.texi38
-rw-r--r--src/dirinfo.c25
-rw-r--r--src/gpgme.def2
-rw-r--r--src/gpgme.h.in3
-rw-r--r--src/libgpgme.vers2
-rw-r--r--tests/t-engine-info.c18
7 files changed, 89 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 8f9127e0..f625ab95 100644
--- a/NEWS
+++ b/NEWS
@@ -5,10 +5,13 @@ Noteworthy changes in version 1.5.0 (unreleased)
located via the envvar PATH. All configuration options to set the
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
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)
diff --git a/doc/gpgme.texi b/doc/gpgme.texi
index 4425396b..e12fd738 100644
--- a/doc/gpgme.texi
+++ b/doc/gpgme.texi
@@ -878,6 +878,41 @@ allocated string describing the protocol @var{protocol}, or
@section Engine Version Check
@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}})
The function @code{gpgme_engine_check_version} verifies that 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
This is a string holding the directory name of the crypto engine's
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
This is a string containing the version number of the crypto engine.
diff --git a/src/dirinfo.c b/src/dirinfo.c
index 845bc489..8824c9a4 100644
--- a/src/dirinfo.c
+++ b/src/dirinfo.c
@@ -357,3 +357,28 @@ _gpgme_get_basename (const char *name)
return s+1;
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;
+}
diff --git a/src/gpgme.def b/src/gpgme.def
index 0478cb62..ee0c42e2 100644
--- a/src/gpgme.def
+++ b/src/gpgme.def
@@ -213,5 +213,7 @@ EXPORTS
gpgme_data_identify @161
+ gpgme_get_dirinfo @162
+
; END
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 5c4de6be..050051a4 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -2090,6 +2090,9 @@ const char *gpgme_check_version_internal (const char *req_version,
gpgme_check_version_internal (req_version, \
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
pointer to the first engine in the statically allocated linked list
is returned in *INFO. If an error occurs, it is returned. The
diff --git a/src/libgpgme.vers b/src/libgpgme.vers
index fe18e6a5..4db1d408 100644
--- a/src/libgpgme.vers
+++ b/src/libgpgme.vers
@@ -87,6 +87,8 @@ GPGME_1.1 {
gpgme_set_pinentry_mode;
gpgme_get_pinentry_mode;
+
+ gpgme_get_dirinfo;
};
diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c
index 11fe4a4e..53f5b2fa 100644
--- a/tests/t-engine-info.c
+++ b/tests/t-engine-info.c
@@ -109,12 +109,26 @@ main (int argc, char **argv )
}
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);
fail_if_err (err);
for (; info; info = info->next)
- fprintf (stdout, "protocol=%d engine='%s' v='%s' (min='%s')\n",
- info->protocol, info->file_name, info->version, info->req_version);
+ 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]");
return 0;
}