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
21e389bc
Commit
21e389bc
authored
Apr 15, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add special accessor for structured types in API.
parent
2abf518f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
10 deletions
+91
-10
plist.h
include/plist/plist.h
+19
-0
plist.c
src/plist.c
+28
-0
plist.i
swig/plist.i
+44
-10
No files found.
include/plist/plist.h
View file @
21e389bc
...
@@ -140,6 +140,25 @@ extern "C" {
...
@@ -140,6 +140,25 @@ extern "C" {
*/
*/
PLIST_API
plist_t
plist_get_prev_sibling
(
plist_t
node
);
PLIST_API
plist_t
plist_get_prev_sibling
(
plist_t
node
);
/**
* Get the nth child of a #PLIST_ARRAY node.
*
* @param node the node of type #PLIST_ARRAY
* @param n the index of the child to get. Range is [0, array_size[
* @return the nth children or NULL if node is not of type #PLIST_ARRAY
*/
PLIST_API
plist_t
plist_get_array_nth_el
(
plist_t
node
,
uint32_t
n
);
/**
* Get the child of a #PLIST_DICT node from the associated key value.
*
* @param node the node of type #PLIST_DICT
* @param key the key associated to the requested value
* @return the key associated value or NULL if node is not of type #PLIST_DICT
*/
PLIST_API
plist_t
plist_get_dict_el_from_key
(
plist_t
node
,
const
char
*
key
);
/********************************************
/********************************************
* *
* *
* Setters *
* Setters *
...
...
src/plist.c
View file @
21e389bc
...
@@ -165,6 +165,34 @@ plist_t plist_get_prev_sibling(plist_t node)
...
@@ -165,6 +165,34 @@ plist_t plist_get_prev_sibling(plist_t node)
return
(
plist_t
)
g_node_prev_sibling
((
GNode
*
)
node
);
return
(
plist_t
)
g_node_prev_sibling
((
GNode
*
)
node
);
}
}
plist_t
plist_get_array_nth_el
(
plist_t
node
,
uint32_t
n
)
{
plist_t
ret
=
NULL
;
if
(
node
&&
PLIST_ARRAY
==
plist_get_node_type
(
node
))
{
uint32_t
i
=
0
;
plist_t
temp
=
plist_get_first_child
(
node
);
while
(
i
<=
n
&&
temp
)
{
if
(
i
==
n
)
ret
=
temp
;
temp
=
plist_get_next_sibling
(
temp
);
i
++
;
}
}
return
ret
;
}
plist_t
plist_get_dict_el_from_key
(
plist_t
node
,
const
char
*
key
)
{
plist_t
ret
=
NULL
;
if
(
node
&&
PLIST_DICT
==
plist_get_node_type
(
node
))
{
plist_t
key_node
=
plist_find_node_by_key
(
node
,
key
);
ret
=
plist_get_next_sibling
(
key_node
);
}
return
ret
;
}
static
char
compare_node_value
(
plist_type
type
,
plist_data_t
data
,
const
void
*
value
,
uint64_t
length
)
static
char
compare_node_value
(
plist_type
type
,
plist_data_t
data
,
const
void
*
value
,
uint64_t
length
)
{
{
char
res
=
FALSE
;
char
res
=
FALSE
;
...
...
swig/plist.i
View file @
21e389bc
...
@@ -180,22 +180,56 @@ typedef struct {
...
@@ -180,22 +180,56 @@ typedef struct {
}
}
PListNode* find_node_by_key(char *s) {
PListNode* find_node_by_key(char *s) {
plist_t node = plist_find_node_by_key($self->node, s);
if (node) {
PListNode* plist = allocate_wrapper();
PListNode* plist = allocate_wrapper();
if (plist) {
if (plist) {
plist->node = plist_find_node_by_key($self->node, s)
;
plist->node = node
;
plist->should_keep_plist = 1;
plist->should_keep_plist = 1;
}
}
return plist;
return plist;
}
}
return NULL;
}
PListNode* find_node_by_string(char* s) {
PListNode* find_node_by_string(char* s) {
plist_t node = plist_find_node_by_string($self->node, s);
if (node) {
PListNode* plist = allocate_wrapper();
if (plist) {
plist->node = node;
plist->should_keep_plist = 1;
}
return plist;
}
return NULL;
}
PListNode* get_array_nth_el(unsigned int n) {
plist_t node = plist_get_array_nth_el($self->node, n);
if (node) {
PListNode* plist = allocate_wrapper();
PListNode* plist = allocate_wrapper();
if (plist) {
if (plist) {
plist->node = plist_find_node_by_string($self->node, s)
;
plist->node = node
;
plist->should_keep_plist = 1;
plist->should_keep_plist = 1;
}
}
return plist;
return plist;
}
}
return NULL;
}
PListNode* get_dict_el_from_key(char *key) {
plist_t node = plist_get_dict_el_from_key($self->node, key);
if (node) {
PListNode* plist = allocate_wrapper();
if (plist) {
plist->node = node;
plist->should_keep_plist = 1;
}
return plist;
}
return NULL;
}
char* to_xml () {
char* to_xml () {
char* s = NULL;
char* s = NULL;
...
...
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