Commit 3368c030 authored by Christophe Massiot's avatar Christophe Massiot

* src/libvlc.c: Expand ~/ in --config-file.

 * modules/control/http.c: New RPN functions :
   - 'module' vlc_config_save ('module' can be an empty string) returns status
   - vlc_config_reset
parent 2851705c
...@@ -1366,11 +1366,11 @@ static mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name, ...@@ -1366,11 +1366,11 @@ static mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
return s; return s;
} }
if( *psz_dir == '~' ) if( psz_dir[0] == '~' && psz_dir[1] == '/' )
{ {
/* This is incomplete : we should also support the ~cmassiot/ syntax. */ /* This is incomplete : we should also support the ~cmassiot/ syntax. */
snprintf( dir, sizeof(dir), "%s/%s", p_intf->p_vlc->psz_homedir, snprintf( dir, sizeof(dir), "%s/%s", p_intf->p_vlc->psz_homedir,
psz_dir + 1 ); psz_dir + 2 );
psz_dir = dir; psz_dir = dir;
} }
...@@ -4037,6 +4037,26 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -4037,6 +4037,26 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
} }
free( psz_variable ); free( psz_variable );
} }
else if( !strcmp( s, "vlc_config_save" ) )
{
char *psz_module = SSPop( st );
int i_result;
if( !*psz_module )
{
free( psz_module );
psz_module = NULL;
}
i_result = config_SaveConfigFile( p_intf, psz_module );
if( psz_module != NULL )
free( psz_module );
SSPushN( st, i_result );
}
else if( !strcmp( s, "vlc_config_reset" ) )
{
config_ResetAll( p_intf );
}
/* 6. playlist functions */ /* 6. playlist functions */
else if( !strcmp( s, "playlist_add" ) ) else if( !strcmp( s, "playlist_add" ) )
{ {
......
...@@ -366,6 +366,17 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -366,6 +366,17 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
/* Set the config file stuff */ /* Set the config file stuff */
p_vlc->psz_homedir = config_GetHomeDir(); p_vlc->psz_homedir = config_GetHomeDir();
p_vlc->psz_configfile = config_GetPsz( p_vlc, "config" ); p_vlc->psz_configfile = config_GetPsz( p_vlc, "config" );
if( p_vlc->psz_configfile != NULL && p_vlc->psz_configfile[0] == '~'
&& p_vlc->psz_configfile[1] == '/' )
{
char *psz = malloc( strlen(p_vlc->psz_homedir)
+ strlen(p_vlc->psz_configfile) );
/* This is incomplete : we should also support the ~cmassiot/ syntax. */
sprintf( psz, "%s/%s", p_vlc->psz_homedir,
p_vlc->psz_configfile + 2 );
free( p_vlc->psz_configfile );
p_vlc->psz_configfile = psz;
}
/* Check for plugins cache options */ /* Check for plugins cache options */
if( config_GetInt( p_vlc, "reset-plugins-cache" ) ) if( config_GetInt( p_vlc, "reset-plugins-cache" ) )
......
...@@ -1012,8 +1012,8 @@ int config_CreateDir( vlc_object_t *p_this, char *psz_dirname ) ...@@ -1012,8 +1012,8 @@ int config_CreateDir( vlc_object_t *p_this, char *psz_dirname )
* save. * save.
* Really stupid no ? * Really stupid no ?
*****************************************************************************/ *****************************************************************************/
int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
vlc_bool_t b_autosave ) vlc_bool_t b_autosave )
{ {
module_t *p_parser; module_t *p_parser;
vlc_list_t *p_list; vlc_list_t *p_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment