Use xbps_callback_array_iter_in_repolist() and removed dup code.

--HG--
extra : convert_revision : 7eb9c1b3df3fc7fde2ff61ac0cce1d635c3fef18
This commit is contained in:
Juan RP
2009-02-14 02:26:11 +01:00
parent 90fd3828e6
commit 83ed100fcf
4 changed files with 16 additions and 57 deletions

View File

@@ -70,7 +70,6 @@ int
xbps_install_binary_pkg(const char *pkgname, const char *destdir)
{
struct cbargs cb;
char *plist;
int rv = 0;
assert(pkgname != NULL);
@@ -80,22 +79,14 @@ xbps_install_binary_pkg(const char *pkgname, const char *destdir)
} else
destdir = "NOTSET";
/*
* Get the dictionary with the list of registered repositories.
*/
plist = xbps_append_full_path(true, NULL, XBPS_REPOLIST);
if (plist == NULL)
return EINVAL;
cb.pkgname = pkgname;
cb.destdir = destdir;
/*
* Iterate over the repository pool and find out if we have
* all available binary packages.
*/
rv = xbps_callback_array_iter_in_repolist(plist,
install_binpkg_repo_cb, (void *)&cb);
free(plist);
rv = xbps_callback_array_iter_in_repolist(install_binpkg_repo_cb,
(void *)&cb);
return rv;
}

View File

@@ -66,16 +66,19 @@ xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
}
int
xbps_callback_array_iter_in_repolist(const char *plist,
int (*fn)(prop_object_t, void *, bool *),
xbps_callback_array_iter_in_repolist(int (*fn)(prop_object_t, void *, bool *),
void *arg)
{
prop_dictionary_t repolistd;
char *plist;
int rv = 0;
assert(plist != NULL);
assert(fn != NULL);
plist = xbps_append_full_path(true, NULL, XBPS_REPOLIST);
if (plist == NULL)
return EINVAL;
/*
* Get the dictionary with the list of registered repositories.
*/
@@ -91,6 +94,7 @@ xbps_callback_array_iter_in_repolist(const char *plist,
rv = xbps_callback_array_iter_in_dict(repolistd, "repository-list",
fn, arg);
prop_object_release(repolistd);
free(plist);
return rv;
}