summaryrefslogtreecommitdiff
path: root/src/fix.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-18 13:01:51 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-18 13:02:27 +0300
commitfe41ae07b90bbd4609ee6871def851a41027aae8 (patch)
tree7f5a872c5ee030450e3cfdb84a73c9338f69d7f4 /src/fix.c
parentc51d82f8f616c2c8939b74c1d78f723ef778f0c8 (diff)
downloadapk-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/fix.c')
-rw-r--r--src/fix.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/fix.c b/src/fix.c
index 7314ddc..c14f93f 100644
--- a/src/fix.c
+++ b/src/fix.c
@@ -52,12 +52,13 @@ static int mark_recalculate(apk_hash_item item, void *ctx)
return 0;
}
-static int fix_main(void *pctx, struct apk_database *db, int argc, char **argv)
+static int fix_main(void *pctx, struct apk_database *db, struct apk_string_array *args)
{
struct fix_ctx *ctx = (struct fix_ctx *) pctx;
struct apk_name *name;
struct apk_package *pkg;
- int r = 0, i;
+ char **parg;
+ int r = 0;
if (!ctx->solver_flags)
ctx->solver_flags = APK_SOLVERF_REINSTALL;
@@ -65,22 +66,22 @@ static int fix_main(void *pctx, struct apk_database *db, int argc, char **argv)
if (ctx->fix_directory_permissions)
apk_hash_foreach(&db->installed.dirs, mark_recalculate, db);
- for (i = 0; i < argc; i++) {
+ foreach_array_item(parg, args) {
pkg = NULL;
- if (strstr(argv[i], ".apk") != NULL) {
+ if (strstr(*parg, ".apk") != NULL) {
struct apk_sign_ctx sctx;
apk_sign_ctx_init(&sctx, APK_SIGN_VERIFY_AND_GENERATE,
NULL, db->keys_fd);
- r = apk_pkg_read(db, argv[i], &sctx, &pkg);
+ r = apk_pkg_read(db, *parg, &sctx, &pkg);
apk_sign_ctx_free(&sctx);
if (r != 0) {
- apk_error("%s: %s", argv[i], apk_error_str(r));
+ apk_error("%s: %s", *parg, apk_error_str(r));
goto err;
}
name = pkg->name;
} else {
- name = apk_db_get_name(db, APK_BLOB_STR(argv[i]));
+ name = apk_db_get_name(db, APK_BLOB_STR(*parg));
pkg = apk_pkg_get_installed(name);
}
if (pkg == NULL || pkg->ipkg == NULL) {