- graph_create_from_file (file);
-
- return (0);
-} /* }}} int register_file */
-
-static int FIXME_graph_create_from_file (const graph_ident_t *file, /* {{{ */
- const char *title)
-{
- graph_config_t *cfg;
-
- cfg = malloc (sizeof (*cfg));
- if (cfg == NULL)
- return (ENOMEM);
- memset (cfg, 0, sizeof (*cfg));
-
- cfg->select.host = strdup (file->host);
- cfg->select.plugin = strdup (file->plugin);
- cfg->select.plugin_instance = strdup (file->plugin_instance);
- cfg->select.type = strdup (file->type);
- cfg->select.type_instance = strdup (file->type_instance);
-
- cfg->title = NULL;
- if (title != NULL)
- cfg->title = strdup (title);
- cfg->vertical_label = NULL;
- cfg->instances = NULL;
- cfg->next = NULL;
-
- graph_append (cfg);
-
- return (0);
-} /* }}} int FIXME_graph_create_from_file */
-
-/* FIXME: Actually read the config file here. */
-static int read_graph_config (void) /* {{{ */
-{
- if (graph_config_head != NULL)
- return (0);
-
- graph_ident_t ident;
-
-
- ident.host = ANY_TOKEN;
- ident.plugin = "cpu";
- ident.plugin_instance = ANY_TOKEN;
- ident.type = "cpu";
- ident.type_instance = ALL_TOKEN;
- FIXME_graph_create_from_file (&ident, "CPU {instance} usage");
-
- ident.plugin = "memory";
- ident.plugin_instance = "";
- ident.type = "memory";
- FIXME_graph_create_from_file (&ident, "Memory usage");
-
- ident.plugin = "swap";
- ident.plugin_instance = "";
- ident.type = "swap";
- FIXME_graph_create_from_file (&ident, "Swap");
-
- ident.plugin = ANY_TOKEN;
- ident.plugin_instance = ANY_TOKEN;
- ident.type = "ps_state";
- FIXME_graph_create_from_file (&ident, "Processes");
-
- ident.host = ALL_TOKEN;
- ident.plugin = "cpu";
- ident.plugin_instance = ALL_TOKEN;
- ident.type = "cpu";
- ident.type_instance = "idle";
- FIXME_graph_create_from_file (&ident, "CPU idle overview");
-
- return (0);
-} /* }}} int read_graph_config */
-
-static int gl_compare (const void *p0, const void *p1) /* {{{ */
-{
- const graph_ident_t *gl0 = p0;
- const graph_ident_t *gl1 = p1;
- int status;
-
- status = strcmp (gl0->host, gl1->host);
- if (status != 0)
- return (status);
-
- status = strcmp (gl0->plugin, gl1->plugin);
- if (status != 0)
- return (status);
-
- status = strcmp_s (gl0->plugin_instance, gl1->plugin_instance);
- if (status != 0)
- return (status);
-
- status = strcmp (gl0->type, gl1->type);
- if (status != 0)
- return (status);
-
- return (strcmp_s (gl0->type_instance, gl1->type_instance));
-} /* }}} int gl_compare */
-
-static void gl_clear_entry (graph_ident_t *gl) /* {{{ */
-{
- if (gl == NULL)
- return;
-
- free (gl->host);
- free (gl->plugin);
- free (gl->plugin_instance);
- free (gl->type);
- free (gl->type_instance);
-
- gl->host = NULL;
- gl->plugin = NULL;
- gl->plugin_instance = NULL;
- gl->type = NULL;
- gl->type_instance = NULL;
-} /* }}} void gl_clear_entry */
-
-static void gl_clear (void) /* {{{ */
-{
- size_t i;
- graph_config_t *cfg;
-
- cfg = graph_config_head;
- graph_config_head = NULL;
- graph_destroy (cfg);
-
- for (i = 0; i < graph_list_length; i++)
- gl_clear_entry (graph_list + i);
-
- free (graph_list);
- graph_list = NULL;
- graph_list_length = 0;
- gl_last_update = 0;
-} /* }}} void gl_clear */
-
-static int gl_add_copy (graph_ident_t *gl) /* {{{ */
-{
- graph_ident_t *ptr;
- int status;
-
- if (gl == NULL)
- return (EINVAL);
-
- ptr = realloc (graph_list, sizeof (*graph_list) * (graph_list_length + 1));
- if (ptr == NULL)
- return (ENOMEM);
- graph_list = ptr;
-
- ptr = graph_list + graph_list_length;
- memset (ptr, 0, sizeof (*ptr));
- ptr->host = NULL;
- ptr->plugin = NULL;
- ptr->plugin_instance = NULL;
- ptr->type = NULL;
- ptr->type_instance = NULL;
-
-#define DUP_OR_BREAK(member) do { \
- ptr->member = NULL; \
- if (gl->member != NULL) \
- { \
- ptr->member = strdup (gl->member); \
- if (ptr->member == NULL) \
- break; \
- } \
-} while (0)
-
- status = ENOMEM;
- do