From 3199529ab3ed39737454f9f0b4e91915955c38b2 Mon Sep 17 00:00:00 2001 From: Thomas Albers Date: Thu, 10 Aug 2023 11:18:49 +0200 Subject: Add attempts number as a command line option --- zup.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'zup.c') diff --git a/zup.c b/zup.c index d3acc54..5fe1e61 100644 --- a/zup.c +++ b/zup.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -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; -- cgit v1.2.3