libxbps: require a pointer to xbps_handle in functions that need it.

This removes 2 global vars from lib/initend.c and easier to know
what functions require access to xbps_handle.
This commit is contained in:
Juan RP
2012-06-14 08:22:11 +02:00
parent a3adbcda95
commit 3e9e87fc2a
60 changed files with 1143 additions and 901 deletions

View File

@@ -93,14 +93,16 @@ get_state(prop_dictionary_t dict)
}
int
xbps_pkg_state_installed(const char *pkgname, pkg_state_t *state)
xbps_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgname,
pkg_state_t *state)
{
prop_dictionary_t pkgd;
assert(pkgname != NULL);
assert(state != NULL);
pkgd = xbps_pkgdb_get_pkgd(pkgname, false);
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
if (pkgd == NULL)
return ENOENT;
@@ -156,17 +158,16 @@ set_pkg_objs(prop_dictionary_t pkgd, const char *name, const char *version)
}
int
xbps_set_pkg_state_installed(const char *pkgname,
xbps_set_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgname,
const char *version,
pkg_state_t state)
{
struct xbps_handle *xhp;
prop_dictionary_t pkgd;
bool newpkg = false;
int rv;
assert(pkgname != NULL);
xhp = xbps_handle_get();
if (xhp->pkgdb == NULL) {
xhp->pkgdb = prop_array_create();
@@ -198,7 +199,7 @@ xbps_set_pkg_state_installed(const char *pkgname,
return EINVAL;
}
} else {
pkgd = xbps_pkgdb_get_pkgd(pkgname, false);
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
if (pkgd == NULL) {
newpkg = true;
pkgd = prop_dictionary_create();