void getselections(const char *const *argv) { struct pkg_array array; struct pkginfo *pkg; const char *thisarg; int i, found; modstatdb_init(admindir,msdbrw_readonly); pkg_array_init_from_db(&array); pkg_array_sort(&array, pkg_sorter_by_name); if (!*argv) { for (i = 0; i < array.n_pkgs; i++) { pkg = array.pkgs[i]; if (pkg->status == stat_notinstalled) continue; getsel1package(pkg); } } else { while ((thisarg= *argv++)) { found= 0; for (i = 0; i < array.n_pkgs; i++) { pkg = array.pkgs[i]; if (fnmatch(thisarg,pkg->name,0)) continue; getsel1package(pkg); found++; } if (!found) fprintf(stderr,_("No packages found matching %s.\n"),thisarg); } } m_output(stdout, _("<standard output>")); m_output(stderr, _("<standard error>")); pkg_array_destroy(&array); }
int getselections(const char *const *argv) { struct pkg_array array; struct pkginfo *pkg; const char *thisarg; int i, found; modstatdb_open(msdbrw_readonly); pkg_array_init_from_db(&array); pkg_array_sort(&array, pkg_sorter_by_nonambig_name_arch); if (!*argv) { for (i = 0; i < array.n_pkgs; i++) { pkg = array.pkgs[i]; if (pkg->status == PKG_STAT_NOTINSTALLED) continue; getsel1package(pkg); } } else { while ((thisarg= *argv++)) { struct pkg_spec pkgspec; found= 0; pkg_spec_init(&pkgspec, PKG_SPEC_PATTERNS | PKG_SPEC_ARCH_WILDCARD); pkg_spec_parse(&pkgspec, thisarg); for (i = 0; i < array.n_pkgs; i++) { pkg = array.pkgs[i]; if (!pkg_spec_match_pkg(&pkgspec, pkg, &pkg->installed)) continue; getsel1package(pkg); found++; } if (!found) notice(_("no packages found matching %s"), thisarg); pkg_spec_destroy(&pkgspec); } } m_output(stdout, _("<standard output>")); m_output(stderr, _("<standard error>")); pkg_array_destroy(&array); return 0; }