-} /* }}} int register_file */
-
-static int FIXME_graph_create_from_file (const char *host, /* {{{ */
- const char *plugin, const char *plugin_instance,
- const char *type, const char *type_instance,
- const char *title)
-{
- graph_config_t *cfg;
-
- cfg = malloc (sizeof (*cfg));
- if (cfg == NULL)
- return (ENOMEM);
- memset (cfg, 0, sizeof (*cfg));
-
- cfg->select = ident_create (host, plugin, plugin_instance, type, 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);
-
- FIXME_graph_create_from_file (ANY_TOKEN, "cpu", ANY_TOKEN, "cpu", ALL_TOKEN,
- "CPU {instance} usage");
- FIXME_graph_create_from_file (ANY_TOKEN, "memory", "", "memory", ALL_TOKEN,
- "Memory usage");
- FIXME_graph_create_from_file (ANY_TOKEN, "swap", "", "swap", ALL_TOKEN,
- "Swap");
- FIXME_graph_create_from_file (ANY_TOKEN, ANY_TOKEN, ANY_TOKEN, "ps_state", ALL_TOKEN,
- "Processes");
- FIXME_graph_create_from_file (ANY_TOKEN, "cpu", ALL_TOKEN, "cpu", "idle",
- "CPU idle overview");
-
- return (0);
-} /* }}} int read_graph_config */
-
-static void gl_clear (void) /* {{{ */
-{
- graph_config_t *cfg;
-
- cfg = graph_config_head;
- graph_config_head = NULL;
- graph_destroy (cfg);
-
- gl_last_update = 0;
-} /* }}} void gl_clear */
-
-static int callback_type (const char *type, void *user_data) /* {{{ */
-{
- gl_ident_stage_t *gl;
- graph_ident_t *ident;
- int status;
-
- if ((type == NULL) || (user_data == NULL))
- return (EINVAL);
-
- gl = user_data;
- if ((gl->type != NULL) || (gl->type_instance != NULL))
- return (EINVAL);
-
- gl->type = strdup (type);
- if (gl->type == NULL)
- return (ENOMEM);
-
- gl->type_instance = strchr (gl->type, '-');
- if (gl->type_instance != NULL)
- {
- *gl->type_instance = 0;
- gl->type_instance++;
- }
- else
- {
- gl->type_instance = gl->type + strlen (gl->type);
- }
-
- ident = ident_create (gl->host,
- gl->plugin, gl->plugin_instance,
- gl->type, gl->type_instance);
- if (ident == 0)
- {
- status = -1;
- }
- else
- {
- status = register_file (ident);
- ident_destroy (ident);
- }
-
- free (gl->type);
- gl->type = NULL;
- gl->type_instance = NULL;
-
- return (status);
-} /* }}} int callback_type */
-
-static int callback_plugin (const char *plugin, void *user_data) /* {{{ */
-{
- gl_ident_stage_t *gl;
- int status;
-
- if ((plugin == NULL) || (user_data == NULL))
- return (EINVAL);
-
- gl = user_data;
- if ((gl->plugin != NULL) || (gl->plugin_instance != NULL))
- return (EINVAL);
-
- gl->plugin = strdup (plugin);
- if (gl->plugin == NULL)
- return (ENOMEM);
-
- gl->plugin_instance = strchr (gl->plugin, '-');
- if (gl->plugin_instance != NULL)
- {
- *gl->plugin_instance = 0;
- gl->plugin_instance++;
- }
- else
- {
- gl->plugin_instance = gl->plugin + strlen (gl->plugin);
- }
-
- status = foreach_type (gl->host, plugin, callback_type, gl);
-
- free (gl->plugin);
- gl->plugin = NULL;
- gl->plugin_instance = NULL;
-
- return (status);
-} /* }}} int callback_plugin */
-
-static int callback_host (const char *host, void *user_data) /* {{{ */
-{
- gl_ident_stage_t *gl;
- int status;
-
- if ((host == NULL) || (user_data == NULL))
- return (EINVAL);
-
- gl = user_data;
- if (gl->host != NULL)
- return (EINVAL);
-
- gl->host = strdup (host);
- if (gl->host == NULL)
- return (ENOMEM);
-
- status = foreach_plugin (host, callback_plugin, gl);
-
- free (gl->host);
- gl->host = NULL;
-
- return (status);
-} /* }}} int callback_host */