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
ca400904
Commit
ca400904
authored
Jan 04, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup warning flags and fixes missing static attribute for local funtions.
parent
135e43c1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
25 deletions
+93
-25
Makefile.am
Makefile.am
+1
-1
autogen.sh
autogen.sh
+1
-1
configure.ac
configure.ac
+4
-0
as-compiler-flag.m4
m4/as-compiler-flag.m4
+62
-0
Makefile.am
src/Makefile.am
+1
-1
bplist.c
src/bplist.c
+21
-21
plist.c
src/plist.c
+1
-1
plist.h
src/plist.h
+2
-0
No files found.
Makefile.am
View file @
ca400904
AUTOMAKE_OPTIONS
=
foreign
AUTOMAKE_OPTIONS
=
foreign
ACLOCAL_AMFLAGS
=
-I
m4
SUBDIRS
=
src include plutil
SUBDIRS
=
src include plutil
pkgconfigdir
=
$(libdir)
/pkgconfig
pkgconfigdir
=
$(libdir)
/pkgconfig
...
...
autogen.sh
View file @
ca400904
#!/bin/sh
#!/bin/sh
aclocal
aclocal
-I
m4
libtoolize
libtoolize
autoheader
autoheader
automake
--add-missing
automake
--add-missing
...
...
configure.ac
View file @
ca400904
...
@@ -6,6 +6,7 @@ AC_INIT(libplist, 0.1.0, nospam@nowhere.com)
...
@@ -6,6 +6,7 @@ AC_INIT(libplist, 0.1.0, nospam@nowhere.com)
AM_INIT_AUTOMAKE(libplist, 0.1.0)
AM_INIT_AUTOMAKE(libplist, 0.1.0)
AC_CONFIG_SRCDIR([src/])
AC_CONFIG_SRCDIR([src/])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LIBTOOL
AC_PROG_LIBTOOL
...
@@ -44,4 +45,7 @@ if test "$no_debug_code" = true; then
...
@@ -44,4 +45,7 @@ if test "$no_debug_code" = true; then
AC_DEFINE(STRIP_DEBUG_CODE,1,[Strip debug reporting code])
AC_DEFINE(STRIP_DEBUG_CODE,1,[Strip debug reporting code])
fi
fi
AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default")
AC_SUBST(GLOBAL_CFLAGS)
AC_OUTPUT(Makefile src/Makefile include/Makefile plutil/Makefile libplist-1.0.pc)
AC_OUTPUT(Makefile src/Makefile include/Makefile plutil/Makefile libplist-1.0.pc)
m4/as-compiler-flag.m4
0 → 100644
View file @
ca400904
dnl as-compiler-flag.m4 0.1.0
dnl autostars m4 macro for detection of compiler flags
dnl David Schleef <ds@schleef.org>
dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $
dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
AC_DEFUN([AS_COMPILER_FLAG],
[
AC_MSG_CHECKING([to see if compiler understands $1])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
CFLAGS="$save_CFLAGS"
if test "X$flag_ok" = Xyes ; then
m4_ifvaln([$2],[$2])
true
else
m4_ifvaln([$3],[$3])
true
fi
AC_MSG_RESULT([$flag_ok])
])
dnl AS_COMPILER_FLAGS(VAR, FLAGS)
dnl Tries to compile with the given CFLAGS.
AC_DEFUN([AS_COMPILER_FLAGS],
[
list=$2
flags_supported=""
flags_unsupported=""
AC_MSG_CHECKING([for supported compiler flags])
for each in $list
do
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $each"
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
CFLAGS="$save_CFLAGS"
if test "X$flag_ok" = Xyes ; then
flags_supported="$flags_supported $each"
else
flags_unsupported="$flags_unsupported $each"
fi
done
AC_MSG_RESULT([$flags_supported])
if test "X$flags_unsupported" != X ; then
AC_MSG_WARN([unsupported compiler flags: $flags_unsupported])
fi
$1="$$1 $flags_supported"
])
src/Makefile.am
View file @
ca400904
INCLUDES
=
-I
$(top_srcdir)
/include
INCLUDES
=
-I
$(top_srcdir)
/include
AM_CFLAGS
=
$(libxml2_CFLAGS)
$(libglib2_CFLAGS)
-D_GNU_SOURCE
AM_CFLAGS
=
$(
GLOBAL_CFLAGS)
$(
libxml2_CFLAGS)
$(libglib2_CFLAGS)
-D_GNU_SOURCE
AM_LDFLAGS
=
$(libxml2_LIBS)
$(libglib2_LIBS)
AM_LDFLAGS
=
$(libxml2_LIBS)
$(libglib2_LIBS)
lib_LTLIBRARIES
=
libplist.la
lib_LTLIBRARIES
=
libplist.la
...
...
src/bplist.c
View file @
ca400904
...
@@ -59,9 +59,9 @@ enum {
...
@@ -59,9 +59,9 @@ enum {
BPLIST_MASK
=
0xF0
BPLIST_MASK
=
0xF0
};
};
void
byte_convert
(
char
*
address
,
size_t
size
)
static
void
byte_convert
(
char
*
address
,
size_t
size
)
{
{
in
t
i
=
0
,
j
=
0
;
uint8_
t
i
=
0
,
j
=
0
;
char
tmp
=
'\0'
;
char
tmp
=
'\0'
;
for
(
i
=
0
;
i
<
(
size
/
2
);
i
++
)
{
for
(
i
=
0
;
i
<
(
size
/
2
);
i
++
)
{
...
@@ -83,7 +83,7 @@ void byte_convert(char *address, size_t size)
...
@@ -83,7 +83,7 @@ void byte_convert(char *address, size_t size)
#define get_needed_bytes(x) (x <= 1<<8 ? 1 : ( x <= 1<<16 ? 2 : ( x <= (uint64_t)1<<32 ? 4 : 8)))
#define get_needed_bytes(x) (x <= 1<<8 ? 1 : ( x <= 1<<16 ? 2 : ( x <= (uint64_t)1<<32 ? 4 : 8)))
#define get_real_bytes(x) (x >> 32 ? 4 : 8)
#define get_real_bytes(x) (x >> 32 ? 4 : 8)
plist_t
parse_uint_node
(
char
*
bnode
,
uint8_t
size
,
char
**
next_object
)
static
plist_t
parse_uint_node
(
char
*
bnode
,
uint8_t
size
,
char
**
next_object
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -114,7 +114,7 @@ plist_t parse_uint_node(char *bnode, uint8_t size, char **next_object)
...
@@ -114,7 +114,7 @@ plist_t parse_uint_node(char *bnode, uint8_t size, char **next_object)
return
g_node_new
(
data
);
return
g_node_new
(
data
);
}
}
plist_t
parse_real_node
(
char
*
bnode
,
uint8_t
size
)
static
plist_t
parse_real_node
(
char
*
bnode
,
uint8_t
size
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -136,7 +136,7 @@ plist_t parse_real_node(char *bnode, uint8_t size)
...
@@ -136,7 +136,7 @@ plist_t parse_real_node(char *bnode, uint8_t size)
return
g_node_new
(
data
);
return
g_node_new
(
data
);
}
}
plist_t
parse_string_node
(
char
*
bnode
,
uint8_t
size
)
static
plist_t
parse_string_node
(
char
*
bnode
,
uint8_t
size
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -148,7 +148,7 @@ plist_t parse_string_node(char *bnode, uint8_t size)
...
@@ -148,7 +148,7 @@ plist_t parse_string_node(char *bnode, uint8_t size)
return
g_node_new
(
data
);
return
g_node_new
(
data
);
}
}
plist_t
parse_unicode_node
(
char
*
bnode
,
uint8_t
size
)
static
plist_t
parse_unicode_node
(
char
*
bnode
,
uint8_t
size
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -160,7 +160,7 @@ plist_t parse_unicode_node(char *bnode, uint8_t size)
...
@@ -160,7 +160,7 @@ plist_t parse_unicode_node(char *bnode, uint8_t size)
return
g_node_new
(
data
);
return
g_node_new
(
data
);
}
}
plist_t
parse_data_node
(
char
*
bnode
,
uint64_t
size
,
uint32_t
ref_size
)
static
plist_t
parse_data_node
(
char
*
bnode
,
uint64_t
size
,
uint32_t
ref_size
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -172,7 +172,7 @@ plist_t parse_data_node(char *bnode, uint64_t size, uint32_t ref_size)
...
@@ -172,7 +172,7 @@ plist_t parse_data_node(char *bnode, uint64_t size, uint32_t ref_size)
return
g_node_new
(
data
);
return
g_node_new
(
data
);
}
}
plist_t
parse_dict_node
(
char
*
bnode
,
uint64_t
size
,
uint32_t
ref_size
)
static
plist_t
parse_dict_node
(
char
*
bnode
,
uint64_t
size
,
uint32_t
ref_size
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -184,7 +184,7 @@ plist_t parse_dict_node(char *bnode, uint64_t size, uint32_t ref_size)
...
@@ -184,7 +184,7 @@ plist_t parse_dict_node(char *bnode, uint64_t size, uint32_t ref_size)
return
g_node_new
(
data
);
return
g_node_new
(
data
);
}
}
plist_t
parse_array_node
(
char
*
bnode
,
uint64_t
size
,
uint32_t
ref_size
)
static
plist_t
parse_array_node
(
char
*
bnode
,
uint64_t
size
,
uint32_t
ref_size
)
{
{
plist_data_t
data
=
plist_new_plist_data
();
plist_data_t
data
=
plist_new_plist_data
();
...
@@ -198,7 +198,7 @@ plist_t parse_array_node(char *bnode, uint64_t size, uint32_t ref_size)
...
@@ -198,7 +198,7 @@ plist_t parse_array_node(char *bnode, uint64_t size, uint32_t ref_size)
plist_t
parse_bin_node
(
char
*
object
,
uint8_t
dict_size
,
char
**
next_object
)
static
plist_t
parse_bin_node
(
char
*
object
,
uint8_t
dict_size
,
char
**
next_object
)
{
{
if
(
!
object
)
if
(
!
object
)
return
NULL
;
return
NULL
;
...
@@ -297,7 +297,7 @@ plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_object)
...
@@ -297,7 +297,7 @@ plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_object)
return
NULL
;
return
NULL
;
}
}
gpointer
copy_plist_data
(
gconstpointer
src
,
gpointer
data
)
static
gpointer
copy_plist_data
(
gconstpointer
src
,
gpointer
data
)
{
{
plist_data_t
srcdata
=
(
plist_data_t
)
src
;
plist_data_t
srcdata
=
(
plist_data_t
)
src
;
plist_data_t
dstdata
=
plist_new_plist_data
();
plist_data_t
dstdata
=
plist_new_plist_data
();
...
@@ -387,7 +387,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
...
@@ -387,7 +387,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
}
}
//setup children for structured types
//setup children for structured types
in
t
j
=
0
,
str_i
=
0
,
str_j
=
0
;
uint32_
t
j
=
0
,
str_i
=
0
,
str_j
=
0
;
uint32_t
index1
=
0
,
index2
=
0
;
uint32_t
index1
=
0
,
index2
=
0
;
for
(
i
=
0
;
i
<
num_objects
;
i
++
)
{
for
(
i
=
0
;
i
<
num_objects
;
i
++
)
{
...
@@ -449,7 +449,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
...
@@ -449,7 +449,7 @@ void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist)
*
plist
=
nodeslist
[
root_object
];
*
plist
=
nodeslist
[
root_object
];
}
}
guint
plist_data_hash
(
gconstpointer
key
)
static
guint
plist_data_hash
(
gconstpointer
key
)
{
{
plist_data_t
data
=
plist_get_data
((
plist_t
)
key
);
plist_data_t
data
=
plist_get_data
((
plist_t
)
key
);
...
@@ -494,7 +494,7 @@ guint plist_data_hash(gconstpointer key)
...
@@ -494,7 +494,7 @@ guint plist_data_hash(gconstpointer key)
return
hash
;
return
hash
;
}
}
gboolean
plist_data_compare
(
gconstpointer
a
,
gconstpointer
b
)
static
gboolean
plist_data_compare
(
gconstpointer
a
,
gconstpointer
b
)
{
{
if
(
!
a
||
!
b
)
if
(
!
a
||
!
b
)
return
FALSE
;
return
FALSE
;
...
@@ -550,7 +550,7 @@ struct serialize_s {
...
@@ -550,7 +550,7 @@ struct serialize_s {
GHashTable
*
ref_table
;
GHashTable
*
ref_table
;
};
};
void
serialize_plist
(
GNode
*
node
,
gpointer
data
)
static
void
serialize_plist
(
GNode
*
node
,
gpointer
data
)
{
{
struct
serialize_s
*
ser
=
(
struct
serialize_s
*
)
data
;
struct
serialize_s
*
ser
=
(
struct
serialize_s
*
)
data
;
uint64_t
current_index
=
ser
->
objects
->
len
;
uint64_t
current_index
=
ser
->
objects
->
len
;
...
@@ -585,7 +585,7 @@ void write_int(GByteArray * bplist, uint64_t val)
...
@@ -585,7 +585,7 @@ void write_int(GByteArray * bplist, uint64_t val)
free
(
buff
);
free
(
buff
);
}
}
void
write_real
(
GByteArray
*
bplist
,
double
val
)
static
void
write_real
(
GByteArray
*
bplist
,
double
val
)
{
{
uint64_t
size
=
get_real_bytes
(
*
((
uint64_t
*
)
&
val
));
//cheat to know used space
uint64_t
size
=
get_real_bytes
(
*
((
uint64_t
*
)
&
val
));
//cheat to know used space
uint8_t
*
buff
=
(
uint8_t
*
)
malloc
(
sizeof
(
uint8_t
)
+
size
);
uint8_t
*
buff
=
(
uint8_t
*
)
malloc
(
sizeof
(
uint8_t
)
+
size
);
...
@@ -596,7 +596,7 @@ void write_real(GByteArray * bplist, double val)
...
@@ -596,7 +596,7 @@ void write_real(GByteArray * bplist, double val)
free
(
buff
);
free
(
buff
);
}
}
void
write_raw_data
(
GByteArray
*
bplist
,
uint8_t
mark
,
uint8_t
*
val
,
uint64_t
size
)
static
void
write_raw_data
(
GByteArray
*
bplist
,
uint8_t
mark
,
uint8_t
*
val
,
uint64_t
size
)
{
{
uint8_t
marker
=
mark
|
(
size
<
15
?
size
:
0xf
);
uint8_t
marker
=
mark
|
(
size
<
15
?
size
:
0xf
);
g_byte_array_append
(
bplist
,
&
marker
,
sizeof
(
uint8_t
));
g_byte_array_append
(
bplist
,
&
marker
,
sizeof
(
uint8_t
));
...
@@ -612,18 +612,18 @@ void write_raw_data(GByteArray * bplist, uint8_t mark, uint8_t * val, uint64_t s
...
@@ -612,18 +612,18 @@ void write_raw_data(GByteArray * bplist, uint8_t mark, uint8_t * val, uint64_t s
free
(
buff
);
free
(
buff
);
}
}
void
write_data
(
GByteArray
*
bplist
,
uint8_t
*
val
,
uint64_t
size
)
static
void
write_data
(
GByteArray
*
bplist
,
uint8_t
*
val
,
uint64_t
size
)
{
{
write_raw_data
(
bplist
,
BPLIST_DATA
,
val
,
size
);
write_raw_data
(
bplist
,
BPLIST_DATA
,
val
,
size
);
}
}
void
write_string
(
GByteArray
*
bplist
,
char
*
val
)
static
void
write_string
(
GByteArray
*
bplist
,
char
*
val
)
{
{
uint64_t
size
=
strlen
(
val
);
uint64_t
size
=
strlen
(
val
);
write_raw_data
(
bplist
,
BPLIST_STRING
,
val
,
size
);
write_raw_data
(
bplist
,
BPLIST_STRING
,
val
,
size
);
}
}
void
write_array
(
GByteArray
*
bplist
,
GNode
*
node
,
GHashTable
*
ref_table
,
uint8_t
dict_param_size
)
static
void
write_array
(
GByteArray
*
bplist
,
GNode
*
node
,
GHashTable
*
ref_table
,
uint8_t
dict_param_size
)
{
{
uint64_t
size
=
g_node_n_children
(
node
);
uint64_t
size
=
g_node_n_children
(
node
);
uint8_t
marker
=
BPLIST_ARRAY
|
(
size
<
15
?
size
:
0xf
);
uint8_t
marker
=
BPLIST_ARRAY
|
(
size
<
15
?
size
:
0xf
);
...
@@ -652,7 +652,7 @@ void write_array(GByteArray * bplist, GNode * node, GHashTable * ref_table, uint
...
@@ -652,7 +652,7 @@ void write_array(GByteArray * bplist, GNode * node, GHashTable * ref_table, uint
}
}
void
write_dict
(
GByteArray
*
bplist
,
GNode
*
node
,
GHashTable
*
ref_table
,
uint8_t
dict_param_size
)
static
void
write_dict
(
GByteArray
*
bplist
,
GNode
*
node
,
GHashTable
*
ref_table
,
uint8_t
dict_param_size
)
{
{
uint64_t
size
=
g_node_n_children
(
node
)
/
2
;
uint64_t
size
=
g_node_n_children
(
node
)
/
2
;
uint8_t
marker
=
BPLIST_DICT
|
(
size
<
15
?
size
:
0xf
);
uint8_t
marker
=
BPLIST_DICT
|
(
size
<
15
?
size
:
0xf
);
...
...
src/plist.c
View file @
ca400904
...
@@ -136,7 +136,7 @@ plist_t plist_get_prev_sibling(plist_t node)
...
@@ -136,7 +136,7 @@ plist_t plist_get_prev_sibling(plist_t node)
return
(
plist_t
)
g_node_prev_sibling
((
GNode
*
)
node
);
return
(
plist_t
)
g_node_prev_sibling
((
GNode
*
)
node
);
}
}
char
compare_node_value
(
plist_type
type
,
plist_data_t
data
,
void
*
value
,
uint64_t
length
)
static
char
compare_node_value
(
plist_type
type
,
plist_data_t
data
,
void
*
value
,
uint64_t
length
)
{
{
char
res
=
FALSE
;
char
res
=
FALSE
;
switch
(
type
)
{
switch
(
type
)
{
...
...
src/plist.h
View file @
ca400904
...
@@ -55,6 +55,8 @@ plist_t plist_new_node(plist_data_t data);
...
@@ -55,6 +55,8 @@ plist_t plist_new_node(plist_data_t data);
plist_data_t
plist_get_data
(
const
plist_t
node
);
plist_data_t
plist_get_data
(
const
plist_t
node
);
plist_data_t
plist_new_plist_data
();
plist_data_t
plist_new_plist_data
();
void
plist_free_plist_data
(
plist_data_t
node
);
void
plist_free_plist_data
(
plist_data_t
node
);
plist_type
plist_get_node_type
(
plist_t
node
);
uint64_t
plist_get_node_uint_val
(
plist_t
node
);
#endif
#endif
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