summaryrefslogtreecommitdiff
path: root/zup.c
diff options
context:
space:
mode:
Diffstat (limited to 'zup.c')
-rw-r--r--zup.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/zup.c b/zup.c
index d3acc54..5fe1e61 100644
--- a/zup.c
+++ b/zup.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <errno.h>
#include <getopt.h>
#include <unistd.h>
@@ -97,7 +98,7 @@ parse_baud(const char *str)
static int
parse_options(int argc, char *const argv[])
{
- const char *sopts = "b:p:hHVPRrv";
+ const char *sopts = "a:b:p:hHVPRrv";
const struct option lopts[] = {
{"baud", required_argument, 0, 'b'},
{"verbose", no_argument, 0, 'v'},
@@ -106,6 +107,7 @@ parse_options(int argc, char *const argv[])
{"repl", no_argument, 0, 'R'},
{"port", required_argument, 0, 'p'},
{"progress", no_argument, 0, 'P'},
+ {"attempts", required_argument, 0, 'a'},
{"human-readable", no_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{ 0, 0, 0, 0 }
@@ -123,6 +125,15 @@ parse_options(int argc, char *const argv[])
}
break;
+ case 'a':
+ errno = 0;
+ param.max_attempts = strtoul(optarg, NULL, 10);
+ if (errno) {
+ perror("Invalid attempts number\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
+
case 'v':
param.verbose = 1;
break;