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
2abe140b
Commit
2abe140b
authored
May 07, 2012
by
Alejandro Mery
Browse files
fex2bin: open out as fd instead of FILE*
parent
049f0daf
Changes
1
Hide whitespace changes
Inline
Side-by-side
fex2bin.c
View file @
2abe140b
...
...
@@ -22,6 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include "script_bin.h"
...
...
@@ -226,7 +229,8 @@ parse_error:
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
=
1
;
FILE
*
in
=
stdin
,
*
out
=
stdout
;
FILE
*
in
=
stdin
;
int
out
=
1
;
const
char
*
fn
[]
=
{
"stdin"
,
"stdout"
};
struct
script
*
script
;
...
...
@@ -244,7 +248,7 @@ int main(int argc, char *argv[])
if
(
argc
>
2
)
{
fn
[
1
]
=
argv
[
2
];
if
((
out
=
f
open
(
fn
[
1
],
"w"
))
==
NULL
)
{
if
((
out
=
open
(
fn
[
1
],
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0666
))
<
0
)
{
errf
(
"%s: %s
\n
"
,
fn
[
1
],
strerror
(
errno
));
goto
usage
;
}
...
...
@@ -272,6 +276,6 @@ usage:
done:
if
(
in
&&
in
!=
stdin
)
fclose
(
in
);
if
(
out
&&
out
!=
stdout
)
f
close
(
out
);
if
(
out
>
2
)
close
(
out
);
return
ret
;
}
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