Skip to content
Snippets Groups Projects
Commit aba78308 authored by Niels Möller's avatar Niels Möller
Browse files

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

options.

Rev: nettle/examples/nettle-benchmark.c:1.15
parent f19a068d
Branches
Tags
No related merge requests found
...@@ -513,7 +513,16 @@ main(int argc, char **argv) ...@@ -513,7 +513,16 @@ main(int argc, char **argv)
NULL NULL
}; };
while ( (c = getopt(argc, argv, "f:")) != -1) enum { OPT_HELP = 300 };
static const struct option options[] =
{
/* Name, args, flag, val */
{ "help", no_argument, NULL, OPT_HELP },
{ "clock-frequency", required_argument, NULL, 'f' },
{ NULL, 0, NULL, 0 }
};
while ( (c = getopt_long(argc, argv, "f:", options, NULL)) != -1)
switch (c) switch (c)
{ {
case 'f': case 'f':
...@@ -521,8 +530,11 @@ main(int argc, char **argv) ...@@ -521,8 +530,11 @@ main(int argc, char **argv)
if (frequency > 0.0) if (frequency > 0.0)
break; break;
case ':': case '?': case OPT_HELP:
fprintf(stderr, "Usage: nettle-benchmark [-f clock frequency] [alg]\n"); printf("Usage: nettle-benchmark [-f clock frequency] [alg]\n");
return EXIT_SUCCESS;
case '?':
return EXIT_FAILURE; return EXIT_FAILURE;
default: default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment