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
bfd8c56c
Commit
bfd8c56c
authored
May 29, 2011
by
Nikias Bassen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use simple sscanf for parsing dates if strptime is not available
parent
b82787f1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
xplist.c
src/xplist.c
+15
-2
No files found.
src/xplist.c
View file @
bfd8c56c
...
...
@@ -260,6 +260,20 @@ static void node_to_xml(node_t* node, void *xml_struct)
return
;
}
static
void
parse_date
(
const
char
*
strval
,
struct
tm
*
btime
)
{
if
(
!
btime
)
return
;
memset
(
btime
,
0
,
sizeof
(
struct
tm
));
if
(
!
strval
)
return
;
#ifdef strptime
strptime
((
char
*
)
strval
,
"%Y-%m-%dT%H:%M:%SZ"
,
btime
);
#else
sscanf
(
strval
,
"%d-%d-%dT%d:%d:%dZ"
,
&
btime
->
tm_year
,
&
btime
->
tm_mon
,
&
btime
->
tm_mday
,
&
btime
->
tm_hour
,
&
btime
->
tm_min
,
&
btime
->
tm_sec
);
btime
->
tm_year
-=
1900
;
btime
->
tm_mon
--
;
#endif
}
static
void
xml_to_node
(
xmlNodePtr
xml_node
,
plist_t
*
plist_node
)
{
xmlNodePtr
node
=
NULL
;
...
...
@@ -330,8 +344,7 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
time_t
time
=
0
;
if
(
strlen
(
strval
)
>=
11
)
{
struct
tm
btime
;
memset
(
&
btime
,
0
,
sizeof
(
struct
tm
));
strptime
((
char
*
)
strval
,
"%Y-%m-%dT%H:%M:%SZ"
,
&
btime
);
parse_date
((
const
char
*
)
strval
,
&
btime
);
time
=
mktime
(
&
btime
);
}
data
->
timeval
.
tv_sec
=
(
long
)
time
;
...
...
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