summaryrefslogtreecommitdiff
path: root/scan_urlencoded_query.c
diff options
context:
space:
mode:
Diffstat (limited to 'scan_urlencoded_query.c')
-rw-r--r--scan_urlencoded_query.c24
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
59size_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}