Use xbps_regpkgdb_foreach_pkg_cb() where needed.

This commit is contained in:
Juan RP 2011-12-22 14:41:40 +01:00
parent 7bfcdee791
commit 32597d85c1
2 changed files with 13 additions and 12 deletions

View File

@ -190,11 +190,6 @@ main(int argc, char **argv)
if (argc < 1 || argc > 2)
usage(xhp);
if (xhp->regpkgdb_dictionary == NULL) {
printf("No packages currently installed.\n");
goto out;
}
lpc.check_state = true;
lpc.state = 0;
if (argv[1]) {
@ -219,9 +214,12 @@ main(int argc, char **argv)
/*
* Find the longest pkgver string to pretty print the output.
*/
lpc.pkgver_len = find_longest_pkgver(xhp->regpkgdb_dictionary);
rv = xbps_callback_array_iter_in_dict(xhp->regpkgdb_dictionary,
"packages", list_pkgs_in_dict, &lpc);
lpc.pkgver_len = find_longest_pkgver(NULL);
rv = xbps_regpkgdb_foreach_pkg_cb(list_pkgs_in_dict, &lpc);
if (rv == ENOENT) {
printf("No packages currently registered.\n");
rv = 0;
}
} else if (strcasecmp(argv[0], "install") == 0) {
/* Installs a binary package and required deps. */
@ -368,8 +366,7 @@ main(int argc, char **argv)
if (argc != 1)
usage(xhp);
rv = xbps_callback_array_iter_in_dict(xhp->regpkgdb_dictionary,
"packages", list_manual_pkgs, NULL);
rv = xbps_regpkgdb_foreach_pkg_cb(list_manual_pkgs, NULL);
} else if (strcasecmp(argv[0], "show-revdeps") == 0) {
/*

View File

@ -190,8 +190,12 @@ find_longest_pkgver(prop_dictionary_t d)
{
size_t len = 0;
(void)xbps_callback_array_iter_in_dict(d, "packages",
_find_longest_pkgver_cb, &len);
if (prop_object_type(d) == PROP_TYPE_DICTIONARY)
(void)xbps_callback_array_iter_in_dict(d, "packages",
_find_longest_pkgver_cb, &len);
else
(void)xbps_regpkgdb_foreach_pkg_cb(
_find_longest_pkgver_cb, &len);
return len;
}