summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-01-27 17:11:05 +0000
committerStef Walter <stef@memberwebs.com>2006-01-27 17:11:05 +0000
commit36f86d822d09ec0d91839ee68178d8602e1970e2 (patch)
tree8e38c8dd76d004ff79c5c0d43ad7b5d284549176 /daemon
parent169551c223d9d14ddfaf4db583e591a3cb8ef6dc (diff)
Config: Parse timeout and fix interval parsing.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/config.c24
1 files changed, 20 insertions, 4 deletions
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)
{