summaryrefslogtreecommitdiffstats
path: root/src/pacman/query.c
diff options
context:
space:
mode:
authorSimon Gomizelj <simongmzlj@gmail.com>2013-02-28 19:56:28 +0100
committerAllan McRae <allan@archlinux.org>2013-03-07 06:55:03 +0100
commit098cfe516d0a406ace95b12eeb5a2fecaff27a8b (patch)
treeda81ce6bc467a69f628c5f1e67b12b0c4c961a0d /src/pacman/query.c
parent8b03b1a8776043978aeac31682f94d65b4f3e514 (diff)
downloadpacman-098cfe516d0a406ace95b12eeb5a2fecaff27a8b.tar.gz
pacman-098cfe516d0a406ace95b12eeb5a2fecaff27a8b.tar.xz
refactor common code in query_search/sync_search
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src/pacman/query.c')
-rw-r--r--src/pacman/query.c56
1 files changed, 1 insertions, 55 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 1247c3d4..ba8d7bc7 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -262,62 +262,8 @@ targcleanup:
/* search the local database for a matching package */
static int query_search(alpm_list_t *targets)
{
- alpm_list_t *i, *searchlist;
- int freelist;
alpm_db_t *db_local = alpm_get_localdb(config->handle);
- unsigned short cols;
-
- /* if we have a targets list, search for packages matching it */
- if(targets) {
- searchlist = alpm_db_search(db_local, targets);
- freelist = 1;
- } else {
- searchlist = alpm_db_get_pkgcache(db_local);
- freelist = 0;
- }
- if(searchlist == NULL) {
- return 1;
- }
-
- cols = getcols(fileno(stdout));
- for(i = searchlist; i; i = alpm_list_next(i)) {
- alpm_list_t *grp;
- alpm_pkg_t *pkg = i->data;
-
- if(!config->quiet) {
- printf(LOCAL_PREFIX "%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- } else {
- fputs(alpm_pkg_get_name(pkg), stdout);
- }
-
-
- if(!config->quiet) {
- if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
- alpm_list_t *k;
- fputs(" (", stdout);
- for(k = grp; k; k = alpm_list_next(k)) {
- const char *group = k->data;
- fputs(group, stdout);
- if(alpm_list_next(k)) {
- /* only print a spacer if there are more groups */
- putchar(' ');
- }
- }
- putchar(')');
- }
-
- /* we need a newline and initial indent first */
- fputs("\n ", stdout);
- indentprint(alpm_pkg_get_desc(pkg), 4, cols);
- }
- fputc('\n', stdout);
- }
-
- /* we only want to free if the list was a search list */
- if(freelist) {
- alpm_list_free(searchlist);
- }
- return 0;
+ return dump_pkg_search(db_local, targets, 0);
}
static int query_group(alpm_list_t *targets)