VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
url.c File Reference
Include dependency graph for url.c:

Macros

#define SMB_SCHEME   "smb"

Functions

char * decode_URI_duplicate (const char *str)
 Decodes an encoded URI component.
char * decode_URI (char *str)
 Decodes an encoded URI component in place.
static bool isurisafe (int c)
static char * encode_URI_bytes (const char *str, size_t *restrict lenp)
char * encode_URI_component (const char *str)
 Encodes a URI component (RFC3986 §2).
char * vlc_path2uri (const char *path, const char *scheme)
 Builds a URL representation from a local file path.
char * make_path (const char *url)
 Tries to convert a URI to a local (UTF-8-encoded) file path.
static char * vlc_idna_to_ascii (const char *idn)
 Converts a UTF-8 nul-terminated IDN to nul-terminated ASCII domain name.
void vlc_UrlParse (vlc_url_t *restrict url, const char *str, unsigned char opt)
 Splits an URL into parts.
void vlc_UrlClean (vlc_url_t *restrict url)
 Releases resources allocated by vlc_UrlParse().

Macro Definition Documentation

#define SMB_SCHEME   "smb"

Referenced by vlc_path2uri().

Function Documentation

char* decode_URI ( char *  str)

Decodes an encoded URI component in place.

This function does NOT decode entire URIs. Instead, it decodes one component at a time (e.g. host name, directory, file name). Decoded URIs do not exist in the real world (see RFC3986 §2.4). Complete URIs are always "encoded" (or they are syntaxically invalid).

Note that URI encoding is different from Javascript escaping. Especially, white spaces and Unicode non-ASCII code points are encoded differently.

Parameters
strnul-terminated URI component to decode
Returns
str on success, NULL if it was not properly encoded

Referenced by decode_URI_duplicate(), input_item_SetURI(), make_path(), and vlc_UrlParse().

char* decode_URI_duplicate ( const char *  str)

Decodes an encoded URI component.

See also decode_URI().

Returns
decoded string allocated on the heap, or NULL on error.

References decode_URI(), and strdup().

Referenced by test_decode().

static char* encode_URI_bytes ( const char *  str,
size_t *restrict  lenp 
)
static

References isurisafe(), likely, and unlikely.

Referenced by encode_URI_component(), and vlc_path2uri().

char* encode_URI_component ( const char *  str)

Encodes a URI component (RFC3986 §2).

Parameters
strnul-terminated UTF-8 representation of the component.
Note
Obviously, a URI containing nul bytes cannot be passed.
Returns
encoded string (must be free()'d), or NULL for ENOMEM.

References encode_URI_bytes(), and likely.

static bool isurisafe ( int  c)
inlinestatic

Referenced by encode_URI_bytes().

char* make_path ( const char *  url)

Tries to convert a URI to a local (UTF-8-encoded) file path.

Parameters
urlURI to convert
Returns
NULL on error, a nul-terminated string otherwise (use free() to release it)

References asprintf(), decode_URI(), strdup(), strndup(), and unlikely.

Referenced by get_path(), input_item_WriteMeta(), and subtitles_Detect().

static char * vlc_idna_to_ascii ( const char *  idn)
static

Converts a UTF-8 nul-terminated IDN to nul-terminated ASCII domain name.

Parameters
idnUTF-8 Internationalized Domain Name to convert
Returns
a heap-allocated string or NULL on error.

References strdup(), and unlikely.

Referenced by vlc_UrlParse().

char* vlc_path2uri ( const char *  path,
const char *  scheme 
)

Builds a URL representation from a local file path.

Parameters
pathpath to convert (or URI to copy)
schemeURI scheme to use (default is auto: "file", "fd" or "smb")
Returns
a nul-terminated URI string (use free() to release it), or NULL in case of error

References asprintf(), DIR_SEP, DIR_SEP_CHAR, encode_URI_bytes(), SMB_SCHEME, strdup(), unlikely, vlc_getcwd(), and vlc_path2uri().

Referenced by GetFilenames(), libvlc_InternalInit(), LoadSlaves(), make_URI_def(), playlist_FindArtInCache(), playlist_Import(), playlist_MLLoad(), playlist_SaveArt(), SubtitleAdd(), system_Configure(), vlc_path2uri(), vlm_ControlMediaInstanceStart(), vlm_OnMediaUpdate(), and WMCOPYWNDPROC().

void vlc_UrlClean ( vlc_url_t *restrict  url)

Releases resources allocated by vlc_UrlParse().

Referenced by httpd_HostCreate(), and input_item_SetURI().

void vlc_UrlParse ( vlc_url_t *restrict  url,
const char *  str,
unsigned char  opt 
)

Splits an URL into parts.

Parameters
urlstructure of URL parts [OUT]
strnul-terminated URL string to split
optif non-zero, character separating paths from options, normally the question mark
Note
Use vlc_UrlClean() to free associated resources
Bug:
Errors cannot be detected.
Returns
nothing

References decode_URI(), strdup(), unlikely, and vlc_idna_to_ascii().

Referenced by httpd_HostCreate(), and input_item_SetURI().