summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e305947)
raw | patch | inline | side by side (parent: e305947)
author | Florian Forster <ff@octo.it> | |
Wed, 21 Jul 2010 09:29:50 +0000 (11:29 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 21 Jul 2010 09:29:50 +0000 (11:29 +0200) |
src/graph_instance.c | patch | blob | history | |
src/graph_instance.h | patch | blob | history |
diff --git a/src/graph_instance.c b/src/graph_instance.c
index 89fdcfbc6a5b8a249e2b0ed977bcbd6c36471b02..5ca8c66ab854250fe0169357e815a67dd783af18 100644 (file)
--- a/src/graph_instance.c
+++ b/src/graph_instance.c
return (0);
} /* }}} _Bool inst_matches_field */
+int inst_to_json (const graph_instance_t *inst, /* {{{ */
+ yajl_gen handler)
+{
+ size_t i;
+
+ if ((inst == NULL) || (handler == NULL))
+ return (EINVAL);
+
+ /* TODO: error handling */
+ yajl_gen_map_open (handler);
+ yajl_gen_string (handler,
+ (unsigned char *) "select",
+ (unsigned int) strlen ("select"));
+ ident_to_json (inst->select, handler);
+ yajl_gen_string (handler,
+ (unsigned char *) "files",
+ (unsigned int) strlen ("files"));
+ yajl_gen_array_open (handler);
+ for (i = 0; i < inst->files_num; i++)
+ ident_to_json (inst->files[i], handler);
+ yajl_gen_array_close (handler);
+ yajl_gen_map_close (handler);
+
+ return (0);
+} /* }}} int inst_to_json */
+
int inst_describe (graph_config_t *cfg, graph_instance_t *inst, /* {{{ */
char *buffer, size_t buffer_size)
{
diff --git a/src/graph_instance.h b/src/graph_instance.h
index 249fe4d2c77d5f2a90131f7b66bd88b2254063a7..5a9cd478838acc72833ea127f10056d20bf4c9c9 100644 (file)
--- a/src/graph_instance.h
+++ b/src/graph_instance.h
#include <time.h>
+#include <yajl/yajl_gen.h>
+
#include "graph_types.h"
#include "graph_ident.h"
#include "rrd_args.h"
_Bool inst_matches_field (graph_instance_t *inst,
graph_ident_field_t field, const char *field_value);
+int inst_to_json (const graph_instance_t *inst, yajl_gen handler);
+
int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
char *buffer, size_t buffer_size);