diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-10-05 18:52:51 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-10-09 16:09:19 +0300 |
commit | 354713d2f746c197eed6a1feb4c6af3420af6c15 (patch) | |
tree | f9dd51bbdde0f25f8e122832cf006076b8452d28 /src/app_list.c | |
parent | 7a7eca86709fcf31dbb1acf8b82ff411828fb67b (diff) | |
download | apk-tools-354713d2f746c197eed6a1feb4c6af3420af6c15.tar.gz apk-tools-354713d2f746c197eed6a1feb4c6af3420af6c15.tar.bz2 apk-tools-354713d2f746c197eed6a1feb4c6af3420af6c15.tar.xz apk-tools-354713d2f746c197eed6a1feb4c6af3420af6c15.zip |
rename apk_db_options to apk_ctx, rework logging
makes apk_verbosity non-global
fixes #10682
Diffstat (limited to 'src/app_list.c')
-rw-r--r-- | src/app_list.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/app_list.c b/src/app_list.c index 5606df0..a7e05b8 100644 --- a/src/app_list.c +++ b/src/app_list.c @@ -18,6 +18,7 @@ #include "apk_print.h" struct list_ctx { + int verbosity; unsigned int installed : 1; unsigned int orphaned : 1; unsigned int available : 1; @@ -36,8 +37,7 @@ static int origin_matches(const struct list_ctx *ctx, const struct apk_package * if (pkg->origin == NULL) return 0; - foreach_array_item(pmatch, ctx->filters) - { + foreach_array_item(pmatch, ctx->filters) { if (apk_blob_compare(APK_BLOB_STR(*pmatch), *pkg->origin) == 0) return 1; } @@ -103,8 +103,7 @@ static void print_package(const struct apk_package *pkg, const struct list_ctx * if (pkg->ipkg) printf(" [installed]"); - else - { + else { const struct apk_package *u; u = is_upgradable(pkg->name, pkg); @@ -113,10 +112,9 @@ static void print_package(const struct apk_package *pkg, const struct list_ctx * } - if (apk_verbosity > 1) - { + if (ctx->verbosity > 1) { printf("\n %s\n", pkg->description); - if (apk_verbosity > 2) + if (ctx->verbosity > 2) printf(" <%s>\n", pkg->url); } @@ -147,8 +145,7 @@ static void iterate_providers(const struct apk_name *name, const struct list_ctx { struct apk_provider *p; - foreach_array_item(p, name->providers) - { + foreach_array_item(p, name->providers) { if (!ctx->match_providers && p->pkg->name != name) continue; @@ -162,19 +159,17 @@ static void iterate_providers(const struct apk_name *name, const struct list_ctx static void print_result(struct apk_database *db, const char *match, struct apk_name *name, void *pctx) { struct list_ctx *ctx = pctx; + struct apk_name **pname; if (name == NULL) return; - if (ctx->match_depends) - { - struct apk_name **pname; - + if (ctx->match_depends) { foreach_array_item(pname, name->rdepends) iterate_providers(*pname, ctx); - } - else + } else { iterate_providers(name, ctx); + } } #define LIST_OPTIONS(OPT) \ @@ -188,7 +183,7 @@ static void print_result(struct apk_database *db, const char *match, struct apk_ APK_OPT_APPLET(option_desc, LIST_OPTIONS); -static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int opt, const char *optarg) +static int option_parse_applet(void *pctx, struct apk_ctx *ac, int opt, const char *optarg) { struct list_ctx *ctx = pctx; @@ -235,6 +230,7 @@ static int list_main(void *pctx, struct apk_database *db, struct apk_string_arra { struct list_ctx *ctx = pctx; + ctx->verbosity = apk_out_verbosity(&db->ctx->out); ctx->filters = args; if (ctx->match_origin) |