VLC
3.0.15
|
Functions | |
char * | vlc_uri_decode_duplicate (const char *str) |
Decodes an URI component. More... | |
char * | vlc_uri_decode (char *str) |
Decodes an URI component in place. More... | |
static bool | isurisafe (int c) |
static bool | isurisubdelim (int c) |
static bool | isurihex (int c) |
static char * | encode_URI_bytes (const char *str, size_t *restrict lenp) |
char * | vlc_uri_encode (const char *str) |
Encodes a URI component. More... | |
char * | vlc_path2uri (const char *path, const char *scheme) |
Converts local path to URL. More... | |
char * | vlc_uri2path (const char *url) |
Converts a URI to a local path. More... | |
static char * | vlc_idna_to_ascii (const char *idn) |
Converts a UTF-8 nul-terminated IDN to nul-terminated ASCII domain name. More... | |
static char * | vlc_iri2uri (const char *iri) |
static bool | vlc_uri_component_validate (const char *str, const char *extras) |
static bool | vlc_uri_host_validate (const char *str) |
static bool | vlc_uri_path_validate (const char *str) |
static int | vlc_UrlParseInner (vlc_url_t *restrict url, const char *str) |
int | vlc_UrlParse (vlc_url_t *url, const char *str) |
Parses an URI or IRI. More... | |
static char * | vlc_uri_fixup_inner (const char *str, const char *extras) |
int | vlc_UrlParseFixup (vlc_url_t *url, const char *str) |
Parses an URI or IRI and fix up the path part. More... | |
void | vlc_UrlClean (vlc_url_t *restrict url) |
static char * | vlc_uri_merge_paths (const char *base, const char *ref) |
Merge paths. More... | |
static char * | vlc_uri_remove_dot_segments (char *str) |
Remove dot segments. More... | |
char * | vlc_uri_compose (const vlc_url_t *uri) |
Composes an URI. More... | |
char * | vlc_uri_resolve (const char *base, const char *ref) |
Resolves an URI reference. More... | |
char * | vlc_uri_fixup (const char *str) |
Fixes up a URI string. More... | |
Variables | |
static const char | urihex [] = "0123456789ABCDEF" |
|
static |
References isurisafe(), likely, unlikely, and urihex.
Referenced by vlc_path2uri(), and vlc_uri_encode().
|
static |
Referenced by vlc_uri_component_validate(), and vlc_uri_fixup_inner().
|
static |
Referenced by encode_URI_bytes(), vlc_uri_component_validate(), and vlc_uri_fixup_inner().
|
static |
Referenced by vlc_uri_component_validate(), and vlc_uri_fixup_inner().
|
static |
Converts a UTF-8 nul-terminated IDN to nul-terminated ASCII domain name.
idn | UTF-8 Internationalized Domain Name to convert |
References vlc_memstream::error, p, strdup(), unlikely, and vlc_alloc().
Referenced by vlc_UrlParseInner().
|
static |
References p, unlikely, and urihex.
Referenced by vlc_UrlParseInner().
char* vlc_path2uri | ( | const char * | path, |
const char * | scheme | ||
) |
Converts local path to URL.
Builds a URL representation from a local UTF-8 null-terminated file path.
path | file path |
scheme | URI scheme to use (default is auto: "file", "fd" or "smb") |
References asprintf(), DIR_SEP, DIR_SEP_CHAR, encode_URI_bytes(), p, strdup(), unlikely, vlc_getcwd(), and vlc_path2uri().
Referenced by GetDefaultArtUri(), GetFilenames(), playlist_Export(), playlist_FindArtInCache(), playlist_Import(), playlist_SaveArt(), subtitles_Detect(), system_Configure(), system_ConfigureDbus(), and vlc_path2uri().
char* vlc_uri2path | ( | const char * | url | ) |
Converts a URI to a local path.
Builds a local path (UTF-8-encoded null-terminated string) from a URI if the URI scheme allows.
url | URI |
References asprintf(), p, strdup(), strndup(), unlikely, and vlc_uri_decode().
Referenced by get_path(), input_item_WriteMeta(), and subtitles_Detect().
|
static |
References isurihex(), isurisafe(), and isurisubdelim().
Referenced by vlc_uri_fixup(), vlc_uri_host_validate(), vlc_uri_path_validate(), and vlc_UrlParseFixup().
char* vlc_uri_compose | ( | const vlc_url_t * | ) |
Composes an URI.
Converts a decomposed/parsed URI structure (vlc_url_t) into a nul-terminated URI literal string.
See also IETF RFC3986 section 5.3 for details.
References vlc_memstream::error, vlc_url_t::i_port, vlc_url_t::psz_host, vlc_url_t::psz_option, vlc_url_t::psz_password, vlc_url_t::psz_path, vlc_url_t::psz_protocol, vlc_url_t::psz_username, vlc_memstream::stream, unlikely, vlc_memstream_close(), vlc_memstream_open(), vlc_memstream_printf(), vlc_memstream_putc(), vlc_memstream_puts(), vlc_memstream_write(), and vlc_uri_encode().
Referenced by vlc_getProxyUrl(), and vlc_uri_resolve().
char* vlc_uri_decode | ( | char * | str | ) |
Decodes an URI component in place.
Decodes one null-terminated UTF-8 URI component to aa null-terminated UTF-8 string in place.
See also vlc_uri_decode_duplicate() for the not-in-place variant.
str | null-terminated component |
Referenced by input_item_SetURI(), mrl_FragmentSplit(), vlc_uri2path(), vlc_uri_decode_duplicate(), and vlc_UrlParseInner().
char* vlc_uri_decode_duplicate | ( | const char * | str | ) |
Decodes an URI component.
See also vlc_uri_decode() for the in-place variant.
References strdup(), and vlc_uri_decode().
Referenced by find_closest_path(), and vlc_credential_store().
char* vlc_uri_encode | ( | const char * | str | ) |
Encodes a URI component.
Substitutes URI-unsafe, URI delimiters and non-ASCII characters into their URI-encoded URI-safe representation. See also IETF RFC3986 §2.
str | nul-terminated UTF-8 representation of the component. |
References encode_URI_bytes(), and likely.
Referenced by vlc_uri_compose().
char* vlc_uri_fixup | ( | const char * | ) |
Fixes up a URI string.
Attempts to convert a nul-terminated string into a syntactically valid URI. If the string is, or may be, a syntactically valid URI, an exact copy is returned. In any case, the result will only contain URI-safe and URI delimiter characters (generic delimiters or sub-delimiters) and all percent signs will be followed by two hexadecimal characters.
References strdup(), vlc_uri_component_validate(), and vlc_uri_fixup_inner().
Referenced by vlc_http_res_get_redirect().
|
static |
References isurihex(), isurisafe(), isurisubdelim(), vlc_memstream::stream, vlc_memstream_close(), vlc_memstream_open(), vlc_memstream_printf(), and vlc_memstream_putc().
Referenced by vlc_uri_fixup(), and vlc_UrlParseFixup().
|
static |
References vlc_uri_component_validate().
Referenced by vlc_UrlParseInner().
|
static |
Merge paths.
See IETF RFC3986 section 5.2.3 for details.
References asprintf(), and unlikely.
Referenced by vlc_uri_resolve().
|
static |
References vlc_uri_component_validate().
Referenced by vlc_UrlParse(), and vlc_UrlParseFixup().
|
static |
Remove dot segments.
See IETF RFC3986 section 5.2.4 for details.
References memrchr().
Referenced by vlc_uri_resolve().
char* vlc_uri_resolve | ( | const char * | base, |
const char * | ref | ||
) |
Resolves an URI reference.
Resolves an URI reference relative to a base URI. If the reference is an absolute URI, then this function simply returns a copy of the URI reference.
base | base URI (as a nul-terminated string) |
ref | URI reference (also as a nul-terminated string) |
References vlc_memstream::error, vlc_url_t::i_port, vlc_url_t::psz_host, vlc_url_t::psz_option, vlc_url_t::psz_password, vlc_url_t::psz_path, vlc_url_t::psz_protocol, vlc_url_t::psz_username, strdup(), unlikely, vlc_uri_compose(), vlc_uri_merge_paths(), vlc_uri_remove_dot_segments(), vlc_UrlClean(), and vlc_UrlParse().
Referenced by vlc_http_res_get_redirect().
void vlc_UrlClean | ( | vlc_url_t *restrict | url | ) |
Referenced by input_item_SetURI(), Open(), vlc_getProxyUrl(), vlc_http_request(), vlc_http_res_init(), vlc_https_connect_proxy(), and vlc_uri_resolve().
int vlc_UrlParse | ( | vlc_url_t * | url, |
const char * | str | ||
) |
Parses an URI or IRI.
Extracts the following parts from an URI string:
The function accepts URIs, as well as UTF-8-encoded IRIs. For IRIs, the hier part (specifically, the host name) is assumed to be an IDN and is decoded to ASCII according, so it can be used for DNS resolution. If the host is an IPv6 address literal, brackets are stripped.
Any missing part is set to nul. For historical reasons, the target structure is always initialized, even if parsing the URI string fails.
On error, errno is set to one of the following value:
url | structure of URL parts [OUT] |
str | nul-terminated URL string to split |
0 | success |
-1 | failure |
References vlc_url_t::psz_path, vlc_uri_path_validate(), and vlc_UrlParseInner().
Referenced by input_item_SetURI(), Open(), vlc_getProxyUrl(), vlc_http_request(), vlc_http_res_init(), vlc_https_connect_proxy(), and vlc_uri_resolve().
int vlc_UrlParseFixup | ( | vlc_url_t * | url, |
const char * | str | ||
) |
Parses an URI or IRI and fix up the path part.
References vlc_url_t::psz_path, vlc_url_t::psz_pathbuffer, vlc_uri_component_validate(), vlc_uri_fixup_inner(), vlc_uri_path_validate(), and vlc_UrlParseInner().
|
static |
References strdup(), unlikely, vlc_idna_to_ascii(), vlc_iri2uri(), vlc_uri_decode(), and vlc_uri_host_validate().
Referenced by vlc_UrlParse(), and vlc_UrlParseFixup().
|
static |
Referenced by encode_URI_bytes(), and vlc_iri2uri().