diff options
author | Thomas Albers <thomas@thomaslabs.org> | 2023-08-10 11:18:49 +0200 |
---|---|---|
committer | Thomas Albers <thomas@thomaslabs.org> | 2023-08-10 11:18:49 +0200 |
commit | 3199529ab3ed39737454f9f0b4e91915955c38b2 (patch) | |
tree | 0961c0edfce659573e4040d2c4c3a831b8745b2d /zup.c | |
parent | 932424af0aadcfcc9dcf3f66ff844fea6ac53986 (diff) |
Add attempts number as a command line option
Diffstat (limited to 'zup.c')
-rw-r--r-- | zup.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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; |