summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-09-03 13:44:48 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-09-03 13:44:48 +0300
commitfd42c073bf77d37562851ae84cfce1a3a5feb818 (patch)
tree8345723e39a2fba07f7d20e520bd6530b883d0ed
parentbd156836703e52166c282a0fea50a45498cfabdd (diff)
downloadapk-tools-fd42c073bf77d37562851ae84cfce1a3a5feb818.tar.gz
apk-tools-fd42c073bf77d37562851ae84cfce1a3a5feb818.tar.bz2
apk-tools-fd42c073bf77d37562851ae84cfce1a3a5feb818.tar.xz
apk-tools-fd42c073bf77d37562851ae84cfce1a3a5feb818.zip
extract: pass root object instead of database
-rw-r--r--src/apk_extract.h6
-rw-r--r--src/app_extract.c2
-rw-r--r--src/app_manifest.c7
-rw-r--r--src/app_mkndx.c8
-rw-r--r--src/extract_v3.c15
5 files changed, 19 insertions, 19 deletions
diff --git a/src/apk_extract.h b/src/apk_extract.h
index 94fc401..c44ed87 100644
--- a/src/apk_extract.h
+++ b/src/apk_extract.h
@@ -14,7 +14,7 @@
#include "apk_print.h"
#include "apk_io.h"
-struct adb;
+struct adb_obj;
struct apk_ctx;
struct apk_extract_ctx;
@@ -30,8 +30,8 @@ int apk_extract_file(int atfd, const struct apk_file_info *ae,
struct apk_extract_ops {
int (*v2index)(struct apk_extract_ctx *, apk_blob_t *desc, struct apk_istream *is);
int (*v2meta)(struct apk_extract_ctx *, struct apk_istream *is);
- int (*v3index)(struct apk_extract_ctx *, struct adb *);
- int (*v3meta)(struct apk_extract_ctx *, struct adb *);
+ int (*v3index)(struct apk_extract_ctx *, struct adb_obj *);
+ int (*v3meta)(struct apk_extract_ctx *, struct adb_obj *);
int (*script)(struct apk_extract_ctx *, unsigned int script, size_t size, struct apk_istream *is);
int (*file)(struct apk_extract_ctx *, const struct apk_file_info *fi, struct apk_istream *is);
};
diff --git a/src/app_extract.c b/src/app_extract.c
index 7c3fa58..0d13db1 100644
--- a/src/app_extract.c
+++ b/src/app_extract.c
@@ -133,7 +133,7 @@ static int apk_extract_volume(struct apk_ctx *ac, const struct apk_file_info *fi
return r;
}
-static int extract_v3_meta(struct apk_extract_ctx *ectx, struct adb *db)
+static int extract_v3_meta(struct apk_extract_ctx *ectx, struct adb_obj *pkg)
{
return 0;
}
diff --git a/src/app_manifest.c b/src/app_manifest.c
index f048d28..5c2e085 100644
--- a/src/app_manifest.c
+++ b/src/app_manifest.c
@@ -87,19 +87,18 @@ static int process_pkg_file(struct apk_extract_ctx *ectx, const struct apk_file_
return 0;
}
-static int process_v3_meta(struct apk_extract_ctx *ectx, struct adb *db)
+static int process_v3_meta(struct apk_extract_ctx *ectx, struct adb_obj *pkg)
{
struct manifest_file_ctx *mctx = container_of(ectx, struct manifest_file_ctx, ectx);
struct apk_out *out = mctx->out;
- struct adb_obj pkg, paths, path, files, file;
+ struct adb_obj paths, path, files, file;
struct apk_digest digest;
struct apk_pathbuilder pb;
char buf[APK_DIGEST_MAX_LENGTH*2+1];
apk_blob_t hex;
int i, j;
- adb_r_rootobj(db, &pkg, &schema_package);
- adb_ro_obj(&pkg, ADBI_PKG_PATHS, &paths);
+ adb_ro_obj(pkg, ADBI_PKG_PATHS, &paths);
for (i = ADBI_FIRST; i <= adb_ra_num(&paths); i++) {
adb_ro_obj(&paths, i, &path);
diff --git a/src/app_mkndx.c b/src/app_mkndx.c
index b26c2ff..a68e18b 100644
--- a/src/app_mkndx.c
+++ b/src/app_mkndx.c
@@ -176,15 +176,13 @@ static int mkndx_parse_v2meta(struct apk_extract_ctx *ectx, struct apk_istream *
return 0;
}
-static int mkndx_parse_v3meta(struct apk_extract_ctx *ectx, struct adb *db)
+static int mkndx_parse_v3meta(struct apk_extract_ctx *ectx, struct adb_obj *pkg)
{
struct mkndx_ctx *ctx = container_of(ectx, struct mkndx_ctx, ectx);
- struct adb_obj obj;
-
- adb_r_rootobj(db, &obj, &schema_package);
+ struct adb *db = pkg->db;
adb_val_t o = adb_wa_append(&ctx->pkgs,
- adb_w_copy(&ctx->db, db, adb_ro_val(&obj, ADBI_PKG_PKGINFO)));
+ adb_w_copy(&ctx->db, db, adb_ro_val(pkg, ADBI_PKG_PKGINFO)));
if (ADB_IS_ERROR(o)) return -ADB_VAL_VALUE(o);
return 0;
}
diff --git a/src/extract_v3.c b/src/extract_v3.c
index 4d5740f..a5a1459 100644
--- a/src/extract_v3.c
+++ b/src/extract_v3.c
@@ -120,13 +120,14 @@ static int apk_extract_v3_next_file(struct apk_extract_ctx *ectx)
int r;
if (!ctx->cur_path) {
- r = ectx->ops->v3meta(ectx, &ctx->db);
- if (r < 0) return r;
-
// one time init
ctx->cur_path = ADBI_FIRST;
ctx->cur_file = 0;
adb_r_rootobj(&ctx->db, &ctx->pkg, &schema_package);
+
+ r = ectx->ops->v3meta(ectx, &ctx->pkg);
+ if (r < 0) return r;
+
adb_ro_obj(&ctx->pkg, ADBI_PKG_PATHS, &ctx->paths);
adb_ro_obj(&ctx->paths, ctx->cur_path, &ctx->path);
adb_ro_obj(&ctx->path, ADBI_DI_FILES, &ctx->files);
@@ -190,12 +191,12 @@ static int apk_extract_v3_data_block(struct adb *db, struct adb_block *b, struct
return apk_extract_v3_file(ectx, sz, is);
}
-static int apk_extract_v3_verify_index(struct apk_extract_ctx *ectx, struct adb *db)
+static int apk_extract_v3_verify_index(struct apk_extract_ctx *ectx, struct adb_obj *obj)
{
return 0;
}
-static int apk_extract_v3_verify_meta(struct apk_extract_ctx *ectx, struct adb *db)
+static int apk_extract_v3_verify_meta(struct apk_extract_ctx *ectx, struct adb_obj *obj)
{
return 0;
}
@@ -222,6 +223,7 @@ int apk_extract_v3(struct apk_extract_ctx *ectx, struct apk_istream *is)
struct apk_extract_v3_ctx ctx = {
.ectx = ectx,
};
+ struct adb_obj obj;
int r;
if (IS_ERR(is)) return PTR_ERR(is);
@@ -244,7 +246,8 @@ int apk_extract_v3(struct apk_extract_ctx *ectx, struct apk_istream *is)
r = -APKE_FORMAT_NOT_SUPPORTED;
break;
}
- r = ectx->ops->v3index(ectx, &ctx.db);
+ adb_r_rootobj(&ctx.db, &obj, &schema_index);
+ r = ectx->ops->v3index(ectx, &obj);
break;
default:
r = -APKE_ADB_SCHEMA;