changeset 13778:cb2060acb34f

[gaim-migrate @ 16190] Added wrapper for send() so that errno is set correctly committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 18 May 2006 13:48:11 +0000
parents a5bfc93b5309
children 42edc3d4941d
files src/win32/libc_interface.c src/win32/libc_interface.h
diffstat 2 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/win32/libc_interface.c	Thu May 18 04:47:04 2006 +0000
+++ b/src/win32/libc_interface.c	Thu May 18 13:48:11 2006 +0000
@@ -285,20 +285,25 @@
 	}
 }
 
-int wgaim_write(int fd, const void *buf, unsigned int size) {
+int wgaim_send(int fd, const void *buf, unsigned int size, int flags) {
 	int ret;
 
-	if(wgaim_is_socket(fd)) {
-		if((ret = send(fd, buf, size, 0)) == SOCKET_ERROR) {
-			errno = WSAGetLastError();
-			if(errno == WSAEWOULDBLOCK)
-				errno = EAGAIN;
-			return -1;
-		} else {
-			/* success */
-			return ret;
-		}
-	} else
+	ret = send(fd, buf, size, flags);
+
+	if (ret == SOCKET_ERROR) {
+		errno = WSAGetLastError();
+		if(errno == WSAEWOULDBLOCK)
+			errno = EAGAIN;
+		return -1;
+	}
+	return ret;
+}
+
+int wgaim_write(int fd, const void *buf, unsigned int size) {
+
+	if(wgaim_is_socket(fd))
+		return wgaim_send(fd, buf, size, 0);
+	else
 		return write(fd, buf, size);
 }
 
--- a/src/win32/libc_interface.h	Thu May 18 04:47:04 2006 +0000
+++ b/src/win32/libc_interface.h	Thu May 18 13:48:11 2006 +0000
@@ -112,6 +112,10 @@
 #define recv(fd, buf, len, flags) \
 wgaim_recv(fd, buf, len, flags)
 
+int wgaim_send(int fd, const void *buf, unsigned int size, int flags);
+#define send(socket, buf, buflen, flags) \
+wgaim_send(socket, buf, buflen, flags)
+
 int wgaim_close(int fd);
 #define close( fd ) \
 wgaim_close( fd )