Data Structures | Defines | Functions | Variables

strings.c File Reference

Include dependency graph for strings.c:

Data Structures

struct  xml_entity_s

Defines

#define INSERT_STRING(string)
#define INSERT_STRING_NO_FREE(string)
#define SMB_SCHEME   "smb"

Functions

char * decode_URI_duplicate (const char *psz)
 Decode encoded URI component.
char * decode_URI (char *psz)
 Decode an encoded URI component in place.
static bool isurisafe (int c)
static char * encode_URI_bytes (const char *psz_uri, size_t len)
char * encode_URI_component (const char *psz_uri)
 Encodes a URI component (RFC3986 §2).
static int cmp_entity (const void *key, const void *elem)
void resolve_xml_special_chars (char *psz_value)
 Converts "&lt;", "&gt;" and "&amp;" to "<", ">" and "&".
char * convert_xml_special_chars (const char *str)
 XML-encode an UTF-8 string.
char * vlc_b64_encode_binary (const uint8_t *src, size_t i_src)
char * vlc_b64_encode (const char *src)
size_t vlc_b64_decode_binary_to_buffer (uint8_t *p_dst, size_t i_dst, const char *p_src)
size_t vlc_b64_decode_binary (uint8_t **pp_dst, const char *psz_src)
char * vlc_b64_decode (const char *psz_src)
char * str_format_time (const char *tformat)
 Formats current time into a heap-allocated string.
static void format_duration (char *buf, size_t len, int64_t duration)
char * str_format_meta (vlc_object_t *p_object, const char *string)
char * str_format (vlc_object_t *p_this, const char *psz_src)
 Apply str format time and str format meta.
void filename_sanitize (char *str)
 Remove forbidden, potentially forbidden and otherwise evil characters from filenames.
void path_sanitize (char *str)
 Remove forbidden characters from full paths (leaves slashes).
char * make_URI (const char *path, const char *scheme)
 Convert a file path to a URI.
char * make_path (const char *url)
 Tries to convert a URI to a local (UTF-8-encoded) file path.
time_t str_duration (const char *psz_duration)

Variables

static struct xml_entity_s xml_entities []

Define Documentation

#define INSERT_STRING (   string  ) 
Value:
if( string != NULL )                            \
                    {                                               \
                        int len = strlen( string );                 \
                        dst = xrealloc( dst, i_size = i_size + len );\
                        memcpy( (dst+d), string, len );             \
                        d += len;                                   \
                        free( string );                             \
                    }

Referenced by str_format_meta().

#define INSERT_STRING_NO_FREE (   string  ) 
Value:
{                                               \
                        int len = strlen( string );                 \
                        dst = xrealloc( dst, i_size = i_size + len );\
                        memcpy( dst+d, string, len );               \
                        d += len;                                   \
                    }

Referenced by str_format_meta().

#define SMB_SCHEME   "smb"

Referenced by make_URI().


Function Documentation

static int cmp_entity ( const void *  key,
const void *  elem 
) [static]
char* decode_URI ( char *  psz  ) 

Decode an encoded URI component in place.

This function does NOT decode entire URIs. It decodes components (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.

Returns:
psz 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 *  psz  ) 

Decode encoded URI component.

See also decode_URI().

Returns:
decoded duplicated string

References decode_URI(), and strdup().

Referenced by test_decode().

static char* encode_URI_bytes ( const char *  psz_uri,
size_t  len 
) [static]

References isurisafe().

Referenced by encode_URI_component(), and make_URI().

char* encode_URI_component ( const char *  psz_uri  ) 

Encodes a URI component (RFC3986 §2).

Parameters:
psz_uri nul-terminated UTF-8 representation of the component. Obviously, you can't pass a URI containing a nul character, but you don't want to do that, do you?
Returns:
encoded string (must be free()'d), or NULL for ENOMEM.

References encode_URI_bytes().

static void format_duration ( char *  buf,
size_t  len,
int64_t  duration 
) [static]

References lldiv(), lldiv_t::quot, and lldiv_t::rem.

Referenced by str_format_meta().

static bool isurisafe ( int  c  )  [inline, static]

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:
url URI to convert
Returns:
NULL on error, a nul-terminated string otherwise (use free() to release it)

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

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

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

Convert a file path to a URI.

If already a URI, return a copy of the string.

Parameters:
path path to convert (or URI to copy)
scheme URI 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(), make_URI(), SMB_SCHEME, strdup(), and vlc_getcwd().

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


Variable Documentation

struct xml_entity_s xml_entities[] [static]
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines