From 209201bc5d400b68d71af0830efe9085c3648665 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Fri, 27 Nov 2020 17:23:33 +0200 Subject: add abstraction to adb "walking" - a sax like API to enumerate whole db This converts 'adbdump' applet to generate adb_walk api callbacks, and implement gentext backend to generate the yaml-like text output. --- src/adb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/adb.c') diff --git a/src/adb.c b/src/adb.c index 44b3589..e86e243 100644 --- a/src/adb.c +++ b/src/adb.c @@ -503,10 +503,12 @@ adb_val_t adb_w_blob(struct adb *db, apk_blob_t b) val.u16 = htole16(n); vec[0].iov_len = sizeof val.u16; o = ADB_TYPE_BLOB_16; - } else { + } else if (n > 0) { val.u8 = n; vec[0].iov_len = sizeof val.u8; o = ADB_TYPE_BLOB_8; + } else { + return ADB_VAL_NULL; } return ADB_VAL(o, adb_w_data(db, vec, ARRAY_SIZE(vec), vec[0].iov_len)); @@ -712,7 +714,7 @@ adb_val_t adb_wa_append(struct adb_obj *o, adb_val_t v) assert(o->schema->kind == ADB_KIND_ARRAY); if (o->num >= o->obj[ADBI_NUM_ENTRIES]) return adb_w_error(o->db, E2BIG); if (ADB_IS_ERROR(v)) return adb_w_error(o->db, ADB_VAL_VALUE(v)); - o->obj[o->num++] = v; + if (v != ADB_VAL_NULL) o->obj[o->num++] = v; return v; } -- cgit v1.2.3-70-g09d2