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
7f28d8f7
Commit
7f28d8f7
authored
Jan 23, 2015
by
Martin Szulecki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plistutil: Cleanup code style a bit and remove obsolete extra header
parent
f4caa6a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
102 deletions
+79
-102
Makefile.am
tools/Makefile.am
+1
-1
plistutil.c
tools/plistutil.c
+78
-72
plistutil.h
tools/plistutil.h
+0
-29
No files found.
tools/Makefile.am
View file @
7f28d8f7
...
...
@@ -3,5 +3,5 @@ AM_LDFLAGS =
bin_PROGRAMS
=
plistutil
plistutil_SOURCES
=
plistutil.c
plistutil.h
plistutil_SOURCES
=
plistutil.c
plistutil_LDADD
=
$(top_builddir)
/src/libplist.la
tools/plistutil.c
View file @
7f28d8f7
...
...
@@ -22,7 +22,6 @@
#include "plist/plist.h"
#include "plistutil.h"
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -33,6 +32,77 @@
#pragma warning(disable:4996)
#endif
typedef
struct
_options
{
char
*
in_file
,
*
out_file
;
uint8_t
debug
,
in_fmt
,
out_fmt
;
}
options_t
;
static
void
print_usage
(
int
argc
,
char
*
argv
[])
{
char
*
name
=
NULL
;
name
=
strrchr
(
argv
[
0
],
'/'
);
printf
(
"Usage: %s -i|--infile FILE [-o|--outfile FILE] [-d|--debug]
\n
"
,
(
name
?
name
+
1
:
argv
[
0
]));
printf
(
"Convert a plist FILE from binary to XML format or vice-versa.
\n\n
"
);
printf
(
" -i, --infile FILE
\t
The FILE to convert from
\n
"
);
printf
(
" -o, --outfile FILE
\t
Optional FILE to convert to or stdout if not used
\n
"
);
printf
(
" -d, --debug
\t\t
Enable extended debug output
\n
"
);
printf
(
"
\n
"
);
}
static
options_t
*
parse_arguments
(
int
argc
,
char
*
argv
[])
{
int
i
=
0
;
options_t
*
options
=
(
options_t
*
)
malloc
(
sizeof
(
options_t
));
memset
(
options
,
0
,
sizeof
(
options_t
));
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
!
strcmp
(
argv
[
i
],
"--infile"
)
||
!
strcmp
(
argv
[
i
],
"-i"
))
{
if
((
i
+
1
)
==
argc
)
{
free
(
options
);
return
NULL
;
}
options
->
in_file
=
argv
[
i
+
1
];
i
++
;
continue
;
}
if
(
!
strcmp
(
argv
[
i
],
"--outfile"
)
||
!
strcmp
(
argv
[
i
],
"-o"
))
{
if
((
i
+
1
)
==
argc
)
{
free
(
options
);
return
NULL
;
}
options
->
out_file
=
argv
[
i
+
1
];
i
++
;
continue
;
}
if
(
!
strcmp
(
argv
[
i
],
"--debug"
)
||
!
strcmp
(
argv
[
i
],
"-d"
))
{
options
->
debug
=
1
;
}
if
(
!
strcmp
(
argv
[
i
],
"--help"
)
||
!
strcmp
(
argv
[
i
],
"-h"
))
{
free
(
options
);
return
NULL
;
}
}
if
(
!
options
->
in_file
)
{
free
(
options
);
return
NULL
;
}
return
options
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -43,27 +113,26 @@ int main(int argc, char *argv[])
int
read_size
=
0
;
char
*
plist_entire
=
NULL
;
struct
stat
*
filestats
=
(
struct
stat
*
)
malloc
(
sizeof
(
struct
stat
));
Options
*
options
=
parse_arguments
(
argc
,
argv
);
options_t
*
options
=
parse_arguments
(
argc
,
argv
);
if
(
!
options
)
{
print_usage
();
print_usage
(
argc
,
argv
);
free
(
filestats
);
return
0
;
}
//read input file
// read input file
iplist
=
fopen
(
options
->
in_file
,
"rb"
);
if
(
!
iplist
)
return
1
;
stat
(
options
->
in_file
,
filestats
);
plist_entire
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
(
filestats
->
st_size
+
1
));
read_size
=
fread
(
plist_entire
,
sizeof
(
char
),
filestats
->
st_size
,
iplist
);
fclose
(
iplist
);
//convert one format to another
// convert from binary to xml or vice-versa
if
(
memcmp
(
plist_entire
,
"bplist00"
,
8
)
==
0
)
{
plist_from_bin
(
plist_entire
,
read_size
,
&
root_node
);
...
...
@@ -88,7 +157,7 @@ int main(int argc, char *argv[])
fwrite
(
plist_out
,
size
,
sizeof
(
char
),
oplist
);
fclose
(
oplist
);
}
//if no output file specified, write to stdout
//
if no output file specified, write to stdout
else
fwrite
(
plist_out
,
size
,
sizeof
(
char
),
stdout
);
...
...
@@ -100,66 +169,3 @@ int main(int argc, char *argv[])
free
(
options
);
return
0
;
}
Options
*
parse_arguments
(
int
argc
,
char
*
argv
[])
{
int
i
=
0
;
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
)
{
free
(
options
);
return
NULL
;
}
options
->
in_file
=
argv
[
i
+
1
];
i
++
;
continue
;
}
if
(
!
strcmp
(
argv
[
i
],
"--outfile"
)
||
!
strcmp
(
argv
[
i
],
"-o"
))
{
if
((
i
+
1
)
==
argc
)
{
free
(
options
);
return
NULL
;
}
options
->
out_file
=
argv
[
i
+
1
];
i
++
;
continue
;
}
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"
))
{
free
(
options
);
return
NULL
;
}
}
if
(
!
options
->
in_file
/*|| !options->out_file */
)
{
free
(
options
);
return
NULL
;
}
return
options
;
}
void
print_usage
()
{
printf
(
"Usage: plistutil -i|--infile in_file.plist -o|--outfile out_file.plist [--debug]
\n
"
);
printf
(
"
\n
"
);
printf
(
"
\t
-i or --infile: The file to read in.
\n
"
);
printf
(
"
\t
-o or --outfile: The file to convert to.
\n
"
);
printf
(
"
\t
-d, -v or --debug: Provide extended debug information.
\n\n
"
);
}
tools/plistutil.h
deleted
100644 → 0
View file @
f4caa6a7
/*
* plistutil.h
* header for plist convertion tool
*
* Copyright (c) 2008 Zach C. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
typedef
struct
_options
{
char
*
in_file
,
*
out_file
;
uint8_t
debug
,
in_fmt
,
out_fmt
;
}
Options
;
Options
*
parse_arguments
(
int
argc
,
char
*
argv
[]);
void
print_usage
();
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