diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2022-02-16 20:58:45 +0100 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2022-02-16 21:10:36 +0100 |
commit | 93eb1de2a7e6b74e15a038634eccd6b5e43dec47 (patch) | |
tree | 1725de5bb93dc319807141223a618ba865e1b230 /src/main.c | |
parent | c80bd1c52565b74b1b6203d1fead97e59c7b4c7e (diff) |
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.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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); |