diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | src/code-from-errno.c | 42 | ||||
-rw-r--r-- | src/gpg-error.m4 | 2 |
3 files changed, 51 insertions, 3 deletions
@@ -3,6 +3,16 @@ * lang/cl/gpg-error.lisp (gpg-err-source-t): Add :gpg-err-source-any. +2007-06-18 Werner Koch <[email protected]> + + * src/code-from-errno.c (w32_special_errnos) [W32]: New. This is + to provide some common mappings for winsocket error codes. + (gpg_err_code_from_errno, gpg_err_code_from_syserror): Use it. + +2007-05-09 Werner Koch <[email protected]> + + * src/gpg-error.m4: Print found version on success. + 2006-12-09 Marcus Brinkmann <[email protected]> * src/Makefile.am (EXTRA_DIST): Add README. diff --git a/src/code-from-errno.c b/src/code-from-errno.c index 96fcf20..2895d82 100644 --- a/src/code-from-errno.c +++ b/src/code-from-errno.c @@ -23,11 +23,37 @@ #endif #include <errno.h> +#ifdef HAVE_W32_SYSTEM +#include <winsock2.h> +#endif #include <gpg-error.h> #include "code-from-errno.h" +#ifdef HAVE_W32_SYSTEM +/* Under Windows socket related error codes are defined in a different + file and prefixed with "WSA". As their ranges don't overlap, we map + some of them to our usual error codes. */ +gpg_err_code_t +w32_special_errnos (int err) +{ + switch (err) + { + case WSAEADDRINUSE: return GPG_ERR_EADDRINUSE; + case WSAEADDRNOTAVAIL: return GPG_ERR_EADDRNOTAVAIL; + case WSAECONNABORTED: return GPG_ERR_ECONNABORTED; + case WSAECONNREFUSED: return GPG_ERR_ECONNREFUSED; + case WSAECONNRESET: return GPG_ERR_ECONNRESET; + case WSAENAMETOOLONG: return GPG_ERR_ENAMETOOLONG; + case WSAEHOSTDOWN: return GPG_ERR_EHOSTDOWN; + case WSAEHOSTUNREACH: return GPG_ERR_EHOSTUNREACH; + default: + return GPG_ERR_UNKNOWN_ERRNO; + } +} +#endif /*HAVE_W32_SYSTEM*/ + /* Retrieve the error code for the system error ERR. This returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report this). */ @@ -42,7 +68,13 @@ gpg_err_code_from_errno (int err) idx = errno_to_idx (err); if (idx < 0) - return GPG_ERR_UNKNOWN_ERRNO; + { +#ifdef HAVE_W32_SYSTEM + return w32_special_errnos (err); +#else + return GPG_ERR_UNKNOWN_ERRNO; +#endif + } return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; } @@ -63,7 +95,13 @@ gpg_err_code_from_syserror (void) idx = errno_to_idx (err); if (idx < 0) - return GPG_ERR_UNKNOWN_ERRNO; + { +#ifdef HAVE_W32_SYSTEM + return w32_special_errnos (err); +#else + return GPG_ERR_UNKNOWN_ERRNO; +#endif + } return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; } diff --git a/src/gpg-error.m4 b/src/gpg-error.m4 index e85f511..9d96d16 100644 --- a/src/gpg-error.m4 +++ b/src/gpg-error.m4 @@ -51,7 +51,7 @@ AC_DEFUN([AM_PATH_GPG_ERROR], if test $ok = yes; then GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags` GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs` - AC_MSG_RESULT(yes) + AC_MSG_RESULT([yes ($gpg_error_config_version)]) ifelse([$2], , :, [$2]) else GPG_ERROR_CFLAGS="" |