From e0a9c2a4aa4fc6b648ae20071c35797c4a103e42 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Wed, 3 Jan 2007 05:11:48 +0000 Subject: Added option to get ip from query string + parser, fixed two bugs concerning grow/shrink of vectors. Now cleans up a torrent BEFORE trying to remove a peer -> this may remove peer already and must be done anyway. --- scan_urlencoded_query.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'scan_urlencoded_query.c') diff --git a/scan_urlencoded_query.c b/scan_urlencoded_query.c index 7bd5ee1..a21ec04 100644 --- a/scan_urlencoded_query.c +++ b/scan_urlencoded_query.c @@ -18,13 +18,13 @@ size_t scan_urlencoded_query(char **string, char *deststring, int flags) { unsigned char *d = (unsigned char*)deststring; register unsigned char b, c; - while ( is_unreserved( c = *s++) ) { - if (c=='%') { + while( is_unreserved( c = *s++) ) { + if( c=='%') { if( ( c = scan_fromhex(*s++) ) == 0xff ) return -1; if( ( b = scan_fromhex(*s++) ) == 0xff ) return -1; c=(c<<4)|b; } - if(d) *d++ = c; + if( d ) *d++ = c; } switch( c ) { @@ -55,3 +55,21 @@ size_t scan_fixed_int( char *data, size_t len, int *tmp ) { while( (len > 0) && (*data >= '0') && (*data <= '9') ) { --len; *tmp = 10**tmp + *data++-'0'; } return len; } + +size_t scan_fixed_ip( char *data, size_t len, unsigned char ip[4] ) { + int u, i; + + for( i=0; i<4; ++i ) { + register unsigned int j; + j = scan_fixed_int( data, len, &u ); + if( j == len ) return len; + ip[i] = u; + data += len - j; + len = j; + if ( i<3 ) { + if( !len || *data != '.') return -1; + --len; ++data; + } + } + return len; +} -- cgit v1.2.3