diff --git a/src/core/store_json.c b/src/core/store_json.c
index a069d8543872ea79e20edd8f31c0355f372488dd..4fd309b3ec4ac6fa81f982fd9e71b2d3226d0af7 100644 (file)
--- a/src/core/store_json.c
+++ b/src/core/store_json.c
buf, type, flags));
} /* sdb_store_json_formatter */
buf, type, flags));
} /* sdb_store_json_formatter */
+/* TODO: Move sdb_store_emit* somewhere else. */
+
int
int
-sdb_store_json_emit(sdb_store_json_formatter_t *f, sdb_store_obj_t *obj)
+sdb_store_emit(sdb_store_obj_t *obj, sdb_store_writer_t *w, sdb_object_t *wd)
{
{
- if ((! f) || (! obj))
+ if ((! obj) || (! w)
+ || (! w->store_host) || (! w->store_service)
+ || (! w->store_metric) || (! w->store_attribute))
return -1;
switch (obj->type) {
return -1;
switch (obj->type) {
(const char * const *)obj->backends,
obj->backends_num,
};
(const char * const *)obj->backends,
obj->backends_num,
};
- return sdb_store_json_writer.store_host(&host, SDB_OBJ(f));
+ return w->store_host(&host, wd);
}
case SDB_SERVICE:
{
}
case SDB_SERVICE:
{
(const char * const *)obj->backends,
obj->backends_num,
};
(const char * const *)obj->backends,
obj->backends_num,
};
- return sdb_store_json_writer.store_service(&service, SDB_OBJ(f));
+ return w->store_service(&service, wd);
}
case SDB_METRIC:
{
}
case SDB_METRIC:
{
(const char * const *)obj->backends,
obj->backends_num,
};
(const char * const *)obj->backends,
obj->backends_num,
};
- return sdb_store_json_writer.store_metric(&metric, SDB_OBJ(f));
+ return w->store_metric(&metric, wd);
}
case SDB_ATTRIBUTE:
{
}
case SDB_ATTRIBUTE:
{
if (obj->parent && (obj->parent->type != SDB_HOST)
&& obj->parent->parent)
attr.hostname = obj->parent->parent->_name;
if (obj->parent && (obj->parent->type != SDB_HOST)
&& obj->parent->parent)
attr.hostname = obj->parent->parent->_name;
- return sdb_store_json_writer.store_attribute(&attr, SDB_OBJ(f));
+ return w->store_attribute(&attr, wd);
}
}
return -1;
}
}
return -1;
-} /* sdb_store_json_emit */
+} /* sdb_store_emit */
int
int
-sdb_store_json_emit_full(sdb_store_json_formatter_t *f, sdb_store_obj_t *obj,
- sdb_store_matcher_t *filter)
+sdb_store_emit_full(sdb_store_obj_t *obj, sdb_store_matcher_t *filter,
+ sdb_store_writer_t *w, sdb_object_t *wd)
{
sdb_avltree_t *trees[] = { NULL, NULL, NULL };
size_t i;
{
sdb_avltree_t *trees[] = { NULL, NULL, NULL };
size_t i;
- if (sdb_store_json_emit(f, obj))
+ if (sdb_store_emit(obj, w, wd))
return -1;
if (obj->type == SDB_HOST) {
return -1;
if (obj->type == SDB_HOST) {
if (filter && (! sdb_store_matcher_matches(filter, child, NULL)))
continue;
if (filter && (! sdb_store_matcher_matches(filter, child, NULL)))
continue;
- if (sdb_store_json_emit_full(f, child, filter)) {
+ if (sdb_store_emit_full(child, filter, w, wd)) {
sdb_avltree_iter_destroy(iter);
return -1;
}
sdb_avltree_iter_destroy(iter);
return -1;
}
sdb_avltree_iter_destroy(iter);
}
return 0;
sdb_avltree_iter_destroy(iter);
}
return 0;
-} /* sdb_store_json_emit_full */
+} /* sdb_store_emit_full */
int
sdb_store_json_finish(sdb_store_json_formatter_t *f)
int
sdb_store_json_finish(sdb_store_json_formatter_t *f)