update of config file parser from Vladimir

This commit is contained in:
Denis Vlasenko
2008-07-16 22:12:18 +00:00
parent 38e54f1c13
commit c01340fe26
4 changed files with 52 additions and 177 deletions

View File

@ -160,21 +160,13 @@ int nameif_main(int argc, char **argv)
prepend_new_eth_table(&clist, ifname, *argv++);
}
} else {
ifh = xfopen(fname, "r");
while ((line = xmalloc_fgets(ifh)) != NULL) {
char *next;
line_ptr = skip_whitespace(line);
if ((line_ptr[0] == '#') || (line_ptr[0] == '\n'))
goto read_next_line;
next = skip_non_whitespace(line_ptr);
if (*next)
*next++ = '\0';
prepend_new_eth_table(&clist, line_ptr, next);
read_next_line:
free(line);
struct parser_t parser;
if (config_open(&parser, fname)) {
char *tokens[2];
while (config_read(&parser, tokens, 2, 2, " \t", '#'))
prepend_new_eth_table(&clist, tokens[0], tokens[1]);
config_close(&parser);
}
fclose(ifh);
}
ctl_sk = xsocket(PF_INET, SOCK_DGRAM, 0);