Loading...
Searching...
No Matches
A minimal, non-destructive URI parser

A minimal, non-destructive parser for URI references. More...

Detailed Description

A minimal, non-destructive parser for URI references.

This module acts on URI references, and thus process both relative references and URIs.

Note that fragment identifiers are not handled by the implementation.

See also
https://tools.ietf.org/html/rfc3986

Handler functions for uri_parser

Author
Cenk Gündoğan cenk..nosp@m.guen.nosp@m.dogan.nosp@m.@haw.nosp@m.-hamb.nosp@m.urg..nosp@m.de

Data Structures

struct  uri_parser_result_t
 container that holds all results More...
 
struct  uri_parser_query_param_t
 Container to represent a query parameter. More...
 

Functions

bool uri_parser_is_absolute (const char *uri, size_t uri_len)
 Checks whether uri is in absolute form.
 
bool uri_parser_is_absolute_string (const char *uri)
 Checks whether uri is in absolute form.
 
int uri_parser_process (uri_parser_result_t *result, const char *uri, size_t uri_len)
 Parse a URI reference.
 
int uri_parser_process_string (uri_parser_result_t *result, const char *uri)
 Parse a URI reference.
 
int uri_parser_split_query (const uri_parser_result_t *uri_parsed, uri_parser_query_param_t *params, size_t params_len)
 Provides a list of URI query parameters from a given URI parser result.
 

Function Documentation

◆ uri_parser_is_absolute()

bool uri_parser_is_absolute ( const char *  uri,
size_t  uri_len 
)

Checks whether uri is in absolute form.

Parameters
[in]uriURI reference to check. Must not be NULL
[in]uri_lenLength of uri
Precondition
uri != NULL
Returns
true if uri is a URI
false if uri is a relative reference

◆ uri_parser_is_absolute_string()

bool uri_parser_is_absolute_string ( const char *  uri)

Checks whether uri is in absolute form.

Parameters
[in]uriZero-terminated URI reference to check. Must not be Null
Precondition
uri != NULL
Returns
true if uri is a URI
false if uri is a relative reference

◆ uri_parser_process()

int uri_parser_process ( uri_parser_result_t result,
const char *  uri,
size_t  uri_len 
)

Parse a URI reference.

Parameters
[out]resultpointer to a container that will hold the result
[in]uriURI to parse. Must not be NULL
[in]uri_lenLength of uri
Precondition
uri != NULL
Returns
0 on success
-1 on parsing error

◆ uri_parser_process_string()

int uri_parser_process_string ( uri_parser_result_t result,
const char *  uri 
)

Parse a URI reference.

Parameters
[out]resultpointer to a container that will hold the result
[in]uriZero-terminated URI to parse. Must not be NULL
Precondition
uri != NULL
Returns
0 on success
-1 on parsing error

◆ uri_parser_split_query()

int uri_parser_split_query ( const uri_parser_result_t uri_parsed,
uri_parser_query_param_t params,
size_t  params_len 
)

Provides a list of URI query parameters from a given URI parser result.

Note
The function DOES NOT check for duplicate query parameters.
Precondition
uri_parsed != NULL
params != NULL and all its elements are set to zero.
Parameters
[in]uri_parsedA parsed URI result. Must not be NULL.
[out]paramsAn array of uri_parser_query_param_t. Must not be NULL and all zero-valued on call. Will be filled with the name-value-pairs in uri_parser_result_t::query of uri_parsed. If the number of query parameters in uri_parsed exceeds params_len, the list will be truncated and the function returns -2.
[in]params_lenThe length of params
Returns
number of filled entries in params on success. Might be 0 if uri_parser_result_t::query is NULL.
-1 on parsing error.
-2 when the number of query parameters exceeds params_len. In that case, the array is filled with the first params_len name-value-pairs in uri_parser_result_t::query of uri_parsed.