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
6710f4bf
Commit
6710f4bf
authored
Oct 28, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format sources to ANSI style using AStyle (astyle --style=ansi).
parent
fed25735
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
3049 additions
and
2905 deletions
+3049
-2905
Array.h
include/plist/Array.h
+20
-20
Boolean.h
include/plist/Boolean.h
+15
-15
Data.h
include/plist/Data.h
+15
-15
Date.h
include/plist/Date.h
+15
-15
Dictionary.h
include/plist/Dictionary.h
+24
-24
Integer.h
include/plist/Integer.h
+15
-15
Node.h
include/plist/Node.h
+19
-19
Real.h
include/plist/Real.h
+15
-15
String.h
include/plist/String.h
+15
-15
Structure.h
include/plist/Structure.h
+16
-16
Utils.h
include/plist/Utils.h
+13
-13
plist++.h
include/plist/plist++.h
+3
-3
plist.h
include/plist/plist.h
+695
-693
plutil.c
plutil/plutil.c
+120
-105
plutil.h
plutil/plutil.h
+7
-6
Array.cpp
src/Array.cpp
+26
-26
Boolean.cpp
src/Boolean.cpp
+3
-3
Data.cpp
src/Data.cpp
+3
-3
Date.cpp
src/Date.cpp
+3
-3
Dictionary.cpp
src/Dictionary.cpp
+39
-39
Integer.cpp
src/Integer.cpp
+3
-3
Node.cpp
src/Node.cpp
+35
-34
Real.cpp
src/Real.cpp
+3
-3
String.cpp
src/String.cpp
+3
-3
Structure.cpp
src/Structure.cpp
+5
-5
Utils.cpp
src/Utils.cpp
+33
-33
bplist.c
src/bplist.c
+741
-704
plist.c
src/plist.c
+633
-579
plist.h
src/plist.h
+16
-14
xplist.c
src/xplist.c
+292
-272
plist_cmp.c
test/plist_cmp.c
+102
-98
plist_test.c
test/plist_test.c
+102
-94
No files found.
include/plist/Array.h
View file @
6710f4bf
...
...
@@ -30,7 +30,7 @@ namespace PList
class
Array
:
public
Structure
{
public
:
public
:
Array
(
Node
*
parent
=
NULL
);
Array
(
plist_t
node
,
Node
*
parent
=
NULL
);
Array
(
Array
&
a
);
...
...
@@ -45,7 +45,7 @@ class Array : public Structure
void
Remove
(
Node
*
node
);
void
Remove
(
unsigned
int
pos
);
private
:
private
:
std
::
vector
<
Node
*>
_array
;
};
...
...
include/plist/Boolean.h
View file @
6710f4bf
...
...
@@ -29,7 +29,7 @@ namespace PList
class
Boolean
:
public
Node
{
public
:
public
:
Boolean
(
Node
*
parent
=
NULL
);
Boolean
(
plist_t
node
,
Node
*
parent
=
NULL
);
Boolean
(
Boolean
&
b
);
...
...
include/plist/Data.h
View file @
6710f4bf
...
...
@@ -30,7 +30,7 @@ namespace PList
class
Data
:
public
Node
{
public
:
public
:
Data
(
Node
*
parent
=
NULL
);
Data
(
plist_t
node
,
Node
*
parent
=
NULL
);
Data
(
Data
&
d
);
...
...
include/plist/Date.h
View file @
6710f4bf
...
...
@@ -34,7 +34,7 @@ namespace PList
class
Date
:
public
Node
{
public
:
public
:
Date
(
Node
*
parent
=
NULL
);
Date
(
plist_t
node
,
Node
*
parent
=
NULL
);
Date
(
Date
&
d
);
...
...
include/plist/Dictionary.h
View file @
6710f4bf
...
...
@@ -31,7 +31,7 @@ namespace PList
class
Dictionary
:
public
Structure
{
public
:
public
:
Dictionary
(
Node
*
parent
=
NULL
);
Dictionary
(
plist_t
node
,
Node
*
parent
=
NULL
);
Dictionary
(
Dictionary
&
d
);
...
...
@@ -50,7 +50,7 @@ class Dictionary : public Structure
void
Remove
(
Node
*
node
);
void
Remove
(
const
std
::
string
&
key
);
private
:
private
:
std
::
map
<
std
::
string
,
Node
*>
_map
;
...
...
include/plist/Integer.h
View file @
6710f4bf
...
...
@@ -29,7 +29,7 @@ namespace PList
class
Integer
:
public
Node
{
public
:
public
:
Integer
(
Node
*
parent
=
NULL
);
Integer
(
plist_t
node
,
Node
*
parent
=
NULL
);
Integer
(
Integer
&
i
);
...
...
include/plist/Node.h
View file @
6710f4bf
...
...
@@ -29,7 +29,7 @@ namespace PList
class
Node
{
public
:
public
:
virtual
~
Node
();
virtual
Node
*
Clone
()
=
0
;
...
...
@@ -39,7 +39,7 @@ class Node
plist_type
GetType
();
plist_t
GetPlist
();
protected
:
protected
:
Node
(
Node
*
parent
=
NULL
);
Node
(
plist_t
node
,
Node
*
parent
=
NULL
);
Node
(
plist_type
type
,
Node
*
parent
=
NULL
);
...
...
include/plist/Real.h
View file @
6710f4bf
...
...
@@ -29,7 +29,7 @@ namespace PList
class
Real
:
public
Node
{
public
:
public
:
Real
(
Node
*
parent
=
NULL
);
Real
(
plist_t
node
,
Node
*
parent
=
NULL
);
Real
(
Real
&
d
);
...
...
include/plist/String.h
View file @
6710f4bf
...
...
@@ -30,7 +30,7 @@ namespace PList
class
String
:
public
Node
{
public
:
public
:
String
(
Node
*
parent
=
NULL
);
String
(
plist_t
node
,
Node
*
parent
=
NULL
);
String
(
String
&
s
);
...
...
include/plist/Structure.h
View file @
6710f4bf
...
...
@@ -31,7 +31,7 @@ namespace PList
class
Structure
:
public
Node
{
public
:
public
:
virtual
~
Structure
();
uint32_t
GetSize
();
...
...
@@ -41,11 +41,11 @@ class Structure : public Node
virtual
void
Remove
(
Node
*
node
)
=
0
;
protected
:
protected
:
Structure
(
Node
*
parent
=
NULL
);
Structure
(
plist_type
type
,
Node
*
parent
=
NULL
);
private
:
private
:
Structure
(
Structure
&
s
);
Structure
&
operator
=
(
const
Structure
&
s
);
};
...
...
include/plist/Utils.h
View file @
6710f4bf
...
...
@@ -27,17 +27,17 @@
namespace
PList
{
class
Utils
{
public
:
class
Utils
{
public
:
static
Node
*
FromPlist
(
plist_t
node
,
Node
*
parent
=
NULL
);
static
Structure
*
FromXml
(
const
std
::
string
&
xml
);
static
Structure
*
FromBin
(
const
std
::
vector
<
char
>&
bin
);
private
:
private
:
Utils
();
~
Utils
();
};
};
};
#endif // PLIST__UTILS_H
include/plist/plist++.h
View file @
6710f4bf
include/plist/plist.h
View file @
6710f4bf
This diff is collapsed.
Click to expand it.
plutil/plutil.c
View file @
6710f4bf
...
...
@@ -43,7 +43,8 @@ int main(int argc, char *argv[])
struct
stat
*
filestats
=
(
struct
stat
*
)
malloc
(
sizeof
(
struct
stat
));
Options
*
options
=
parse_arguments
(
argc
,
argv
);
if
(
!
options
)
{
if
(
!
options
)
{
print_usage
();
free
(
filestats
);
return
0
;
...
...
@@ -61,10 +62,13 @@ int main(int argc, char *argv[])
//convert one format to another
if
(
memcmp
(
plist_entire
,
"bplist00"
,
8
)
==
0
)
{
if
(
memcmp
(
plist_entire
,
"bplist00"
,
8
)
==
0
)
{
plist_from_bin
(
plist_entire
,
filestats
->
st_size
,
&
root_node
);
plist_to_xml
(
root_node
,
&
plist_out
,
&
size
);
}
else
{
}
else
{
plist_from_xml
(
plist_entire
,
filestats
->
st_size
,
&
root_node
);
plist_to_bin
(
root_node
,
&
plist_out
,
&
size
);
}
...
...
@@ -72,8 +76,10 @@ int main(int argc, char *argv[])
free
(
plist_entire
);
free
(
filestats
);
if
(
plist_out
)
{
if
(
options
->
out_file
!=
NULL
)
{
if
(
plist_out
)
{
if
(
options
->
out_file
!=
NULL
)
{
FILE
*
oplist
=
fopen
(
options
->
out_file
,
"wb"
);
if
(
!
oplist
)
return
1
;
...
...
@@ -85,7 +91,8 @@ int main(int argc, char *argv[])
fwrite
(
plist_out
,
size
,
sizeof
(
char
),
stdout
);
free
(
plist_out
);
}
else
}
else
printf
(
"ERROR
\n
"
);
free
(
options
);
...
...
@@ -99,9 +106,12 @@ Options *parse_arguments(int argc, char *argv[])
Options
*
options
=
(
Options
*
)
malloc
(
sizeof
(
Options
));
memset
(
options
,
0
,
sizeof
(
Options
));
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
!
strcmp
(
argv
[
i
],
"--infile"
)
||
!
strcmp
(
argv
[
i
],
"-i"
))
{
if
((
i
+
1
)
==
argc
)
{
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
!
strcmp
(
argv
[
i
],
"--infile"
)
||
!
strcmp
(
argv
[
i
],
"-i"
))
{
if
((
i
+
1
)
==
argc
)
{
free
(
options
);
return
NULL
;
}
...
...
@@ -110,8 +120,10 @@ Options *parse_arguments(int argc, char *argv[])
continue
;
}
if
(
!
strcmp
(
argv
[
i
],
"--outfile"
)
||
!
strcmp
(
argv
[
i
],
"-o"
))
{
if
((
i
+
1
)
==
argc
)
{
if
(
!
strcmp
(
argv
[
i
],
"--outfile"
)
||
!
strcmp
(
argv
[
i
],
"-o"
))
{
if
((
i
+
1
)
==
argc
)
{
free
(
options
);
return
NULL
;
}
...
...
@@ -120,17 +132,20 @@ Options *parse_arguments(int argc, char *argv[])
continue
;
}
if
(
!
strcmp
(
argv
[
i
],
"--debug"
)
||
!
strcmp
(
argv
[
i
],
"-d"
)
||
!
strcmp
(
argv
[
i
],
"-v"
))
{
if
(
!
strcmp
(
argv
[
i
],
"--debug"
)
||
!
strcmp
(
argv
[
i
],
"-d"
)
||
!
strcmp
(
argv
[
i
],
"-v"
))
{
options
->
debug
=
1
;
}
if
(
!
strcmp
(
argv
[
i
],
"--help"
)
||
!
strcmp
(
argv
[
i
],
"-h"
))
{
if
(
!
strcmp
(
argv
[
i
],
"--help"
)
||
!
strcmp
(
argv
[
i
],
"-h"
))
{
free
(
options
);
return
NULL
;
}
}
if
(
!
options
->
in_file
/*|| !options->out_file */
)
{
if
(
!
options
->
in_file
/*|| !options->out_file */
)
{
free
(
options
);
return
NULL
;
}
...
...
plutil/plutil.h
View file @
6710f4bf
...
...
@@ -19,7 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
typedef
struct
_options
{
typedef
struct
_options
{
char
*
in_file
,
*
out_file
;
uint8_t
debug
,
in_fmt
,
out_fmt
;
}
Options
;
...
...
src/Array.cpp
View file @
6710f4bf
src/Boolean.cpp
View file @
6710f4bf
src/Data.cpp
View file @
6710f4bf
src/Date.cpp
View file @
6710f4bf
src/Dictionary.cpp
View file @
6710f4bf
src/Integer.cpp
View file @
6710f4bf
src/Node.cpp
View file @
6710f4bf
...
...
@@ -37,7 +37,8 @@ Node::Node(plist_type type, Node* parent) : _parent(parent)
{
_node
=
NULL
;
switch
(
type
)
{
switch
(
type
)
{
case
PLIST_BOOLEAN
:
_node
=
plist_new_bool
(
0
);
break
;
...
...
src/Real.cpp
View file @
6710f4bf
src/String.cpp
View file @
6710f4bf
src/Structure.cpp
View file @
6710f4bf
src/Utils.cpp
View file @
6710f4bf
...
...
@@ -38,7 +38,7 @@ Node* Utils::FromPlist(plist_t node, Node* parent)
if
(
node
)
{
plist_type
type
=
plist_get_node_type
(
node
);
switch
(
type
)
switch
(
type
)
{
case
PLIST_DICT
:
ret
=
new
Dictionary
(
node
,
parent
);
...
...
src/bplist.c
View file @
6710f4bf
This diff is collapsed.
Click to expand it.
src/plist.c
View file @
6710f4bf
This diff is collapsed.
Click to expand it.
src/plist.h
View file @
6710f4bf
...
...
@@ -35,8 +35,10 @@
#endif
struct
plist_data_s
{
union
{
struct
plist_data_s
{
union
{
char
boolval
;
uint64_t
intval
;
double
realval
;
...
...
src/xplist.c
View file @
6710f4bf
...
...
@@ -72,7 +72,8 @@ static gchar *format_string(const char *buf, int cols, int depth)
assert
(
depth
>=
0
);
// Inserts new lines and tabs at appropriate locations
for
(
i
=
0
;
i
<
nlines
;
i
++
)
{
for
(
i
=
0
;
i
<
nlines
;
i
++
)
{
new_buf
[
i
*
colw
]
=
'\n'
;
for
(
j
=
0
;
j
<
depth
;
j
++
)
new_buf
[
i
*
colw
+
1
+
j
]
=
'\t'
;
...
...
@@ -90,7 +91,8 @@ static gchar *format_string(const char *buf, int cols, int depth)
struct
xml_node
{
struct
xml_node
{
xmlNodePtr
xml
;
uint32_t
depth
;
};
...
...
@@ -134,7 +136,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
xstruct
=
(
struct
xml_node
*
)
xml_struct
;
node_data
=
plist_get_data
(
node
);
switch
(
node_data
->
type
)
{
switch
(
node_data
->
type
)
{
case
PLIST_BOOLEAN
:
{
if
(
node_data
->
boolval
)
...
...
@@ -166,7 +169,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
case
PLIST_DATA
:
tag
=
XPLIST_DATA
;
if
(
node_data
->
length
)
{
if
(
node_data
->
length
)
{
valtmp
=
g_base64_encode
(
node_data
->
buff
,
node_data
->
length
);
val
=
format_string
(
valtmp
,
60
,
xstruct
->
depth
);
g_free
(
valtmp
);
...
...
@@ -188,7 +192,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
break
;
}
for
(
i
=
0
;
i
<
xstruct
->
depth
;
i
++
)
{
for
(
i
=
0
;
i
<
xstruct
->
depth
;
i
++
)
{
xmlNodeAddContent
(
xstruct
->
xml
,
BAD_CAST
(
"
\t
"
));
}
child_node
=
xmlNewChild
(
xstruct
->
xml
,
NULL
,
tag
,
BAD_CAST
(
val
));
...
...
@@ -199,14 +204,17 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
if
(
node_data
->
type
==
PLIST_ARRAY
||
node_data
->
type
==
PLIST_DICT
)
xmlNodeAddContent
(
child_node
,
BAD_CAST
(
"
\n
"
));
if
(
isStruct
)
{
if
(
isStruct
)
{
struct
xml_node
child
=
{
child_node
,
xstruct
->
depth
+
1
};
g_node_children_foreach
(
node
,
G_TRAVERSE_ALL
,
node_to_xml
,
&
child
);
}
//fix indent for structured types
if
(
node_data
->
type
==
PLIST_ARRAY
||
node_data
->
type
==
PLIST_DICT
)
{
if
(
node_data
->
type
==
PLIST_ARRAY
||
node_data
->
type
==
PLIST_DICT
)
{
for
(
i
=
0
;
i
<
xstruct
->
depth
;
i
++
)
{
for
(
i
=
0
;
i
<
xstruct
->
depth
;
i
++
)
{
xmlNodeAddContent
(
child_node
,
BAD_CAST
(
"
\t
"
));
}
}
...
...
@@ -227,7 +235,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
if
(
!
xml_node
)
return
;
for
(
node
=
xml_node
->
children
;
node
;
node
=
node
->
next
)
{
for
(
node
=
xml_node
->
children
;
node
;
node
=
node
->
next
)
{
while
(
node
&&
!
xmlStrcmp
(
node
->
name
,
XPLIST_TEXT
))
node
=
node
->
next
;
...
...
@@ -241,21 +250,24 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
else
*
plist_node
=
subnode
;
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_TRUE
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_TRUE
))
{
data
->
boolval
=
TRUE
;
data
->
type
=
PLIST_BOOLEAN
;
data
->
length
=
1
;
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_FALSE
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_FALSE
))
{
data
->
boolval
=
FALSE
;
data
->
type
=
PLIST_BOOLEAN
;
data
->
length
=
1
;
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_INT
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_INT
))
{
xmlChar
*
strval
=
xmlNodeGetContent
(
node
);
data
->
intval
=
g_ascii_strtoull
((
char
*
)
strval
,
NULL
,
0
);
data
->
type
=
PLIST_UINT
;
...
...
@@ -264,7 +276,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_REAL
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_REAL
))
{
xmlChar
*
strval
=
xmlNodeGetContent
(
node
);
data
->
realval
=
atof
((
char
*
)
strval
);
data
->
type
=
PLIST_REAL
;
...
...
@@ -273,7 +286,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DATE
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DATE
))
{
xmlChar
*
strval
=
xmlNodeGetContent
(
node
);
g_time_val_from_iso8601
((
char
*
)
strval
,
&
data
->
timeval
);
data
->
type
=
PLIST_DATE
;
...
...
@@ -282,12 +296,14 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_STRING
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_STRING
))
{
xmlChar
*
strval
=
xmlNodeGetContent
(
node
);
len
=
strlen
((
char
*
)
strval
);
type
=
xmlDetectCharEncoding
(
strval
,
len
);
if
(
XML_CHAR_ENCODING_UTF8
==
type
||
XML_CHAR_ENCODING_ASCII
==
type
||
XML_CHAR_ENCODING_NONE
==
type
)
{
if
(
XML_CHAR_ENCODING_UTF8
==
type
||
XML_CHAR_ENCODING_ASCII
==
type
||
XML_CHAR_ENCODING_NONE
==
type
)
{
data
->
strval
=
strdup
((
char
*
)
strval
);
data
->
type
=
PLIST_STRING
;
data
->
length
=
strlen
(
data
->
strval
);
...
...
@@ -296,7 +312,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_KEY
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_KEY
))
{
xmlChar
*
strval
=
xmlNodeGetContent
(
node
);
data
->
strval
=
strdup
((
char
*
)
strval
);
data
->
type
=
PLIST_KEY
;
...
...
@@ -305,7 +322,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DATA
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DATA
))
{
xmlChar
*
strval
=
xmlNodeGetContent
(
node
);
gsize
size
=
0
;
guchar
*
dec
=
g_base64_decode
((
char
*
)
strval
,
&
size
);
...
...
@@ -318,13 +336,15 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_ARRAY
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_ARRAY
))
{
data
->
type
=
PLIST_ARRAY
;
xml_to_node
(
node
,
&
subnode
);
continue
;
}
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DICT
))
{
if
(
!
xmlStrcmp
(
node
->
name
,
XPLIST_DICT
))
{
data
->
type
=
PLIST_DICT
;
xml_to_node
(
node
,
&
subnode
);
continue
;
...
...
test/plist_cmp.c
View file @
6710f4bf
...
...
@@ -46,7 +46,8 @@ char compare_plist(plist_t node_l, plist_t node_r)
if
(
!
cur_l
&&
!
cur_r
)
return
plist_compare_node_value
(
node_l
,
node_r
);
while
(
cur_l
&&
cur_r
&&
res
)
{
while
(
cur_l
&&
cur_r
&&
res
)
{
if
(
!
(
res
=
compare_plist
(
cur_l
,
cur_r
)))
return
res
;
...
...
@@ -77,7 +78,8 @@ int main(int argc, char *argv[])
struct
stat
*
filestats1
=
(
struct
stat
*
)
malloc
(
sizeof
(
struct
stat
));
struct
stat
*
filestats2
=
(
struct
stat
*
)
malloc
(
sizeof
(
struct
stat
));
if
(
argc
!=
3
)
{
if
(
argc
!=
3
)
{
printf
(
"Wrong input
\n
"
);
return
1
;
}
...
...
@@ -89,7 +91,8 @@ int main(int argc, char *argv[])
iplist1
=
fopen
(
file_in1
,
"rb"
);
iplist2
=
fopen
(
file_in2
,
"rb"
);
if
(
!
iplist1
||
!
iplist2
)
{
if
(
!
iplist1
||
!
iplist2
)
{
printf
(
"File does not exists
\n
"
);
return
2
;
}
...
...
@@ -119,7 +122,8 @@ int main(int argc, char *argv[])
else
plist_from_xml
(
plist_2
,
size_in2
,
&
root_node2
);
if
(
!
root_node1
||
!
root_node2
)
{
if
(
!
root_node1
||
!
root_node2
)
{
printf
(
"PList parsing failed
\n
"
);
return
3
;
}
...
...
test/plist_test.c
View file @
6710f4bf
...
...
@@ -46,7 +46,8 @@ int main(int argc, char *argv[])
int
size_out2
=
0
;
char
*
file_in
=
NULL
;
struct
stat
*
filestats
=
(
struct
stat
*
)
malloc
(
sizeof
(
struct
stat
));
if
(
argc
!=
2
)
{
if
(
argc
!=
2
)
{
printf
(
"Wrong input
\n
"
);
return
1
;
}
...
...
@@ -55,7 +56,8 @@ int main(int argc, char *argv[])
//read input file
iplist
=
fopen
(
file_in
,
"rb"
);
if
(
!
iplist
)
{
if
(
!
iplist
)
{
printf
(
"File does not exists
\n
"
);
return
2
;
}
...
...
@@ -69,7 +71,8 @@ int main(int argc, char *argv[])
//convert one format to another
plist_from_xml
(
plist_xml
,
size_in
,
&
root_node1
);
if
(
!
root_node1
)
{
if
(
!
root_node1
)
{
printf
(
"PList XML parsing failed
\n
"
);
return
3
;
}
...
...
@@ -77,7 +80,8 @@ int main(int argc, char *argv[])
printf
(
"PList XML parsing succeeded
\n
"
);
plist_to_bin
(
root_node1
,
&
plist_bin
,
&
size_out
);
if
(
!
plist_bin
)
{
if
(
!
plist_bin
)
{
printf
(
"PList BIN writing failed
\n
"
);
return
4
;
}
...
...
@@ -85,7 +89,8 @@ int main(int argc, char *argv[])
printf
(
"PList BIN writing succeeded
\n
"
);
plist_from_bin
(
plist_bin
,
size_out
,
&
root_node2
);
if
(
!
root_node2
)
{
if
(
!
root_node2
)
{
printf
(
"PList BIN parsing failed
\n
"
);
return
5
;
}
...
...
@@ -93,14 +98,16 @@ int main(int argc, char *argv[])
printf
(
"PList BIN parsing succeeded
\n
"
);
plist_to_xml
(
root_node2
,
&
plist_xml2
,
&
size_out2
);
if
(
!
plist_xml2
)
{
if
(
!
plist_xml2
)
{
printf
(
"PList XML writing failed
\n
"
);
return
8
;
}
else
printf
(
"PList XML writing succeeded
\n
"
);
if
(
plist_xml2
)
{
if
(
plist_xml2
)
{
FILE
*
oplist
=
NULL
;
char
file_out
[
512
];
sprintf
(
file_out
,
"%s.out"
,
file_in
);
...
...
@@ -116,7 +123,8 @@ int main(int argc, char *argv[])
free
(
plist_xml2
);
free
(
filestats
);
if
(
size_in
!=
size_out2
)
{
if
(
size_in
!=
size_out2
)
{
printf
(
"Size of input and output is different
\n
"
);
printf
(
"Input size : %i
\n
"
,
size_in
);
printf
(
"Output size : %i
\n
"
,
size_out2
);
...
...
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