summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b578a6b)
raw | patch | inline | side by side (parent: b578a6b)
author | Florian Forster <ff@octo.it> | |
Tue, 7 Sep 2010 14:56:55 +0000 (16:56 +0200) | ||
committer | Florian Forster <ff@octo.it> | |
Tue, 7 Sep 2010 14:56:55 +0000 (16:56 +0200) |
src/graph_list.c | patch | blob | history | |
src/graph_list.h | patch | blob | history |
diff --git a/src/graph_list.c b/src/graph_list.c
index ac4bfac78a3082e76293e98637a497c088142aaa..a0f0f29850932ecf4b51484b32591ed904455626 100644 (file)
--- a/src/graph_list.c
+++ b/src/graph_list.c
static time_t gl_last_update = 0;
+/* TODO: Turn this into an array for multiple data providers. */
+static data_provider_t *data_provider = NULL;
+
/*
* Private functions
*/
return (0);
} /* }}} int gl_register_file */
+static int gl_register_ident (const graph_ident_t *ident, /* {{{ */
+ __attribute__((unused)) void *user_data)
+{
+ /* TODO: Check for duplicates if multiple data providers are used. */
+
+ return (gl_register_file (ident, user_data));
+} /* }}} int gl_register_ident */
+
static const char *get_part_from_param (const char *prim_key, /* {{{ */
const char *sec_key)
{
return (0);
} /* }}} int graph_config_submit */
-int gl_register_ident (const char *provider, const graph_ident_t *ident) /* {{{ */
-{
- char *ident_str = ident_to_string (ident);
-
- fprintf (stderr, "gl_register_ident (provider = %s, ident = %s)\n",
- provider, ident_str);
-
- free (ident_str);
- return (0);
-} /* }}} int gl_register_ident */
-
int gl_register_data_provider (const char *name, data_provider_t *p) /* {{{ */
{
fprintf (stderr, "gl_register_data_provider (name = %s, ptr = %p)\n",
name, (void *) p);
+ if (data_provider == NULL)
+ data_provider = malloc (sizeof (*data_provider));
+ if (data_provider == NULL)
+ return (ENOMEM);
+
+ *data_provider = *p;
+
return (0);
} /* }}} int gl_register_data_provider */
if ((status != 0)
|| ((gl_last_update + UPDATE_INTERVAL) < now))
{
+ if (data_provider == NULL)
+ {
+ fprintf (stderr, "No data provider has been registered\n");
+ return (ENOENT);
+ }
+
/* Clear state */
gl_clear_instances ();
gl_clear_hosts ();
gl_destroy (&gl_dynamic, &gl_dynamic_num);
- status = fs_scan (/* callback = */ gl_register_file,
- /* user data = */ NULL);
+ /* TODO: Iterate over all data providers */
+ data_provider->get_idents (data_provider->private_data,
+ gl_register_ident, /* user data = */ NULL);
+
gl_last_update = now;
}
diff --git a/src/graph_list.h b/src/graph_list.h
index f388fbe4e93ae4afc18f8ca377abd02634ab44cc..ff35f18e06d545fbb38fca7d7c2364c2017def00 100644 (file)
--- a/src/graph_list.h
+++ b/src/graph_list.h
int gl_config_submit (void);
-int gl_register_ident (const char *provider, const graph_ident_t *ident);
int gl_register_data_provider (const char *name, data_provider_t *p);
graph_config_t *gl_graph_get_selected (void);