summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-08-06 14:25:03 +0300
committerTimo Teras <timo.teras@iki.fi>2009-08-06 14:25:03 +0300
commitecdacd15032578148489f868fd928fb502032c60 (patch)
treee8ad3d487b60017f3f4975d09bbeac4a77b8d0b7 /src/search.c
parentfac43e2d60b550425481052e521d141730a303de (diff)
downloadapk-tools-ecdacd15032578148489f868fd928fb502032c60.tar.gz
apk-tools-ecdacd15032578148489f868fd928fb502032c60.tar.bz2
apk-tools-ecdacd15032578148489f868fd928fb502032c60.tar.xz
apk-tools-ecdacd15032578148489f868fd928fb502032c60.zip
all: implement database open options
so user can override trusted keys directory and repositories file.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c18
1 files changed, 6 insertions, 12 deletions
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,