summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plist.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/plist.c b/src/plist.c
index 95bc43c..a9a6173 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -212,6 +212,14 @@ plist_t plist_array_get_item(plist_t node, uint32_t n)
212 return ret; 212 return ret;
213} 213}
214 214
215uint32_t plist_array_get_item_index(plist_t node)
216{
217 plist_t father = plist_get_parent(node);
218 if (PLIST_ARRAY == plist_get_node_type(father)) {
219 return g_node_child_position(father, node);
220 }
221}
222
215void plist_array_set_item(plist_t node, plist_t item, uint32_t n) 223void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
216{ 224{
217 if (node && PLIST_ARRAY == plist_get_node_type(node)) { 225 if (node && PLIST_ARRAY == plist_get_node_type(node)) {
@@ -252,13 +260,38 @@ void plist_array_remove_item(plist_t node, uint32_t n)
252 return; 260 return;
253} 261}
254 262
255uint32_t plist_dict_get_size(plist_t node) 263void plist_dict_new_iter(plist_t node, plist_dict_iter *iter)
256{ 264{
257 uint32_t ret = 0; 265 if (iter && *iter == NULL) {
258 if (node && PLIST_DICT == plist_get_node_type(node)) { 266 *iter = malloc(sizeof(uint32_t));
259 ret = g_node_n_children(node) / 2; 267 **iter = 0;
268 }
269 return;
270}
271
272void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val)
273{
274 if (node && PLIST_DICT == plist_get_node_type(node) && *iter < g_node_n_children(node) / 2) {
275
276 if (key) {
277 plist_get_key_val((plist_t)g_node_nth_child(node, 2 * (*iter)), key);
278 }
279
280 if (val) {
281 val = (plist_t) g_node_nth_child(node, 2 * (*iter) + 1);
282 }
283
284 *iter += 2;
285 }
286 return;
287}
288
289void plist_dict_get_item_key(plist_t node, char **key)
290{
291 plist_t father = plist_get_parent(node);
292 if (PLIST_DICT == plist_get_node_type(father)) {
293 plist_get_key_val( (plist_t) g_node_prev_sibling(node), key);
260 } 294 }
261 return ret;
262} 295}
263 296
264plist_t plist_dict_get_item(plist_t node, const char* key) 297plist_t plist_dict_get_item(plist_t node, const char* key)