diff options
author | Timo Teräs <timo.teras@iki.fi> | 2023-03-04 18:12:29 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2023-03-06 21:39:48 +0200 |
commit | 4e200c8fc2e3f3ca7b1a8f48f22eb80edcb6b75b (patch) | |
tree | c4e18b2b7a2d905e694510403ef57d52fcc3afae | |
parent | 8a6d213c18c87c11c2514d37d1593f61cad7645d (diff) | |
download | apk-tools-4e200c8fc2e3f3ca7b1a8f48f22eb80edcb6b75b.tar.gz apk-tools-4e200c8fc2e3f3ca7b1a8f48f22eb80edcb6b75b.tar.bz2 apk-tools-4e200c8fc2e3f3ca7b1a8f48f22eb80edcb6b75b.tar.xz apk-tools-4e200c8fc2e3f3ca7b1a8f48f22eb80edcb6b75b.zip |
dot: use apk_db_foreach_matching_name
-rw-r--r-- | src/app_dot.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/app_dot.c b/src/app_dot.c index ab20700..5cd72f1 100644 --- a/src/app_dot.c +++ b/src/app_dot.c @@ -132,9 +132,15 @@ static int dump_pkg(struct dot_ctx *ctx, struct apk_package *pkg) return ret; } -static int foreach_pkg(apk_hash_item item, void *ctx) +static int dump(struct apk_database *db, const char *match, struct apk_name *name, void *pctx) { - dump_pkg((struct dot_ctx *) ctx, (struct apk_package *) item); + struct dot_ctx *ctx = pctx; + struct apk_provider *p; + + if (!name) return 0; + + foreach_array_item(p, name->providers) + dump_pkg(ctx, p->pkg); return 0; } @@ -142,20 +148,8 @@ static int dot_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *arg { struct apk_database *db = ac->db; struct dot_ctx *ctx = (struct dot_ctx *) pctx; - struct apk_provider *p; - char **parg; - if (args->num) { - foreach_array_item(parg, args) { - struct apk_name *name = apk_db_get_name(db, APK_BLOB_STR(*parg)); - if (!name) - continue; - foreach_array_item(p, name->providers) - dump_pkg(ctx, p->pkg); - } - } else { - apk_hash_foreach(&db->available.packages, foreach_pkg, pctx); - } + apk_db_foreach_matching_name(db, args, dump, pctx); if (!ctx->not_empty) return 1; |