32 #include "xbps_api_impl.h"
35 remove_obj_from_array(prop_array_t array,
const char *str,
int mode)
37 prop_object_iterator_t iter;
39 const char *curname, *pkgdep;
44 assert(prop_object_type(array) == PROP_TYPE_ARRAY);
46 iter = prop_array_iterator(array);
50 while ((obj = prop_object_iterator_next(iter))) {
53 if (prop_string_equals_cstring(obj, str)) {
57 }
else if (mode == 1) {
59 pkgdep = prop_string_cstring_nocopy(obj);
61 if (curpkgname == NULL)
63 if (strcmp(curpkgname, str) == 0) {
69 }
else if (mode == 2) {
71 prop_dictionary_get_cstring_nocopy(obj,
73 if (strcmp(curname, str) == 0) {
77 }
else if (mode == 3) {
79 prop_dictionary_get_cstring_nocopy(obj,
81 if (strcmp(curname, str) == 0) {
85 }
else if (mode == 4) {
87 prop_dictionary_get_cstring_nocopy(obj,
96 prop_object_iterator_release(iter);
103 prop_array_remove(array, idx);
108 xbps_remove_string_from_array(prop_array_t array,
const char *str)
110 return remove_obj_from_array(array, str, 0);
114 xbps_remove_pkgname_from_array(prop_array_t array,
const char *str)
116 return remove_obj_from_array(array, str, 1);
120 xbps_remove_pkg_from_array_by_name(prop_array_t array,
const char *str)
122 return remove_obj_from_array(array, str, 2);
126 xbps_remove_pkg_from_array_by_pkgver(prop_array_t array,
const char *str)
128 return remove_obj_from_array(array, str, 3);
132 xbps_remove_pkg_from_array_by_pattern(prop_array_t array,
const char *str)
134 return remove_obj_from_array(array, str, 4);