]> git.sesse.net Git - vlc/commitdiff
* src/libvlc.c: Expand ~/ in --config-file.
authorChristophe Massiot <massiot@videolan.org>
Wed, 17 Aug 2005 15:12:51 +0000 (15:12 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 17 Aug 2005 15:12:51 +0000 (15:12 +0000)
 * 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
src/libvlc.c
src/misc/configuration.c

index e849e1493490a408e7f331f14aff9abd5d06b9d0..61252b3f041dbeb83e24eb8bb7aacad9c76d1ebe 100644 (file)
@@ -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" ) )
         {
index 80a1f9b42f7f42981bebb618aaf16684ec5777c7..793c60825b447cb189228731056e20c532f743be 100644 (file)
@@ -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" ) )
index 820cb4da6dd3fb639e6967c9a290e7103a43e439..04e04a5c706bb12253392eb59ee313d6d48ac2eb 100644 (file)
@@ -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;