X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fconfigfile.c;h=e162dd995edf2efe69d37cf80616c1489f9d9717;hb=d6e55d065c568b599a9c27b2540c7e0233cf2318;hp=99dded93c8117aca7a780cfa6ae830163304fb7c;hpb=17fcc3c1cd67ceb0b8305cabb9e7c1e66aba561f;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index 99dded93..e162dd99 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -1059,3 +1059,28 @@ int cf_util_get_port_number (const oconfig_item_t *ci) /* {{{ */ 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 */ +