about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2012-01-28 08:59:16 -0600
committerMarco Peereboom <marco@conformal.com>2012-01-28 08:59:16 -0600
commitf7d6d6cad3ab41337d26704caafef41dee5372c4 (patch)
tree28d67036bcb818458194b0cbf7f759afd27def86
parentd771ce008b6ec459b9567c9508a292c98f39c169 (diff)
downloadxombrero-f7d6d6cad3ab41337d26704caafef41dee5372c4.tar.gz
make gnutls play nice with file descriptors, fixes windows gnutls errors
-rw-r--r--xxxterm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 5bd1b2d..974e270 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -1553,6 +1553,20 @@ done:
 	return (rv);
 }
 
+#ifdef __MINGW32__
+static ssize_t
+custom_gnutls_push(void *s, const void *buf, size_t len)
+{
+	return send((size_t)s, buf, len, 0);
+}
+
+static ssize_t
+custom_gnutls_pull(void *s, void *buf, size_t len)
+{
+	return recv((size_t)s, buf, len, 0);
+}
+#endif
+
 int
 stop_tls(gnutls_session_t gsession, gnutls_certificate_credentials_t xcred)
 {
@@ -1588,6 +1602,11 @@ start_tls(const gchar **error_str, int s, gnutls_session_t *gs,
 	gnutls_priority_set_direct(gsession, "PERFORMANCE", NULL);
 	gnutls_credentials_set(gsession, GNUTLS_CRD_CERTIFICATE, xcred);
 	gnutls_transport_set_ptr(gsession, (gnutls_transport_ptr_t)(long)s);
+#ifdef __MINGW32__
+	/* sockets on windows don't use file descriptors */
+	gnutls_transport_set_push_function(gsession, custom_gnutls_push);
+	gnutls_transport_set_pull_function(gsession, custom_gnutls_pull);
+#endif
 	if ((rv = gnutls_handshake(gsession)) < 0) {
 		snprintf(myerror, sizeof myerror,
 		    "gnutls_handshake failed %d fatal %d %s",