From 17829cd6b48fda4ff74222964e091cd4b919713f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 15 Jul 2011 18:45:38 +0200 Subject: [PATCH] libxbps: add xbps_find_virtualpkg_in_array_by_{name,pattern} and use it. --- include/xbps_api.h | 23 +++++++++++++++++++++++ lib/package_requiredby.c | 2 +- lib/plist_find.c | 12 ++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/xbps_api.h b/include/xbps_api.h index 1927a0ce..6862b83c 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -667,6 +667,29 @@ prop_dictionary_t xbps_find_pkg_in_array_by_name(prop_array_t array, prop_dictionary_t xbps_find_pkg_in_array_by_pattern(prop_array_t array, const char *pattern); +/** + * Finds a virtual package dictionary in a proplib array by matching a + * package name. + * + * @param[in] array The proplib array where to look for. + * @param[in] name The virtual package name to match. + * + * @return true on success, false otherwise and errno is set appropiately. + */ +prop_dictionary_t xbps_find_virtualpkg_in_array_by_name(prop_array_t array, + const char *name); + +/** + * Finds a virtual package dictionary in a proplib array by matching a + * package pattern. + * + * @param[in] array The proplib array where to look for. + * @param[in] pattern The virtual package pattern to match. + * + * @return true on success, false otherwise and errno is set appropiately. + */ +prop_dictionary_t xbps_find_virtualpkg_in_array_by_pattern(prop_array_t array, + const char *pattern); /** * Match a package name in the specified array of strings. * diff --git a/lib/package_requiredby.c b/lib/package_requiredby.c index cd51999a..9de83a42 100644 --- a/lib/package_requiredby.c +++ b/lib/package_requiredby.c @@ -168,7 +168,7 @@ xbps_requiredby_pkg_add(prop_array_t pkgs_array, prop_dictionary_t pkgd) break; } pkgd_regpkgdb = - xbps_find_pkg_in_array_by_pattern(pkgs_array, str); + xbps_find_virtualpkg_in_array_by_pattern(pkgs_array, str); if (pkgd_regpkgdb == NULL) return EINVAL; diff --git a/lib/plist_find.c b/lib/plist_find.c index 64910948..15be41eb 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -121,6 +121,18 @@ xbps_find_pkg_in_array_by_pattern(prop_array_t array, const char *pattern) return find_pkg_in_array(array, pattern, true, false); } +prop_dictionary_t +xbps_find_virtualpkg_in_array_by_name(prop_array_t array, const char *name) +{ + return find_pkg_in_array(array, name, false, true); +} + +prop_dictionary_t +xbps_find_virtualpkg_in_array_by_pattern(prop_array_t array, const char *pattern) +{ + return find_pkg_in_array(array, pattern, true, true); +} + static const char * find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern) {