summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-06-06 11:52:30 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-06-06 11:52:30 +0200
commit83b706f76b791a315fbc3760f9b9c204fef44031 (patch)
tree5bf3555a7b26be7edb0ac3cced36af5fc1aa206d /src/config.c
parent8089ac9d10e0db60d3bc4cf52a9c0576fb01f421 (diff)
config: store dns nameservers in a string
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/config.c b/src/config.c
index e8901f5..d7d0b06 100644
--- a/src/config.c
+++ b/src/config.c
@@ -76,7 +76,7 @@ static struct config core_config = {
/* Network */
{
"",
- { SA_INIT },
+ { {""} },
0
},
@@ -101,25 +101,27 @@ static int range_print(struct re_printf *pf, const struct range *rng)
static int dns_server_handler(const struct pl *pl, void *arg)
{
struct config_net *cfg = arg;
- struct sa sa;
+ const size_t max_count = ARRAY_SIZE(cfg->nsv);
int err;
- err = sa_decode(&sa, pl->p, pl->l);
- if (err) {
- warning("config: dns_server: could not decode `%r'\n", pl);
- return err;
- }
-
- if (cfg->nsc >= ARRAY_SIZE(cfg->nsv)) {
+ if (cfg->nsc >= max_count) {
warning("config: too many DNS nameservers (max %zu)\n",
- ARRAY_SIZE(cfg->nsv));
+ max_count);
return EOVERFLOW;
}
/* Append dns_server to the network config */
- cfg->nsv[cfg->nsc++] = sa;
+ err = pl_strcpy(pl, cfg->nsv[cfg->nsc].addr,
+ sizeof(cfg->nsv[0].addr));
+ if (err) {
+ warning("config: dns_server: could not copy string (%r)\n",
+ pl);
+ return err;
+ }
- return err;
+ ++cfg->nsc;
+
+ return 0;
}