Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwn
libplist
Commits
3b764749
Commit
3b764749
authored
Dec 12, 2013
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new plist_dict_merge() function
parent
8f644ca5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
plist.h
include/plist/plist.h
+10
-0
plist.c
src/plist.c
+27
-0
No files found.
include/plist/plist.h
View file @
3b764749
...
...
@@ -336,6 +336,16 @@ extern "C"
*/
PLIST_API
void
plist_dict_remove_item
(
plist_t
node
,
const
char
*
key
);
/**
* Merge a dictionary into another. This will add all key/value pairs
* from the source dictionary to the target dictionary, overwriting
* any existing key/value pairs that are already present in target.
*
* @param target pointer to an existing node of type #PLIST_DICT
* @param source node of type #PLIST_DICT that should be merged into target
*/
PLIST_API
void
plist_dict_merge
(
plist_t
*
target
,
plist_t
source
);
/********************************************
* *
...
...
src/plist.c
View file @
3b764749
...
...
@@ -446,6 +446,33 @@ void plist_dict_remove_item(plist_t node, const char* key)
return
;
}
void
plist_dict_merge
(
plist_t
*
target
,
plist_t
source
)
{
if
(
!
target
||
!*
target
||
(
plist_get_node_type
(
*
target
)
!=
PLIST_DICT
)
||
!
source
||
(
plist_get_node_type
(
source
)
!=
PLIST_DICT
))
return
;
char
*
key
=
NULL
;
plist_dict_iter
it
=
NULL
;
plist_t
subnode
=
NULL
;
plist_dict_new_iter
(
source
,
&
it
);
if
(
!
it
)
return
;
do
{
plist_dict_next_item
(
source
,
it
,
&
key
,
&
subnode
);
if
(
!
key
)
break
;
if
(
plist_dict_get_item
(
*
target
,
key
)
!=
NULL
)
plist_dict_remove_item
(
*
target
,
key
);
plist_dict_insert_item
(
*
target
,
key
,
plist_copy
(
subnode
));
free
(
key
);
key
=
NULL
;
}
while
(
1
);
free
(
it
);
}
plist_t
plist_access_pathv
(
plist_t
plist
,
uint32_t
length
,
va_list
v
)
{
plist_t
current
=
plist
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment