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
583bb249
Commit
583bb249
authored
Oct 11, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to change a node's type.
parent
120b7348
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
plist.h
include/plist/plist.h
+8
-0
plist.c
src/plist.c
+35
-3
No files found.
include/plist/plist.h
View file @
583bb249
...
...
@@ -410,6 +410,14 @@ extern "C" {
* *
********************************************/
/**
* Forces type of node. Changing type of structured nodes is only allowed if node is empty.
* Reset value of node;
* @param node the node
* @param type the key value
*/
PLIST_API
void
plist_set_type
(
plist_t
node
,
plist_type
type
);
/**
* Set the value of a node.
* Forces type of node to #PLIST_KEY
...
...
src/plist.c
View file @
583bb249
...
...
@@ -44,10 +44,8 @@ plist_data_t plist_new_plist_data(void)
return
data
;
}
static
void
plist_free_
node
(
GNode
*
node
,
gpointer
none
)
static
void
plist_free_
data
(
plist_data_t
data
)
{
g_node_unlink
(
node
);
plist_data_t
data
=
plist_get_data
(
node
);
if
(
data
)
{
switch
(
data
->
type
)
{
case
PLIST_KEY
:
...
...
@@ -62,6 +60,13 @@ static void plist_free_node(GNode * node, gpointer none)
}
free
(
data
);
}
}
static
void
plist_free_node
(
GNode
*
node
,
gpointer
none
)
{
g_node_unlink
(
node
);
plist_data_t
data
=
plist_get_data
(
node
);
plist_free_data
(
data
);
node
->
data
=
NULL
;
g_node_children_foreach
(
node
,
G_TRAVERSE_ALL
,
plist_free_node
,
NULL
);
}
...
...
@@ -664,6 +669,33 @@ static plist_t plist_set_element_val(plist_t node, plist_type type, const void *
}
}
void
plist_set_type
(
plist_t
node
,
plist_type
type
)
{
if
(
g_node_n_children
(
node
)
==
0
)
{
plist_data_t
data
=
plist_get_data
(
node
);
plist_free_data
(
data
);
data
=
plist_new_plist_data
();
data
->
type
=
type
;
switch
(
type
){
case
PLIST_BOOLEAN
:
data
->
length
=
sizeof
(
uint8_t
);
break
;
case
PLIST_UINT
:
data
->
length
=
sizeof
(
uint64_t
);
break
;
case
PLIST_REAL
:
data
->
length
=
sizeof
(
double
);
break
;
case
PLIST_DATE
:
data
->
length
=
sizeof
(
GTimeVal
);
break
;
default:
data
->
length
=
0
;
break
;
}
}
}
void
plist_set_key_val
(
plist_t
node
,
const
char
*
val
)
{
plist_set_element_val
(
node
,
PLIST_KEY
,
val
,
strlen
(
val
));
...
...
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