[Mplayer-cvslog] CVS: main mplayer.c,1.230,1.231 cfgparser.c,1.25,1.26 cfgparser.h,1.6,1.7

Arpi of Ize arpi at mplayer.dev.hu
Wed Aug 22 21:29:50 CEST 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv24825

Modified Files:
	mplayer.c cfgparser.c cfgparser.h 
Log Message:
multifile support in config parser

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -r1.230 -r1.231
--- mplayer.c	22 Aug 2001 19:02:28 -0000	1.230
+++ mplayer.c	22 Aug 2001 19:29:47 -0000	1.231
@@ -424,6 +424,11 @@
 static sh_audio_t *sh_audio=NULL;
 static sh_video_t *sh_video=NULL;
 
+// for multifile support:
+char **filenames=NULL;
+int num_filenames=0;
+int curr_filename=0;
+
 char* filename=NULL; //"MI2-Trailer.avi";
 stream_t* stream=NULL;
 int file_format=DEMUXER_TYPE_UNKNOWN;
@@ -460,7 +465,10 @@
    {
 #endif
     parse_cfgfiles();
-    if (parse_command_line(conf, argc, argv, envp, &filename) < 0) exit(1);
+    if ((num_filenames=parse_command_line(conf, argc, argv, envp, &filenames)) < 0) exit(1);
+    printf("XXX num_filenames: %d\n",num_filenames);
+    curr_filename=0;
+    filename=(num_filenames>0)?filenames[curr_filename]:NULL;
     
     mp_msg_init(verbose+MSGL_STATUS);
 

Index: cfgparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- cfgparser.c	15 Aug 2001 19:26:22 -0000	1.25
+++ cfgparser.c	22 Aug 2001 19:29:47 -0000	1.26
@@ -431,10 +431,11 @@
 	return ret;
 }
 
-int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char **filename)
+int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char ***filenames)
 {
 	int i;
-	int found_filename = 0;
+	char **f = NULL;
+	int f_nr = 0;
 	int tmp;
 	char *opt;
 
@@ -452,13 +453,8 @@
 
 	for (i = 1; i < argc; i++) {
 		opt = argv[i];
-		if (*opt != '-') {
-			if (found_filename) {
-				printf("invalid option:\n");
-				goto err_out;
-			}
+		if (*opt != '-')
 			goto filename;
-		}
 
 		/* remove trailing '-' */
 		opt++;
@@ -467,14 +463,12 @@
 
 		switch (tmp) {
 		case ERR_NOT_AN_OPTION:
-			/* opt is not an option -> treat it as a filename */
-			if (found_filename) {
-				/* we already have a filename */
-				goto err_out;
-			}
 filename:
-			found_filename = 1;
-			*filename = argv[i];
+			/* opt is not an option -> treat it as a filename */
+			if (!(f = (char **) realloc(f, sizeof(*f) * (f_nr + 2))))
+				goto err_out_mem;
+
+			f[f_nr++] = argv[i];
 			break;
 		case ERR_MISSING_PARAM:
 		case ERR_OUT_OF_RANGE:
@@ -485,8 +479,14 @@
 			i += tmp;
 		}
 	}
+	if (f)
+		f[f_nr] = NULL;
+	if (filenames)
+		*filenames = f;
 	--recursion_depth;
-	return found_filename;
+	return f_nr; //filenames_nr;
+err_out_mem:
+	printf("can't allocate memory for filenames\n");
 err_out:
 	--recursion_depth;
 	printf("command line: %s\n", argv[i]);

Index: cfgparser.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- cfgparser.h	15 Aug 2001 19:26:22 -0000	1.6
+++ cfgparser.h	22 Aug 2001 19:29:47 -0000	1.7
@@ -47,11 +47,11 @@
  */
 int parse_config_file(struct config *conf, char *conffile);
 
-/* parse_command_line reutrns:
+/* parse_command_line returns:
  * 	-1 on error (invalid option...)
  * 	 0 if there was no filename on command line
- * 	 1 if it found a filename
+ * 	 >=1 if there were filenames
  */
-int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char **filename);
+int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char ***filenames);
 
 #endif /* __CONFIG_H */




More information about the MPlayer-cvslog mailing list