return (def);
} /* }}} graph_def_t *def_config_get_obj */
+static int def_to_json_recursive (const graph_def_t *def, /* {{{ */
+ yajl_gen handler)
+{
+ char color[16];
+
+ if (def == NULL)
+ return (0);
+
+ snprintf (color, sizeof (color), "%06"PRIx32, def->color);
+ color[sizeof (color) - 1] = 0;
+
+ yajl_gen_map_open (handler);
+
+#define yajl_gen_string_cast(h,p,l) \
+ yajl_gen_string (h, (unsigned char *) p, (unsigned int) l)
+
+ yajl_gen_string_cast (handler, "select", strlen ("select"));
+ ident_to_json (def->select, handler);
+ yajl_gen_string_cast (handler, "ds_name", strlen ("ds_name"));
+ yajl_gen_string_cast (handler, def->ds_name, strlen (def->ds_name));
+ yajl_gen_string_cast (handler, "legend", strlen ("legend"));
+ yajl_gen_string_cast (handler, def->legend, strlen (def->legend));
+ yajl_gen_string_cast (handler, "color", strlen ("color"));
+ yajl_gen_string_cast (handler, color, strlen (color));
+ yajl_gen_string_cast (handler, "stack", strlen ("stack"));
+ yajl_gen_bool (handler, def->stack);
+ yajl_gen_string_cast (handler, "area", strlen ("area"));
+ yajl_gen_bool (handler, def->area);
+ yajl_gen_string_cast (handler, "format", strlen ("format"));
+ yajl_gen_string_cast (handler, def->format, strlen (def->format));
+
+ yajl_gen_map_close (handler);
+
+ return (def_to_json_recursive (def->next, handler));
+} /* }}} int def_to_json_recursive */
+
/*
* Public functions
*/
return (0);
} /* }}} int def_get_rrdargs */
+int def_to_json (const graph_def_t *def, /* {{{ */
+ yajl_gen handler)
+{
+ if (handler == NULL)
+ return (EINVAL);
+
+ yajl_gen_array_open (handler);
+ def_to_json_recursive (def, handler);
+ yajl_gen_array_close (handler);
+
+ return (0);
+} /* }}} int def_to_json */
+
/* vim: set sw=2 sts=2 et fdm=marker : */