# HG changeset patch # User alex # Date 1004666572 0 # Node ID 169d97f8aeaf4a1b88a1085877cf7c480631b0cf # Parent e2f6002936211c8b29244d312135a9a36a2595a7 fixed subconfig, exiting on error, supporting flags diff -r e2f600293621 -r 169d97f8aeaf cfgparser.c --- a/cfgparser.c Fri Nov 02 01:35:27 2001 +0000 +++ b/cfgparser.c Fri Nov 02 02:02:52 2001 +0000 @@ -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;