From 36f86d822d09ec0d91839ee68178d8602e1970e2 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 27 Jan 2006 17:11:05 +0000 Subject: Config: Parse timeout and fix interval parsing. --- daemon/config.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'daemon') diff --git a/daemon/config.c b/daemon/config.c index d102126..78ad04b 100644 --- a/daemon/config.c +++ b/daemon/config.c @@ -67,6 +67,7 @@ config_ctx; #define CONFIG_POLL "poll" #define CONFIG_INTERVAL "interval" +#define CONFIG_TIMEOUT "timeout" #define CONFIG_FIELD "field." #define CONFIG_SNMP "snmp" @@ -323,17 +324,32 @@ config_value(const char* header, const char* name, char* value, int i; if(ctx->interval > 0) - errx(2, "%s: " CONFIG_INTERVAL " specified twice: %s", - ctx->confname, value); + errx(2, "%s: " CONFIG_INTERVAL " specified twice: %s", ctx->confname, value); i = strtol(value, &t, 10); - if(i < 1) - err(2, "%s: " CONFIG_INTERVAL " must be a positive number: %s", + if(i < 1 || *t) + errx(2, "%s: " CONFIG_INTERVAL " must be a number (seconds) greater than zero: %s", ctx->confname, value); ctx->interval = (uint32_t)i; } + if(strcmp(name, CONFIG_TIMEOUT) == 0) + { + char* t; + int i; + + if(ctx->timeout > 0) + errx(2, "%s: " CONFIG_TIMEOUT " specified twice: %s", ctx->confname, value); + + i = strtol(value, &t, 10); + if(i < 1 || *t) + errx(2, "%s: " CONFIG_TIMEOUT " must be a a number (seconds) greater than zero: %s", + ctx->confname, value); + + ctx->timeout = (uint32_t)i; + } + /* If it starts with "field." */ if(strncmp(name, CONFIG_FIELD, KL(CONFIG_FIELD)) == 0) { -- cgit v1.2.3