#include <cutils/bhash.h>
#include <hutils/uri.h>
Go to the source code of this file.
Define Documentation
Typedef Documentation
Function Documentation
M_INLINE const char* QUERYSTRING_find |
( |
QUERYSTRING * |
query, |
|
|
const char * |
name |
|
) |
| |
Definition at line 95 of file query.c.
{
HASH_Entry *cur;
HASHNAMEVALUE *nv;
HASH_DELETEALL( cur, &query->name_to_value )
nv = (HASHNAMEVALUE *) cur;
free( nv->name );
free( nv->value );
HASH_DELETEALL_END
HASH_free( &query->name_to_value );
return 0;
}
Definition at line 36 of file query.c.
{
char *start, *pos, *name;
int state = 0;
size_t off;
char is_escaped_char;
pos = uri->query;
if (HASH_init( &query->name_to_value, 32, 1, compare_entry, 0 ) ) {
return -1;
}
for( ; *pos != 0 ; ++pos ) {
off = pos - uri->cdata;
is_escaped_char = uri->cdata_is_escaped[ off ];
switch(state) {
case 0:
start = pos;
state = 1;
case 1:
if (is_escaped_char != 0 || *pos != '=') {
break;
}
state = 2;
case 2:
name = strdup_range(start, pos);
state = 3;
start = pos + 1;
break;
case 3:
if (is_escaped_char == 0 && *pos == '&') {
state = 0;
if (QUERYSTRING_add( query, name, strdup_range(start, pos) ) ) {
return -1;
}
}
break;
}
}
if (state <= 2) {
if (QUERYSTRING_add( query, strdup_range(start, pos), strdup("") ) ) {
return -1;
}
} else {
if (QUERYSTRING_add( query, name, strdup_range(start, pos) ) ) {
return -1;
}
}
return 0;
}