evolution-exchange r1636 - in trunk: . camel



Author: tml
Date: Thu May  8 00:50:12 2008
New Revision: 1636
URL: http://svn.gnome.org/viewvc/evolution-exchange?rev=1636&view=rev

Log:
2008-05-08  Tor Lillqvist  <tml novell com>

	* camel/camel-stub-marshal.c: Use closesocket() instead of close()
	for sockets on Windows. Use camel_read_socket() and
	camel_write_socket() instead of camel_read() and camel_write().



Modified:
   trunk/ChangeLog
   trunk/camel/camel-stub-marshal.c

Modified: trunk/camel/camel-stub-marshal.c
==============================================================================
--- trunk/camel/camel-stub-marshal.c	(original)
+++ trunk/camel/camel-stub-marshal.c	Thu May  8 00:50:12 2008
@@ -27,6 +27,20 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+
+#include <glib.h>
+
+#ifndef G_OS_WIN32
+#define CLOSESOCKET(s) close (s)
+#else
+#define CLOSESOCKET(s) closesocket (s)
+#include <winsock2.h>
+/* Note: pthread.h from pthreads-win32 also defines ETIMEDOUT (!), as
+ * this same value.
+ */
+#define ETIMEDOUT WSAETIMEDOUT
+#endif
+
 #include <camel/camel-file-utils.h>
 
 #include "camel-stub-marshal.h"
@@ -77,7 +91,7 @@
 void
 camel_stub_marshal_free (CamelStubMarshal *marshal)
 {
-	close (marshal->fd);
+	CLOSESOCKET (marshal->fd);
 	g_byte_array_free (marshal->out, TRUE);
 	g_byte_array_free (marshal->in, TRUE);
 	g_free (marshal);
@@ -90,7 +104,7 @@
 	ssize_t n;
 
 	do {
-		if ((n = camel_read (marshal->fd, buf + nread, len - nread)) <= 0) {
+		if ((n = camel_read_socket (marshal->fd, buf + nread, len - nread)) <= 0) {
 			if (errno != ETIMEDOUT)
 				break;
 			else
@@ -100,7 +114,7 @@
 	} while (nread < len);
 
 	if (nread < len) {
-		close (marshal->fd);
+		CLOSESOCKET (marshal->fd);
 		marshal->fd = -1;
 		return FALSE;
 	}
@@ -452,8 +466,8 @@
 	marshal->out->data[2] = (left >> 16) & 0xFF;
 	marshal->out->data[3] = (left >> 24) & 0xFF;
 
-	if (camel_write (marshal->fd, (char *) marshal->out->data, marshal->out->len) == -1) {
-		close (marshal->fd);
+	if (camel_write_socket (marshal->fd, (char *) marshal->out->data, marshal->out->len) == -1) {
+		CLOSESOCKET (marshal->fd);
 		marshal->fd = -1;
 		return -1;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]