diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-12-18 17:21:49 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2005-12-18 17:21:49 +0100 |
commit | 7308b63f3300d5b2a326edfde6c50a18bc05e3e5 (patch) | |
tree | 8706696e03a5602119e49bc0c370eaaf587eefc2 | |
parent | 00f434f7854d593b8a204724281ec4c794d0098c (diff) |
Fix two typos
-rw-r--r-- | doc/README | 2 | ||||
-rw-r--r-- | protocols/ssl_openssl.c | 86 |
2 files changed, 11 insertions, 77 deletions
@@ -49,7 +49,7 @@ BitlBee's only real dependency is GLib. This is available on virtually every platform. Any recent version of GLib (including 1.x versions) will work. These days, MSN Messenger clients have to connect to the MS Passport servers -through HTTPS. BitlBee can use serveral SSL libraries for this: GnuTLS, NSS +through HTTPS. BitlBee can use several SSL libraries for this: GnuTLS, NSS (which comes with Mozilla) and OpenSSL. OpenSSL is not GPL-compatible in some situations, so using GnuTLS or NSS is preferred. However, especially on *BSD, OpenSSL can be considered part of the operating system, which eliminates the diff --git a/protocols/ssl_openssl.c b/protocols/ssl_openssl.c index ae55f3f9..e62f95b9 100644 --- a/protocols/ssl_openssl.c +++ b/protocols/ssl_openssl.c @@ -4,7 +4,7 @@ * Copyright 2002-2004 Wilmer van der Gaast and others * \********************************************************************/ -/* SSL module - GnuTLS version */ +/* SSL module - OpenTLS version */ /* This program is free software; you can redistribute it and/or modify @@ -40,13 +40,11 @@ static gboolean initialized = FALSE; struct scd { - ssl_input_function func; + SslInputFunction func; gpointer data; int fd; gboolean established; - int inpa; - int lasterr; /* Necessary for SSL_get_error */ SSL *ssl; SSL_CTX *ssl_ctx; }; @@ -55,7 +53,7 @@ static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) -void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) +void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) { struct scd *conn = g_new0( struct scd, 1 ); SSL_METHOD *meth; @@ -94,45 +92,19 @@ void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data return( conn ); } -static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ); - static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) { struct scd *conn = data; if( source == -1 ) - return ssl_handshake( data, -1, cond ); + goto ssl_connected_failure; - /* Make it non-blocking at least during the handshake... */ - sock_make_nonblocking( conn->fd ); SSL_set_fd( conn->ssl, conn->fd ); - return ssl_handshake( data, source, cond ); -} - -static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ) -{ - struct scd *conn = data; - int st; - - if( conn->inpa != -1 ) - { - gaim_input_remove( conn->inpa ); - conn->inpa = -1; - } - - if( ( st = SSL_connect( conn->ssl ) ) < 0 ) - { - conn->lasterr = SSL_get_error( conn->ssl, st ); - if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE ) - goto ssl_connected_failure; - - conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data ); - return; - } + if( SSL_connect( conn->ssl ) < 0 ) + goto ssl_connected_failure; conn->established = TRUE; - sock_make_blocking( conn->fd ); /* For now... */ conn->func( conn->data, conn, cond ); return; @@ -154,57 +126,24 @@ ssl_connected_failure: int ssl_read( void *conn, char *buf, int len ) { - int st; - if( !((struct scd*)conn)->established ) - { - ssl_errno = SSL_NOHANDSHAKE; - return -1; - } - - st = SSL_read( ((struct scd*)conn)->ssl, buf, len ); + return( 0 ); - ssl_errno = SSL_OK; - if( st <= 0 ) - { - ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); - if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) - ssl_errno = SSL_AGAIN; - } - - return st; + return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) ); } int ssl_write( void *conn, const char *buf, int len ) { - int st; - if( !((struct scd*)conn)->established ) - { - ssl_errno = SSL_NOHANDSHAKE; - return -1; - } - - st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); + return( 0 ); - ssl_errno = SSL_OK; - if( st <= 0 ) - { - ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); - if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) - ssl_errno = SSL_AGAIN; - } - - return st; + return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) ); } void ssl_disconnect( void *conn_ ) { struct scd *conn = conn_; - if( conn->inpa != -1 ) - gaim_input_remove( conn->inpa ); - if( conn->established ) SSL_shutdown( conn->ssl ); @@ -219,8 +158,3 @@ int ssl_getfd( void *conn ) { return( ((struct scd*)conn)->fd ); } - -GaimInputCondition ssl_getdirection( void *conn ) -{ - return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ ); -} |