diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/code-from-errno.c | 42 | ||||
-rw-r--r-- | src/mkerrcodes1.awk | 8 |
2 files changed, 9 insertions, 41 deletions
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"; } |