diff options
author | Timo Teräs <timo.teras@iki.fi> | 2013-06-18 13:01:51 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2013-06-18 13:02:27 +0300 |
commit | fe41ae07b90bbd4609ee6871def851a41027aae8 (patch) | |
tree | 7f5a872c5ee030450e3cfdb84a73c9338f69d7f4 /src/fetch.c | |
parent | c51d82f8f616c2c8939b74c1d78f723ef778f0c8 (diff) | |
download | apk-tools-fe41ae07b90bbd4609ee6871def851a41027aae8.tar.gz apk-tools-fe41ae07b90bbd4609ee6871def851a41027aae8.tar.bz2 apk-tools-fe41ae07b90bbd4609ee6871def851a41027aae8.tar.xz apk-tools-fe41ae07b90bbd4609ee6871def851a41027aae8.zip |
apk: use string array in applet mains, separate apk_name_foreach_matching
Diffstat (limited to 'src/fetch.c')
-rw-r--r-- | src/fetch.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/fetch.c b/src/fetch.c index f2aa6e9..eaa6961 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -190,26 +190,27 @@ static void mark_package(struct fetch_ctx *ctx, struct apk_package *pkg) pkg->marked = 1; } -static int fetch_main(void *pctx, struct apk_database *db, int argc, char **argv) +static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_array *args) { struct fetch_ctx *ctx = (struct fetch_ctx *) pctx; struct apk_dependency_array *world; struct apk_change *change; - int r = 0, i; + char **parg; + int r = 0; if (ctx->outdir_fd == 0) ctx->outdir_fd = AT_FDCWD; - if ((argc > 0) && (strcmp(argv[0], "coffee") == 0)) { + if ((args->num == 1) && (strcmp(args->item[0], "coffee") == 0)) { if (apk_flags & APK_FORCE) return cup(); apk_message("Go and fetch your own coffee."); return 0; } - for (i = 0; i < argc; i++) { + foreach_array_item(parg, args) { struct apk_dependency dep = (struct apk_dependency) { - .name = apk_db_get_name(db, APK_BLOB_STR(argv[i])), + .name = apk_db_get_name(db, APK_BLOB_STR(*parg)), .version = apk_blob_atomize(APK_BLOB_NULL), .result_mask = APK_DEPMASK_ANY, }; @@ -222,7 +223,7 @@ static int fetch_main(void *pctx, struct apk_database *db, int argc, char **argv r = apk_solver_solve(db, 0, world, &changeset); apk_dependency_array_free(&world); if (r != 0) { - apk_error("%s: unable to get dependencies", argv[i]); + apk_error("%s: unable to get dependencies", dep.name->name); ctx->errors++; } else { foreach_array_item(change, changeset.changes) |