[svn] w32pth - r20 - trunk
svn author marcus
cvs at cvs.gnupg.org
Fri Feb 15 20:05:24 CET 2008
Author: marcus
Date: 2008-02-15 20:05:23 +0100 (Fri, 15 Feb 2008)
New Revision: 20
Modified:
trunk/ChangeLog
trunk/w32-pth.c
Log:
2008-02-15 Marcus Brinkmann <marcus at g10code.de>
* w32-pth.c (map_wsa_to_errno, map_w32_to_errno): New functions.
(do_pth_read, do_pth_write): Use these to set errno.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-02-13 12:53:28 UTC (rev 19)
+++ trunk/ChangeLog 2008-02-15 19:05:23 UTC (rev 20)
@@ -1,3 +1,8 @@
+2008-02-15 Marcus Brinkmann <marcus at g10code.de>
+
+ * w32-pth.c (map_wsa_to_errno, map_w32_to_errno): New functions.
+ (do_pth_read, do_pth_write): Use these to set errno.
+
2008-02-12 Marcus Brinkmann <marcus at g10code.de>
* Makefile.in: Removed.
Modified: trunk/w32-pth.c
===================================================================
--- trunk/w32-pth.c 2008-02-13 12:53:28 UTC (rev 19)
+++ trunk/w32-pth.c 2008-02-15 19:05:23 UTC (rev 20)
@@ -175,6 +175,77 @@
}
+int
+map_wsa_to_errno (long wsa_err)
+{
+ switch (wsa_err)
+ {
+ case 0:
+ return 0;
+
+ case WSAEINTR:
+ return EINTR;
+
+ case WSAEBADF:
+ return EBADF;
+
+ case WSAEACCES:
+ return EACCES;
+
+ case WSAEFAULT:
+ return EFAULT;
+
+ case WSAEINVAL:
+ return EINVAL;
+
+ case WSAEMFILE:
+ return EMFILE;
+
+ case WSAEWOULDBLOCK:
+ return EAGAIN;
+
+ case WSAENAMETOOLONG:
+ return ENAMETOOLONG;
+
+ case WSAENOTEMPTY:
+ return ENOTEMPTY;
+
+ default:
+ return EIO;
+ }
+}
+
+
+int
+map_w32_to_errno (DWORD w32_err)
+{
+ switch (w32_err)
+ {
+ case 0:
+ return 0;
+
+ case ERROR_FILE_NOT_FOUND:
+ return ENOENT;
+
+ case ERROR_PATH_NOT_FOUND:
+ return ENOENT;
+
+ case ERROR_ACCESS_DENIED:
+ return EPERM;
+
+ case ERROR_INVALID_HANDLE:
+ case ERROR_INVALID_BLOCK:
+ return EINVAL;
+
+ case ERROR_NOT_ENOUGH_MEMORY:
+ return ENOMEM;
+
+ default:
+ return EIO;
+ }
+}
+
+
static int
fd_is_socket (int fd)
{
@@ -462,11 +533,14 @@
log_get_prefix (NULL), fd,
w32_strerror (strerr, sizeof strerr));
n = -1;
+ errno = map_w32_to_errno (GetLastError ());
}
else
n = (int) nread;
}
}
+ else if (n == -1)
+ errno = map_wsa_to_errno (WSAGetLastError ());
return n;
}
@@ -563,11 +637,14 @@
log_get_prefix (NULL), fd,
w32_strerror (strerr, sizeof strerr));
n = -1;
+ errno = map_w32_to_errno (GetLastError ());
}
else
n = (int) nwrite;
}
}
+ else if (n == -1)
+ errno = map_wsa_to_errno (WSAGetLastError ());
return n;
}
More information about the Gnupg-commits
mailing list