X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fnetwork.c;h=c85ea4fd07133a727bbd9ad45f112e164e68ea1f;hb=a40508f4bb841bba5a1a33bb2d74cf8d8a68ba08;hp=2520000b9d926664b30a4dac7086b20de06e70bd;hpb=eaca75aa6c133cc6ff3d707f7ae8dbfbe51a6d2a;p=dockapps%2Fwmnotify.git diff --git a/src/network.c b/src/network.c index 2520000..c85ea4f 100644 --- a/src/network.c +++ b/src/network.c @@ -30,6 +30,11 @@ #define RECV_FLAGS 0 +/* Common buffers for IMAP4 and POP3. */ +char tx_buffer[WMNOTIFY_BUFSIZE + 1]; +char rx_buffer[WMNOTIFY_BUFSIZE + 1]; + + int SocketOpen( char *server_name, int port ) { @@ -190,12 +195,28 @@ WmnotifyGetResponse( char *buffer, int max_size ) #if HAVE_SSL if( wmnotify_infos.use_ssl == TRUE ) { len = SSL_read( ssl_infos.ssl, buffer, max_size ); /* Get reply & decrypt */ - if( len <= 0 ) { - SSL_get_error( ssl_infos.ssl, len ); - len = -1; + switch( SSL_get_error( ssl_infos.ssl, len ) ) { + case SSL_ERROR_NONE: + /* Success. */ + break; + case SSL_ERROR_ZERO_RETURN: + fprintf( stderr, "%s: SSL_read() connection closed.\n", PACKAGE ); + break; + case SSL_ERROR_SYSCALL: + fprintf( stderr, "%s: SSL_read() I/O error.\n", PACKAGE ); + goto ssl_error; + case SSL_ERROR_SSL: + fprintf( stderr, "%s: SSL_read() protocol error.\n", PACKAGE ); + goto ssl_error; + default: + fprintf( stderr, "%s: SSL_read() error.\n", PACKAGE ); + goto ssl_error; } - + return len; + + ssl_error: + return -1; } #endif /* HAVE_SSL */