if (ci->children[i].children == NULL)
dispatch_value_plugin (name, ci->children + i);
else
- {DEBUG ("No nested config blocks allowed for this plugin.");}
+ {
+ WARNING ("There is a `%s' block within the "
+ "configuration for the %s plugin. "
+ "The plugin either only expects "
+ "\"simple\" configuration statements "
+ "or wasn't loaded using `LoadPlugin'."
+ " Please check your configuration.",
+ ci->children[i].key, name);
+ }
}
return (0);
temp = NULL;
/* If (src->children_num == 0) the array size is decreased. If offset
- * is _not_ the last element, (offset < (src->children_num - 1)), then
+ * is _not_ the last element, (offset < (dst->children_num - 1)), then
* we need to move the trailing elements before resizing the array. */
- if ((src->children_num == 0) && (offset < (src->children_num - 1)))
+ if ((src->children_num == 0) && (offset < (dst->children_num - 1)))
{
- int nmemb = src->children_num - (offset + 1);
- memmove (src->children + offset, src->children + offset + 1,
+ int nmemb = dst->children_num - (offset + 1);
+ memmove (dst->children + offset, dst->children + offset + 1,
sizeof (oconfig_item_t) * nmemb);
}
sizeof (oconfig_item_t) * nmemb);
}
- /* Last but not least: If there are new childrem, copy them to the
+ /* Last but not least: If there are new children, copy them to the
* memory reserved for them. */
if (src->children_num > 0)
{
/* Now replace the i'th child in `root' with `new'. */
cf_ci_replace_child (root, new, i);
+ /* ... and go back to the new i'th child. */
+ --i;
+
sfree (new->values);
sfree (new);
} /* for (i = 0; i < root->children_num; i++) */
return (0);
} /* int cf_read */
+
+/* Assures the config option is a string, duplicates it and returns the copy in
+ * "ret_string". If necessary "*ret_string" is freed first. Returns zero upon
+ * success. */
+int cf_util_get_string (const oconfig_item_t *ci, char **ret_string) /* {{{ */
+{
+ char *string;
+
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ ERROR ("cf_util_get_string: The %s plugin requires "
+ "exactly one string argument.", ci->key);
+ return (-1);
+ }
+
+ string = strdup (ci->values[0].value.string);
+ if (string == NULL)
+ return (-1);
+
+ if (*ret_string != NULL)
+ sfree (*ret_string);
+ *ret_string = string;
+
+ return (0);
+} /* }}} int cf_util_get_string */
+
+/* Assures that the config option is a string. The string is then converted to
+ * a port number using `service_name_to_port_number' and returned. Returns the
+ * port number in the range [1-65535] or less than zero upon failure. */
+int cf_util_get_port_number (const oconfig_item_t *ci) /* {{{ */
+{
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ ERROR ("cf_util_get_port_number: The %s plugin requires "
+ "exactly one string argument.", ci->key);
+ return (-1);
+ }
+
+ return (service_name_to_port_number (ci->values[0].value.string));
+} /* }}} int cf_util_get_port_number */