+static int o_config_add_query_result (o_query_t *q, /* {{{ */
+ oconfig_item_t *ci)
+{
+ o_result_t *r;
+ int status;
+ int i;
+
+ if (ci->values_num != 0)
+ {
+ WARNING ("oracle plugin: The `Result' block doesn't accept any arguments. "
+ "Ignoring %i argument%s.",
+ ci->values_num, (ci->values_num == 1) ? "" : "s");
+ }
+
+ r = (o_result_t *) malloc (sizeof (*r));
+ if (r == NULL)
+ {
+ ERROR ("oracle plugin: malloc failed.");
+ return (-1);
+ }
+ memset (r, 0, sizeof (*r));
+ r->type = NULL;
+ r->instances = NULL;
+ r->values = NULL;
+ r->next = NULL;
+
+ /* Fill the `o_result_t' structure.. */
+ status = 0;
+ for (i = 0; i < ci->children_num; i++)
+ {
+ oconfig_item_t *child = ci->children + i;
+
+ if (strcasecmp ("Type", child->key) == 0)
+ status = o_config_set_string (&r->type, child);
+ else if (strcasecmp ("InstancesFrom", child->key) == 0)
+ status = o_config_add_string (&r->instances, &r->instances_num, child);
+ else if (strcasecmp ("ValuesFrom", child->key) == 0)
+ status = o_config_add_string (&r->values, &r->values_num, child);
+ else
+ {
+ WARNING ("oracle plugin: Query `%s': Option `%s' not allowed here.",
+ q->name, child->key);
+ status = -1;
+ }
+
+ if (status != 0)
+ break;
+ }
+
+ /* Check that all necessary options have been given. */
+ while (status == 0)
+ {
+ if (r->type == NULL)
+ {
+ WARNING ("oracle plugin: `Type' not given for "
+ "result in query `%s'", q->name);
+ status = -1;
+ }
+ if (r->instances == NULL)
+ {
+ WARNING ("oracle plugin: `InstancesFrom' not given for "
+ "result in query `%s'", q->name);
+ status = -1;
+ }
+ if (r->values == NULL)
+ {
+ WARNING ("oracle plugin: `ValuesFrom' not given for "
+ "result in query `%s'", q->name);
+ status = -1;
+ }
+
+ break;
+ } /* while (status == 0) */
+
+ /* If all went well, add this result to the list of results within the
+ * query structure. */
+ if (status == 0)
+ {
+ if (q->results == NULL)
+ {
+ q->results = r;
+ }
+ else
+ {
+ o_result_t *last;
+
+ last = q->results;
+ while (last->next != NULL)
+ last = last->next;
+
+ last->next = r;
+ }
+ }
+
+ if (status != 0)
+ {
+ o_result_free (r);
+ return (-1);
+ }
+
+ return (0);
+} /* }}} int o_config_add_query_result */
+