From 93eb1de2a7e6b74e15a038634eccd6b5e43dec47 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Wed, 16 Feb 2022 20:58:45 +0100 Subject: main: fix -r and -t options Add -t option to optstring. Check for optarg when using -r. Fixes max_redirect initializing to the same value of max_clients when using short option -r. --- src/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 3d776b7..65b68fc 100644 --- a/src/main.c +++ b/src/main.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); while (1) { - val = getopt_long(argc, argv, "n:r::d", tip_repo_opts, NULL); + val = getopt_long(argc, argv, "n:t:r::d", tip_repo_opts, NULL); if (val < 0) break; @@ -67,16 +67,18 @@ int main(int argc, char *argv[]) } break; case 'r': - if (optind < argc && + if (optarg) { + max_redirect = atoi(optarg); + } else if (optind < argc && argv[optind][0] != '-') { max_redirect = atoi(argv[optind++]); - if (max_redirect < 0) { - syslog(LOG_ERR, "Invalid number for redirections"); - return EXIT_FAILURE; - } } else { max_redirect = max_clients; } + if (max_redirect < 0) { + syslog(LOG_ERR, "Invalid number for redirections"); + return EXIT_FAILURE; + } break; case 't': root = strdup(optarg); -- cgit v1.2.3-18-g5258