diff options
Diffstat (limited to 'src/assuan-error.c')
-rw-r--r-- | src/assuan-error.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/src/assuan-error.c b/src/assuan-error.c index 4eba7ff..60cb0d3 100644 --- a/src/assuan-error.c +++ b/src/assuan-error.c @@ -29,30 +29,6 @@ #include "assuan.h" #include "assuan-defs.h" -/* If true the modern gpg-error style error codes are used in the - API. */ -static gpg_err_source_t err_source; - -/* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error - sources. Note, that this function is not thread-safe and should be - used right at startup. Switching back to the old style mode is not - supported. */ -void -assuan_set_assuan_err_source (gpg_err_source_t errsource) -{ - errsource &= 0xff; - err_source = errsource ? errsource : 31 /*GPG_ERR_SOURCE_ANY*/; -} - - -/* Helper to map old style Assuan error codes to gpg-error codes. - This is used internally to keep an compatible ABI. */ -gpg_error_t -_assuan_error (gpg_err_code_t errcode) -{ - return gpg_err_make (err_source, errcode); -} - /* A small helper function to treat EAGAIN transparently to the caller. */ @@ -68,3 +44,20 @@ _assuan_error_is_eagain (gpg_error_t err) else return 0; } + + + +#ifdef HAVE_W32_SYSTEM +char * +_assuan_w32_strerror (assuan_context_t ctx, int ec) +{ + if (ec == -1) + ec = (int)GetLastError (); + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec, + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + ctx->w32_strerror, sizeof (ctx->w32_strerror) - 1, NULL); + + return ctx->w32_strerror; +} +#endif + |