diff options
author | Marcus Brinkmann <[email protected]> | 2009-07-17 01:37:42 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2009-07-17 01:37:42 +0000 |
commit | eea21ee9383f652b446d60208620590860621556 (patch) | |
tree | 795e7bdfff0060e256c8afee2f0bb65373fea546 | |
parent | 2009-06-23 Marcus Brinkmann <[email protected]> (diff) | |
download | libgpg-error-eea21ee9383f652b446d60208620590860621556.tar.gz libgpg-error-eea21ee9383f652b446d60208620590860621556.zip |
2009-07-17 Marcus Brinkmann <[email protected]>
* src/mkerrcodes1.awk: Output code to cause WSA Errors to be
transparently translated.
* src/code-from-errno.c [HAVE_W32_SYSTEM]: Don't include winsock2.h.
(w32_special_errnos) [HAVE_W32_SYSTEM]: Removed.
(gpg_err_code_from_errno) [HAVE_W32_SYSTEM]: Remove special case.
* README: Document problem with printing some WSA Errors.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | README | 14 | ||||
-rw-r--r-- | src/code-from-errno.c | 42 | ||||
-rw-r--r-- | src/mkerrcodes1.awk | 8 |
4 files changed, 32 insertions, 41 deletions
@@ -1,3 +1,12 @@ +2009-07-17 Marcus Brinkmann <[email protected]> + + * src/mkerrcodes1.awk: Output code to cause WSA Errors to be + transparently translated. + * src/code-from-errno.c [HAVE_W32_SYSTEM]: Don't include winsock2.h. + (w32_special_errnos) [HAVE_W32_SYSTEM]: Removed. + (gpg_err_code_from_errno) [HAVE_W32_SYSTEM]: Remove special case. + * README: Document problem with printing some WSA Errors. + 2009-06-23 Marcus Brinkmann <[email protected]> Update to libtool 2.2.6a. @@ -74,3 +74,17 @@ b) If you don't have any a trusted version of GnuPG, you can attempt Now check that this checksum is _exactly_ the same as the one published via the announcement list and probably via Usenet. + + +Known Problems +-------------- + +On Windows, WSA Error Codes can be provided as system error codes and +will be transparently converted to the corresponding gpg error codes. +However, not all of them have detailed description when printed with +gpg_strerror, but will default to "Unknown system error (NUMBER)" for +pretty printing. For example, WSAEHOSTDOWN will be translated to +GPG_ERR_EHOSTDOWN, but there is no corresponding EHOSTDOWN in Windows +and thus gpg_strerror will default to "Unknown system error (8029)". +(This could be fixed by adding our own error strings replacing or +extending the system error strings, including their translations). diff --git a/src/code-from-errno.c b/src/code-from-errno.c index 2895d82..96fcf20 100644 --- a/src/code-from-errno.c +++ b/src/code-from-errno.c @@ -23,37 +23,11 @@ #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). */ @@ -68,13 +42,7 @@ gpg_err_code_from_errno (int err) idx = errno_to_idx (err); if (idx < 0) - { -#ifdef HAVE_W32_SYSTEM - return w32_special_errnos (err); -#else - return GPG_ERR_UNKNOWN_ERRNO; -#endif - } + return GPG_ERR_UNKNOWN_ERRNO; return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; } @@ -95,13 +63,7 @@ gpg_err_code_from_syserror (void) idx = errno_to_idx (err); if (idx < 0) - { -#ifdef HAVE_W32_SYSTEM - return w32_special_errnos (err); -#else - return GPG_ERR_UNKNOWN_ERRNO; -#endif - } + return GPG_ERR_UNKNOWN_ERRNO; return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; } diff --git a/src/mkerrcodes1.awk b/src/mkerrcodes1.awk index 3e92636..a771a73 100644 --- a/src/mkerrcodes1.awk +++ b/src/mkerrcodes1.awk @@ -70,7 +70,10 @@ header { if ($1 ~ /^[0-9]/) { print "#include <errno.h>"; - print ""; + print "#ifdef _WIN32"; + print "#include <winsock2.h>"; + print "#endif"; + print ""; header = 0; } else @@ -87,4 +90,7 @@ header { print "#ifdef " $errnoidx; print $errnoidx "\tGPG_ERR_" $errnoidx; print "#endif"; + print "#ifdef WSA" $errnoidx; + print "WSA" $errnoidx "\tGPG_ERR_" $errnoidx; + print "#endif"; } |