summaryrefslogtreecommitdiff
path: root/src/add.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/add.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/add.c')
-rw-r--r--src/add.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/add.c b/src/add.c
index 9fe09b4..9f900e3 100644
--- a/src/add.c
+++ b/src/add.c
@@ -58,13 +58,14 @@ static int non_repository_check(struct apk_database *db)
return 1;
}
-static int add_main(void *ctx, struct apk_database *db, int argc, char **argv)
+static int add_main(void *ctx, struct apk_database *db, struct apk_string_array *args)
{
struct add_ctx *actx = (struct add_ctx *) ctx;
struct apk_package *virtpkg = NULL;
struct apk_dependency virtdep;
struct apk_dependency_array *world = NULL;
- int i, r = 0;
+ char **parg;
+ int r = 0;
apk_dependency_array_copy(&world, db->world);
@@ -96,10 +97,10 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv)
virtpkg = apk_db_pkg_add(db, virtpkg);
}
- for (i = 0; i < argc; i++) {
+ foreach_array_item(parg, args) {
struct apk_dependency dep;
- if (strstr(argv[i], ".apk") != NULL) {
+ if (strstr(*parg, ".apk") != NULL) {
struct apk_package *pkg = NULL;
struct apk_sign_ctx sctx;
@@ -108,20 +109,20 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv)
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));
return -1;
}
apk_dep_from_pkg(&dep, db, pkg);
} else {
- apk_blob_t b = APK_BLOB_STR(argv[i]);
+ apk_blob_t b = APK_BLOB_STR(*parg);
apk_blob_pull_dep(&b, db, &dep);
if (APK_BLOB_IS_NULL(b) || b.len > 0) {
apk_error("'%s' is not a valid dependency, format is name(@tag)([<>=]version)",
- argv[i]);
+ *parg);
return -1;
}
}