summaryrefslogtreecommitdiffstats
path: root/common/simple-pwquery.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2007-06-14 19:05:07 +0200
committerWerner Koch <wk@gnupg.org>2007-06-14 19:05:07 +0200
commit0cfbfd6186c7b28a355069ebb89b9739908318c6 (patch)
treea1e2990f266ca151fc47f06d41f40bca743eea76 /common/simple-pwquery.h
parentSyntax fix - should build now - however not tested. (diff)
downloadgnupg2-0cfbfd6186c7b28a355069ebb89b9739908318c6.tar.xz
gnupg2-0cfbfd6186c7b28a355069ebb89b9739908318c6.zip
A whole bunch of changes to allow building for Windows.
See the ChangeLogs for details.
Diffstat (limited to 'common/simple-pwquery.h')
-rw-r--r--common/simple-pwquery.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/common/simple-pwquery.h b/common/simple-pwquery.h
index ab2724ffa..cb5d9354b 100644
--- a/common/simple-pwquery.h
+++ b/common/simple-pwquery.h
@@ -41,7 +41,6 @@
#define spwq_secure_malloc(a) gcry_malloc_secure (a)
#define spwq_secure_free(a) gcry_free (a)
-
#endif /*SIMPLE_PWQUERY_IMPLEMENTATION*/ /* End configuration stuff. */
@@ -67,6 +66,11 @@ int simple_pwclear (const char *cacheid);
terminated) and return the error code. */
int simple_query (const char *query);
+/* Set the name of the standard socket to be used if GPG_AGENT_INFO is
+ not defined. The use of this function is optional but if it needs
+ to be called before any other function. Returns 0 on success. */
+int simple_pw_set_socket (const char *name);
+
#define SPWQ_OUT_OF_CORE 1
#define SPWQ_IO_ERROR 2
#define SPWQ_PROTOCOL_ERROR 3
@@ -74,5 +78,40 @@ int simple_query (const char *query);
#define SPWQ_NO_AGENT 5
#define SPWQ_SYS_ERROR 6
#define SPWQ_GENERAL_ERROR 7
+#define SPWQ_NO_PIN_ENTRY 8
+
+
+/* We often need to map error codes to gpg-error style error codes.
+ To have a consistent mapping this macro may be used to implemt the
+ mapping function. */
+#define MAP_SPWQ_ERROR_IMPL \
+ static gpg_error_t \
+ map_spwq_error (int err) \
+ { \
+ switch (err) \
+ { \
+ case 0: \
+ return 0; \
+ case SPWQ_OUT_OF_CORE: \
+ return gpg_error_from_errno (ENOMEM); \
+ case SPWQ_IO_ERROR: \
+ return gpg_error_from_errno (EIO); \
+ case SPWQ_PROTOCOL_ERROR: \
+ return gpg_error (GPG_ERR_PROTOCOL_VIOLATION); \
+ case SPWQ_ERR_RESPONSE: \
+ return gpg_error (GPG_ERR_INV_RESPONSE); \
+ case SPWQ_NO_AGENT: \
+ return gpg_error (GPG_ERR_NO_AGENT); \
+ case SPWQ_SYS_ERROR: \
+ return gpg_error_from_syserror (); \
+ case SPWQ_NO_PIN_ENTRY: \
+ return gpg_error (GPG_ERR_NO_PIN_ENTRY); \
+ case SPWQ_GENERAL_ERROR: \
+ default: \
+ return gpg_error (GPG_ERR_GENERAL); \
+ } \
+ }
+/* End of MAP_SPWQ_ERROR_IMPL. */
+
#endif /*SIMPLE_PWQUERY_H*/