audstrings.c File Reference

#include "audstrings.h"
#include <stdio.h>
#include <glib.h>
#include <audacious/i18n.h>
#include <string.h>
#include <ctype.h>

Go to the source code of this file.

Functions

static gchar * str_replace_drive_letter (gchar *str)
 Performs in place replacement of Windows-style drive letter with '/' (slash).
gchar * str_append (gchar *str, const gchar *add_str)
gchar * str_replace (gchar *str, gchar *new_str)
void str_replace_in (gchar **str, gchar *new_str)
gboolean str_has_prefix_nocase (const gchar *str, const gchar *prefix)
gboolean str_has_suffix_nocase (const gchar *str, const gchar *suffix)
gboolean str_has_suffixes_nocase (const gchar *str, gchar *const *suffixes)
void str_set_utf8_impl (gchar *(*stu_impl)(const gchar *), gchar *(*stuf_impl)(const gchar *, gssize, gsize *, gsize *, GError **))
gchar * str_to_utf8 (const gchar *str)
 Convert given string from nearly any encoding to UTF-8 encoding.
gchar * str_to_utf8_full (const gchar *str, gssize len, gsize *bytes_read, gsize *bytes_written, GError **err)
gchar * str_assert_utf8 (const gchar *str)
 This function can be used to assert that a given string is valid UTF-8.
const gchar * str_skip_chars (const gchar *str, const gchar *chars)
gchar * convert_dos_path (gchar *path)
gchar * filename_get_subtune (const gchar *filename, gint *track)
 Checks if given URI contains a subtune indicator/number.
gchar * filename_split_subtune (const gchar *filename, gint *track)
 Given file path/URI contains ending indicating subtune number "?<number>", splits the string into filename without subtune value.
void string_replace_char (gchar *string, gchar old_str, gchar new_str)
static gchar get_hex_digit (const gchar **get)
static void string_decode_percent_2 (const gchar *from, gchar *to)
void string_decode_percent (gchar *s)
static gboolean is_legal_char (gchar c, gboolean is_filename)
static gchar make_hex_digit (gint i)
gchar * string_encode_percent (const gchar *string, gboolean is_filename)
gboolean uri_is_utf8 (const gchar *uri, gboolean warn)
gchar * uri_to_utf8 (const gchar *uri)
void uri_check_utf8 (gchar **uri, gboolean warn)
gchar * filename_to_uri (const gchar *name)
gchar * uri_to_filename (const gchar *uri)
gchar * uri_to_display (const gchar *uri)
gchar * uri_get_extension (const gchar *uri)
void string_cut_extension (gchar *string)
gint string_compare (const gchar *ap, const gchar *bp)
gint string_compare_encoded (const gchar *ap, const gchar *bp)
const void * memfind (const void *mem, gint size, const void *token, gint length)
gchar * str_replace_fragment (gchar *s, gint size, const gchar *old, const gchar *new)
void string_canonize_case (gchar *str)

Variables

static gchar *(* str_to_utf8_impl )(const gchar *) = NULL
static gchar *(* str_to_utf8_full_impl )(const gchar *, gssize, gsize *, gsize *, GError **) = NULL

Function Documentation

gchar* convert_dos_path ( gchar *  path  ) 

Definition at line 200 of file audstrings.c.

Referenced by construct_uri().

gchar* filename_get_subtune ( const gchar *  filename,
gint track 
)

Checks if given URI contains a subtune indicator/number.

If it does, track is set to to it, and position of subtune separator in the URI string is returned.

Parameters:
filename Filename/URI to split.
track Pointer to variable where subtune number should be assigned or NULL if it is not needed.
Returns:
Position of subtune separator character in filename or NULL if none found. Notice that this value should NOT be modified, even though it is not declared const for technical reasons.

Definition at line 226 of file audstrings.c.

Referenced by filename_split_subtune().

gchar* filename_split_subtune ( const gchar *  filename,
gint track 
)

Given file path/URI contains ending indicating subtune number "?<number>", splits the string into filename without subtune value.

If given track pointer is non-NULL, subtune number is assigned into it.

Parameters:
filename Filename/URI to split.
track Pointer to variable where subtune number should be assigned or NULL if it is not needed.
Returns:
Newly allocated splitted filename without the subtune indicator. This string must be freed with g_free(). NULL will be returned if there was any failure.

Definition at line 257 of file audstrings.c.

Referenced by file_find_decoder(), file_read_image(), file_read_tuple(), file_write_tuple(), and playback_thread().

gchar* filename_to_uri ( const gchar *  name  ) 

Definition at line 443 of file audstrings.c.

Referenced by add_cb(), convert_filenames(), load_playlists(), save_playlists(), and uri_to_utf8().

static gchar get_hex_digit ( const gchar **  get  )  [inline, static]

Definition at line 279 of file audstrings.c.

Referenced by string_compare_encoded(), and string_decode_percent_2().

static gboolean is_legal_char ( gchar  c,
gboolean  is_filename 
) [static]

Definition at line 319 of file audstrings.c.

Referenced by string_encode_percent().

static gchar make_hex_digit ( gint  i  )  [static]

Definition at line 330 of file audstrings.c.

Referenced by string_encode_percent().

const void* memfind ( const void *  mem,
gint  size,
const void *  token,
gint  length 
)

Definition at line 628 of file audstrings.c.

gchar* str_append ( gchar *  str,
const gchar *  add_str 
)

Definition at line 64 of file audstrings.c.

gchar* str_assert_utf8 ( const gchar *  str  ) 

This function can be used to assert that a given string is valid UTF-8.

If it is, a copy of the string is returned. However, if the string is NOT valid UTF-8, a warning and a callstack backtrace is printed in order to see where the problem occured.

This is a temporary measure for removing useless str_to_utf8 etc. calls and will be eventually removed. This function should be used in place of str_to_utf8() calls when it can be reasonably assumed that the input should already be in unicode encoding.

Parameters:
str String to be tested and converted to UTF-8 encoding.
Returns:
String in UTF-8 encoding, or NULL if conversion failed or input was NULL.

Definition at line 160 of file audstrings.c.

gboolean str_has_prefix_nocase ( const gchar *  str,
const gchar *  prefix 
)

Definition at line 83 of file audstrings.c.

gboolean str_has_suffix_nocase ( const gchar *  str,
const gchar *  suffix 
)

Definition at line 89 of file audstrings.c.

Referenced by scan_plugin_func(), and str_has_suffixes_nocase().

gboolean str_has_suffixes_nocase ( const gchar *  str,
gchar *const *  suffixes 
)

Definition at line 96 of file audstrings.c.

gchar* str_replace ( gchar *  str,
gchar *  new_str 
)

Definition at line 70 of file audstrings.c.

Referenced by str_append(), and str_replace_in().

static gchar* str_replace_drive_letter ( gchar *  str  )  [static]

Performs in place replacement of Windows-style drive letter with '/' (slash).

Parameters:
str String to be manipulated.
Returns:
Pointer to the string if succesful, NULL if failed or if input was NULL.

Definition at line 45 of file audstrings.c.

Referenced by convert_dos_path().

gchar* str_replace_fragment ( gchar *  s,
gint  size,
const gchar *  old,
const gchar *  new 
)

Definition at line 654 of file audstrings.c.

void str_replace_in ( gchar **  str,
gchar *  new_str 
)

Definition at line 77 of file audstrings.c.

void str_set_utf8_impl ( gchar *(*)(const gchar *)  stu_impl,
gchar *(*)(const gchar *, gssize, gsize *, gsize *, GError **)  stuf_impl 
)

Definition at line 114 of file audstrings.c.

Referenced by chardet_init().

const gchar* str_skip_chars ( const gchar *  str,
const gchar *  chars 
)

Definition at line 192 of file audstrings.c.

gchar* str_to_utf8 ( const gchar *  str  ) 

Convert given string from nearly any encoding to UTF-8 encoding.

Parameters:
str Local filename/path to convert.
Returns:
String in UTF-8 encoding. Must be freed with g_free().

Definition at line 128 of file audstrings.c.

Referenced by str_assert_utf8(), tuple_associate_string(), tuple_associate_string_rel(), and uri_to_display().

gchar* str_to_utf8_full ( const gchar *  str,
gssize  len,
gsize *  bytes_read,
gsize *  bytes_written,
GError **  err 
)

Definition at line 134 of file audstrings.c.

void string_canonize_case ( gchar *  str  ) 

Definition at line 687 of file audstrings.c.

Referenced by tuple_new_unlocked().

gint string_compare ( const gchar *  ap,
const gchar *  bp 
)

Definition at line 537 of file audstrings.c.

Referenced by plugin_compare(), and tuple_compare_string().

gint string_compare_encoded ( const gchar *  ap,
const gchar *  bp 
)

Definition at line 581 of file audstrings.c.

Referenced by filename_compare_basename(), and sort_cb().

void string_cut_extension ( gchar *  string  ) 

Definition at line 525 of file audstrings.c.

Referenced by tuple_formatter_make_title_string().

void string_decode_percent ( gchar *  s  ) 

Definition at line 311 of file audstrings.c.

static void string_decode_percent_2 ( const gchar *  from,
gchar *  to 
) [static]
gchar* string_encode_percent ( const gchar *  string,
gboolean  is_filename 
)

Definition at line 340 of file audstrings.c.

Referenced by filename_to_uri().

void string_replace_char ( gchar *  string,
gchar  old_str,
gchar  new_str 
)
void uri_check_utf8 ( gchar **  uri,
gboolean  warn 
)

Definition at line 429 of file audstrings.c.

Referenced by make_entries().

gchar* uri_get_extension ( const gchar *  uri  ) 

Definition at line 506 of file audstrings.c.

gboolean uri_is_utf8 ( const gchar *  uri,
gboolean  warn 
)

Definition at line 377 of file audstrings.c.

Referenced by playlist_rescan_file(), and uri_check_utf8().

gchar* uri_to_display ( const gchar *  uri  ) 

Definition at line 486 of file audstrings.c.

Referenced by describe_song(), and tuple_set_filename().

gchar* uri_to_filename ( const gchar *  uri  ) 
gchar* uri_to_utf8 ( const gchar *  uri  ) 

Definition at line 412 of file audstrings.c.

Referenced by playlist_rescan_file(), and uri_check_utf8().


Variable Documentation

gchar*(* str_to_utf8_full_impl)(const gchar *, gssize, gsize *, gsize *, GError **) = NULL [static]
gchar*(* str_to_utf8_impl)(const gchar *) = NULL [static]

Referenced by str_set_utf8_impl(), and str_to_utf8().


Generated on 27 Aug 2011 for Audacious by  doxygen 1.6.1