Commit f19a068d authored by Niels Möller's avatar Niels Möller
Browse files

(main): Added long options. Deleted -?, and fixed handling of bad

options. Renamed -s to -q (long option --quiet).

Rev: nettle/examples/eratosthenes.c:1.10
parent 2f5356bd
......@@ -243,12 +243,23 @@ main (int argc, char **argv)
int verbose = 0;
int c;
while ( (c = getopt(argc, argv, "?svb:")) != -1)
enum { OPT_HELP = 300 };
static const struct option options[] =
{
/* Name, args, flag, val */
{ "help", no_argument, NULL, OPT_HELP },
{ "verbose", no_argument, NULL, 'v' },
{ "block-size", required_argument, NULL, 'b' },
{ "quiet", required_argument, NULL, 'q' },
{ NULL, 0, NULL, 0}
};
while ( (c = getopt_long(argc, argv, "svb:", options, NULL)) != -1)
switch (c)
{
case '?':
case OPT_HELP:
usage();
return EXIT_FAILURE;
return EXIT_SUCCESS;
case 'b':
block_nbits = CHAR_BIT * atosize(optarg);
if (!block_nbits)
......@@ -258,7 +269,7 @@ main (int argc, char **argv)
}
break;
case 's':
case 'q':
silent = 1;
break;
......@@ -266,6 +277,9 @@ main (int argc, char **argv)
verbose++;
break;
case '?':
return EXIT_FAILURE;
default:
abort();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment