Code

store: Let JSON serializers support (object) filters.
[sysdb.git] / src / frontend / query.c
index 759b9c9795ebbe86da1c9ab4308c0c641f7e10aa..53ba81aac38b03dd24bc07922b146a1dc6d23c4c 100644 (file)
  */
 
 static int
-lookup_tojson(sdb_store_base_t *obj, void *user_data)
+lookup_tojson(sdb_store_obj_t *obj, void *user_data)
 {
        sdb_strbuf_t *buf = user_data;
        if (sdb_strbuf_len(buf) > 1)
                sdb_strbuf_append(buf, ",");
-       return sdb_store_host_tojson(obj, buf, /* flags = */ 0);
+       return sdb_store_host_tojson(obj, buf,
+                       /* filter = */ NULL, /* flags = */ 0);
 } /* lookup_tojson */
 
 /*
@@ -76,7 +77,7 @@ int
 sdb_fe_fetch(sdb_conn_t *conn, const char *name)
 {
        sdb_strbuf_t *buf;
-       sdb_store_base_t *host;
+       sdb_store_obj_t *host;
 
        host = sdb_store_get_host(name);
        if (! host) {
@@ -100,7 +101,8 @@ sdb_fe_fetch(sdb_conn_t *conn, const char *name)
                return -1;
        }
 
-       if (sdb_store_host_tojson(host, buf, /* flags = */ 0)) {
+       if (sdb_store_host_tojson(host, buf,
+                               /* filter = */ NULL, /* flags = */ 0)) {
                sdb_log(SDB_LOG_ERR, "frontend: Failed to serialize "
                                "host '%s' to JSON", name);
                sdb_strbuf_sprintf(conn->errbuf, "Out of memory");
@@ -133,7 +135,8 @@ sdb_fe_list(sdb_conn_t *conn)
                return -1;
        }
 
-       if (sdb_store_tojson(buf, /* flags = */ 0)) {
+       if (sdb_store_tojson(buf,
+                               /* filter = */ NULL, /* flags = */ SDB_SKIP_ALL)) {
                sdb_log(SDB_LOG_ERR, "frontend: Failed to serialize "
                                "store to JSON");
                sdb_strbuf_sprintf(conn->errbuf, "Out of memory");
@@ -166,7 +169,7 @@ sdb_fe_lookup(sdb_conn_t *conn, sdb_store_matcher_t *m)
 
        sdb_strbuf_append(buf, "[");
 
-       if (sdb_store_lookup(m, lookup_tojson, buf)) {
+       if (sdb_store_scan(m, /* filter */ NULL, lookup_tojson, buf)) {
                sdb_log(SDB_LOG_ERR, "frontend: Failed to lookup hosts");
                sdb_strbuf_sprintf(conn->errbuf, "Failed to lookup hosts");
                sdb_strbuf_destroy(buf);