]> git.sesse.net Git - vlc/commitdiff
add "export" command. It behaves exactly like "save" except that commands
authorAntoine Cellerier <dionoea@videolan.org>
Fri, 27 Jan 2006 12:58:05 +0000 (12:58 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Fri, 27 Jan 2006 12:58:05 +0000 (12:58 +0000)
are printed in a vlm_message and not in a file.

src/misc/vlm.c

index c1a176c6ed551908442ca56ca8532f9dcc8f96be..409a346b4362eaf7d288a2dc38e2ca580c49121b 100644 (file)
@@ -617,6 +617,18 @@ static int ExecuteCommand( vlm_t *p_vlm, const char *psz_command,
         }
     }
 
+    else if( !strcmp(ppsz_command[0], "export" ) )
+    {
+        char *psz_buf;
+
+        if( i_command != 1 ) goto syntax_error;
+
+        p_message = vlm_MessageNew( "export", psz_buf = Save( p_vlm ) );
+        free( psz_buf );
+
+        goto success;
+    }
+
     else if( !strcmp(ppsz_command[0], "load") )
     {
         if( i_command != 2 ) goto syntax_error;
@@ -1911,6 +1923,7 @@ static vlm_message_t *vlm_Help( vlm_t *vlm, char *psz_filter )
         MessageAddChild( "del (name)|all|media|schedule" );
         MessageAddChild( "control (name) [instance_name] (command)" );
         MessageAddChild( "save (config_file)" );
+        MessageAddChild( "export" );
         MessageAddChild( "load (config_file)" );
 
         message_child = MessageAdd( "Media Proprieties Syntax:" );
@@ -1992,9 +2005,12 @@ static int Load( vlm_t *vlm, char *file )
 static char *Save( vlm_t *vlm )
 {
     char *save = NULL;
+    char psz_header[] = "\n"
+                        "# VLC media player VLM command batch\n"
+                        "# http://www.videolan.org/vlc/\n\n" ;
     char *p;
     int i,j;
-    int i_length = 0;
+    int i_length = strlen( psz_header );
 
     for( i = 0; i < vlm->i_media; i++ )
     {
@@ -2096,6 +2112,8 @@ static char *Save( vlm_t *vlm )
     p = save = malloc( i_length );
     *save = '\0';
 
+    p += sprintf( p, "%s", psz_header );
+
     /* finally we can write in it */
     for( i = 0; i < vlm->i_media; i++ )
     {