Data Structures | Enumerations | Functions | Variables
url.h File Reference

URL parsing. More...

Data Structures

struct  vtm_url
 

Enumerations

enum  vtm_url_scheme { VTM_URL_SCHEME_HTTPS, VTM_URL_SCHEME_HTTP }
 

Functions

VTM_API int vtm_url_parse (const char *str, struct vtm_url *url)
 
VTM_API void vtm_url_release (struct vtm_url *url)
 
VTM_API int vtm_url_encode (const char *s, void *buf, size_t len)
 
VTM_API int vtm_url_decode (const char *s, void *buf, size_t len)
 

Variables

const char * VTM_URL_SCHEMES []
 

Function Documentation

VTM_API int vtm_url_parse ( const char *  str,
struct vtm_url url 
)

Parses an URL string.

Parameters
strthe URL as NUL-terminated string
[out]urlthe url structure that is filled
Returns
VTM_OK if the URL was successfully parsed
VTM_E_INVALID_ARG if input is not a valid URL
VTM_E_NOT_SUPPRORTED if parts of the url are not supported yet, for example unknown schemes
VTM_API void vtm_url_release ( struct vtm_url url)

Releases all allocated resources of an url struct.

Parameters
urlthe url that should should be released
VTM_API int vtm_url_encode ( const char *  s,
void *  buf,
size_t  len 
)

URL encoding with percent sign.

All characters except A-Z, a-Z, 0-9 and [-._~] are replaced with the percent sign + their ASCII number.

Parameters
sthe NUL-terminated input string
[out]bufholds the encoded NUL-terminated string
lenthe length of the buffer
Returns
VTM_OK if the encoding was successful
VTM_E_MAX_REACHED if the provided buffer is too small
VTM_API int vtm_url_decode ( const char *  s,
void *  buf,
size_t  len 
)

URL decoding with percent sign.

All xx patterns are replaced with the corresponding ASCII character.

Parameters
sthe NUL-terminated input string
[out]bufholds the decoded NUL-terminated string
lenthe length of the buffer
Returns
VTM_OK if the decoding was successful
VTM_E_MAX_REACHED if the provided buffer is too small
VTM_E_INVALID_ARG if the input string was not properly encoded