# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include "../libvlc.h"
#include "vlc_charset.h"
#include "vlc_keys.h"
#include <errno.h> /* errno */
#include <assert.h>
#include <limits.h>
+#ifdef __APPLE__
+# include <xlocale.h>
+#else
+#include <locale.h>
+#endif
#include "configuration.h"
#include "modules/modules.h"
return src ? strdup (src) : NULL;
}
+/**
+ * Get the user's configuration file
+ */
+static char *config_GetConfigFile( void )
+{
+ char *psz_dir = config_GetUserConfDir();
+ char *psz_configfile;
+
+ if( asprintf( &psz_configfile, "%s" DIR_SEP CONFIG_FILE, psz_dir ) == -1 )
+ psz_configfile = NULL;
+ free( psz_dir );
+ return psz_configfile;
+}
+
static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
{
char *psz_filename = libvlc_priv (p_obj->p_libvlc)->psz_configfile;
if( !psz_filename )
{
- psz_filename = config_GetConfigFile( p_obj->p_libvlc );
+ psz_filename = config_GetConfigFile();
}
msg_Dbg( p_obj, "opening config file (%s)", psz_filename );
* Specification configs */
char *psz_old;
if( asprintf( &psz_old, "%s" DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE,
- p_obj->p_libvlc->psz_homedir ) != -1 )
+ config_GetHomeDir() ) != -1 )
{
p_stream = utf8_fopen( psz_old, mode );
if( p_stream )
"VLC will now use %s.", psz_old, psz_filename );
char *psz_readme;
if( asprintf(&psz_readme,"%s"DIR_SEP CONFIG_DIR DIR_SEP"README",
- p_obj->p_libvlc->psz_homedir ) != -1 )
+ config_GetHomeDir() ) != -1 )
{
FILE *p_readme = utf8_fopen( psz_readme, "wt" );
if( p_readme )
"version 0.6. Your\nconfiguration has been "
"copied to the new location:\n%s\nYou can "
"delete this directory and all its contents.",
- libvlc_priv(p_obj->p_libvlc)->psz_configdir);
+ psz_filename);
fclose( p_readme );
}
free( psz_readme );
char line[1024], section[1022];
section[0] = '\0';
+ /* Ensure consistent number formatting... */
+ locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
+ locale_t baseloc = uselocale (loc);
+
while (fgets (line, 1024, file) != NULL)
{
/* Ignore comments and empty lines */
case CONFIG_ITEM_FLOAT:
if( !*psz_option_value )
break; /* ignore empty option */
- p_item->value.f = (float)i18n_atof( psz_option_value);
+ p_item->value.f = (float)atof (psz_option_value);
p_item->saved.f = p_item->value.f;
break;
fclose (file);
vlc_list_release( p_list );
+ if (loc != (locale_t)0)
+ {
+ uselocale (baseloc);
+ freelocale (loc);
+ }
vlc_mutex_unlock( &priv->config_lock );
return 0;
*****************************************************************************/
int config_CreateDir( vlc_object_t *p_this, const char *psz_dirname )
{
- if( !psz_dirname && !*psz_dirname ) return -1;
+ if( !psz_dirname || !*psz_dirname ) return -1;
if( utf8_mkdir( psz_dirname, 0700 ) == 0 )
return 0;
if( libvlc_priv (p_this->p_libvlc)->psz_configfile == NULL )
{
- const char *psz_configdir =
- libvlc_priv(p_this->p_libvlc)->psz_configdir;
+ char *psz_configdir = config_GetUserConfDir();
if( !psz_configdir ) /* XXX: This should never happen */
{
msg_Err( p_this, "no configuration directory defined" );
}
config_CreateDir( p_this, psz_configdir );
+ free( psz_configdir );
}
file = config_OpenConfigFile( p_this, "rt" );
fprintf( file, "\xEF\xBB\xBF###\n### " COPYRIGHT_MESSAGE "\n###\n\n"
"###\n### lines beginning with a '#' character are comments\n###\n\n" );
+ /* Ensure consistent number formatting... */
+ locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
+ locale_t baseloc = uselocale (loc);
+
/* Look for the selected module, if NULL then save everything */
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
}
vlc_list_release( p_list );
+ if (loc != (locale_t)0)
+ {
+ uselocale (baseloc);
+ freelocale (loc);
+ }
/*
* Restore old settings from the config in file
return SaveConfigFile( p_this, psz_module_name, false );
}
-/**
- * Get the user's configuration file
- */
-char *config_GetConfigFile( libvlc_int_t *p_libvlc )
-{
- char *psz_configfile;
- if( asprintf( &psz_configfile, "%s" DIR_SEP CONFIG_FILE,
- libvlc_priv (p_libvlc)->psz_configdir ) == -1 )
- return NULL;
- return psz_configfile;
-}
-
/**
* Get the user's configuration file when given with the --config option
*/
{
/* This is incomplete: we should also support the ~cmassiot/ syntax */
char *psz_buf;
- if( asprintf( &psz_buf, "%s/%s", p_libvlc->psz_homedir,
+ if( asprintf( &psz_buf, "%s/%s", config_GetHomeDir(),
psz_configfile + 2 ) == -1 )
{
free( psz_configfile );