summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f3fc23c)
raw | patch | inline | side by side (parent: f3fc23c)
author | Florian Forster <octo@verplant.org> | |
Wed, 8 Sep 2010 09:25:49 +0000 (11:25 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Wed, 8 Sep 2010 09:25:49 +0000 (11:25 +0200) |
src/graph.c | patch | blob | history | |
src/graph.h | patch | blob | history |
diff --git a/src/graph.c b/src/graph.c
index ad47e46faed2ec173b1d59637a483581e58ed7c5..fdbf71357fd91c274e9a5c883b1cfc8dd996d431 100644 (file)
--- a/src/graph.c
+++ b/src/graph.c
return (0);
} /* }}} int graph_to_json */
+int graph_def_to_json (const graph_config_t *cfg, /* {{{ */
+ yajl_gen handler)
+{
+#define yajl_gen_string_cast(h,p,l) \
+ yajl_gen_string (h, (unsigned char *) p, (unsigned int) l)
+
+ if ((cfg == NULL) || (handler == NULL))
+ return (EINVAL);
+
+ yajl_gen_map_open (handler);
+
+ yajl_gen_string_cast (handler, "select", strlen ("select"));
+ ident_to_json (cfg->select, handler);
+ yajl_gen_string_cast (handler, "title", strlen ("title"));
+ yajl_gen_string_cast (handler, cfg->title, strlen (cfg->title));
+ yajl_gen_string_cast (handler, "vertical_label", strlen ("vertical_label"));
+ yajl_gen_string_cast (handler, cfg->vertical_label, strlen (cfg->vertical_label));
+ yajl_gen_string_cast (handler, "show_zero", strlen ("show_zero"));
+ yajl_gen_bool (handler, cfg->show_zero);
+
+ yajl_gen_string_cast (handler, "defs", strlen ("defs"));
+ def_to_json (cfg->defs, handler);
+
+ yajl_gen_map_close (handler);
+
+ return (0);
+#undef yajl_gen_string_cast
+} /* }}} int graph_def_to_json */
+
static int graph_sort_instances_cb (const void *v0, const void *v1) /* {{{ */
{
return (inst_compare (*(graph_instance_t * const *) v0,
diff --git a/src/graph.h b/src/graph.h
index e9c603ac8dcdbc2510bd42a7d16232627f5cdefe..2873103ba1153f5c105ce0903f8e72080b7b5cec 100644 (file)
--- a/src/graph.h
+++ b/src/graph.h
int graph_compare (graph_config_t *cfg, const graph_ident_t *ident);
int graph_to_json (const graph_config_t *cfg, yajl_gen handler);
+int graph_def_to_json (const graph_config_t *cfg, yajl_gen handler);
size_t graph_num_instances (graph_config_t *cfg);