summaryrefslogtreecommitdiff
path: root/packages/libetpan/libetpan-0.36/gnutls.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packages/libetpan/libetpan-0.36/gnutls.patch')
-rw-r--r--packages/libetpan/libetpan-0.36/gnutls.patch214
1 files changed, 214 insertions, 0 deletions
diff --git a/packages/libetpan/libetpan-0.36/gnutls.patch b/packages/libetpan/libetpan-0.36/gnutls.patch
index e69de29bb2..d2ccdcf9d0 100644
--- a/packages/libetpan/libetpan-0.36/gnutls.patch
+++ b/packages/libetpan/libetpan-0.36/gnutls.patch
@@ -0,0 +1,214 @@
+
+#
+# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
+#
+
+--- libetpan/src/Makefile.in~gnutls 2005-03-10 10:11:30.000000000 +0100
++++ libetpan/src/Makefile.in 2005-03-11 21:43:10.975597607 +0100
+@@ -15,7 +15,7 @@
+
+ VERSINFO = @API_VERSION@
+ CC = @CC@
+-LDFLAGS = @LIBS@ @SSLLIBS@ @LDFLAGS@ @DBLIB@
++LDFLAGS = @LIBS@ @SSLLIBS@ @LDFLAGS@ @DBLIB@ @GNUTLSLIBS@
+
+ SUBLIBS = data-types/libdata-types.la \
+ low-level/liblow-level.la \
+--- libetpan/src/data-types/mailstream_ssl.c~gnutls 2005-03-10 10:11:30.000000000 +0100
++++ libetpan/src/data-types/mailstream_ssl.c 2005-03-11 21:44:56.373673788 +0100
+@@ -61,7 +61,12 @@
+ /* mailstream_low, ssl */
+
+ #ifdef USE_SSL
++#ifndef USE_GNUTLS
+ #include <openssl/ssl.h>
++#else
++#include <errno.h>
++#include <gnutls/openssl.h>
++#endif
+ #ifdef LIBETPAN_REENTRANT
+ #include <pthread.h>
+ #endif
+@@ -85,9 +90,9 @@
+ #ifdef USE_SSL
+ static int mailstream_low_ssl_close(mailstream_low * s);
+ static ssize_t mailstream_low_ssl_read(mailstream_low * s,
+- void * buf, size_t count);
++ void * buf, size_t count);
+ static ssize_t mailstream_low_ssl_write(mailstream_low * s,
+- const void * buf, size_t count);
++ const void * buf, size_t count);
+ static void mailstream_low_ssl_free(mailstream_low * s);
+ static int mailstream_low_ssl_get_fd(mailstream_low * s);
+
+@@ -113,10 +118,10 @@
+ SSL_CTX * tmp_ctx;
+ int fd_flags;
+ int old_fd_flags;
+-
++
+ #ifdef LIBETPAN_REENTRANT
+ pthread_mutex_lock(&ssl_lock);
+-#endif
++#endif
+ if (!ssl_init_done) {
+ SSL_library_init();
+ ssl_init_done = 1;
+@@ -124,35 +129,37 @@
+ #ifdef LIBETPAN_REENTRANT
+ pthread_mutex_unlock(&ssl_lock);
+ #endif
+-
++
+ tmp_ctx = SSL_CTX_new(TLSv1_client_method());
+ if (tmp_ctx == NULL)
+ goto err;
+-
++
+ ssl_conn = (SSL *) SSL_new(tmp_ctx);
+ if (ssl_conn == NULL)
+ goto free_ctx;
+-
++
+ if (SSL_set_fd(ssl_conn, fd) == 0)
+ goto free_ssl_conn;
+-
++
++#ifndef USE_GNUTLS
+ SSL_set_read_ahead(ssl_conn, 1);
+-
++#endif
++
+ r = SSL_connect(ssl_conn);
+ if (r <= 0)
+ goto free_ssl_conn;
+-
++
+ fd_flags = fcntl(fd, F_GETFL, 0);
+ old_fd_flags = fd_flags;
+ fd_flags |= O_NDELAY;
+ r = fcntl(fd, F_SETFL, fd_flags);
+ if (r < 0)
+ goto free_ssl_conn;
+-
++
+ ssl_data = malloc(sizeof(* ssl_data));
+ if (ssl_data == NULL)
+ goto reset_fd_flags;
+-
++
+ ssl_data->fd = fd;
+ ssl_data->ssl_conn = ssl_conn;
+ ssl_data->ssl_ctx = tmp_ctx;
+@@ -241,52 +248,101 @@
+ }
+
+ static ssize_t mailstream_low_ssl_read(mailstream_low * s,
+- void * buf, size_t count)
++ void * buf, size_t count)
+ {
+ struct mailstream_ssl_data * ssl_data;
+ int r;
+
+ ssl_data = (struct mailstream_ssl_data *) s->data;
+-
++
+ while (1) {
+ int ssl_r;
+ fd_set fds_read;
++#ifndef USE_GNUTLS
+ struct timeval timeout;
+-
++#else
++ fd_set fds_excp;
++
++ {
++ struct timeval timeout2;
++ timeout2 = mailstream_network_delay;
++
++ FD_ZERO(&fds_read);
++ FD_SET(ssl_data->fd, &fds_read);
++ FD_ZERO(&fds_excp);
++ FD_SET(ssl_data->fd, &fds_excp);
++ r = select(ssl_data->fd + 1, &fds_read, NULL, &fds_excp, &timeout2);
++ if (r==0) {
++ return -1;
++ }
++ if (FD_ISSET(ssl_data->fd, &fds_excp))
++ return -1;
++ if (!FD_ISSET(ssl_data->fd, &fds_read))
++ return 0;
++ }
++#endif
+ r = SSL_read(ssl_data->ssl_conn, buf, count);
+- if (r > 0)
++ if (r > 0) {
+ return r;
+-
++ }
++#ifdef USE_GNUTLS
++ if (errno!=EAGAIN&&errno!=EWOULDBLOCK) {
++ return r;
++ }
++#else
+ ssl_r = SSL_get_error(ssl_data->ssl_conn, r);
+ switch (ssl_r) {
+ case SSL_ERROR_NONE:
+ return r;
+-
++
+ case SSL_ERROR_ZERO_RETURN:
+ return r;
+-
++
+ case SSL_ERROR_WANT_READ:
+ timeout = mailstream_network_delay;
+-
++
+ FD_ZERO(&fds_read);
+ FD_SET(ssl_data->fd, &fds_read);
+ r = select(ssl_data->fd + 1, &fds_read, NULL, NULL, &timeout);
+ if (r == 0)
+ return -1;
+ break;
+-
++
+ default:
+ return r;
+ }
++#endif
+ }
+ }
+
+ static ssize_t mailstream_low_ssl_write(mailstream_low * s,
+- const void * buf, size_t count)
++ const void * buf, size_t count)
+ {
+ struct mailstream_ssl_data * ssl_data;
+
+ ssl_data = (struct mailstream_ssl_data *) s->data;
++#ifdef USE_GNUTLS
++ {
++ fd_set fds_write;
++ fd_set fds_excp;
++ struct timeval timeout;
++ int r;
++
++ timeout = mailstream_network_delay;
++
++ FD_ZERO(&fds_write);
++ FD_SET(ssl_data->fd, &fds_write);
++ FD_ZERO(&fds_excp);
++ FD_SET(ssl_data->fd, &fds_excp);
++ r = select(ssl_data->fd + 1, NULL, &fds_write, &fds_excp, &timeout);
++ if (r == 0)
++ return -1;
++ if (FD_ISSET(ssl_data->fd, &fds_excp))
++ return -1;
++ if (!FD_ISSET(ssl_data->fd, &fds_write))
++ return 0;
++ }
++#endif
+ return SSL_write(ssl_data->ssl_conn, buf, count);
+ }
+ #endif