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
49cbc8df
Commit
49cbc8df
authored
Nov 07, 2019
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add plist_get_data_ptr() and plist_get_string_ptr() to the interface
parent
4d458690
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
plist.h
include/plist/plist.h
+26
-0
plist.c
src/plist.c
+25
-0
No files found.
include/plist/plist.h
View file @
49cbc8df
...
...
@@ -462,6 +462,19 @@ extern "C"
*/
void
plist_get_string_val
(
plist_t
node
,
char
**
val
);
/**
* Get a pointer to the buffer of a #PLIST_STRING node.
*
* @note DO NOT MODIFY the buffer. Mind that the buffer is only available
* until the plist node gets freed. Make a copy if needed.
*
* @param node The node
* @param length If non-NULL, will be set to the length of the string
*
* @return Pointer to the NULL-terminated buffer.
*/
const
char
*
plist_get_string_ptr
(
plist_t
node
,
uint64_t
*
length
);
/**
* Get the value of a #PLIST_BOOLEAN node.
* This function does nothing if node is not of type #PLIST_BOOLEAN
...
...
@@ -500,6 +513,19 @@ extern "C"
*/
void
plist_get_data_val
(
plist_t
node
,
char
**
val
,
uint64_t
*
length
);
/**
* Get a pointer to the data buffer of a #PLIST_DATA node.
*
* @note DO NOT MODIFY the buffer. Mind that the buffer is only available
* until the plist node gets freed. Make a copy if needed.
*
* @param node The node
* @param length Pointer to a uint64_t that will be set to the length of the buffer
*
* @return Pointer to the buffer
*/
const
char
*
plist_get_data_ptr
(
plist_t
node
,
uint64_t
*
length
);
/**
* Get the value of a #PLIST_DATE node.
* This function does nothing if node is not of type #PLIST_DATE
...
...
src/plist.c
View file @
49cbc8df
...
...
@@ -868,6 +868,19 @@ PLIST_API void plist_get_string_val(plist_t node, char **val)
assert
(
length
==
strlen
(
*
val
));
}
PLIST_API
const
char
*
plist_get_string_ptr
(
plist_t
node
,
uint64_t
*
length
)
{
if
(
!
node
)
return
NULL
;
plist_type
type
=
plist_get_node_type
(
node
);
if
(
PLIST_STRING
!=
type
)
return
NULL
;
plist_data_t
data
=
plist_get_data
(
node
);
if
(
length
)
*
length
=
data
->
length
;
return
(
const
char
*
)
data
->
strval
;
}
PLIST_API
void
plist_get_bool_val
(
plist_t
node
,
uint8_t
*
val
)
{
if
(
!
node
||
!
val
)
...
...
@@ -926,6 +939,18 @@ PLIST_API void plist_get_data_val(plist_t node, char **val, uint64_t * length)
plist_get_type_and_value
(
node
,
&
type
,
(
void
*
)
val
,
length
);
}
PLIST_API
const
char
*
plist_get_data_ptr
(
plist_t
node
,
uint64_t
*
length
)
{
if
(
!
node
||
!
length
)
return
NULL
;
plist_type
type
=
plist_get_node_type
(
node
);
if
(
PLIST_DATA
!=
type
)
return
NULL
;
plist_data_t
data
=
plist_get_data
(
node
);
*
length
=
data
->
length
;
return
(
const
char
*
)
data
->
buff
;
}
PLIST_API
void
plist_get_date_val
(
plist_t
node
,
int32_t
*
sec
,
int32_t
*
usec
)
{
if
(
!
node
)
...
...
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