summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8b5b923)
raw | patch | inline | side by side (parent: 8b5b923)
author | Florian Forster <ff@octo.it> | |
Tue, 15 Jun 2010 12:18:32 +0000 (14:18 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 15 Jun 2010 12:18:32 +0000 (14:18 +0200) |
action_list_graphs.c | patch | blob | history | |
graph_ident.c | patch | blob | history | |
graph_ident.h | patch | blob | history | |
graph_instance.c | patch | blob | history | |
graph_instance.h | patch | blob | history |
diff --git a/action_list_graphs.c b/action_list_graphs.c
index 4ec9a30948d7c9f9e87644d20b3ac3c4de9a58c1..d7cea47f41f8635475c6e00bdf991e799a3fc422 100644 (file)
--- a/action_list_graphs.c
+++ b/action_list_graphs.c
graph_instance_t *inst,
__attribute__((unused)) void *user_data)
{
- char buffer[1024];
+ char params[1024];
+ char desc[1024];
- memset (buffer, 0, sizeof (buffer));
- inst_get_params (cfg, inst, buffer, sizeof (buffer));
+ memset (params, 0, sizeof (params));
+ inst_get_params (cfg, inst, params, sizeof (params));
+
+ memset (desc, 0, sizeof (desc));
+ inst_describe (cfg, inst, desc, sizeof (desc));
- printf ("<li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n", buffer, buffer);
+ printf ("<li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n", params, desc);
return (0);
} /* }}} int print_graph_inst_html */
diff --git a/graph_ident.c b/graph_ident.c
index 454cc1a1cd9141e3dee50f715663416eff2347e2..b008a56dac3ae6da05fc3e5d0b2b44b141f826fa 100644 (file)
--- a/graph_ident.c
+++ b/graph_ident.c
#include "common.h"
#include "filesystem.h"
-#define IS_ANY(str) (((str) != NULL) && (strcasecmp (ANY_TOKEN, (str)) == 0))
-#define IS_ALL(str) (((str) != NULL) && (strcasecmp (ALL_TOKEN, (str)) == 0))
-
/*
* Data types
*/
diff --git a/graph_ident.h b/graph_ident.h
index 442bcfeba499e6cd3402da090574b2d6ee63230e..5107011ed3dec9d9848ee874895c3cdf32df9bd5 100644 (file)
--- a/graph_ident.h
+++ b/graph_ident.h
#define ANY_TOKEN "/any/"
#define ALL_TOKEN "/all/"
+#define IS_ANY(str) (((str) != NULL) && (strcasecmp (ANY_TOKEN, (str)) == 0))
+#define IS_ALL(str) (((str) != NULL) && (strcasecmp (ALL_TOKEN, (str)) == 0))
+
struct graph_ident_s;
typedef struct graph_ident_s graph_ident_t;
diff --git a/graph_instance.c b/graph_instance.c
index 11629a5ade4d761d7827104bb58430a6c4d44299..d9821d004ce0991f2a40f2c0ae1b4d7ef82501f4 100644 (file)
--- a/graph_instance.c
+++ b/graph_instance.c
return (NULL);
} /* }}} graph_instance_t *inst_find_matching */
+int inst_describe (graph_config_t *cfg, graph_instance_t *inst, /* {{{ */
+ char *buffer, size_t buffer_size)
+{
+ graph_ident_t *cfg_select;
+
+ if ((cfg == NULL) || (inst == NULL)
+ || (buffer == NULL) || (buffer_size < 2))
+ return (EINVAL);
+
+ cfg_select = graph_get_selector (cfg);
+ if (cfg_select == NULL)
+ {
+ fprintf (stderr, "inst_describe: graph_get_selector failed\n");
+ return (-1);
+ }
+
+ buffer[0] = 0;
+
+#define CHECK_FIELD(field) do { \
+ if (IS_ANY (ident_get_##field (cfg_select))) \
+ { \
+ if (buffer[0] != 0) \
+ strlcat (buffer, "/", buffer_size); \
+ strlcat (buffer, ident_get_##field (inst->select), buffer_size); \
+ } \
+} while (0)
+
+ CHECK_FIELD (host);
+ CHECK_FIELD (plugin);
+ CHECK_FIELD (plugin_instance);
+ CHECK_FIELD (type);
+ CHECK_FIELD (type_instance);
+
+#undef CHECK_FIELD
+
+ if (buffer[0] == 0)
+ strlcat (buffer, "default", buffer_size);
+
+ ident_destroy (cfg_select);
+
+ return (0);
+} /* }}} int inst_describe */
+
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/graph_instance.h b/graph_instance.h
index 39cb4c96b91bf2f87bae894b2b45da0455c889c1..b90f98414d3f1c4e4b5e2e0648849af69577d656 100644 (file)
--- a/graph_instance.h
+++ b/graph_instance.h
graph_instance_t *inst_find_matching (graph_instance_t *inst,
const graph_ident_t *ident);
+int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
+ char *buffer, size_t buffer_size);
+
#endif /* GRAPH_INSTANCE_H */
/* vim: set sw=2 sts=2 et fdm=marker : */