libxbps: added xbps_match_any_virtualpkg_in_rundeps(array rundeps, array provides).

Matches any pkgdep from provides array in the rundeps array with
pkgpatterns. True on match, false otherwise.
This commit is contained in:
Juan RP 2011-10-27 18:48:59 +02:00
parent f87b40eb76
commit 9034df9bc2
2 changed files with 37 additions and 1 deletions

View File

@ -55,7 +55,7 @@
*/
#define XBPS_PKGINDEX_VERSION "1.2"
#define XBPS_API_VERSION "20111027"
#define XBPS_API_VERSION "20111027-1"
#define XBPS_VERSION "0.10.2"
/**
@ -856,6 +856,19 @@ bool xbps_match_virtual_pkg_in_dict(prop_dictionary_t pkgd,
const char *str,
bool bypattern);
/**
* Match any virtual package from array \a provides in they array \a rundeps
* with dependencies.
*
* @param[in] rundeps Proplib array with dependencies as strings, i.e foo>=2.0.
* @param[in] provides Proplib array of strings with virtual pkgdeps, i.e
* foo-1.0 blah-2.0.
*
* @return True if \a any virtualpkg has been matched, false otherwise.
*/
bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
prop_array_t provides);
/**
* Finds a package dictionary in a proplib array by matching a package name.
*

View File

@ -58,6 +58,29 @@ xbps_match_virtual_pkg_in_dict(prop_dictionary_t d,
return found;
}
bool
xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
prop_array_t provides)
{
const char *vpkgver, *pkgpattern;
size_t i, x;
bool found = false;
for (i = 0; i < prop_array_count(provides); i++) {
prop_array_get_cstring_nocopy(provides, i, &vpkgver);
for (x = 0; x < prop_array_count(rundeps); x++) {
prop_array_get_cstring_nocopy(rundeps, x, &pkgpattern);
if (xbps_pkgpattern_match(vpkgver, pkgpattern)) {
found = true;
break;
}
if (found)
break;
}
}
return found;
}
static bool
match_string_in_array(prop_array_t array, const char *str, int mode)
{