Go to the source code of this file.
Data Structures | |
struct | GNUNET_Uri |
Copyright (C) 2016 Jack Engqvist Johansson. More... | |
struct | GNUNET_UriParam |
Functions | |
int | GNUNET_uri_parse (struct GNUNET_Uri *url, char *url_str) |
Parse a URL to a struct. More... | |
int | GNUNET_uri_split_path (char *path, char **parts, int max_parts) |
Split a path into several strings. More... | |
int | GNUNET_uri_parse_query (char *query, char delimiter, struct GNUNET_UriParam *params, int max_params) |
Parse a query string into a key/value struct. More... | |
int GNUNET_uri_parse | ( | struct GNUNET_Uri * | url, |
char * | u | ||
) |
Parse a URL to a struct.
The URL string should be in one of the following formats:
Absolute URL: scheme ":" [ "//" ] [ username ":" password "@" ] host [ ":" port ] [ "/" ] [ path ] [ "?" query ] [ "#" fragment ]
Relative URL: path [ "?" query ] [ "#" fragment ]
The following parts will be parsed to the corresponding struct member.
*url: a pointer to the struct where to store the parsed values. *url_str: a pointer to the url to be parsed (null terminated). The string will be modified.
Returns 0 on success, otherwise -1.
Definition at line 160 of file uri.c.
References find_fragment(), find_path(), find_query(), GNUNET_Uri::fragment, GNUNET_Uri::host, is_relative(), natoi(), parse_scheme(), GNUNET_Uri::password, GNUNET_Uri::path, GNUNET_Uri::port, GNUNET_Uri::query, GNUNET_Uri::scheme, u, and GNUNET_Uri::username.
int GNUNET_uri_split_path | ( | char * | path, |
char ** | parts, | ||
int | max_parts | ||
) |
Split a path into several strings.
No data is copied, the slashed are used as null terminators and then pointers to each path part will be stored in **parts. Double slashes will be treated as one.
*path: the path to split. The string will be modified. **parts: a pointer to an array of (char *) where to store the result. max_parts: max number of parts to parse.
Returns the number of parsed items. -1 on error.
Definition at line 261 of file uri.c.
int GNUNET_uri_parse_query | ( | char * | query, |
char | delimiter, | ||
struct GNUNET_UriParam * | params, | ||
int | max_params | ||
) |
Parse a query string into a key/value struct.
The query string should be a null terminated string of parameters separated by a delimiter. Each parameter are checked for the equal sign character. If it appears in the parameter, it will be used as a null terminator and the part that comes after it will be the value of the parameter.
No data are copied, the equal sign and delimiters are used as null terminators and then pointers to each parameter key and value will be stored in the yuarel_param struct.
*query: the query string to parse. The string will be modified. delimiter: the character that separates the key/value pairs from each other. *params: an array of (struct yuarel_param) where to store the result. max_values: max number of parameters to parse.
Returns the number of parsed items. -1 on error.
Definition at line 313 of file uri.c.
References key, GNUNET_UriParam::key, and GNUNET_UriParam::val.