aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/files.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-23 12:57:49 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-23 12:57:49 +0000
commitc90c3f30a899b5f0aae58e54839109aa9b3eaee6 (patch)
tree190c1a90f38aa4ddbfdddf52ea89978d42536606 /networking/udhcp/files.c
parent48237b0c88343154d58854020c3a9c8b07c61b10 (diff)
downloadbusybox-c90c3f30a899b5f0aae58e54839109aa9b3eaee6.tar.gz
add "wpad" DHCP option. Spotted some optimization opportunities: -80 bytes
Diffstat (limited to 'networking/udhcp/files.c')
-rw-r--r--networking/udhcp/files.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 2c2c5422c..829d7e960 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -95,7 +95,8 @@ struct option_set *find_option(struct option_set *opt_list, char code)
/* add an option to the opt_list */
-static void attach_option(struct option_set **opt_list, struct dhcp_option *option, char *buffer, int length)
+static void attach_option(struct option_set **opt_list,
+ const struct dhcp_option *option, char *buffer, int length)
{
struct option_set *existing, *new, **curr;
@@ -135,7 +136,7 @@ static int read_opt(const char *const_line, void *arg)
{
struct option_set **opt_list = arg;
char *opt, *val, *endptr;
- struct dhcp_option *option;
+ const struct dhcp_option *option;
int retval = 0, length;
char buffer[8];
char *line;
@@ -144,16 +145,21 @@ static int read_opt(const char *const_line, void *arg)
/* Cheat, the only const line we'll actually get is "" */
line = (char *) const_line;
- if (!(opt = strtok(line, " \t="))) return 0;
+ opt = strtok(line, " \t=");
+ if (!opt) return 0;
- for (option = dhcp_options; option->code; option++)
+ option = dhcp_options;
+ while (1) {
+ if (!option->code)
+ return 0;
if (!strcasecmp(option->name, opt))
break;
-
- if (!option->code) return 0;
+ option++;
+ }
do {
- if (!(val = strtok(NULL, ", \t"))) break;
+ val = strtok(NULL, ", \t");
+ if (!val) break;
length = option_lengths[option->flags & TYPE_MASK];
retval = 0;
opt = buffer; /* new meaning for variable opt */