diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -29,11 +29,11 @@ int max_clients = DEFAULT_MAX_CLIENTS; const char *root = "."; -bool redirect; +int max_redirect = 0; static struct option tip_repo_opts[] = { { "max-clients", 1, 0, 'n' }, - { "redirect", 0, 0, 'r' }, + { "redirect", 2, 0, 'r' }, { "root", 1, 0, 't' }, { "daemon", 0, 0, 'd' }, { NULL }, @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); while (1) { - val = getopt_long(argc, argv, "n:rd", tip_repo_opts, NULL); + val = getopt_long(argc, argv, "n:r::d", tip_repo_opts, NULL); if (val < 0) break; @@ -67,7 +67,15 @@ int main(int argc, char *argv[]) } break; case 'r': - redirect = true; + if (optarg) { + max_redirect = atoi(optarg); + if (max_redirect <= 0) { + syslog(LOG_ERR, "Invalid number for redirections"); + return EXIT_FAILURE; + } + } else { + max_redirect = max_clients; + } break; case 't': root = strdup(optarg); |