mirror of
https://github.com/void-linux/void-packages.git
synced 2025-09-05 19:43:07 +02:00
xbps-bin: simplify previous.
--HG-- extra : convert_revision : 30d4433b86c4a60fe56a98cb011f3534273818b3
This commit is contained in:
parent
db0484ae6e
commit
edc4a572bb
3 changed files with 38 additions and 30 deletions
|
@ -62,6 +62,21 @@ xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop_object_iterator_t
|
||||||
|
xbps_get_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
||||||
|
{
|
||||||
|
prop_array_t array;
|
||||||
|
|
||||||
|
if (dict == NULL || key == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
array = prop_dictionary_get(dict, key);
|
||||||
|
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return prop_array_iterator(array);
|
||||||
|
}
|
||||||
|
|
||||||
prop_dictionary_t
|
prop_dictionary_t
|
||||||
xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
|
xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
|
||||||
const char *pkgname)
|
const char *pkgname)
|
||||||
|
@ -197,27 +212,13 @@ fail:
|
||||||
void
|
void
|
||||||
xbps_list_pkgs_in_dict(prop_dictionary_t dict, const char *key)
|
xbps_list_pkgs_in_dict(prop_dictionary_t dict, const char *key)
|
||||||
{
|
{
|
||||||
prop_array_t array;
|
|
||||||
prop_object_t obj;
|
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
|
prop_object_t obj;
|
||||||
const char *pkgname, *version, *short_desc;
|
const char *pkgname, *version, *short_desc;
|
||||||
|
|
||||||
if (dict == NULL || key == NULL) {
|
iter = xbps_get_array_iter_from_dict(dict, key);
|
||||||
printf("%s: NULL dict/key\n", __func__);
|
if (iter == NULL)
|
||||||
exit(1);
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
array = prop_dictionary_get(dict, key);
|
|
||||||
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY) {
|
|
||||||
printf("%s: NULL or incorrect array type\n", __func__);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = prop_array_iterator(array);
|
|
||||||
if (iter == NULL) {
|
|
||||||
printf("%s: NULL iter\n", __func__);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
|
@ -232,15 +233,12 @@ xbps_list_pkgs_in_dict(prop_dictionary_t dict, const char *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xbps_list_strings_in_array(prop_array_t array)
|
xbps_list_strings_in_array(prop_dictionary_t dict, const char *key)
|
||||||
{
|
{
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
|
|
||||||
if (array == NULL)
|
iter = xbps_get_array_iter_from_dict(dict, key);
|
||||||
return;
|
|
||||||
|
|
||||||
iter = prop_array_iterator(array);
|
|
||||||
if (iter == NULL)
|
if (iter == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,18 @@ xbps_find_pkg_in_dict(prop_dictionary_t, const char *, const char *);
|
||||||
bool
|
bool
|
||||||
xbps_find_string_in_array(prop_array_t, const char *);
|
xbps_find_string_in_array(prop_array_t, const char *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets an array iterator from a dictionary with a specified key.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* - prop_dictionary_t: dictionary to search the array.
|
||||||
|
* - const char *: key of the array.
|
||||||
|
*
|
||||||
|
* Returns the object iterator, NULL otherwise.
|
||||||
|
*/
|
||||||
|
prop_object_iterator_t
|
||||||
|
xbps_get_array_iter_from_dict(prop_dictionary_t, const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lists information about all packages found in a dictionary, by
|
* Lists information about all packages found in a dictionary, by
|
||||||
* using a triplet: pkgname, version and short_desc.
|
* using a triplet: pkgname, version and short_desc.
|
||||||
|
@ -88,13 +100,14 @@ void
|
||||||
xbps_list_pkgs_in_dict(prop_dictionary_t, const char *);
|
xbps_list_pkgs_in_dict(prop_dictionary_t, const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lists all string values in an array.
|
* Lists all string values in an array object in a dictionary.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* - prop_array_t: array where to search on.
|
* - prop_dictionary_t: dictionary that has the array.
|
||||||
|
* - const char *: key of the array.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xbps_list_strings_in_array(prop_array_t);
|
xbps_list_strings_in_array(prop_dictionary_t, const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Registers a repository specified by an URI into the pool.
|
* Registers a repository specified by an URI into the pool.
|
||||||
|
|
|
@ -94,7 +94,6 @@ int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
prop_dictionary_t dict;
|
prop_dictionary_t dict;
|
||||||
prop_array_t array;
|
|
||||||
repo_info_t *rinfo = NULL;
|
repo_info_t *rinfo = NULL;
|
||||||
char pkgindex[PATH_MAX], *tmp;
|
char pkgindex[PATH_MAX], *tmp;
|
||||||
|
|
||||||
|
@ -158,9 +157,7 @@ main(int argc, char **argv)
|
||||||
exit(EINVAL);
|
exit(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
array = prop_dictionary_get(dict, "repository-list");
|
xbps_list_strings_in_array(dict, "repository-list");
|
||||||
if (array)
|
|
||||||
xbps_list_strings_in_array(array);
|
|
||||||
|
|
||||||
} else if (strcmp(argv[1], "show") == 0) {
|
} else if (strcmp(argv[1], "show") == 0) {
|
||||||
/* Shows info about a binary package. */
|
/* Shows info about a binary package. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue