Make xbps_add_array_to_dict accept any object, not just arrays.
Thus it's now named xbps_add_obj_to_dict(). --HG-- extra : convert_revision : 81a53b615cd7578a2c99f40f9b8550e2ee7fa426
This commit is contained in:
parent
836bb96d9c
commit
256b562770
3 changed files with 11 additions and 11 deletions
|
@ -36,16 +36,16 @@
|
||||||
static void xbps_list_strings_in_array2(prop_object_t);
|
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_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
|
||||||
const char *key)
|
const char *key)
|
||||||
{
|
{
|
||||||
if (dict == NULL || array == NULL || key == NULL)
|
if (dict == NULL || obj == NULL || key == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!prop_dictionary_set(dict, key, array))
|
if (!prop_dictionary_set(dict, key, obj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
prop_object_release(array);
|
prop_object_release(obj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ xbps_register_repository(const char *uri)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Add the array obj into the main dictionary. */
|
/* Add the array obj into the main dictionary. */
|
||||||
if (!xbps_add_array_to_dict(dict, array, "repository-list"))
|
if (!xbps_add_obj_to_dict(dict, array, "repository-list"))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Write dictionary into plist file. */
|
/* Write dictionary into plist file. */
|
||||||
|
|
|
@ -27,17 +27,17 @@
|
||||||
#define _XBPS_PLIST_UTILS_H_
|
#define _XBPS_PLIST_UTILS_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adds an array object with specified key into a dictionary.
|
* Adds an opaque object with specified key into a dictionary.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* - prop_dictionary_t: dictionary to store the array.
|
* - prop_dictionary_t: dictionary to store the array.
|
||||||
* - prop_array_t: the array to be stored.
|
* - prop_object_t: the object to be stored.
|
||||||
* - const char *: the key associated with the array.
|
* - const char *: the key associated with the object.
|
||||||
*
|
*
|
||||||
* Returns true on success, false on failure.
|
* Returns true on success, false on failure.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
xbps_add_array_to_dict(prop_dictionary_t, prop_array_t, const char *);
|
xbps_add_obj_to_dict(prop_dictionary_t, prop_object_t, const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adds an opaque object into an array.
|
* Adds an opaque object into an array.
|
||||||
|
|
|
@ -137,7 +137,7 @@ unregister_pkg(prop_dictionary_t dict, const char *pkgname, const char *dbfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_array_remove(array, i);
|
prop_array_remove(array, i);
|
||||||
if (!xbps_add_array_to_dict(dict, array, "packages")) {
|
if (!xbps_add_obj_to_dict(dict, array, "packages")) {
|
||||||
printf("=> ERROR: couldn't unregister %s from database\n",
|
printf("=> ERROR: couldn't unregister %s from database\n",
|
||||||
pkgname);
|
pkgname);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -242,7 +242,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
/* Add array into main dictionary. */
|
/* Add array into main dictionary. */
|
||||||
dbdict = prop_dictionary_create();
|
dbdict = prop_dictionary_create();
|
||||||
if (!xbps_add_array_to_dict(dbdict, dbarray,
|
if (!xbps_add_obj_to_dict(dbdict, dbarray,
|
||||||
"packages_installed")) {
|
"packages_installed")) {
|
||||||
printf("=> ERROR: couldn't register pkg\n");
|
printf("=> ERROR: couldn't register pkg\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue