+int def_config (graph_config_t *cfg, const oconfig_item_t *ci) /* {{{ */
+{
+ graph_ident_t *ident;
+ char *ds_name = NULL;
+ char *legend = NULL;
+ graph_def_t *def;
+ int i;
+
+ ident = gl_graph_get_selector (cfg);
+ if (ident == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < ci->children_num; i++)
+ {
+ oconfig_item_t *child;
+
+#define HANDLE_FIELD(name,field) \
+ else if (strcasecmp (name, child->key) == 0) \
+ def_config_##field (child, ident)
+
+ child = ci->children + i;
+ if (strcasecmp ("DSName", child->key) == 0)
+ graph_config_get_string (child, &ds_name);
+ else if (strcasecmp ("Legend", child->key) == 0)
+ graph_config_get_string (child, &legend);
+ HANDLE_FIELD ("Host", host);
+ HANDLE_FIELD ("Plugin", plugin);
+ HANDLE_FIELD ("PluginInstance", plugin_instance);
+ HANDLE_FIELD ("Type", type);
+ HANDLE_FIELD ("TypeInstance", type_instance);
+
+#undef HANDLE_FIELD
+ }
+
+ def = def_create (cfg, ident, ds_name);
+ if (def == NULL)
+ {
+ fprintf (stderr, "def_config: def_create failed (ds_name = %s)\n",
+ (ds_name != NULL) ? ds_name : "(null)");
+ ident_destroy (ident);
+ return (EINVAL);
+ }
+
+ def->legend = legend;
+
+ ident_destroy (ident);
+ free (ds_name);
+
+ return (gl_graph_add_def (cfg, def));
+} /* }}} int def_config */
+