Commit e9ded494 authored by Niels Möller's avatar Niels Möller

* examples/rsa-keygen.c (main): Added long options. Deleted -?,

and fixed handling of bad options.

* examples/next-prime.c (main): Deleted -?, and fixed handling of
bad options.
* examples/random-prime.c (main): Likewise.

Rev: nettle/examples/random-prime.c:1.4
Rev: nettle/examples/rsa-keygen.c:1.3
parent ff0c3e27
......@@ -65,16 +65,17 @@ main(int argc, char **argv)
clock_t start;
clock_t end;
enum { OPT_HELP = 300 };
static const struct option options[] =
{
/* Name, args, flag, val */
{ "help", no_argument, NULL, '?' },
{ "help", no_argument, NULL, OPT_HELP },
{ "verbose", no_argument, NULL, 'v' },
{ "random", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0}
};
while ( (c = getopt_long(argc, argv, "v?r:", options, NULL)) != -1)
while ( (c = getopt_long(argc, argv, "vr:", options, NULL)) != -1)
switch (c)
{
case 'v':
......@@ -83,8 +84,10 @@ main(int argc, char **argv)
case 'r':
random_file = optarg;
break;
case '?':
case OPT_HELP:
usage();
return EXIT_SUCCESS;
case '?':
return EXIT_FAILURE;
default:
abort();
......
......@@ -51,7 +51,6 @@ progress(void *ctx, int c)
fputc(c, stderr);
}
int
main(int argc, char **argv)
{
......@@ -67,7 +66,16 @@ main(int argc, char **argv)
struct nettle_buffer pub_buffer;
struct nettle_buffer priv_buffer;
while ( (c = getopt(argc, argv, "o:r:")) != -1)
enum { OPT_HELP = 300 };
static const struct option options[] =
{
/* Name, args, flag, val */
{ "help", no_argument, NULL, OPT_HELP },
{ "random", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0}
};
while ( (c = getopt_long(argc, argv, "o:r:", options, NULL)) != -1)
switch (c)
{
case 'o':
......@@ -77,14 +85,14 @@ main(int argc, char **argv)
case 'r':
random_name = optarg;
break;
case OPT_HELP:
printf("FIXME: Usage information.\n");
return EXIT_SUCCESS;
case '?':
if (isprint (optopt))
werror("Unknown option `-%c'.\n", optopt);
else
werror("Unknown option character `\\x%x'.\n",
optopt);
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