diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/misc.c | 12 | ||||
| -rw-r--r-- | lib/ssl_bogus.c | 9 | ||||
| -rw-r--r-- | lib/ssl_client.h | 3 | ||||
| -rw-r--r-- | lib/ssl_gnutls.c | 11 | ||||
| -rw-r--r-- | lib/ssl_nss.c | 12 | ||||
| -rw-r--r-- | lib/ssl_openssl.c | 9 | 
6 files changed, 47 insertions, 9 deletions
| @@ -156,6 +156,7 @@ void strip_html( char *in )  	char out[strlen(in)+1];  	char *s = out, *cs;  	int i, matched; +	int taglen;  	memset( out, 0, sizeof( out ) ); @@ -172,9 +173,18 @@ void strip_html( char *in )  			while( *in && *in != '>' )  				in ++; +			taglen = in - cs - 1;   /* not <0 because the above loop runs at least once */  			if( *in )  			{ -				if( g_strncasecmp( cs+1, "br", 2) == 0 ) +				if( g_strncasecmp( cs+1, "b", taglen) == 0 ) +					*(s++) = '\x02'; +				else if( g_strncasecmp( cs+1, "/b", taglen) == 0 ) +					*(s++) = '\x02'; +				else if( g_strncasecmp( cs+1, "i", taglen) == 0 ) +					*(s++) = '\x1f'; +				else if( g_strncasecmp( cs+1, "/i", taglen) == 0 ) +					*(s++) = '\x1f'; +				else if( g_strncasecmp( cs+1, "br", taglen) == 0 )  					*(s++) = '\n';  				in ++;  			} diff --git a/lib/ssl_bogus.c b/lib/ssl_bogus.c index 9c368c66..e7966f57 100644 --- a/lib/ssl_bogus.c +++ b/lib/ssl_bogus.c @@ -27,6 +27,10 @@  int ssl_errno; +void ssl_init( void ) +{ +} +  void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )  {  	return( NULL ); @@ -65,3 +69,8 @@ int ssl_pending( void *conn )  {  	return 0;  } + +int ssl_pending( void *conn ) +{ +	return 0; +} diff --git a/lib/ssl_client.h b/lib/ssl_client.h index 0a8e82d8..08654be7 100644 --- a/lib/ssl_client.h +++ b/lib/ssl_client.h @@ -46,6 +46,9 @@ extern int ssl_errno;  typedef gboolean (*ssl_input_function)(gpointer, void*, b_input_condition); +/* Perform any global initialization the SSL library might need. */ +G_MODULE_EXPORT void ssl_init( void ); +  /* Connect to host:port, call the given function when the connection is     ready to be used for SSL traffic. This is all done asynchronously, no     blocking I/O! (Except for the DNS lookups, for now...) */ diff --git a/lib/ssl_gnutls.c b/lib/ssl_gnutls.c index 5a14b825..721137b8 100644 --- a/lib/ssl_gnutls.c +++ b/lib/ssl_gnutls.c @@ -60,6 +60,13 @@ static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition  static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); +void ssl_init( void ) +{ +	gnutls_global_init(); +	initialized = TRUE; +	atexit( gnutls_global_deinit ); +} +  void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )  {  	struct scd *conn = g_new0( struct scd, 1 ); @@ -121,9 +128,7 @@ static gboolean ssl_connected( gpointer data, gint source, b_input_condition con  	if( !initialized )  	{ -		gnutls_global_init(); -		initialized = TRUE; -		atexit( gnutls_global_deinit ); +		ssl_init();  	}  	gnutls_certificate_allocate_credentials( &conn->xcred ); diff --git a/lib/ssl_nss.c b/lib/ssl_nss.c index de6e7ec6..b0e2f9f9 100644 --- a/lib/ssl_nss.c +++ b/lib/ssl_nss.c @@ -90,6 +90,14 @@ static SECStatus nss_bad_cert (void *arg, PRFileDesc *socket)  } +void ssl_init( void ) +{ +	PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); +	NSS_NoDB_Init(NULL); +	NSS_SetDomesticPolicy(); +	initialized = TRUE; +} +  void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )  {  	struct scd *conn = g_new0( struct scd, 1 ); @@ -106,9 +114,7 @@ void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data  	if( !initialized )  	{ -		PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); -		NSS_NoDB_Init(NULL); -		NSS_SetDomesticPolicy(); +		ssl_init();  	} diff --git a/lib/ssl_openssl.c b/lib/ssl_openssl.c index 8abff390..c0105687 100644 --- a/lib/ssl_openssl.c +++ b/lib/ssl_openssl.c @@ -56,6 +56,12 @@ static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition  static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); +void ssl_init( void ) +{ +	initialized = TRUE; +	SSLeay_add_ssl_algorithms(); +} +  void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )  {  	struct scd *conn = g_new0( struct scd, 1 ); @@ -114,8 +120,7 @@ static gboolean ssl_connected( gpointer data, gint source, b_input_condition con  	if( !initialized )  	{ -		initialized = TRUE; -		SSLeay_add_ssl_algorithms(); +		ssl_init();  	}  	meth = TLSv1_client_method(); | 
