[Mplayer-cvslog] CVS: main parser-mpcmd.c,1.15,1.16

Roberto Togni CVS syncmail at mplayerhq.hu
Mon Jun 7 20:58:10 CEST 2004


CVS change done by Roberto Togni CVS

Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv17718

Modified Files:
	parser-mpcmd.c 
Log Message:
Support dvd://start_title-end_title as requested on wishlist
Patch by adland


Index: parser-mpcmd.c
===================================================================
RCS file: /cvsroot/mplayer/main/parser-mpcmd.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- parser-mpcmd.c	24 Apr 2004 13:15:31 -0000	1.15
+++ parser-mpcmd.c	7 Jun 2004 18:58:08 -0000	1.16
@@ -21,6 +21,7 @@
 #define LOCAL 1
 #define DROP_LOCAL 2
 
+#define dvd_range(a)  (a>0 && a<256)
 #define UNSET_GLOBAL (mode = LOCAL)
 // Use this 1 if you want to have only global option (no per file option)
 // #define UNSET_GLOBAL (mode = GLOBAL)
@@ -58,9 +59,10 @@
 play_tree_t*
 m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
 {
-  int i;
+  int i,j,start_title=-1,end_title=-1;
   int tmp = 0;
-  char *opt;
+  char *opt,*splitpos=NULL;
+  char entbuf[10];
   int no_more_opts = 0;
   play_tree_t *last_parent, *last_entry = NULL, *root;
 
@@ -196,7 +198,42 @@
       {
 	play_tree_t* entry = play_tree_new();
 	mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Adding file %s\n",argv[i]);
+        // if required expand DVD filename entries like dvd://1-3 into component titles
+        if ( strstr(argv[i],"dvd://") != NULL )
+	{
+             splitpos=strstr(argv[i]+6,"-");
+             if(splitpos != NULL)
+             {
+               start_title=strtol(argv[i]+6,NULL,10);
+	       if (start_title<0) { //entries like dvd://-2 start title implied 1
+		   end_title=abs(start_title);
+                   start_title=1;
+               } else {
+                   end_title=strtol(splitpos+1,NULL,10);
+               }
+              
+               if (dvd_range(start_title) && dvd_range(end_title) && (start_title<end_title))      
+               {
+                 for (j=start_title;j<=end_title;j++)
+                 {
+                  if (j!=start_title) 
+                      entry=play_tree_new();
+                  snprintf(entbuf,9,"dvd://%d",j);
+                  play_tree_add_file(entry,entbuf);
+                  add_entry(&last_parent,&last_entry,entry);
+		  last_entry = entry;
+                 }
+               } else {
+                 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Invalid play entry %s\n",argv[i]);
+               }
+         
+	     } else { // dvd:// or dvd://x entry
+                play_tree_add_file(entry,argv[i]);
+             }
+        } else {
 	play_tree_add_file(entry,argv[i]);
+	}
+
 	// Lock stdin if it will be used as input
 	if(strcasecmp(argv[i],"-") == 0)
 	  m_config_set_option(config,"use-stdin",NULL);




More information about the MPlayer-cvslog mailing list