From 6cac643f6933e431b90fcb937dec505f989e6a53 Mon Sep 17 00:00:00 2001 From: ulim Date: Mon, 14 Apr 2008 14:59:15 +0200 Subject: more verbose error logging --- dcc.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'dcc.c') diff --git a/dcc.c b/dcc.c index 2fa3f745..fa5a0f76 100644 --- a/dcc.c +++ b/dcc.c @@ -583,11 +583,17 @@ file_transfer_t *dcc_request( struct im_connection *ic, char *line ) regex_t re; file_transfer_t *ft; dcc_file_transfer_t *df; - - if( regcomp( &re, pattern, REG_EXTENDED ) ) - return NULL; - if( regexec( &re, line, 9, pmatch, 0 ) ) + char errbuf[256]; + int regerrcode, gret; + + if( ( regerrcode = regcomp( &re, pattern, REG_EXTENDED ) ) || + ( regerrcode = regexec( &re, line, 9, pmatch, 0 ) ) ) { + regerror( regerrcode,&re,errbuf,sizeof( errbuf ) ); + imcb_log( ic, + "DCC: error parsing 'DCC SEND': %s, line: %s", + errbuf, line ); return NULL; + } if( ( pmatch[1].rm_so > 0 ) && ( pmatch[4].rm_so > 0 ) && @@ -615,7 +621,7 @@ file_transfer_t *dcc_request( struct im_connection *ic, char *line ) /* number means ipv4, something else means ipv6 */ if ( pmatch[5].rm_so > 0 ) { - struct in_addr ipaddr = { htonl( atoi( input + pmatch[5].rm_so ) ) }; + struct in_addr ipaddr = { .s_addr = htonl( atoi( input + pmatch[5].rm_so ) ) }; host = inet_ntoa( ipaddr ); } else { @@ -630,9 +636,13 @@ file_transfer_t *dcc_request( struct im_connection *ic, char *line ) filesize = atoll( input + pmatch[8].rm_so ); memset( &hints, 0, sizeof ( struct addrinfo ) ); - if ( getaddrinfo( host, port, &hints, &rp ) ) + if ( ( gret = getaddrinfo( host, port, &hints, &rp ) ) ) { g_free( input ); + imcb_log( ic, "DCC: getaddrinfo() failed with %s " + "when parsing incoming 'DCC SEND': " + "host %s, port %s", + gai_strerror( gret ), host, port ); return NULL; } @@ -649,6 +659,8 @@ file_transfer_t *dcc_request( struct im_connection *ic, char *line ) return ft; } + imcb_log( ic, "DCC: couldnt parse 'DCC SEND' line: %s", line ); + return NULL; } -- cgit v1.2.3