static alpm_list_t *resolve_pkg(alpm_list_t *targets) { char *pkgname, *reponame; alpm_list_t *t, *r, *ret = NULL; if (targets == NULL) { return all_packages(dblist); } else if (opt_search) { return search_packages(dblist, targets); } else if (opt_groups) { return search_groups(dblist, targets); } /* resolve each target individually from the repo pool */ for (t = targets; t; t = alpm_list_next(t)) { alpm_pkg_t *pkg = NULL; int found = 0; pkgname = reponame = t->data; if (strchr(pkgname, '/')) { strsep(&pkgname, "/"); } else { reponame = NULL; } for (r = dblist; r; r = alpm_list_next(r)) { alpm_db_t *repo = r->data; if (reponame && strcmp(reponame, alpm_db_get_name(repo)) != 0) { continue; } pkg = alpm_db_get_pkg(repo, pkgname); if (pkg == NULL) { continue; } found = 1; ret = alpm_list_add(ret, pkg); if (opt_readone) { break; } } if (!found && opt_verbose) { fprintf(stderr, "error: package `%s' not found\n", pkgname); } } return ret; }
static alpm_list_t *resolve_targets(alpm_list_t *dblist, alpm_list_t *targets) { if(targets == NULL) { return all_packages(dblist); } if(opt_what == SEARCH_REGEX) { return search_packages(dblist, targets); } if(opt_what == SEARCH_GROUPS) { return search_groups(dblist, targets); } return search_exact(dblist, targets); }