From 823fdcfcb10e8dcf4d950a941abd8b271b8d3cab Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 20 Jun 2012 10:56:11 -0300 Subject: [PATCH] tools/antorcha.c: require option -F for firmware upload --- tools/antorcha.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/antorcha.c b/tools/antorcha.c index 31af37e..c9d566c 100644 --- a/tools/antorcha.c +++ b/tools/antorcha.c @@ -194,14 +194,40 @@ static void firmware(struct atrf_dsc *dsc, const char *name) } +static void usage(const char *name) +{ + fprintf(stderr, "usage: %s -F firmware_file\n", name); + exit(1); +} + + int main(int argc, char **argv) { + const char *fw = NULL; struct atrf_dsc *dsc; + int c; + + while ((c = getopt(argc, argv, "F:")) != EOF) + switch (c) { + case 'F': + fw = optarg; + break; + default: + usage(*argv); + } + + if (argc != optind) + usage(*argv); + if (!fw) + usage(*argv); dsc = atrf_open(NULL); if (!dsc) return 1; + rf_init(dsc, 8, 15); - firmware(dsc, argv[1]); + if (fw) + firmware(dsc, fw); + return 0; }