Example #1
0
/* -Qs, only 1 target for now */
static int query_search(alpm_db_t *localdb, const char *pkgname)
{
    int ret, found;
    const char *repo;
    alpm_list_t *i, *k, *dbcache, *groups;
    alpm_list_t *syncdbs;
    alpm_pkg_t *pkg;

    dbcache = alpm_db_get_pkgcache(localdb);
    syncdbs = alpm_option_get_syncdbs(config->handle);

    for (k = dbcache; k; k = k->next) {
        pkg = k->data;
        groups = NULL;

        if (!strcmp(pkgname, alpm_pkg_get_name(pkg))) {
            repo = which_db(syncdbs, pkgname, &groups);
            color_repo(repo);
            printf("%s%s %s%s", color.bold, pkgname,
                   color.bgreen, alpm_pkg_get_version(pkg));
            color_groups(groups);
            printf("%s %s\n", TAB, alpm_pkg_get_desc(pkg));
            found = 1;
        }
    }

    return found ? 0: -1;
}
Example #2
0
/* For plain -Q, -Qs, -Ss */
void print_pkg_pretty(alpm_list_t *sdbs, pmpkg_t *pkg, enum dumplvl_t lvl)
{
	alpm_list_t *grp = NULL;
	const char *repo;
	int found_db, grpcnt;

	repo = which_db(sdbs, alpm_pkg_get_name(pkg), &grp);
	color_repo(repo);
	printf("%s%s %s%s%s", color.bold, alpm_pkg_get_name(pkg),
		   color.bgreen, alpm_pkg_get_version(pkg), color.nocolor);

	color_groups(grp);

	if (lvl == DUMP_Q_SEARCH) {
		printf("%s%s\n", TAB, alpm_pkg_get_desc(pkg));
	} else if (lvl == DUMP_S_SEARCH) {
		printf("%s%s", TAB, alpm_pkg_get_desc(pkg));
	}
}