From ecdacd15032578148489f868fd928fb502032c60 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Thu, 6 Aug 2009 14:25:03 +0300 Subject: all: implement database open options so user can override trusted keys directory and repositories file. --- src/search.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/search.c') diff --git a/src/search.c b/src/search.c index 52429eb..91c2913 100644 --- a/src/search.c +++ b/src/search.c @@ -98,7 +98,8 @@ static int search_desc(struct apk_database *db, int argc, char **argv) return 0; } -static int search_parse(void *ctx, int optch, int optindex, const char *optarg) +static int search_parse(void *ctx, struct apk_db_options *dbopts, + int optch, int optindex, const char *optarg) { struct search_ctx *ictx = (struct search_ctx *) ctx; @@ -112,22 +113,14 @@ static int search_parse(void *ctx, int optch, int optindex, const char *optarg) return 0; } -static int search_main(void *ctx, int argc, char **argv) +static int search_main(void *ctx, struct apk_database *db, int argc, char **argv) { struct search_ctx *ictx = (struct search_ctx *) ctx; - struct apk_database db; - int r; - - if (apk_db_open(&db, apk_root, APK_OPENF_READ | APK_OPENF_NO_STATE) < 0) - return -1; if (ictx->action != NULL) - r = ictx->action(&db, argc, argv); - else - r = search_list(&db, argc, argv); + return ictx->action(db, argc, argv); - apk_db_close(&db); - return r; + return search_list(db, argc, argv); } static struct apk_option search_options[] = { @@ -138,6 +131,7 @@ static struct apk_applet apk_search = { .name = "search", .help = "Search package names (and descriptions) by wildcard PATTERN.", .arguments = "PATTERN", + .open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE, .context_size = sizeof(struct search_ctx), .num_options = ARRAY_SIZE(search_options), .options = search_options, -- cgit v1.2.3-60-g2f50