xbps-{bin,repo}: dynamically print all objs in the 'show-files' target.

This commit is contained in:
Juan RP 2011-10-28 23:02:07 +02:00
parent c5fcaa294d
commit 549b5e2e36

View File

@ -95,38 +95,34 @@ show_pkg_info(prop_dictionary_t dict)
int int
show_pkg_files(prop_dictionary_t filesd) show_pkg_files(prop_dictionary_t filesd)
{ {
prop_array_t array; prop_array_t array, allkeys;
prop_object_iterator_t iter = NULL;
prop_object_t obj; prop_object_t obj;
const char *file, *array_str, *target; prop_dictionary_keysym_t ksym;
int i = 0; const char *keyname, *file;
size_t i, x;
/* This will print links, conf_files and files respectively. */ allkeys = prop_dictionary_all_keys(filesd);
for (i = 0; i < 3; i++) { for (i = 0; i < prop_array_count(allkeys); i++) {
if (i == 0) ksym = prop_array_get(allkeys, i);
array_str = "links"; keyname = prop_dictionary_keysym_cstring_nocopy(ksym);
else if (i == 1) if (strcmp(keyname, "dirs") == 0)
array_str = "conf_files";
else
array_str = "files";
array = prop_dictionary_get(filesd, array_str);
if (array == NULL || prop_array_count(array) == 0)
continue; continue;
iter = xbps_array_iter_from_dict(filesd, array_str); array = prop_dictionary_get(filesd, keyname);
if (iter == NULL) if (prop_object_type(array) != PROP_TYPE_ARRAY ||
return EINVAL; prop_array_count(array) == 0)
continue;
while ((obj = prop_object_iterator_next(iter))) { for (x = 0; x < prop_array_count(array); x++) {
obj = prop_array_get(array, x);
prop_dictionary_get_cstring_nocopy(obj, "file", &file); prop_dictionary_get_cstring_nocopy(obj, "file", &file);
printf("%s", file); printf("%s", file);
if (prop_dictionary_get_cstring_nocopy(obj, if (prop_dictionary_get_cstring_nocopy(obj,
"target", &target)) "target", &file))
printf(" -> %s", target); printf(" -> %s", file);
printf("\n"); printf("\n");
} }
prop_object_iterator_release(iter);
} }
return 0; return 0;