diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-10-05 14:24:08 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-10-09 16:09:19 +0300 |
commit | b2af872fff8af2dcde8500f84843c8fa4d554579 (patch) | |
tree | a193819ae91e6b6394a02febaa14627c870a2b8d /src | |
parent | 010497cb5ae50713f0ed4e4c4bf3b860bf751da7 (diff) | |
download | apk-tools-b2af872fff8af2dcde8500f84843c8fa4d554579.tar.gz apk-tools-b2af872fff8af2dcde8500f84843c8fa4d554579.tar.bz2 apk-tools-b2af872fff8af2dcde8500f84843c8fa4d554579.tar.xz apk-tools-b2af872fff8af2dcde8500f84843c8fa4d554579.zip |
db: convert repository list to a string array
Diffstat (limited to 'src')
-rw-r--r-- | src/apk.c | 17 | ||||
-rw-r--r-- | src/apk_database.h | 7 | ||||
-rw-r--r-- | src/database.c | 7 | ||||
-rw-r--r-- | src/lua-apk.c | 2 |
4 files changed, 8 insertions, 25 deletions
@@ -63,16 +63,6 @@ static void version(void) ); } -static struct apk_repository_list *apk_repository_new(const char *url) -{ - struct apk_repository_list *r = calloc(1, sizeof(struct apk_repository_list)); - if (r) { - r->url = url; - list_init(&r->list); - } - return r; -} - #define GLOBAL_OPTIONS(OPT) \ OPT(OPT_GLOBAL_allow_untrusted, "allow-untrusted") \ OPT(OPT_GLOBAL_arch, APK_OPT_ARG "arch") \ @@ -118,8 +108,6 @@ APK_OPT_GROUP(optiondesc_global, "Global", GLOBAL_OPTIONS); static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt, const char *optarg) { - struct apk_repository_list *repo; - switch (opt) { case OPT_GLOBAL_help: return -EINVAL; @@ -133,8 +121,7 @@ static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt dbopts->repositories_file = optarg; break; case OPT_GLOBAL_repository: - repo = apk_repository_new(optarg); - if (repo) list_add(&repo->list, &dbopts->repository_list); + *apk_string_array_add(&dbopts->repository_list) = (char*) optarg; break; case OPT_GLOBAL_quiet: apk_verbosity--; @@ -471,7 +458,7 @@ int main(int argc, char **argv) apk_argv[argc+1] = NULL; memset(&dbopts, 0, sizeof(dbopts)); - list_init(&dbopts.repository_list); + apk_string_array_init(&dbopts.repository_list); apk_string_array_init(&dbopts.private_keys); umask(0); setup_terminal(); diff --git a/src/apk_database.h b/src/apk_database.h index 1b0dbc6..83388ec 100644 --- a/src/apk_database.h +++ b/src/apk_database.h @@ -117,11 +117,6 @@ struct apk_repository { apk_blob_t description; }; -struct apk_repository_list { - struct list_head list; - const char *url; -}; - struct apk_db_options { int lock_wait; unsigned int cache_max_age; @@ -131,7 +126,7 @@ struct apk_db_options { const char *keys_dir; const char *cache_dir; const char *repositories_file; - struct list_head repository_list; + struct apk_string_array *repository_list; struct apk_string_array *private_keys; }; diff --git a/src/database.c b/src/database.c index 9d1c82b..806f873 100644 --- a/src/database.c +++ b/src/database.c @@ -1511,7 +1511,6 @@ void apk_db_init(struct apk_database *db) int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) { const char *msg = NULL; - struct apk_repository_list *repo = NULL; struct statfs stfs; apk_blob_t blob; int r, fd, write_arch = FALSE; @@ -1695,8 +1694,10 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) } if (!(dbopts->open_flags & APK_OPENF_NO_SYS_REPOS)) { - list_for_each_entry(repo, &dbopts->repository_list, list) - apk_db_add_repository(db, APK_BLOB_STR(repo->url)); + char **repo; + + foreach_array_item(repo, dbopts->repository_list) + apk_db_add_repository(db, APK_BLOB_STR(*repo)); if (dbopts->repositories_file == NULL) { add_repos_from_file(db, db->root_fd, "etc/apk/repositories"); diff --git a/src/lua-apk.c b/src/lua-apk.c index f653163..6cd0208 100644 --- a/src/lua-apk.c +++ b/src/lua-apk.c @@ -170,7 +170,7 @@ static int Papk_db_open(lua_State *L) int r; memset(&opts, 0, sizeof(opts)); - list_init(&opts.repository_list); + apk_string_array_init(&opts.repository_list); if (lua_istable(L, 1)) get_dbopts(L, 1, &opts); else |