OPT_HEX, OPT_GENERATE, OPT_BITS, OPT_SAFE, OPT_CHECKS
} OPTION_CHOICE;
-OPTIONS prime_options[] = {
+const OPTIONS prime_options[] = {
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [number...]\n"},
{OPT_HELP_STR, 1, '-',
" number Number to check for primality\n"},
switch (o) {
case OPT_EOF:
case OPT_ERR:
+opthelp:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
goto end;
case OPT_HELP:
argc = opt_num_rest();
argv = opt_rest();
- if (argc == 0 && !generate) {
+ if (generate) {
+ if (argc != 0) {
+ BIO_printf(bio_err, "Extra arguments given.\n");
+ goto opthelp;
+ }
+ } else if (argc == 0) {
BIO_printf(bio_err, "%s: No prime specified\n", prog);
- goto end;
+ goto opthelp;
}
if (generate) {
else
r = BN_dec2bn(&bn, argv[0]);
- if(!r) {
+ if (!r) {
BIO_printf(bio_err, "Failed to process value (%s)\n", argv[0]);
goto end;
}
}
}
- BN_free(bn);
-
ret = 0;
end:
+ BN_free(bn);
return ret;
}