mirror of
https://github.com/void-linux/void-packages.git
synced 2025-08-02 02:42:56 +02:00
plist_utils: introduce xbps_show_pkg_info().
--HG-- extra : convert_revision : b45e5817be93692280218ceb89133671ee3b1172
This commit is contained in:
parent
6a779c98d5
commit
e6e047bc6b
2 changed files with 67 additions and 0 deletions
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
#include "xbps_api.h"
|
#include "xbps_api.h"
|
||||||
|
|
||||||
|
static void xbps_list_strings_in_array2(prop_object_t);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
xbps_add_array_to_dict(prop_dictionary_t dict, prop_array_t array,
|
xbps_add_array_to_dict(prop_dictionary_t dict, prop_array_t array,
|
||||||
const char *key)
|
const char *key)
|
||||||
|
@ -224,6 +226,44 @@ fail:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xbps_show_pkg_info(prop_dictionary_t dict)
|
||||||
|
{
|
||||||
|
prop_object_iterator_t iter;
|
||||||
|
prop_object_t obj, obj2;
|
||||||
|
|
||||||
|
if (dict == NULL || prop_dictionary_count(dict) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
iter = prop_dictionary_iterator(dict);
|
||||||
|
if (iter == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
/* Print the key */
|
||||||
|
printf("%s: ", prop_dictionary_keysym_cstring_nocopy(obj));
|
||||||
|
/* Get the obj for current keysym */
|
||||||
|
obj2 = prop_dictionary_get_keysym(dict, obj);
|
||||||
|
|
||||||
|
if (prop_object_type(obj2) == PROP_TYPE_STRING) {
|
||||||
|
printf("%s\n", prop_string_cstring_nocopy(obj2));
|
||||||
|
|
||||||
|
} else if (prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
||||||
|
printf("%zu\n",
|
||||||
|
prop_number_unsigned_integer_value(obj2));
|
||||||
|
|
||||||
|
} else if (prop_object_type(obj2) == PROP_TYPE_ARRAY) {
|
||||||
|
printf("\n\t");
|
||||||
|
xbps_callback_array_iter_in_dict(dict,
|
||||||
|
prop_dictionary_keysym_cstring_nocopy(obj),
|
||||||
|
xbps_list_strings_in_array2);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xbps_list_pkgs_in_dict(prop_object_t obj)
|
xbps_list_pkgs_in_dict(prop_object_t obj)
|
||||||
{
|
{
|
||||||
|
@ -239,6 +279,23 @@ xbps_list_pkgs_in_dict(prop_object_t obj)
|
||||||
printf("%s (%s)\t%s\n", pkgname, version, short_desc);
|
printf("%s (%s)\t%s\n", pkgname, version, short_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xbps_list_strings_in_array2(prop_object_t obj)
|
||||||
|
{
|
||||||
|
static uint16_t count;
|
||||||
|
|
||||||
|
if (prop_object_type(obj) != PROP_TYPE_STRING)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (count == 4) {
|
||||||
|
printf("\n\t");
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s ", prop_string_cstring_nocopy(obj));
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xbps_list_strings_in_array(prop_object_t obj)
|
xbps_list_strings_in_array(prop_object_t obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,4 +131,14 @@ xbps_list_strings_in_array(prop_object_t);
|
||||||
bool
|
bool
|
||||||
xbps_register_repository(const char *);
|
xbps_register_repository(const char *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shows information of a package by looking at its dictionary.
|
||||||
|
* All known objects on it will be showed up.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* - prop_dictionary_t: the package dictionary.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xbps_show_pkg_info(prop_dictionary_t);
|
||||||
|
|
||||||
#endif /* !_XBPS_PLIST_UTILS_H_ */
|
#endif /* !_XBPS_PLIST_UTILS_H_ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue