summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 17fcc3c)
raw | patch | inline | side by side (parent: 17fcc3c)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 11:39:10 +0000 (12:39 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 11:39:10 +0000 (12:39 +0100) |
src/configfile.c | patch | blob | history | |
src/configfile.h | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index 99dded93c8117aca7a780cfa6ae830163304fb7c..e162dd995edf2efe69d37cf80616c1489f9d9717 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
return (service_name_to_port_number (ci->values[0].value.string));
} /* }}} int cf_util_get_port_number */
+
+int cf_util_get_cdtime (const oconfig_item_t *ci, cdtime_t *ret_value) /* {{{ */
+{
+ if ((ci == NULL) || (ret_value == NULL))
+ return (EINVAL);
+
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
+ {
+ ERROR ("cf_util_get_cdtime: The %s option requires "
+ "exactly one numeric argument.", ci->key);
+ return (-1);
+ }
+
+ if (ci->values[0].value.number < 0.0)
+ {
+ ERROR ("cf_util_get_cdtime: The numeric argument of the %s "
+ "option must not be negative.", ci->key);
+ return (-1);
+ }
+
+ *ret_value = DOUBLE_TO_CDTIME_T (ci->values[0].value.number);
+
+ return (0);
+} /* }}} int cf_util_get_cdtime */
+
diff --git a/src/configfile.h b/src/configfile.h
index 519a6ff8668668b6f6c6deef72c60041de27a329..65b1efcdd5a07d9a0d7fe7d50228470475bdb524 100644 (file)
--- a/src/configfile.h
+++ b/src/configfile.h
**/
#include "collectd.h"
+#include "utils_time.h"
#include "liboconfig/oconfig.h"
/*
* port number in the range [1-65535] or less than zero upon failure. */
int cf_util_get_port_number (const oconfig_item_t *ci);
+int cf_util_get_cdtime (const oconfig_item_t *ci, cdtime_t *ret_value);
+
#endif /* defined(CONFIGFILE_H) */