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
91923712
Commit
91923712
authored
May 07, 2012
by
Alejandro Mery
Browse files
fex2bin: call generate_bin() and write data out on success
parent
2abe140b
Changes
3
Show whitespace changes
Inline
Side-by-side
fex2bin.c
View file @
91923712
...
@@ -234,8 +234,6 @@ int main(int argc, char *argv[])
...
@@ -234,8 +234,6 @@ int main(int argc, char *argv[])
const
char
*
fn
[]
=
{
"stdin"
,
"stdout"
};
const
char
*
fn
[]
=
{
"stdin"
,
"stdout"
};
struct
script
*
script
;
struct
script
*
script
;
pr_info
(
"WARNING: this tool is still not functional, sorry
\n
"
);
if
(
argc
>
1
)
{
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"-"
)
==
0
)
if
(
strcmp
(
argv
[
1
],
"-"
)
==
0
)
;
/* we are using stdin anyway */
;
/* we are using stdin anyway */
...
@@ -262,11 +260,29 @@ int main(int argc, char *argv[])
...
@@ -262,11 +260,29 @@ int main(int argc, char *argv[])
if
(
parse_fex
(
in
,
fn
[
0
],
script
))
{
if
(
parse_fex
(
in
,
fn
[
0
],
script
))
{
size_t
sections
,
entries
,
bin_size
;
size_t
sections
,
entries
,
bin_size
;
void
*
bin
;
bin_size
=
calculate_bin_size
(
script
,
&
sections
,
&
entries
);
bin_size
=
calculate_bin_size
(
script
,
&
sections
,
&
entries
);
ret
=
0
;
bin
=
calloc
(
1
,
bin_size
);
if
(
!
bin
)
perror
(
"malloc"
);
else
if
(
generate_bin
(
bin
,
bin_size
,
script
,
sections
,
entries
))
{
(
void
)
bin_size
;
while
(
bin_size
)
{
ssize_t
wc
=
write
(
out
,
bin
,
bin_size
);
if
(
wc
>
0
)
{
bin
+=
wc
;
bin_size
-=
wc
;
}
else
if
(
wc
<
0
&&
errno
!=
EINTR
)
{
pr_err
(
"%s: write: %s
\n
"
,
fn
[
2
],
strerror
(
errno
));
break
;
}
}
if
(
bin_size
==
0
)
ret
=
0
;
}
}
}
script_delete
(
script
);
script_delete
(
script
);
...
...
script_bin.c
View file @
91923712
...
@@ -87,4 +87,10 @@ size_t calculate_bin_size(struct script *script,
...
@@ -87,4 +87,10 @@ size_t calculate_bin_size(struct script *script,
bin_size
);
bin_size
);
return
bin_size
;
return
bin_size
;
}
}
#undef WORDS
int
generate_bin
(
void
*
bin
,
size_t
bin_size
,
struct
script
*
script
,
size_t
sections
,
size_t
entries
)
{
pr_err
(
"bin generation not yet implemented
\n
"
);
return
0
;
}
script_bin.h
View file @
91923712
...
@@ -19,4 +19,7 @@
...
@@ -19,4 +19,7 @@
size_t
calculate_bin_size
(
struct
script
*
script
,
size_t
calculate_bin_size
(
struct
script
*
script
,
size_t
*
sections
,
size_t
*
entries
);
size_t
*
sections
,
size_t
*
entries
);
int
generate_bin
(
void
*
bin
,
size_t
bin_size
,
struct
script
*
script
,
size_t
sections
,
size_t
entries
);
#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