Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
32a346a4
Commit
32a346a4
authored
May 03, 2012
by
Alejandro Mery
Browse files
bin2fex: split decompiler of single datums into a separated function
parent
151f7afe
Changes
1
Show whitespace changes
Inline
Side-by-side
bin2fex.c
View file @
32a346a4
...
@@ -68,6 +68,26 @@ static inline int decompile_gpio(struct script_section *section,
...
@@ -68,6 +68,26 @@ static inline int decompile_gpio(struct script_section *section,
return
ok
;
return
ok
;
}
}
/**
*/
static
inline
int
decompile_single
(
struct
script_section
*
section
,
struct
script_section_entry
*
entry
,
int32_t
*
d
,
int
length
,
FILE
*
out
)
{
int
ok
=
1
;
if
(
length
!=
1
)
{
pr_err
(
"%s.%s: invalid length %d (assuming %d)
\n
"
,
section
->
name
,
entry
->
name
,
length
,
1
);
ok
=
0
;
}
fprintf
(
out
,
"%s
\t
= %d
\n
"
,
entry
->
name
,
*
d
);
return
ok
;
}
/**
/**
*/
*/
static
int
decompile_section
(
void
*
bin
,
size_t
bin_size
,
static
int
decompile_section
(
void
*
bin
,
size_t
bin_size
,
...
@@ -86,17 +106,10 @@ static int decompile_section(void *bin, size_t bin_size,
...
@@ -86,17 +106,10 @@ static int decompile_section(void *bin, size_t bin_size,
length
=
(
entry
->
pattern
>>
0
)
&
0xffff
;
length
=
(
entry
->
pattern
>>
0
)
&
0xffff
;
switch
(
type
)
{
switch
(
type
)
{
case
SCRIPT_VALUE_TYPE_SINGLE_WORD
:
{
case
SCRIPT_VALUE_TYPE_SINGLE_WORD
:
int32_t
*
d
=
data
;
if
(
!
decompile_single
(
section
,
entry
,
data
,
length
,
out
))
if
(
length
!=
1
)
{
pr_err
(
"%s.%s: invalid length %d (assuming %d)
\n
"
,
section
->
name
,
entry
->
name
,
length
,
1
);
ok
=
0
;
ok
=
0
;
}
break
;
/* TODO: some are preferred in hexa */
fprintf
(
out
,
"%s
\t
= %d
\n
"
,
entry
->
name
,
*
d
);
};
break
;
case
SCRIPT_VALUE_TYPE_STRING
:
{
case
SCRIPT_VALUE_TYPE_STRING
:
{
size_t
bytes
=
length
<<
2
;
size_t
bytes
=
length
<<
2
;
const
char
*
p
,
*
pe
,
*
s
=
data
;
const
char
*
p
,
*
pe
,
*
s
=
data
;
...
...
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