[svn] gpg-error - r215 - in trunk: . src

svn author marcus cvs at cvs.gnupg.org
Fri Jul 17 03:37:42 CEST 2009


Author: marcus
Date: 2009-07-17 03:37:42 +0200 (Fri, 17 Jul 2009)
New Revision: 215

Modified:
   trunk/ChangeLog
   trunk/README
   trunk/src/code-from-errno.c
   trunk/src/mkerrcodes1.awk
Log:
2009-07-17  Marcus Brinkmann  <marcus at g10code.de>

	* 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.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-06-23 15:04:47 UTC (rev 214)
+++ trunk/ChangeLog	2009-07-17 01:37:42 UTC (rev 215)
@@ -1,3 +1,12 @@
+2009-07-17  Marcus Brinkmann  <marcus at g10code.de>
+
+	* 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  <marcus at g10code.de>
 
 	Update to libtool 2.2.6a.

Modified: trunk/README
===================================================================
--- trunk/README	2009-06-23 15:04:47 UTC (rev 214)
+++ trunk/README	2009-07-17 01:37:42 UTC (rev 215)
@@ -74,3 +74,17 @@
 
    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).

Modified: trunk/src/code-from-errno.c
===================================================================
--- trunk/src/code-from-errno.c	2009-06-23 15:04:47 UTC (rev 214)
+++ trunk/src/code-from-errno.c	2009-07-17 01:37:42 UTC (rev 215)
@@ -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 @@
   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 @@
   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];
 }

Modified: trunk/src/mkerrcodes1.awk
===================================================================
--- trunk/src/mkerrcodes1.awk	2009-06-23 15:04:47 UTC (rev 214)
+++ trunk/src/mkerrcodes1.awk	2009-07-17 01:37:42 UTC (rev 215)
@@ -70,7 +70,10 @@
   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 @@
     print "#ifdef " $errnoidx;
     print $errnoidx "\tGPG_ERR_" $errnoidx;
     print "#endif";
+    print "#ifdef WSA" $errnoidx;
+    print "WSA" $errnoidx "\tGPG_ERR_" $errnoidx;
+    print "#endif";
 }




More information about the Gnupg-commits mailing list