From 3368c030bf8785290a295ce632e678ca931c8a27 Mon Sep 17 00:00:00 2001 From: Christophe Massiot Date: Wed, 17 Aug 2005 15:12:51 +0000 Subject: [PATCH] * 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 --- modules/control/http.c | 24 ++++++++++++++++++++++-- src/libvlc.c | 11 +++++++++++ src/misc/configuration.c | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/modules/control/http.c b/modules/control/http.c index e849e14934..61252b3f04 100644 --- a/modules/control/http.c +++ b/modules/control/http.c @@ -1366,11 +1366,11 @@ static mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name, return s; } - if( *psz_dir == '~' ) + if( psz_dir[0] == '~' && psz_dir[1] == '/' ) { /* This is incomplete : we should also support the ~cmassiot/ syntax. */ snprintf( dir, sizeof(dir), "%s/%s", p_intf->p_vlc->psz_homedir, - psz_dir + 1 ); + psz_dir + 2 ); psz_dir = dir; } @@ -4037,6 +4037,26 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, } 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 */ else if( !strcmp( s, "playlist_add" ) ) { diff --git a/src/libvlc.c b/src/libvlc.c index 80a1f9b42f..793c60825b 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -366,6 +366,17 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) /* Set the config file stuff */ p_vlc->psz_homedir = config_GetHomeDir(); 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 */ if( config_GetInt( p_vlc, "reset-plugins-cache" ) ) diff --git a/src/misc/configuration.c b/src/misc/configuration.c index 820cb4da6d..04e04a5c70 100644 --- a/src/misc/configuration.c +++ b/src/misc/configuration.c @@ -1012,8 +1012,8 @@ int config_CreateDir( vlc_object_t *p_this, char *psz_dirname ) * save. * Really stupid no ? *****************************************************************************/ -int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, - vlc_bool_t b_autosave ) +static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name, + vlc_bool_t b_autosave ) { module_t *p_parser; vlc_list_t *p_list; -- 2.39.2