summaryrefslogtreecommitdiff
path: root/src/adb.h
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.h
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.h')
-rw-r--r--src/adb.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/adb.h b/src/adb.h
index 413ef36..cf3da69 100644
--- a/src/adb.h
+++ b/src/adb.h
@@ -236,4 +236,39 @@ struct adb_xfrm {
};
int adb_c_xfrm(struct adb_xfrm *, int (*cb)(struct adb_xfrm *, struct adb_block *, struct apk_istream *));
+/* SAX style event based handling of ADB */
+
+struct adb_db_schema {
+ unsigned long magic;
+ const struct adb_object_schema *root;
+};
+
+struct adb_walk;
+struct adb_walk_ops {
+ int (*schema)(struct adb_walk *, uint32_t schema_id);
+ int (*comment)(struct adb_walk *, apk_blob_t comment);
+ int (*start_array)(struct adb_walk *, unsigned int num_items);
+ int (*start_object)(struct adb_walk *);
+ int (*end)(struct adb_walk *);
+ int (*key)(struct adb_walk *, apk_blob_t key_name);
+ int (*scalar)(struct adb_walk *, apk_blob_t scalar, int multiline);
+};
+
+extern const struct adb_walk_ops adb_walk_gentext_ops;
+
+struct adb_walk {
+ const struct adb_walk_ops *ops;
+ const struct adb_db_schema *schemas;
+};
+
+struct adb_walk_gentext {
+ struct adb_walk d;
+ FILE *out;
+ int nest;
+ int line_started : 1;
+ int key_printed : 1;
+};
+
+int adb_walk_adb(struct adb_walk *d, struct adb *db, struct apk_trust *trust);
+
#endif