summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2023-03-04 18:12:29 +0200
committerTimo Teräs <timo.teras@iki.fi>2023-04-11 20:47:43 +0300
commitb72ba58207742d044b2933bb2f2ddd3051009aee (patch)
tree596bf53b01ec24b57fb306050778b213a33521bd
parentadafc698009724342762d61176f0edea422bc2b1 (diff)
downloadapk-tools-b72ba58207742d044b2933bb2f2ddd3051009aee.tar.gz
apk-tools-b72ba58207742d044b2933bb2f2ddd3051009aee.tar.bz2
apk-tools-b72ba58207742d044b2933bb2f2ddd3051009aee.tar.xz
apk-tools-b72ba58207742d044b2933bb2f2ddd3051009aee.zip
dot: use apk_db_foreach_matching_name
-rw-r--r--src/app_dot.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/app_dot.c b/src/app_dot.c
index ad9167c..0a86e45 100644
--- a/src/app_dot.c
+++ b/src/app_dot.c
@@ -132,29 +132,23 @@ 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;
}
static int dot_main(void *pctx, struct apk_database *db, struct apk_string_array *args)
{
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;