diff options
author | erdgeist <> | 2007-01-03 05:11:48 +0000 |
---|---|---|
committer | erdgeist <> | 2007-01-03 05:11:48 +0000 |
commit | e0a9c2a4aa4fc6b648ae20071c35797c4a103e42 (patch) | |
tree | 246048aacb395db5c747fc4da260d6abf1f9b99f /scan_urlencoded_query.c | |
parent | f40b373c3b289687872269e4b931ada7044dc0d2 (diff) |
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.
Diffstat (limited to 'scan_urlencoded_query.c')
-rw-r--r-- | scan_urlencoded_query.c | 24 |
1 files changed, 21 insertions, 3 deletions
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) { | |||
18 | unsigned char *d = (unsigned char*)deststring; | 18 | unsigned char *d = (unsigned char*)deststring; |
19 | register unsigned char b, c; | 19 | register unsigned char b, c; |
20 | 20 | ||
21 | while ( is_unreserved( c = *s++) ) { | 21 | while( is_unreserved( c = *s++) ) { |
22 | if (c=='%') { | 22 | if( c=='%') { |
23 | if( ( c = scan_fromhex(*s++) ) == 0xff ) return -1; | 23 | if( ( c = scan_fromhex(*s++) ) == 0xff ) return -1; |
24 | if( ( b = scan_fromhex(*s++) ) == 0xff ) return -1; | 24 | if( ( b = scan_fromhex(*s++) ) == 0xff ) return -1; |
25 | c=(c<<4)|b; | 25 | c=(c<<4)|b; |
26 | } | 26 | } |
27 | if(d) *d++ = c; | 27 | if( d ) *d++ = c; |
28 | } | 28 | } |
29 | 29 | ||
30 | switch( c ) { | 30 | switch( c ) { |
@@ -55,3 +55,21 @@ size_t scan_fixed_int( char *data, size_t len, int *tmp ) { | |||
55 | while( (len > 0) && (*data >= '0') && (*data <= '9') ) { --len; *tmp = 10**tmp + *data++-'0'; } | 55 | while( (len > 0) && (*data >= '0') && (*data <= '9') ) { --len; *tmp = 10**tmp + *data++-'0'; } |
56 | return len; | 56 | return len; |
57 | } | 57 | } |
58 | |||
59 | size_t scan_fixed_ip( char *data, size_t len, unsigned char ip[4] ) { | ||
60 | int u, i; | ||
61 | |||
62 | for( i=0; i<4; ++i ) { | ||
63 | register unsigned int j; | ||
64 | j = scan_fixed_int( data, len, &u ); | ||
65 | if( j == len ) return len; | ||
66 | ip[i] = u; | ||
67 | data += len - j; | ||
68 | len = j; | ||
69 | if ( i<3 ) { | ||
70 | if( !len || *data != '.') return -1; | ||
71 | --len; ++data; | ||
72 | } | ||
73 | } | ||
74 | return len; | ||
75 | } | ||