[Mplayer-cvslog] CVS: main cfg-mplayer.h,1.76,1.77 cfgparser.c,1.24,1.25 cfgparser.h,1.5,1.6

Folke Ashberg folke at mplayer.dev.hu
Wed Aug 15 21:26:24 CEST 2001


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

Modified Files:
	cfg-mplayer.h cfgparser.c cfgparser.h 
Log Message:
New feature for option processing: CONF_TYPE_FUNC_FULL

Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- cfg-mplayer.h	14 Aug 2001 19:00:00 -0000	1.76
+++ cfg-mplayer.h	15 Aug 2001 19:26:22 -0000	1.77
@@ -2,6 +2,7 @@
  * config for cfgparser
  */
 
+
 #ifdef HAVE_FBDEV
 extern char *fb_dev_name;
 extern char *fb_mode_cfgfile;
@@ -50,12 +51,22 @@
 #endif
 
 #ifdef HAVE_AA
-extern int  aaopt_osdcolor;
-extern int  aaopt_extended;
-extern int  aaopt_eight;
-extern char aaopt_driver;
+extern int vo_aa_parseoption(struct config * conf, char *opt, char * param);
 #endif
 
+/*
+ * CONF_TYPE_FUNC_FULL :
+ * allows own implemtations for passing the params
+ * 
+ * the function receives parameter name and argument (if it does not start with - )
+ * useful with a conf.name like 'aa*' to parse several parameters to a function
+ * return 0 =ok, but we didn't need the param (could be the filename)
+ * return 1 =ok, we accepted the param
+ * negative values: see cfgparser.h, ERR_XXX
+ *
+ * by Folke
+ */
+
 struct config conf[]={
 	/* name, pointer, type, flags, min, max */
 	{"include", cfg_include, CONF_TYPE_FUNC_PARAM, 0, 0, 0}, /* this must be the first!!! */
@@ -203,10 +214,7 @@
 #endif
 
 #ifdef HAVE_AA
-	{"aaosdfont", &aaopt_osdcolor, CONF_TYPE_INT, CONF_RANGE, 0, 5 }, 
-	{"aaextended", &aaopt_extended, CONF_TYPE_FLAG, 0, 0, 1 },
-	{"aaeight", &aaopt_eight, CONF_TYPE_FLAG, 0, 0, 1 },
-	{"aadriver", &aaopt_driver, CONF_TYPE_STRING, 0, 0, 0 },
+	{"aa*",	vo_aa_parseoption,  CONF_TYPE_FUNC_FULL, 0, 0, 0 },
 #endif
 
       

Index: cfgparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- cfgparser.c	12 Jul 2001 15:08:02 -0000	1.24
+++ cfgparser.c	15 Aug 2001 19:26:22 -0000	1.25
@@ -14,10 +14,6 @@
 #include <string.h>
 #include <errno.h>
 
-#define ERR_NOT_AN_OPTION	-1
-#define ERR_MISSING_PARAM	-2
-#define ERR_OUT_OF_RANGE	-3
-#define ERR_FUNC_ERR		-4
 
 #define COMMAND_LINE		0
 #define CONFIG_FILE		1
@@ -65,6 +61,14 @@
 	char *endptr;
 
 	for (i = 0; i < nr_options; i++) {
+		int namelength;
+		/* allow 'aa*' in config.name */
+		namelength=strlen(config[i].name);
+		if ( (config[i].name[namelength-1]=='*') && 
+			    !memcmp(opt, config[i].name, namelength-1))
+		        break;
+	    
+	    
 		if (!strcasecmp(opt, config[i].name))
 			break;
 	}
@@ -93,6 +97,7 @@
 				    !strcasecmp(param, "si") ||
 				    !strcasecmp(param, "igen") ||
 				    !strcasecmp(param, "y") ||
+				    !strcasecmp(param, "j") ||
 				    !strcasecmp(param, "i") ||
 				    !strcmp(param, "1"))
 					*((int *) config[i].p) = config[i].max;
@@ -201,6 +206,17 @@
 				goto out;
 			}
 			ret = 1;
+			break;
+		case CONF_TYPE_FUNC_FULL:
+			if (param!=NULL && param[0]=='-'){
+			    ret=((cfg_func_arg_param_t) config[i].p)(config + i, opt, NULL);
+			    if (ret>=0) ret=0;
+			    /* if we return >=0: param is processed again (if there is any) */
+			}else{
+			    ret=((cfg_func_arg_param_t) config[i].p)(config + i, opt, param);
+			    /* if we return 0: need no param, precess it again */
+			    /* if we return 1: accepted param */
+			}
 			break;
 		case CONF_TYPE_FUNC:
 			if ((((cfg_func_t) config[i].p)(config + i)) < 0) {

Index: cfgparser.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- cfgparser.h	19 Mar 2001 03:45:49 -0000	1.5
+++ cfgparser.h	15 Aug 2001 19:26:22 -0000	1.6
@@ -12,6 +12,15 @@
 #define CONF_TYPE_FUNC		4
 #define CONF_TYPE_FUNC_PARAM	5
 #define CONF_TYPE_PRINT		6
+#define CONF_TYPE_FUNC_FULL	7
+
+
+#define ERR_NOT_AN_OPTION	-1
+#define ERR_MISSING_PARAM	-2
+#define ERR_OUT_OF_RANGE	-3
+#define ERR_FUNC_ERR		-4
+
+
 
 #define CONF_MIN		(1<<0)
 #define CONF_MAX		(1<<1)
@@ -27,6 +36,7 @@
 	float min,max;
 };
 
+typedef int (*cfg_func_arg_param_t)(struct config *, char *, char *);
 typedef int (*cfg_func_param_t)(struct config *, char *);
 typedef int (*cfg_func_t)(struct config *);
 




More information about the MPlayer-cvslog mailing list