mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 07:36:17 +02:00
tornado/fw/ben/ben.c (main): use getopt
This commit is contained in:
parent
cb324a81fc
commit
e2172b4eef
@ -13,6 +13,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
@ -92,6 +93,9 @@ static void usage(const char *name)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int do_read = 1;
|
||||||
|
int c;
|
||||||
|
|
||||||
io_setup();
|
io_setup();
|
||||||
|
|
||||||
if (!mmc_init()) {
|
if (!mmc_init()) {
|
||||||
@ -99,11 +103,21 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 1)
|
while ((c = getopt(argc, argv, "w")) != EOF)
|
||||||
read_block();
|
switch (c) {
|
||||||
else if (!strcmp(argv[1], "-w"))
|
case 'w':
|
||||||
write_block();
|
do_read = 0;
|
||||||
else
|
break;
|
||||||
|
default:
|
||||||
|
usage(*argv);
|
||||||
|
}
|
||||||
|
if (optind != argc)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
|
|
||||||
|
if (do_read)
|
||||||
|
read_block();
|
||||||
|
else
|
||||||
|
write_block();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user