[svn] Clean up prototypes and definitions of ssl_init and ssl_connect.

Don't include SSL headers in retr.c.
This commit is contained in:
hniksic 2005-04-11 07:33:36 -07:00
parent 364dc617a4
commit 0e3c6ed569
4 changed files with 29 additions and 17 deletions

View File

@ -1,3 +1,17 @@
2005-04-11 Hrvoje Niksic <hniksic@xemacs.org>
* gen_sslfunc.c (ssl_print_errors): Made static.
(ssl_print_errors): Eliminate potentially dangerous fixed-size
error buffer. Passing NULL to ERR_error_string causes it to use
its own static buffer, which is fine for our purposes.
* gen_sslfunc.c: Include gen_sslfunc.h. Make the declarations of
ssl_init and ssl_conect match the actual definitions.
(ssl_connect): Simply return a boolean, the SSL context is no
longer useful as a return value.
* retr.c: Don't include SSL headers; we don't need them.
2005-04-11 Hrvoje Niksic <hniksic@xemacs.org> 2005-04-11 Hrvoje Niksic <hniksic@xemacs.org>
* config-post.h: Don't define _VA_LIST under Solaris; it breaks * config-post.h: Don't define _VA_LIST under Solaris; it breaks

View File

@ -53,6 +53,7 @@ so, delete this exception statement from your version. */
#include "utils.h" #include "utils.h"
#include "connect.h" #include "connect.h"
#include "url.h" #include "url.h"
#include "gen_sslfunc.h"
#ifndef errno #ifndef errno
extern int errno; extern int errno;
@ -138,15 +139,12 @@ verify_callback (int ok, X509_STORE_CTX *ctx)
/* Print SSL errors. */ /* Print SSL errors. */
void static void
ssl_print_errors (void) ssl_print_errors (void)
{ {
unsigned long curerr = 0; unsigned long curerr = 0;
char errbuff[1024];
xzero (errbuff);
while ((curerr = ERR_get_error ()) != 0) while ((curerr = ERR_get_error ()) != 0)
logprintf (LOG_NOTQUIET, "OpenSSL: %s\n", logprintf (LOG_NOTQUIET, "OpenSSL: %s\n", ERR_error_string (curerr, NULL));
ERR_error_string (curerr, errbuff));
} }
/* Creates a SSL Context and sets some defaults for it */ /* Creates a SSL Context and sets some defaults for it */
@ -329,9 +327,14 @@ ssl_close (int fd, void *ctx)
DEBUGP (("Closed %d/SSL 0x%0lx\n", fd, (unsigned long) ssl)); DEBUGP (("Closed %d/SSL 0x%0lx\n", fd, (unsigned long) ssl));
} }
/* Sets up a SSL structure and performs the handshake on fd. */ /* Sets up a SSL structure and performs the handshake on fd. The
resulting SSL structure is registered with the file descriptor FD
using fd_register_transport. That way subsequent calls to xread,
xwrite, etc., will use the appropriate SSL functions.
SSL * Returns 1 on success, 0 on failure. */
int
ssl_connect (int fd) ssl_connect (int fd)
{ {
SSL *ssl; SSL *ssl;
@ -352,12 +355,13 @@ ssl_connect (int fd)
friends and not care what happens underneath. */ friends and not care what happens underneath. */
fd_register_transport (fd, ssl_read, ssl_write, ssl_poll, ssl_peek, fd_register_transport (fd, ssl_read, ssl_write, ssl_poll, ssl_peek,
ssl_close, ssl); ssl_close, ssl);
DEBUGP (("Connected %d to SSL 0x%0lx\n", fd, (unsigned long) ssl)); DEBUGP (("Connected %d to SSL 0x%0*lx\n", fd, 2 * sizeof (void *),
return ssl; (unsigned long) ssl));
return 1;
err: err:
ssl_print_errors (); ssl_print_errors ();
if (ssl) if (ssl)
SSL_free (ssl); SSL_free (ssl);
return NULL; return 0;
} }

View File

@ -31,9 +31,7 @@ so, delete this exception statement from your version. */
#ifndef GEN_SSLFUNC_H #ifndef GEN_SSLFUNC_H
#define GEN_SSLFUNC_H #define GEN_SSLFUNC_H
int ssl_init PARAMS ((void)); uerr_t ssl_init PARAMS ((void));
int ssl_connect PARAMS ((int)); int ssl_connect PARAMS ((int));
int ssl_print_error PARAMS ((void));
#endif /* GEN_SSLFUNC_H */ #endif /* GEN_SSLFUNC_H */

View File

@ -56,10 +56,6 @@ so, delete this exception statement from your version. */
#include "convert.h" #include "convert.h"
#include "ptimer.h" #include "ptimer.h"
#ifdef HAVE_SSL
# include "gen_sslfunc.h" /* for ssl_iread */
#endif
#ifndef errno #ifndef errno
extern int errno; extern int errno;
#endif #endif