aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-01-29 02:39:39 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-01-29 02:39:39 +0000
commit8fcb57bf0f80cec68ce24ef5d9305f23a8d99779 (patch)
tree03d850f705f4dfca5c848c81a1ed7ee5379b553f /src
parent900548db0ea69b022348ed9e075b013d1f0993f0 (diff)
list: refactor package dumping vs package filtering
Diffstat (limited to 'src')
-rw-r--r--src/list.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/list.c b/src/list.c
index 08c02a1..a3e8f84 100644
--- a/src/list.c
+++ b/src/list.c
@@ -125,36 +125,36 @@ static void print_package(const struct apk_package *pkg, const struct list_ctx *
printf("\n");
}
-static void print_result(struct apk_database *db, const char *match, struct apk_name *name, void *pctx)
+static void filter_package(const struct apk_package *pkg, const struct list_ctx *ctx)
{
- struct list_ctx *ctx = pctx;
- struct apk_provider *p;
- struct apk_package *pkg;
+ if (ctx->match_origin && !origin_matches(ctx, pkg))
+ return;
- if (name == NULL)
+ if (ctx->installed && pkg->ipkg == NULL)
return;
- foreach_array_item(p, name->providers)
- {
- pkg = p->pkg;
+ if (ctx->orphaned && !is_orphaned(pkg->name))
+ return;
- if (ctx->match_origin && !origin_matches(ctx, pkg))
- continue;
+ if (ctx->available && pkg->repos == BIT(1))
+ return;
- if (ctx->installed && pkg->ipkg == NULL)
- continue;
+ if (ctx->upgradable && !is_upgradable(pkg->name, pkg))
+ return;
- if (ctx->orphaned && !is_orphaned(name))
- continue;
+ print_package(pkg, ctx);
+}
- if (ctx->available && pkg->repos == BIT(1))
- continue;
+static void print_result(struct apk_database *db, const char *match, struct apk_name *name, void *pctx)
+{
+ struct list_ctx *ctx = pctx;
+ struct apk_provider *p;
- if (ctx->upgradable && !is_upgradable(name, pkg))
- continue;
+ if (name == NULL)
+ return;
- print_package(pkg, ctx);
- }
+ foreach_array_item(p, name->providers)
+ filter_package(p->pkg, ctx);
}
static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int optch, const char *optarg)