Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/ssl_gnutls.c

    r701acdd4 ra03a9f3  
    3838struct scd
    3939{
    40         SslInputFunction func;
     40        ssl_input_function func;
    4141        gpointer data;
    4242        int fd;
     
    5151
    5252
    53 void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data )
     53void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
    5454{
    5555        struct scd *conn = g_new0( struct scd, 1 );
     
    111111       
    112112        if( conn->inpa != -1 )
     113        {
    113114                gaim_input_remove( conn->inpa );
     115                conn->inpa = -1;
     116        }
    114117       
    115118        if( ( st = gnutls_handshake( conn->session ) ) < 0 )
     
    117120                if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED )
    118121                {
    119                         conn->inpa = gaim_input_add( conn->fd,
    120                                                      gnutls_record_get_direction( conn->session ) ?
    121                                                          GAIM_INPUT_WRITE : GAIM_INPUT_READ,
     122                        conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ),
    122123                                                     ssl_handshake, data );
    123124                }
     
    145146int ssl_read( void *conn, char *buf, int len )
    146147{
     148        int st;
     149       
    147150        if( !((struct scd*)conn)->established )
    148151        {
     
    151154        }
    152155       
    153         return( gnutls_record_recv( ((struct scd*)conn)->session, buf, len ) );
    154        
     156        st = gnutls_record_recv( ((struct scd*)conn)->session, buf, len );
     157       
     158        ssl_errno = SSL_OK;
     159        if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED )
     160                ssl_errno = SSL_AGAIN;
     161       
     162        return st;
    155163}
    156164
    157165int ssl_write( void *conn, const char *buf, int len )
    158166{
     167        int st;
     168       
    159169        if( !((struct scd*)conn)->established )
    160170        {
     
    163173        }
    164174       
    165         return( gnutls_record_send( ((struct scd*)conn)->session, buf, len ) );
     175        st = gnutls_record_send( ((struct scd*)conn)->session, buf, len );
     176       
     177        ssl_errno = SSL_OK;
     178        if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED )
     179                ssl_errno = SSL_AGAIN;
     180       
     181        return st;
    166182}
    167183
     
    169185{
    170186        struct scd *conn = conn_;
     187       
     188        if( conn->inpa != -1 )
     189                gaim_input_remove( conn->inpa );
    171190       
    172191        if( conn->established )
     
    184203        return( ((struct scd*)conn)->fd );
    185204}
     205
     206GaimInputCondition ssl_getdirection( void *conn )
     207{
     208        return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ?
     209                GAIM_INPUT_WRITE : GAIM_INPUT_READ );
     210}
Note: See TracChangeset for help on using the changeset viewer.