Changeset 0fd8559 for lib/ssl_gnutls.c
- Timestamp:
- 2007-02-18T17:48:04Z (17 years ago)
- Branches:
- master
- Children:
- 0f4c1bb5
- Parents:
- 8de63c3 (diff), c7d0f41 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/ssl_gnutls.c
r8de63c3 r0fd8559 49 49 50 50 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ); 51 static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition cond ); 52 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 51 53 52 54 … … 63 65 { 64 66 g_free( conn ); 65 return( NULL ); 67 return NULL; 68 } 69 70 return conn; 71 } 72 73 void *ssl_starttls( int fd, ssl_input_function func, gpointer data ) 74 { 75 struct scd *conn = g_new0( struct scd, 1 ); 76 77 conn->fd = fd; 78 conn->func = func; 79 conn->data = data; 80 conn->inpa = -1; 81 82 /* This function should be called via a (short) timeout instead of 83 directly from here, because these SSL calls are *supposed* to be 84 *completely* asynchronous and not ready yet when this function 85 (or *_connect, for examle) returns. Also, errors are reported via 86 the callback function, not via this function's return value. 87 88 In short, doing things like this makes the rest of the code a lot 89 simpler. */ 90 91 b_timeout_add( 1, ssl_starttls_real, conn ); 92 93 return conn; 94 } 95 96 static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition cond ) 97 { 98 struct scd *conn = data; 99 100 return ssl_connected( conn, conn->fd, GAIM_INPUT_WRITE ); 101 } 102 103 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ) 104 { 105 struct scd *conn = data; 106 107 if( source == -1 ) 108 { 109 conn->func( conn->data, NULL, cond ); 110 g_free( conn ); 111 return FALSE; 66 112 } 67 113 … … 77 123 gnutls_set_default_priority( conn->session ); 78 124 gnutls_credentials_set( conn->session, GNUTLS_CRD_CERTIFICATE, conn->xcred ); 79 80 return( conn );81 }82 83 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );84 85 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond )86 {87 struct scd *conn = data;88 89 if( source == -1 )90 {91 conn->func( conn->data, NULL, cond );92 93 gnutls_deinit( conn->session );94 gnutls_certificate_free_credentials( conn->xcred );95 96 g_free( conn );97 98 return FALSE;99 }100 125 101 126 sock_make_nonblocking( conn->fd );
Note: See TracChangeset
for help on using the changeset viewer.