#include "plugin.h"
#include "configfile.h"
#include "types_list.h"
-#include "utils_threshold.h"
#include "filter_chain.h"
#if HAVE_WORDEXP_H
static int dispatch_loadplugin (const oconfig_item_t *ci)
{
int i;
- uint32_t flags = 0;
+ const char *name;
+ unsigned int flags = 0;
assert (strcasecmp (ci->key, "LoadPlugin") == 0);
if (ci->values_num != 1)
if (ci->values[0].type != OCONFIG_TYPE_STRING)
return (-1);
+ name = ci->values[0].value.string;
+
+ /*
+ * XXX: Magic at work:
+ *
+ * Some of the language bindings, for example the Python and Perl
+ * plugins, need to be able to export symbols to the scripts they run.
+ * For this to happen, the "Globals" flag needs to be set.
+ * Unfortunately, this technical detail is hard to explain to the
+ * average user and she shouldn't have to worry about this, ideally.
+ * So in order to save everyone's sanity use a different default for a
+ * handful of special plugins. --octo
+ */
+ if ((strcasecmp ("Perl", name) == 0)
+ || (strcasecmp ("Python", name) == 0))
+ flags |= PLUGIN_FLAGS_GLOBAL;
+
for (i = 0; i < ci->children_num; ++i) {
- if (ci->children[i].values_num != 1 ||
- ci->children[i].values[0].type != OCONFIG_TYPE_BOOLEAN) {
- WARNING("Ignoring unknown LoadPlugin option %s for plugin %s", ci->children[i].key, ci->values[0].value.string);
- continue;
- }
- if (strcasecmp(ci->children[i].key, "globals") == 0) {
- flags |= PLUGIN_FLAGS_GLOBAL;
- } else {
- WARNING("Ignoring unknown LoadPlugin option %s for plugin %s", ci->children[i].key, ci->values[0].value.string);
+ if (strcasecmp("Globals", ci->children[i].key) == 0)
+ cf_util_get_flag (ci->children + i, &flags, PLUGIN_FLAGS_GLOBAL);
+ else {
+ WARNING("Ignoring unknown LoadPlugin option \"%s\" "
+ "for plugin \"%s\"",
+ ci->children[i].key, ci->values[0].value.string);
}
}
- return (plugin_load (ci->values[0].value.string, flags));
+
+ return (plugin_load (name, (uint32_t) flags));
} /* int dispatch_value_loadplugin */
static int dispatch_value_plugin (const char *plugin, oconfig_item_t *ci)
return (dispatch_loadplugin (ci));
else if (strcasecmp (ci->key, "Plugin") == 0)
return (dispatch_block_plugin (ci));
- else if (strcasecmp (ci->key, "Threshold") == 0)
- return (ut_config (ci));
else if (strcasecmp (ci->key, "Chain") == 0)
return (fc_configure (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 */
+