diff options
Diffstat (limited to 'src/plist-utils.c')
-rw-r--r-- | src/plist-utils.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plist-utils.c b/src/plist-utils.c index fe63439..cc3d11e 100644 --- a/src/plist-utils.c +++ b/src/plist-utils.c @@ -49,3 +49,23 @@ int plist_node_get_item_count(plist_t node) { return count; } +int plist_item_index(plist_t node) { + plist_t parent; + plist_t child; + int count = 0; + + parent = plist_get_parent(node); + + if (parent == NULL || node == NULL) { + return -1; + } + + child = plist_get_first_child(parent); + while (child && child != node) { + count ++; + child = plist_get_next_sibling(child); + } + + return count; +} + |