Mistake on this page? Email us
uriqueryparser.h File Reference

Provides helper functions for parsing URI query parameters. More...

Go to the source code of this file.

Functions

int parse_query_parameter_value_from_uri (const char *uri, const char *parameter_name, const char **parameter_value)
 Parse a query parameter from URI and return the size of the parameter value and a pointer to the value within the URI. More...
 
int parse_query_parameter_value_from_query (const char *query, const char *parameter_name, const char **parameter_value)
 Parse a query parameter from a query and return the size of the parameter value and a pointer to the value within the query. More...
 

Detailed Description

Provides helper functions for parsing URI query parameters.

Function Documentation

int parse_query_parameter_value_from_query ( const char *  query,
const char *  parameter_name,
const char **  parameter_value 
)

Parse a query parameter from a query and return the size of the parameter value and a pointer to the value within the query.

Example usage:

char *value_ptr = NULL;
ssize_t value_len = parse_query_parameter_value("someparameter=value&param2=second", "param2", &value_ptr);

will result in value_len = 6 and value_ptr = "second"

Parameters
queryThe query to parse.
parameter_nameThe parameter name to parse from the query.
[out]parameter_valueA pointer to the parameter value, NULL if parameter does not exist.
Returns
The size of the parameter value, -1 if parameter does not exist in the query.
int parse_query_parameter_value_from_uri ( const char *  uri,
const char *  parameter_name,
const char **  parameter_value 
)

Parse a query parameter from URI and return the size of the parameter value and a pointer to the value within the URI.

Example usage:

char *value_ptr = NULL;
ssize_t value_len = parse_query_parameter_value_from_uri("http://www.myquery.com?someparameter=value", "someparameter", &value_ptr);

will result in value_len = 5 and value_ptr = "value"

Parameters
uriThe URI to parse.
parameter_nameThe parameter name to parse from query.
[out]parameter_valueA pointer to the parameter value, NULL if parameter does not exist.
Returns
The size of the parameter value, -1 if parameter does not exist in the URI.