VLC 4.0.0-dev
Collaboration diagram for String helpers:

Modules

 Character sets
 
 Uniform Resource Locator (URL)
 

Files

file  vlc_strings.h
 Helper functions for nul-terminated strings.
 

Typedefs

typedef struct vlc_player_t vlc_player_t
 

Functions

static int vlc_ascii_toupper (int c)
 
static int vlc_ascii_tolower (int c)
 
static int vlc_ascii_strcasecmp (const char *psz1, const char *psz2)
 Compare two ASCII strings ignoring case. More...
 
static int vlc_ascii_strncasecmp (const char *psz1, const char *psz2, size_t n)
 
void vlc_xml_decode (char *st)
 Decodes XML entities. More...
 
char * vlc_xml_encode (const char *str)
 Encodes XML entities. More...
 
void vlc_hex_encode_binary (const void *input, size_t size, char *output)
 Encode binary data as hex string. More...
 
char * vlc_b64_encode_binary (const void *base, size_t length)
 Base64 encoding. More...
 
char * vlc_b64_encode (const char *str)
 Base64 encoding (string). More...
 
size_t vlc_b64_decode_binary_to_buffer (void *p_dst, size_t i_dst_max, const char *psz_src)
 
size_t vlc_b64_decode_binary (uint8_t **pp_dst, const char *psz_src)
 
char * vlc_b64_decode (const char *psz_src)
 
char * vlc_strftime (const char *)
 Convenience wrapper for strftime(). More...
 
char * vlc_strfplayer (vlc_player_t *player, input_item_t *item, const char *fmt)
 Formats input meta-data. More...
 
static char * str_format (vlc_player_t *player, input_item_t *item, const char *fmt)
 
int vlc_filenamecmp (const char *, const char *)
 
void filename_sanitize (char *)
 Sanitize a file name. More...
 

Detailed Description

Typedef Documentation

◆ vlc_player_t

typedef struct vlc_player_t vlc_player_t

Function Documentation

◆ filename_sanitize()

void filename_sanitize ( char *  str)

Sanitize a file name.

Remove forbidden, potentially forbidden and otherwise evil characters from file names. That includes slashes, and popular characters like colon (on Unix anyway).

Warning
This function should only be used for automatically generated file names. Do not use this on full paths, only single file names without any directory separator!

References EnsureUTF8().

Referenced by ArtCacheGetDirPath(), ArtCacheName(), input_item_CreateFilename(), and vout_snapshot_SaveImage().

◆ str_format()

static char * str_format ( vlc_player_t player,
input_item_t item,
const char *  fmt 
)
inlinestatic

◆ vlc_ascii_strcasecmp()

static int vlc_ascii_strcasecmp ( const char *  psz1,
const char *  psz2 
)
inlinestatic

Compare two ASCII strings ignoring case.

The result is independent of the locale. If there are non-ASCII characters in the strings, their cases are NOT ignored in the comparison.

References vlc_ascii_tolower().

Referenced by cookie_domain_matches(), demux_mapping_cmp(), demux_NewAdvanced(), rtp_ac3_open(), rtp_h264_open(), rtp_mpeg12_open(), rtp_opus_open(), rtp_pcm_open(), rtp_raw_open(), vlc_http_cookies_store(), vlc_http_outfile_create(), vlc_http_res_get_redirect(), and vlc_http_res_init().

◆ vlc_ascii_strncasecmp()

static int vlc_ascii_strncasecmp ( const char *  psz1,
const char *  psz2,
size_t  n 
)
inlinestatic

◆ vlc_ascii_tolower()

static int vlc_ascii_tolower ( int  c)
inlinestatic

◆ vlc_ascii_toupper()

static int vlc_ascii_toupper ( int  c)
inlinestatic

◆ vlc_b64_decode()

char * vlc_b64_decode ( const char *  psz_src)

◆ vlc_b64_decode_binary()

size_t vlc_b64_decode_binary ( uint8_t **  pp_dst,
const char *  psz_src 
)

◆ vlc_b64_decode_binary_to_buffer()

size_t vlc_b64_decode_binary_to_buffer ( void *  p_dst,
size_t  i_dst_max,
const char *  psz_src 
)

◆ vlc_b64_encode()

char * vlc_b64_encode ( const char *  str)

Base64 encoding (string).

Encodes a nul-terminated string into Base64.

Parameters
strnul-terminated string to encode
Returns
a heap-allocated nul-terminated string (or NULL on allocation error).

References vlc_b64_encode_binary().

Referenced by vlc_http_auth_FormatAuthorizationHeader().

◆ vlc_b64_encode_binary()

char * vlc_b64_encode_binary ( const void *  base,
size_t  length 
)

Base64 encoding.

Encodes a buffer into base64 as a (nul-terminated) string.

Parameters
basestart address of buffer to encode
lengthlength in bytes of buffer to encode
Returns
a heap-allocated nul-terminated string (or NULL on allocation error).

References vlc_memstream::length, and unlikely.

Referenced by vlc_b64_encode(), and vlc_http_msg_add_creds_basic().

◆ vlc_filenamecmp()

int vlc_filenamecmp ( const char *  a,
const char *  b 
)

References strcoll.

Referenced by CompareFilenameStrings(), and rdh_compar_filename().

◆ vlc_hex_encode_binary()

void vlc_hex_encode_binary ( const void *  input,
size_t  size,
char *  output 
)

Encode binary data as hex string.

Writes a given data buffer to the output buffer as a null terminated string in hexadecimal representation.

Parameters
inputInput buffer
sizeInput buffer size
[out]outputOutput buffer to write the string to

◆ vlc_strfplayer()

char * vlc_strfplayer ( vlc_player_t player,
input_item_t item,
const char *  fmt 
)

Formats input meta-data.

Formats input and input item meta-informations into a heap-allocated string according to the given player format string.

The player format string contains of replacement specifiers, each specifier begins with the dollar character ($) followed by one of the following letters:

Char Replacement
a Artist metadata
b Album title metadata
c Copyright information metadata
d Description metadata
e 'Encoded by' metadata
f Displayed output frame (- if not available)
g Genre metadata
l Language metadata
n Current Track number metadata
o Total Track number metadata
p Now playing metadata (i.e. currently playing title for livestreams)
r Rating metadata
s Selected subtitle language (- if not available)
t Title metadata
u URL metadata
A Date metadata
B Selected audio track bitrate (- if not available)
C Current chapter index (- if not available)
D Item duration (--:--:-- if not available)
F Item URI
I Current title index (- if not available)
L Item remaining time (--:--:-- if not available)
N Item name
O Current audio track language (- if not available)
P Current playback position (0.0 to 1.0, --.-% if not available)
R Current playback speed (1.0 is normal speed, - if not available)
S Current audio track samplerate (- if not available)
T Current playback time (--:--:-- if not available)
U Publisher metadata
V Volume (0 to 256, --- if not available)
Z Now playing or Artist/Title metadata depending what is available
_ Newline (\n)

Additionally characters can be prepended with a whitespace (e.g. $ T), which will cause a replacement with nothing, when not available, instead of the placeholders documented above.

Parameters
playera locked player instance or NULL (player and item can't be both NULL)
itema valid item or NULL (player and item can't be both NULL)
fmtformat string
Returns
an allocated formatted string (must be free()'d), or NULL in case of error

References aout_Release(), aout_VolumeGet(), es_format_t::audio, AUDIO_ES, vlc_player_track::fmt, es_format_t::i_bitrate, input_stats_t::i_displayed_pictures, audio_format_t::i_rate, input_item_GetDuration(), input_item_GetName(), input_item_GetNowPlayingFb(), input_item_GetTitleFbName(), input_item_GetURI(), input_item_t::lock, name, input_item_t::p_stats, vlc_memstream::ptr, SPU_ES, vlc_memstream::stream, vlc_memstream_close(), vlc_memstream_open(), vlc_memstream_printf(), vlc_memstream_putc(), vlc_memstream_puts(), vlc_meta_Album, vlc_meta_Artist, vlc_meta_Copyright, vlc_meta_Date, vlc_meta_Description, vlc_meta_EncodedBy, vlc_meta_Genre, vlc_meta_Language, vlc_meta_Publisher, vlc_meta_Rating, vlc_meta_Title, vlc_meta_TrackNumber, vlc_meta_TrackTotal, vlc_meta_URL, vlc_mutex_lock(), vlc_mutex_unlock(), vlc_player_aout_Hold(), vlc_player_GetCategoryLanguage(), vlc_player_GetCurrentMedia(), vlc_player_GetLength(), vlc_player_GetPosition(), vlc_player_GetRate(), vlc_player_GetSelectedChapterIdx(), vlc_player_GetSelectedTitleIdx(), vlc_player_GetSelectedTrack(), vlc_player_GetTime(), VLC_TICK_INVALID, write_duration(), and write_meta().

Referenced by str_format().

◆ vlc_strftime()

char * vlc_strftime ( const char *  tformat)

Convenience wrapper for strftime().

Formats the current time into a heap-allocated string.

Parameters
tformattime format (as with C strftime())
Returns
an allocated string (must be free()'d), or NULL on memory error.

References localtime_r(), strdup(), and vlc_assert_unreachable.

Referenced by str_format().

◆ vlc_xml_decode()

void vlc_xml_decode ( char *  st)

Decodes XML entities.

Decodes a null-terminated UTF-8 string of XML character data into a regular nul-terminated UTF-8 string. In other words, replaces XML entities and numerical character references with the corresponding characters.

This function operates in place (the output is always of smaller or equal length than the input) and always succeeds.

Parameters
strnull-terminated string [IN/OUT]

References ARRAY_SIZE, cmp_entity(), xml_entity_s::psz_char, xml_entity_s::psz_entity, psz_value, and xml_entities.

◆ vlc_xml_encode()

char * vlc_xml_encode ( const char *  str)

Encodes XML entities.

Substitutes unsafe characters in a null-terminated UTF-8 strings with an XML entity or numerical character reference.

Parameters
strnull terminated UTF-8 string
Returns
On success, a heap-allocated null-terminated string is returned. If the input string was not a valid UTF-8 sequence, NULL is returned and errno is set to EILSEQ. If there was not enough memory, NULL is returned and errno is to ENOMEM.

References vlc_memstream::stream, unlikely, vlc_memstream_close(), vlc_memstream_open(), vlc_memstream_printf(), vlc_memstream_puts(), vlc_memstream_write(), and vlc_towc().

Referenced by httpd_HtmlError().