diff options
author | Denis Vlasenko | 2008-07-16 22:12:18 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-07-16 22:12:18 +0000 |
commit | c01340fe26b76e172805ff641ad9af6bc45cdc91 (patch) | |
tree | 1b3b57ef2fd7441bb91410b89f763056279baddf /networking/nameif.c | |
parent | 38e54f1c1384e76adafb4e611a6bd456e4351d42 (diff) | |
download | busybox-c01340fe26b76e172805ff641ad9af6bc45cdc91.zip busybox-c01340fe26b76e172805ff641ad9af6bc45cdc91.tar.gz |
update of config file parser from Vladimir
Diffstat (limited to 'networking/nameif.c')
-rw-r--r-- | networking/nameif.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/networking/nameif.c b/networking/nameif.c index f3d333b..506f4fa 100644 --- a/networking/nameif.c +++ b/networking/nameif.c @@ -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); |