CURI
0.1
A tiny URI parser written in C
|
Parsing URIs and URI elements. More...
Data Structures | |
struct | curi_settings |
Parsing parameters. More... | |
Enumerations | |
enum | curi_status { curi_status_success = 0, curi_status_canceled, curi_status_error } |
Error codes returned from this interface. More... | |
Functions | |
void | curi_default_settings (curi_settings *settings) |
Set the given settings to their default value. More... | |
curi_status | curi_parse_full_uri_nt (const char *uri, const curi_settings *settings, void *userData) |
Parse the given NULL-terminated string as a full URI. More... | |
curi_status | curi_parse_full_uri (const char *uri, size_t len, const curi_settings *settings, void *userData) |
Parse the given string as a full URI specifying its length. More... | |
curi_status | curi_parse_path_nt (const char *path, const curi_settings *settings, void *userData) |
Parse the given NULL-terminated string as a URI path. More... | |
curi_status | curi_parse_path (const char *path, size_t len, const curi_settings *settings, void *userData) |
Parse the given string as a URI path specifying its length. More... | |
curi_status | curi_parse_query_nt (const char *query, const curi_settings *settings, void *userData) |
Parse the given NULL-terminated string as a URI query. More... | |
curi_status | curi_parse_query (const char *query, size_t len, const curi_settings *settings, void *userData) |
Parse the given string as a URI query specifying its length. More... | |
Parsing URIs and URI elements.
struct curi_settings |
Parsing parameters.
Data Fields | |
void *(* | allocate )(void *userData, size_t size) |
function used for memory allocation (default is based on malloc). More... | |
void(* | deallocate )(void *userData, void *ptr, size_t size) |
function used for memory deallocation (default is based on free). More... | |
int(* | scheme_callback )(void *userData, const char *scheme, size_t schemeLen) |
if not-NULL, called with the parsed scheme (default is NULL). More... | |
int(* | userinfo_callback )(void *userData, const char *userinfo, size_t userinfoLen) |
if not-NULL, called with the parsed userinfo (default is NULL). More... | |
int(* | host_callback )(void *userData, const char *host, size_t hostLen) |
if not-NULL, called with the parsed host (default is NULL). More... | |
int(* | portStr_callback )(void *userData, const char *portStr, size_t portStrLen) |
if not-NULL, called with the parsed port (default is NULL). More... | |
int(* | port_callback )(void *userData, unsigned int port) |
if not-NULL, called with the parsed port as a number (default is NULL). More... | |
int(* | path_callback )(void *userData, const char *path, size_t pathLen) |
if not-NULL, called with the parsed path (default is NULL). More... | |
int(* | path_segment_callback )(void *userData, const char *pathSegment, size_t pathSegmentLen) |
if not-NULL, called with the parsed path segment (default is NULL). More... | |
int(* | query_callback )(void *userData, const char *query, size_t queryLen) |
if not-NULL, called with the parsed query (default is NULL). More... | |
int(* | query_item_null_callback )(void *userData, const char *queryItemKey, size_t queryItemKeyLen) |
if not-NULL, called with each of the parsed query items having no value (default is NULL). More... | |
int(* | query_item_int_callback )(void *userData, const char *queryItemKey, size_t queryItemKeyLen, long int queryItemValue) |
if not-NULL, called with each of the parsed query items having an int value (default is NULL). More... | |
int(* | query_item_double_callback )(void *userData, const char *queryItemKey, size_t queryItemKeyLen, double queryItemValue) |
if not-NULL, called with each of the parsed query items having an double value (default is NULL). More... | |
int(* | query_item_str_callback )(void *userData, const char *queryItemKey, size_t queryItemKeyLen, const char *queryItemValue, size_t queryItemValueLen) |
if not-NULL, called with each of the parsed query items that hasn't been handled by the previous callbacks (default is NULL). More... | |
char | query_item_separator |
the character separating query items (default is '&'). More... | |
char | query_item_key_separator |
the character separating, in query items, the key from the value (default is '='). More... | |
int(* | fragment_callback )(void *userData, const char *fragment, size_t fragmentLen) |
if not-NULL, called with the parsed fragment (default is NULL). More... | |
int | url_decode |
if != 0, the string passed to the callbacks ae first url decoded, requiring the allocation of a temporary string. More... | |
void*(* curi_settings::allocate)(void *userData, size_t size) |
function used for memory allocation (default is based on malloc).
void(* curi_settings::deallocate)(void *userData, void *ptr, size_t size) |
function used for memory deallocation (default is based on free).
int(* curi_settings::fragment_callback)(void *userData, const char *fragment, size_t fragmentLen) |
if not-NULL, called with the parsed fragment (default is NULL).
int(* curi_settings::host_callback)(void *userData, const char *host, size_t hostLen) |
if not-NULL, called with the parsed host (default is NULL).
int(* curi_settings::path_callback)(void *userData, const char *path, size_t pathLen) |
if not-NULL, called with the parsed path (default is NULL).
int(* curi_settings::path_segment_callback)(void *userData, const char *pathSegment, size_t pathSegmentLen) |
if not-NULL, called with the parsed path segment (default is NULL).
int(* curi_settings::port_callback)(void *userData, unsigned int port) |
if not-NULL, called with the parsed port as a number (default is NULL).
int(* curi_settings::portStr_callback)(void *userData, const char *portStr, size_t portStrLen) |
if not-NULL, called with the parsed port (default is NULL).
int(* curi_settings::query_callback)(void *userData, const char *query, size_t queryLen) |
if not-NULL, called with the parsed query (default is NULL).
int(* curi_settings::query_item_double_callback)(void *userData, const char *queryItemKey, size_t queryItemKeyLen, double queryItemValue) |
if not-NULL, called with each of the parsed query items having an double value (default is NULL).
int(* curi_settings::query_item_int_callback)(void *userData, const char *queryItemKey, size_t queryItemKeyLen, long int queryItemValue) |
if not-NULL, called with each of the parsed query items having an int value (default is NULL).
char curi_settings::query_item_key_separator |
the character separating, in query items, the key from the value (default is '=').
int(* curi_settings::query_item_null_callback)(void *userData, const char *queryItemKey, size_t queryItemKeyLen) |
if not-NULL, called with each of the parsed query items having no value (default is NULL).
char curi_settings::query_item_separator |
the character separating query items (default is '&').
int(* curi_settings::query_item_str_callback)(void *userData, const char *queryItemKey, size_t queryItemKeyLen, const char *queryItemValue, size_t queryItemValueLen) |
if not-NULL, called with each of the parsed query items that hasn't been handled by the previous callbacks (default is NULL).
int(* curi_settings::scheme_callback)(void *userData, const char *scheme, size_t schemeLen) |
if not-NULL, called with the parsed scheme (default is NULL).
int curi_settings::url_decode |
if != 0, the string passed to the callbacks ae first url decoded, requiring the allocation of a temporary string.
int(* curi_settings::userinfo_callback)(void *userData, const char *userinfo, size_t userinfoLen) |
if not-NULL, called with the parsed userinfo (default is NULL).
enum curi_status |
void curi_default_settings | ( | curi_settings * | settings) |
Set the given settings to their default value.
curi_status curi_parse_full_uri | ( | const char * | uri, |
size_t | len, | ||
const curi_settings * | settings, | ||
void * | userData | ||
) |
Parse the given string as a full URI specifying its length.
curi_status curi_parse_full_uri_nt | ( | const char * | uri, |
const curi_settings * | settings, | ||
void * | userData | ||
) |
Parse the given NULL-terminated string as a full URI.
strlen(uri)
, it calls curi_parse_full_uri
with a length set to SIZE_MAX. curi_status curi_parse_path | ( | const char * | path, |
size_t | len, | ||
const curi_settings * | settings, | ||
void * | userData | ||
) |
Parse the given string as a URI path specifying its length.
curi_status curi_parse_path_nt | ( | const char * | path, |
const curi_settings * | settings, | ||
void * | userData | ||
) |
Parse the given NULL-terminated string as a URI path.
strlen(path)
, it calls curi_parse_path
with a length set to SIZE_MAX. curi_status curi_parse_query | ( | const char * | query, |
size_t | len, | ||
const curi_settings * | settings, | ||
void * | userData | ||
) |
Parse the given string as a URI query specifying its length.
curi_status curi_parse_query_nt | ( | const char * | query, |
const curi_settings * | settings, | ||
void * | userData | ||
) |
Parse the given NULL-terminated string as a URI query.
strlen(query)
, it calls curi_parse_query
with a length set to SIZE_MAX.