[MPlayer-cvslog] CVS: main parser-mpcmd.c, 1.22, 1.23 parser-mecmd.c, 1.10, 1.11 mplayer.c, 1.863, 1.864 m_option.h, 1.11, 1.12 m_option.c, 1.38, 1.39

Guillaume Poirier CVS syncmail at mplayerhq.hu
Fri Sep 2 10:29:33 CEST 2005


CVS change done by Guillaume Poirier CVS

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

Modified Files:
	parser-mpcmd.c parser-mecmd.c mplayer.c m_option.h m_option.c 
Log Message:
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "

This one makes

mplayer -vo help -ao help -ac help -vc help -pphelp -af help -vfm help -vf help -afm help -fstype help

produce the desired output.

>From the thread:
Date: Jul 16, 2005 8:25 PM
Subject: [MPlayer-dev-eng] [PATCH] allow multiple help clauses on the command line


Index: parser-mpcmd.c
===================================================================
RCS file: /cvsroot/mplayer/main/parser-mpcmd.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- parser-mpcmd.c	17 Jun 2005 08:11:56 -0000	1.22
+++ parser-mpcmd.c	2 Sep 2005 08:29:30 -0000	1.23
@@ -63,6 +63,7 @@
   char *opt,*splitpos=NULL;
   char entbuf[10];
   int no_more_opts = 0;
+  int opt_exit = 0; // flag indicating whether mplayer should exit without playing anything
   play_tree_t *last_parent, *last_entry = NULL, *root;
 #ifdef MACOSX_FINDER_SUPPORT
   extern play_tree_t *macosx_finder_args(m_config_t *, int , char **);
@@ -196,9 +197,11 @@
 	  }
 	}
 
+	if (tmp <= M_OPT_EXIT) {
+	  opt_exit = 1;
+	  tmp = M_OPT_EXIT - tmp;
+	} else
 	if (tmp < 0) {
-	  if (tmp == M_OPT_EXIT)
-	    exit(0);
 	  goto err_out;
 	}
 	i += tmp;
@@ -252,6 +255,8 @@
       }
   }
 
+  if (opt_exit)
+    goto err_out;
   --recursion_depth;
   if(last_parent != root)
     mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Missing }- ?\n");

Index: parser-mecmd.c
===================================================================
RCS file: /cvsroot/mplayer/main/parser-mecmd.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- parser-mecmd.c	17 Jun 2005 08:11:56 -0000	1.10
+++ parser-mecmd.c	2 Sep 2005 08:29:30 -0000	1.11
@@ -51,6 +51,7 @@
   int tmp;
   char *opt;
   int no_more_opts = 0;
+  int opt_exit = 0;
   m_entry_t *lst = NULL, *entry = NULL;
 	
 #ifdef MP_DEBUG
@@ -98,6 +99,10 @@
 	  }
 	} else {
 	  tmp = m_config_check_option(config, opt, argv[i + 1]);
+	  if (tmp <= M_OPT_EXIT) {
+	    opt_exit = 1;
+	    tmp = M_OPT_EXIT - tmp;
+	  }
 	  if(tmp >= 0) {
 	    entry->opts = realloc(entry->opts,(no+2)*2*sizeof(char*));
 	    entry->opts[2*no] = strdup(opt);
@@ -106,8 +111,6 @@
 	    no++;
 	  } else {
 //	    mp_msg(MSGT_CFGPARSER, MSGL_ERR, "m_config_set_option() failed (%d)\n",tmp);
-	    if(tmp == M_OPT_EXIT)
-	      exit(0);
 	    goto err_out;
 	  }
 	}
@@ -124,6 +127,8 @@
       }
   }
 
+  if (opt_exit)
+    exit(0);
   if(nf == 0) {
     m_entry_list_free(lst);
     mp_msg(MSGT_CFGPARSER, MSGL_ERR, "No file given\n");

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.863
retrieving revision 1.864
diff -u -r1.863 -r1.864
--- mplayer.c	31 Aug 2005 02:15:03 -0000	1.863
+++ mplayer.c	2 Sep 2005 08:29:30 -0000	1.864
@@ -1048,6 +1048,8 @@
 
 int rtc_fd=-1;
 
+int opt_exit = 0; // flag indicating whether mplayer should exit without playing anything
+
 //float a_frame=0;    // Audio
 
 int i;
@@ -1150,8 +1152,8 @@
 
     playtree = m_config_parse_mp_command_line(mconfig, argc, argv);
     if(playtree == NULL)
-      exit_player(NULL);
-
+      opt_exit = 1;
+    else {
     playtree = play_tree_cleanup(playtree);
     if(playtree) {
       playtree_iter = play_tree_iter_new(playtree,mconfig);
@@ -1163,6 +1165,7 @@
 	filename = play_tree_iter_get_file(playtree_iter,1);
       }
     }
+    }
 	
 #ifdef WIN32
 	if(proc_priority){
@@ -1205,12 +1208,12 @@
 
     if(video_driver_list && strcmp(video_driver_list[0],"help")==0){
       list_video_out();
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
 
     if(audio_driver_list && strcmp(audio_driver_list[0],"help")==0){
       list_audio_out();
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
 
 // check codec.conf
@@ -1241,7 +1244,7 @@
         mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_CODECS\n");
       list_codecs(1);
       mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
     if(video_codec_list && strcmp(video_codec_list[0],"help")==0){
       mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoCodecs);
@@ -1249,28 +1252,28 @@
         mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_CODECS\n");
       list_codecs(0);
       mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
     if(video_fm_list && strcmp(video_fm_list[0],"help")==0){
       vfm_help();
       mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
     if(audio_fm_list && strcmp(audio_fm_list[0],"help")==0){
       afm_help();
       mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
     if(af_cfg.list && strcmp(af_cfg.list[0],"help")==0){
       af_help();
       printf("\n");
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
 #ifdef HAVE_X11
     if(vo_fstype_list && strcmp(vo_fstype_list[0],"help")==0){
       fstype_help();
       mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
 #endif
     if((demuxer_name && strcmp(demuxer_name,"help")==0) ||
@@ -1278,9 +1281,12 @@
        (sub_demuxer_name && strcmp(sub_demuxer_name,"help")==0)){
       demuxer_help();
       mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n");
-      exit_player_with_rc(NULL, 0);
+      opt_exit = 1;
     }
 
+    if(opt_exit)
+      exit_player(NULL);
+
 #ifdef USE_EDL
 if (edl_check_mode() == EDL_ERROR && edl_filename)
 {

Index: m_option.h
===================================================================
RCS file: /cvsroot/mplayer/main/m_option.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- m_option.h	27 Dec 2004 17:32:54 -0000	1.11
+++ m_option.h	2 Sep 2005 08:29:30 -0000	1.12
@@ -217,6 +217,11 @@
 #define M_OPT_OUT_OF_RANGE	-4
 #define M_OPT_PARSER_ERR	-5
 #define M_OPT_EXIT              -6
+// M_OPT_EXIT must be the lowest number on this list.
+// To indicate that mplayer should exit without playing anything,
+// a parsing function needs to return M_OPT_EXIT less the number
+// of additional command line parameters it consumed.
+// Generally it will return either M_OPT_EXIT or M_OPT_EXIT - 1.
 
 // FIXME: backward compatibility
 #define ERR_NOT_AN_OPTION	M_OPT_UNKNOWN

Index: m_option.c
===================================================================
RCS file: /cvsroot/mplayer/main/m_option.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- m_option.c	20 Jun 2005 23:07:34 -0000	1.38
+++ m_option.c	2 Sep 2005 08:29:30 -0000	1.39
@@ -1005,7 +1005,7 @@
     for(i = 0 ; mp_imgfmt_list[i].name ; i++)
       mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s",mp_imgfmt_list[i].name);
     mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
-    return M_OPT_EXIT;
+    return M_OPT_EXIT - 1;
   }
   
   if (sscanf(param, "0x%x", &fmt) != 1)
@@ -1093,7 +1093,7 @@
     for(i = 0 ; mp_afmt_list[i].name ; i++)
       mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s",mp_afmt_list[i].name);
     mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
-    return M_OPT_EXIT;
+    return M_OPT_EXIT - 1;
   }
   
   if (sscanf(param, "0x%x", &fmt) != 1)
@@ -1212,7 +1212,7 @@
     char min[50],max[50];
     if(!desc->fields) {
       printf("%s doesn't have any options.\n\n",name);
-      return M_OPT_EXIT;
+      return M_OPT_EXIT - 1;
     }
     printf("\n Name                 Type            Min        Max\n\n");
     for(n = 0 ; desc->fields[n].name ; n++) {
@@ -1233,7 +1233,7 @@
 	     max);
     }
     printf("\n");
-    return M_OPT_EXIT;
+    return M_OPT_EXIT - 1;
   }
 
   for(nopts = 0 ; desc->fields[nopts].name ; nopts++)
@@ -1545,7 +1545,7 @@
       mp_msg(MSGT_VFILTER,MSGL_INFO,"  %-15s: %s\n",
 	     M_ST_MB(char*,ol->list[n],ol->name_off),
 	     M_ST_MB(char*,ol->list[n],ol->info_off));
-    return M_OPT_EXIT;
+    return M_OPT_EXIT - 1;
   }
   ptr = str = strdup(param);
 
@@ -1688,7 +1688,7 @@
 	pre +=  s) 
       mp_msg(MSGT_CFGPARSER, MSGL_ERR, " %s",pre_name);
     mp_msg(MSGT_CFGPARSER, MSGL_ERR, "\n");
-    return M_OPT_EXIT;
+    return M_OPT_EXIT - 1;
   }
 
   for(pre_name = M_ST_MB(char*,pre,obj_p->name_off) ; pre_name ;




More information about the MPlayer-cvslog mailing list