summaryrefslogtreecommitdiff
path: root/src/adb.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-11-27 17:23:33 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-05-26 12:47:48 +0300
commit209201bc5d400b68d71af0830efe9085c3648665 (patch)
tree6477d1fa9b523afc47f37b3b0660281806b41604 /src/adb.c
parent7167bc9e7b67be4b067dfc266872a7ea996bf58a (diff)
downloadapk-tools-209201bc5d400b68d71af0830efe9085c3648665.tar.gz
apk-tools-209201bc5d400b68d71af0830efe9085c3648665.tar.bz2
apk-tools-209201bc5d400b68d71af0830efe9085c3648665.tar.xz
apk-tools-209201bc5d400b68d71af0830efe9085c3648665.zip
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.
Diffstat (limited to 'src/adb.c')
-rw-r--r--src/adb.c6
1 files changed, 4 insertions, 2 deletions
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;
}