Use alphabteical order for getopt

This commit is contained in:
Grégory Soutadé 2016-08-12 18:13:31 +02:00
parent bfdb3b4161
commit 9ebfb9f7cf
1 changed files with 19 additions and 19 deletions

38
gget.c
View File

@ -512,23 +512,8 @@ int main(int argc, char** argv)
int continuous_mode=0;
int exists;
while ((opt = getopt(argc, argv, "hn:l:o:u:qm:")) != -1) {
while ((opt = getopt(argc, argv, "hl:m:n:o:qu:")) != -1) {
switch (opt) {
case 'n':
nb_threads = strtoul(optarg, &endptr, 0);
if (*endptr)
{
usage(argv[0]);
return 1;
}
if (nb_threads == 0)
nb_threads = DEFAULT_NB_THREADS;
else if (nb_threads > MAX_NB_THREADS)
{
printf("Max numberb of threads is %d\n", MAX_NB_THREADS);
nb_threads = MAX_NB_THREADS;
}
break;
case 'l':
max_speed = strtoul(optarg, &endptr, 0);
if (*endptr)
@ -570,15 +555,30 @@ int main(int argc, char** argv)
}
max_chunk_size *= multiplier;
break;
case 'n':
nb_threads = strtoul(optarg, &endptr, 0);
if (*endptr)
{
usage(argv[0]);
return 1;
}
if (nb_threads == 0)
nb_threads = DEFAULT_NB_THREADS;
else if (nb_threads > MAX_NB_THREADS)
{
printf("Max numberb of threads is %d\n", MAX_NB_THREADS);
nb_threads = MAX_NB_THREADS;
}
break;
case 'o':
out_filename = strdup(optarg);
break;
case 'u':
user_agent = strdup(optarg);
break;
case 'q':
quiet = 1;
break;
case 'u':
user_agent = strdup(optarg);
break;
default:
case 'h':
usage(argv[0]);