[Mplayer-cvslog] CVS: main cfgparser.c,1.30,1.31
Alex Beregszaszi
alex at mplayer.dev.hu
Fri Nov 2 03:03:09 CET 2001
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv30504
Modified Files:
cfgparser.c
Log Message:
fixed subconfig, exiting on error, supporting flags
Index: cfgparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- cfgparser.c 2 Nov 2001 01:31:27 -0000 1.30
+++ cfgparser.c 2 Nov 2001 02:02:52 -0000 1.31
@@ -62,9 +62,10 @@
int ret = -1;
char *endptr;
-// printf("read_option: conf=%p optnr=%d opt='%s' param='%s'\n",
-// conf, conf_optnr, opt, param);
-
+#ifdef DEBUG
+ printf("read_option: conf=%p optnr=%d opt='%s' param='%s'\n",
+ conf, conf_optnr, opt, param);
+#endif
for (i = 0; i < conf_optnr; i++) {
int namelength;
/* allow 'aa*' in config.name */
@@ -83,8 +84,10 @@
ret = ERR_NOT_AN_OPTION;
goto out;
}
-// printf("read_option: name='%s' p=%p type=%d\n",
-// conf[i].name, conf[i].p, conf[i].type);
+#ifdef DEBUG
+ printf("read_option: name='%s' p=%p type=%d\n",
+ conf[i].name, conf[i].p, conf[i].type);
+#endif
if (conf[i].flags & CONF_NOCFG && parser_mode == CONFIG_FILE) {
printf("this option can only be used on command line:\n");
ret = ERR_NOT_AN_OPTION;
@@ -260,10 +263,25 @@
token = strtok(param, (char *)&(":"));
while(token)
{
- int i;
+ int ret;
+ int err;
- if ((i = sscanf(token, "%[^=]=%s", subopt, subparam)) == 2)
- read_option(&conf[i].p, subconf_optnr, subopt, subparam);
+ ret = sscanf(token, "%[^=]=%s", subopt, subparam);
+ switch(ret)
+ {
+ case 1:
+ case 2:
+ if ((err = read_option((struct config *)subconf, subconf_optnr, subopt, subparam)) < 0)
+ {
+ printf("Subconfig parsing returned error: %d in token: %s\n",
+ err, token);
+ return(err);
+ }
+ break;
+ default:
+ printf("Invalid subconfig argument! ('%s')\n", token);
+ return(ERR_NOT_AN_OPTION);
+ }
// printf("token: '%s', i=%d, subopt='%s, subparam='%s'\n", token, i, subopt, subparam);
token = strtok(NULL, (char *)&(":"));
}
@@ -527,7 +545,6 @@
printf("Error %d while parsing option: '%s'!\n",
tmp, opt);
goto err_out;
- /* break; */
default:
i += tmp;
break;
More information about the MPlayer-cvslog
mailing list