aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/database.c4
-rw-r--r--src/main.c4
-rw-r--r--src/path.c41
-rw-r--r--src/path.h8
4 files changed, 27 insertions, 30 deletions
diff --git a/src/database.c b/src/database.c
index 2fd61dd08..4010955b7 100644
--- a/src/database.c
+++ b/src/database.c
@@ -230,7 +230,7 @@ db_save(void)
/* block signals when writing the db so we don't get a corrupted db */
fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
fprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
- fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, getFsCharset());
+ fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, path_get_fs_charset());
fprintf(fp, "%s\n", DIRECTORY_INFO_END);
if (directory_save(fp, music_root) < 0) {
@@ -302,7 +302,7 @@ db_load(void)
fsCharset, tempCharset);
WARNING("maybe you need to "
"recreate the db?\n");
- setFsCharset(fsCharset);
+ path_set_fs_charset(fsCharset);
}
} else
FATAL("directory: unknown line in db info: %s\n",
diff --git a/src/main.c b/src/main.c
index e1fc96bdc..39293bb11 100644
--- a/src/main.c
+++ b/src/main.c
@@ -403,7 +403,7 @@ int main(int argc, char *argv[])
open_log_files(options.stdOutput);
- initPaths();
+ path_global_init();
mapper_init();
initPermissions();
initPlaylist();
@@ -474,7 +474,7 @@ int main(int argc, char *argv[])
finishAudioConfig();
finishVolume();
mapper_finish();
- finishPaths();
+ path_global_finish();
finishPermissions();
dc_deinit();
pc_deinit();
diff --git a/src/path.c b/src/path.c
index f241fce8c..b3af926ba 100644
--- a/src/path.c
+++ b/src/path.c
@@ -32,7 +32,7 @@
#include <glib.h>
-static char *fsCharset;
+static char *fs_charset;
char *fs_charset_to_utf8(char *dst, const char *str)
{
@@ -40,7 +40,7 @@ char *fs_charset_to_utf8(char *dst, const char *str)
GError *error = NULL;
p = g_convert(str, -1,
- fsCharset, "utf-8",
+ fs_charset, "utf-8",
NULL, NULL, &error);
if (p == NULL) {
/* no fallback */
@@ -59,7 +59,7 @@ char *utf8_to_fs_charset(char *dst, const char *str)
GError *error = NULL;
p = g_convert(str, -1,
- "utf-8", fsCharset,
+ "utf-8", fs_charset,
NULL, NULL, &error);
if (p == NULL) {
/* fall back to UTF-8 */
@@ -72,38 +72,36 @@ char *utf8_to_fs_charset(char *dst, const char *str)
return dst;
}
-void setFsCharset(const char *charset)
+void path_set_fs_charset(const char *charset)
{
int error = 0;
- if (fsCharset)
- free(fsCharset);
+ g_free(fs_charset);
+ fs_charset = g_strdup(charset);
- fsCharset = xstrdup(charset);
-
- DEBUG("setFsCharset: fs charset is: %s\n", fsCharset);
+ DEBUG("path_set_fs_charset: fs charset is: %s\n", fs_charset);
if (error) {
- free(fsCharset);
+ free(fs_charset);
WARNING("setting fs charset to ISO-8859-1!\n");
- fsCharset = xstrdup("ISO-8859-1");
+ fs_charset = xstrdup("ISO-8859-1");
}
}
-const char *getFsCharset(void)
+const char *path_get_fs_charset(void)
{
- return fsCharset;
+ return fs_charset;
}
-void initPaths(void)
+void path_global_init(void)
{
- ConfigParam *fsCharsetParam = getConfigParam(CONF_FS_CHARSET);
+ ConfigParam *fs_charset_param = getConfigParam(CONF_FS_CHARSET);
char *charset = NULL;
char *originalLocale;
- if (fsCharsetParam) {
- charset = xstrdup(fsCharsetParam->value);
+ if (fs_charset_param) {
+ charset = xstrdup(fs_charset_param->value);
}
#ifdef HAVE_LOCALE
#ifdef HAVE_LANGINFO_CODESET
@@ -138,18 +136,17 @@ void initPaths(void)
#endif
if (charset) {
- setFsCharset(charset);
+ path_set_fs_charset(charset);
free(charset);
} else {
WARNING("setting filesystem charset to ISO-8859-1\n");
- setFsCharset("ISO-8859-1");
+ path_set_fs_charset("ISO-8859-1");
}
}
-void finishPaths(void)
+void path_global_finish(void)
{
- free(fsCharset);
- fsCharset = NULL;
+ g_free(fs_charset);
}
char *pfx_dir(char *dst,
diff --git a/src/path.h b/src/path.h
index c1003d846..16ddb9ed4 100644
--- a/src/path.h
+++ b/src/path.h
@@ -31,17 +31,17 @@
# endif
#endif
-void initPaths(void);
+void path_global_init(void);
-void finishPaths(void);
+void path_global_finish(void);
char *fs_charset_to_utf8(char *dst, const char *str);
char *utf8_to_fs_charset(char *dst, const char *str);
-void setFsCharset(const char *charset);
+void path_set_fs_charset(const char *charset);
-const char *getFsCharset(void);
+const char *path_get_fs_charset(void);
/*
* pfx_dir - sets dst="$pfx/$path" and returns a pointer to path inside * dst