3 # Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
6 --- libetpan/src/Makefile.in~gnutls 2005-03-10 10:11:30.000000000 +0100
7 +++ libetpan/src/Makefile.in 2005-03-11 21:43:10.975597607 +0100
10 VERSINFO = @API_VERSION@
12 -LDFLAGS = @LIBS@ @SSLLIBS@ @LDFLAGS@ @DBLIB@
13 +LDFLAGS = @LIBS@ @SSLLIBS@ @LDFLAGS@ @DBLIB@ @GNUTLSLIBS@
15 SUBLIBS = data-types/libdata-types.la \
16 low-level/liblow-level.la \
17 --- libetpan/src/data-types/mailstream_ssl.c~gnutls 2005-03-10 10:11:30.000000000 +0100
18 +++ libetpan/src/data-types/mailstream_ssl.c 2005-03-11 21:44:56.373673788 +0100
20 /* mailstream_low, ssl */
24 #include <openssl/ssl.h>
27 +#include <gnutls/openssl.h>
29 #ifdef LIBETPAN_REENTRANT
34 static int mailstream_low_ssl_close(mailstream_low * s);
35 static ssize_t mailstream_low_ssl_read(mailstream_low * s,
36 - void * buf, size_t count);
37 + void * buf, size_t count);
38 static ssize_t mailstream_low_ssl_write(mailstream_low * s,
39 - const void * buf, size_t count);
40 + const void * buf, size_t count);
41 static void mailstream_low_ssl_free(mailstream_low * s);
42 static int mailstream_low_ssl_get_fd(mailstream_low * s);
50 #ifdef LIBETPAN_REENTRANT
51 pthread_mutex_lock(&ssl_lock);
58 #ifdef LIBETPAN_REENTRANT
59 pthread_mutex_unlock(&ssl_lock);
63 tmp_ctx = SSL_CTX_new(TLSv1_client_method());
68 ssl_conn = (SSL *) SSL_new(tmp_ctx);
73 if (SSL_set_fd(ssl_conn, fd) == 0)
78 SSL_set_read_ahead(ssl_conn, 1);
82 r = SSL_connect(ssl_conn);
87 fd_flags = fcntl(fd, F_GETFL, 0);
88 old_fd_flags = fd_flags;
90 r = fcntl(fd, F_SETFL, fd_flags);
95 ssl_data = malloc(sizeof(* ssl_data));
101 ssl_data->ssl_conn = ssl_conn;
102 ssl_data->ssl_ctx = tmp_ctx;
103 @@ -241,52 +248,101 @@
106 static ssize_t mailstream_low_ssl_read(mailstream_low * s,
107 - void * buf, size_t count)
108 + void * buf, size_t count)
110 struct mailstream_ssl_data * ssl_data;
113 ssl_data = (struct mailstream_ssl_data *) s->data;
120 struct timeval timeout;
126 + struct timeval timeout2;
127 + timeout2 = mailstream_network_delay;
129 + FD_ZERO(&fds_read);
130 + FD_SET(ssl_data->fd, &fds_read);
131 + FD_ZERO(&fds_excp);
132 + FD_SET(ssl_data->fd, &fds_excp);
133 + r = select(ssl_data->fd + 1, &fds_read, NULL, &fds_excp, &timeout2);
137 + if (FD_ISSET(ssl_data->fd, &fds_excp))
139 + if (!FD_ISSET(ssl_data->fd, &fds_read))
143 r = SSL_read(ssl_data->ssl_conn, buf, count);
150 + if (errno!=EAGAIN&&errno!=EWOULDBLOCK) {
154 ssl_r = SSL_get_error(ssl_data->ssl_conn, r);
160 case SSL_ERROR_ZERO_RETURN:
164 case SSL_ERROR_WANT_READ:
165 timeout = mailstream_network_delay;
169 FD_SET(ssl_data->fd, &fds_read);
170 r = select(ssl_data->fd + 1, &fds_read, NULL, NULL, &timeout);
183 static ssize_t mailstream_low_ssl_write(mailstream_low * s,
184 - const void * buf, size_t count)
185 + const void * buf, size_t count)
187 struct mailstream_ssl_data * ssl_data;
189 ssl_data = (struct mailstream_ssl_data *) s->data;
194 + struct timeval timeout;
197 + timeout = mailstream_network_delay;
199 + FD_ZERO(&fds_write);
200 + FD_SET(ssl_data->fd, &fds_write);
201 + FD_ZERO(&fds_excp);
202 + FD_SET(ssl_data->fd, &fds_excp);
203 + r = select(ssl_data->fd + 1, NULL, &fds_write, &fds_excp, &timeout);
206 + if (FD_ISSET(ssl_data->fd, &fds_excp))
208 + if (!FD_ISSET(ssl_data->fd, &fds_write))
212 return SSL_write(ssl_data->ssl_conn, buf, count);