71 |
#include <sys/socket.h> |
#include <sys/socket.h> |
72 |
#include <netinet/in.h> |
#include <netinet/in.h> |
73 |
|
|
74 |
#if defined(HAVE_LIBGCRYPT) && defined(HAVE_LIBGNUTLS) && defined(HAVE_GNUTLS_GNUTLS_H) |
#if defined(USE_GNUTLS) && defined(HAVE_GNUTLS_GNUTLS_H) |
|
# define HAVE_GNUTLS |
|
|
#endif |
|
|
#if defined(USE_GNUTLS) && defined(HAVE_GNUTLS) |
|
75 |
# include <gnutls/gnutls.h> |
# include <gnutls/gnutls.h> |
76 |
# define HAVE_TLS |
# define HAVE_TLS |
77 |
#endif /* USE_GNUTLS and HAVE_GNUTLS */ |
#endif /* USE_GNUTLS and HAVE_GNUTLS_GNUTLS_H */ |
78 |
|
|
79 |
FILE *diag = NULL; /* diagnostic output */ |
FILE *diag = NULL; /* diagnostic output */ |
80 |
int port = 0; /* Port number (for smtp mode) */ |
int port = 0; /* Port number (for smtp mode) */ |
305 |
{ |
{ |
306 |
int rc; |
int rc; |
307 |
do { |
do { |
308 |
rc = read(fd, buf, size); |
rc = read((int) fd, buf, size); |
309 |
} while (rc == -1 && errno == EAGAIN); |
} while (rc == -1 && errno == EAGAIN); |
310 |
return rc; |
return rc; |
311 |
} |
} |
315 |
{ |
{ |
316 |
int rc; |
int rc; |
317 |
do { |
do { |
318 |
rc = write(fd, buf, size); |
rc = write((int) fd, buf, size); |
319 |
} while (rc == -1 && errno == EAGAIN); |
} while (rc == -1 && errno == EAGAIN); |
320 |
return rc; |
return rc; |
321 |
} |
} |
379 |
gnutls_transport_set_pull_function(session, _tls_fd_pull); |
gnutls_transport_set_pull_function(session, _tls_fd_pull); |
380 |
gnutls_transport_set_push_function(session, _tls_fd_push); |
gnutls_transport_set_push_function(session, _tls_fd_push); |
381 |
|
|
382 |
gnutls_transport_set_ptr2(session, (int)in, (int)out); |
gnutls_transport_set_ptr2(session, |
383 |
|
(gnutls_transport_ptr)in, |
384 |
|
(gnutls_transport_ptr)out); |
385 |
rc = gnutls_handshake(session); |
rc = gnutls_handshake(session); |
386 |
if (rc < 0) { |
if (rc < 0) { |
387 |
gnutls_deinit(session); |
gnutls_deinit(session); |