diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-24 23:38:04 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-24 23:38:04 +0000 |
commit | 0f99d49ae680e675809428deace3c4fe839d323c (patch) | |
tree | 712afab828ee4fb02493bc60e1a37f1142231263 /networking | |
parent | 22f741484391c3b2fd94881fd41c8c0df9749e95 (diff) | |
download | busybox-w32-0f99d49ae680e675809428deace3c4fe839d323c.tar.gz busybox-w32-0f99d49ae680e675809428deace3c4fe839d323c.tar.bz2 busybox-w32-0f99d49ae680e675809428deace3c4fe839d323c.zip |
*: conversion to config parser
function old new delta
config_read 540 597 +57
config_open2 41 44 +3
rtnl_rtprot_initialize 70 66 -4
rtnl_rttable_initialize 78 73 -5
rtnl_rtscope_initialize 88 83 -5
rtnl_rtrealm_initialize 48 43 -5
rtnl_rtdsfield_initialize 48 43 -5
process_module 566 560 -6
bbunpack 391 383 -8
rtnl_tab_initialize 279 121 -158
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/8 up/down: 60/-196) Total: -136 bytes
Diffstat (limited to 'networking')
-rw-r--r-- | networking/libiproute/rt_names.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c index b22df9cb7..1a2d52e86 100644 --- a/networking/libiproute/rt_names.c +++ b/networking/libiproute/rt_names.c | |||
@@ -13,41 +13,27 @@ | |||
13 | #include "libbb.h" | 13 | #include "libbb.h" |
14 | #include "rt_names.h" | 14 | #include "rt_names.h" |
15 | 15 | ||
16 | /* so far all callers have size == 256 */ | ||
17 | #define rtnl_tab_initialize(file, tab, size) rtnl_tab_initialize(file, tab) | ||
18 | #define size 256 | ||
16 | static void rtnl_tab_initialize(const char *file, const char **tab, int size) | 19 | static void rtnl_tab_initialize(const char *file, const char **tab, int size) |
17 | { | 20 | { |
18 | char buf[512]; | 21 | char *token[2]; |
19 | FILE *fp; | 22 | parser_t *parser = config_open2(file, fopen_for_read); |
20 | 23 | if (!parser) | |
21 | fp = fopen_for_read(file); | ||
22 | if (!fp) | ||
23 | return; | 24 | return; |
24 | while (fgets(buf, sizeof(buf), fp)) { | 25 | while (config_read(parser, token, 2, 2, "# \t", 0)) { |
25 | char *p = buf; | 26 | int id = bb_strtou(token[0], NULL, 0); |
26 | int id; | 27 | if (id < 0 || id > size) { |
27 | char namebuf[512]; | 28 | bb_error_msg("database %s is corrupted at line %d", |
28 | 29 | file, parser->lineno); | |
29 | while (*p == ' ' || *p == '\t') | 30 | break; |
30 | p++; | ||
31 | if (*p == '#' || *p == '\n' || *p == 0) | ||
32 | continue; | ||
33 | if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2 | ||
34 | && sscanf(p, "0x%x %s #", &id, namebuf) != 2 | ||
35 | && sscanf(p, "%d %s\n", &id, namebuf) != 2 | ||
36 | && sscanf(p, "%d %s #", &id, namebuf) != 2 | ||
37 | ) { | ||
38 | bb_error_msg("database %s is corrupted at %s", | ||
39 | file, p); | ||
40 | return; | ||
41 | } | 31 | } |
42 | 32 | tab[id] = xstrdup(token[1]); | |
43 | if (id < 0 || id > size) | ||
44 | continue; | ||
45 | |||
46 | tab[id] = xstrdup(namebuf); | ||
47 | } | 33 | } |
48 | fclose(fp); | 34 | config_close(parser); |
49 | } | 35 | } |
50 | 36 | #undef size | |
51 | 37 | ||
52 | static const char **rtnl_rtprot_tab; /* [256] */ | 38 | static const char **rtnl_rtprot_tab; /* [256] */ |
53 | 39 | ||