[evolution-data-server/camel-socks-proxy-master] Make _set_errno_from_pr_error() public



commit 3bb7ad6c8a80fc051a9dcdd0ed452897f6caba5a
Author: Federico Mena Quintero <federico novell com>
Date:   Thu Jul 15 15:17:06 2010 -0500

    Make _set_errno_from_pr_error() public
    
    We need to use this both in the raw TCP stream and in the SSL one.
    Maybe later we can switch to full exceptions.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 camel/camel-tcp-stream-raw.c |   28 ++++++++++++++--------------
 camel/camel-tcp-stream-raw.h |    2 ++
 2 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 4b5a6fe..a6a337e 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -294,11 +294,11 @@ tcp_stream_raw_finalize (GObject *object)
 	G_OBJECT_CLASS (camel_tcp_stream_raw_parent_class)->finalize (object);
 }
 
-static void
-set_errno (gint code)
+void
+_set_errno_from_pr_error (gint pr_code)
 {
 	/* FIXME: this should handle more. */
-	switch (code) {
+	switch (pr_code) {
 	case PR_INVALID_ARGUMENT_ERROR:
 		errno = EINVAL;
 		break;
@@ -389,7 +389,7 @@ read_from_prfd (PRFileDesc *fd, gchar *buffer, gsize n, GError **error)
 		do {
 			nread = PR_Read (fd, buffer, n);
 			if (nread == -1)
-				set_errno (PR_GetError ());
+				_set_errno_from_pr_error (PR_GetError ());
 		} while (nread == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
 					 PR_GetError () == PR_IO_PENDING_ERROR ||
 					 PR_GetError () == PR_WOULD_BLOCK_ERROR));
@@ -421,7 +421,7 @@ read_from_prfd (PRFileDesc *fd, gchar *buffer, gsize n, GError **error)
 
 			res = PR_Poll(pollfds, 2, IO_TIMEOUT);
 			if (res == -1)
-				set_errno(PR_GetError());
+				_set_errno_from_pr_error (PR_GetError());
 			else if (res == 0) {
 #ifdef ETIMEDOUT
 				errno = ETIMEDOUT;
@@ -436,7 +436,7 @@ read_from_prfd (PRFileDesc *fd, gchar *buffer, gsize n, GError **error)
 				do {
 					nread = PR_Read (fd, buffer, n);
 					if (nread == -1)
-						set_errno (PR_GetError ());
+						_set_errno_from_pr_error (PR_GetError ());
 				} while (nread == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
 			}
 		} while (nread == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
@@ -488,7 +488,7 @@ write_to_prfd (PRFileDesc *fd, const gchar *buffer, gsize n, GError **error)
 			do {
 				w = PR_Write (fd, buffer + written, n - written);
 				if (w == -1)
-					set_errno (PR_GetError ());
+					_set_errno_from_pr_error (PR_GetError ());
 			} while (w == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
 					     PR_GetError () == PR_IO_PENDING_ERROR ||
 					     PR_GetError () == PR_WOULD_BLOCK_ERROR));
@@ -524,7 +524,7 @@ write_to_prfd (PRFileDesc *fd, const gchar *buffer, gsize n, GError **error)
 
 			res = PR_Poll (pollfds, 2, IO_TIMEOUT);
 			if (res == -1) {
-				set_errno(PR_GetError());
+				_set_errno_from_pr_error (PR_GetError());
 				if (PR_GetError () == PR_PENDING_INTERRUPT_ERROR)
 					w = 0;
 			} else if (res == 0) {
@@ -539,7 +539,7 @@ write_to_prfd (PRFileDesc *fd, const gchar *buffer, gsize n, GError **error)
 				do {
 					w = PR_Write (fd, buffer + written, n - written);
 					if (w == -1)
-						set_errno (PR_GetError ());
+						_set_errno_from_pr_error (PR_GetError ());
 				} while (w == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
 
 				if (w == -1) {
@@ -608,7 +608,7 @@ tcp_stream_raw_close (CamelStream *stream,
 		priv->sockfd = NULL;
 
 		if (err)
-			set_errno (PR_GetError());
+			_set_errno_from_pr_error (PR_GetError());
 		else
 			return 0;
 	}
@@ -671,7 +671,7 @@ socket_connect (struct addrinfo *host, GError *error)
 
 	fd = PR_OpenTCPSocket(netaddr.raw.family);
 	if (fd == NULL) {
-		set_errno (PR_GetError ());
+		_set_errno_from_pr_error (PR_GetError ());
 		set_g_error_from_errno (error, FALSE);
 		return NULL;
 	}
@@ -681,7 +681,7 @@ socket_connect (struct addrinfo *host, GError *error)
 	if (PR_Connect (fd, &netaddr, cancel_fd?0:CONNECT_TIMEOUT) == PR_FAILURE) {
 		gint errnosave;
 
-		set_errno (PR_GetError ());
+		_set_errno_from_pr_error (PR_GetError ());
 		if (PR_GetError () == PR_IN_PROGRESS_ERROR ||
 		    (cancel_fd && (PR_GetError () == PR_CONNECT_TIMEOUT_ERROR ||
 				   PR_GetError () == PR_IO_TIMEOUT_ERROR))) {
@@ -698,7 +698,7 @@ socket_connect (struct addrinfo *host, GError *error)
 				poll[1].out_flags = 0;
 
 				if (PR_Poll (poll, cancel_fd?2:1, CONNECT_TIMEOUT) == PR_FAILURE) {
-					set_errno (PR_GetError ());
+					_set_errno_from_pr_error (PR_GetError ());
 					goto exception;
 				}
 
@@ -708,7 +708,7 @@ socket_connect (struct addrinfo *host, GError *error)
 				}
 
 				if (PR_ConnectContinue(fd, poll[0].out_flags) == PR_FAILURE) {
-					set_errno (PR_GetError ());
+					_set_errno_from_pr_error (PR_GetError ());
 					if (PR_GetError () != PR_IN_PROGRESS_ERROR)
 						goto exception;
 				} else {
diff --git a/camel/camel-tcp-stream-raw.h b/camel/camel-tcp-stream-raw.h
index 0171e60..8ea1d79 100644
--- a/camel/camel-tcp-stream-raw.h
+++ b/camel/camel-tcp-stream-raw.h
@@ -68,6 +68,8 @@ GType camel_tcp_stream_raw_get_type (void);
 /* public methods */
 CamelStream *camel_tcp_stream_raw_new (void);
 
+void _set_errno_from_pr_error (gint pr_code);
+
 G_END_DECLS
 
 #endif /* CAMEL_TCP_STREAM_RAW_H */



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