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
f2ff0fc8
Commit
f2ff0fc8
authored
May 04, 2012
by
Alejandro Mery
Browse files
fex2bin: open and close input and output files
parent
0dd7e13a
Changes
1
Show whitespace changes
Inline
Side-by-side
fex2bin.c
View file @
f2ff0fc8
...
...
@@ -16,7 +16,42 @@
*/
#include "fex2bin.h"
int
main
(
int
UNUSED
(
argc
),
char
*
UNUSED
(
argv
[]))
#include <errno.h>
#include <stdio.h>
#include <string.h>
/**
*/
int
main
(
int
argc
,
char
*
argv
[])
{
return
0
;
int
ret
=
-
1
;
FILE
*
in
=
stdin
,
*
out
=
stdout
;
const
char
*
fn
[]
=
{
"stdin"
,
"stdout"
};
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"-"
)
==
0
)
;
/* we are using stdin anyway */
else
if
((
fn
[
0
]
=
argv
[
1
])
&&
(
in
=
fopen
(
fn
[
0
],
"r"
))
==
NULL
)
{
errf
(
"%s: %s
\n
"
,
fn
[
0
],
strerror
(
errno
));
goto
usage
;
}
if
(
argc
>
2
)
{
fn
[
1
]
=
argv
[
2
];
if
((
out
=
fopen
(
fn
[
1
],
"w"
))
==
NULL
)
{
errf
(
"%s: %s
\n
"
,
fn
[
1
],
strerror
(
errno
));
goto
usage
;
}
}
}
goto
done
;
usage:
errf
(
"Usage: %s [<script.fex> [<script.bin>]
\n
"
,
argv
[
0
]);
done:
if
(
in
!=
stdin
)
fclose
(
in
);
if
(
out
!=
stdout
)
fclose
(
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