-const OPTIONS exit_options[] = {
- {NULL}
-};
-
-static void list_cipher_fn(const EVP_CIPHER *c,
- const char *from, const char *to, void *arg)
-{
- if (c)
- BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
- else {
- if (!from)
- from = "<undefined>";
- if (!to)
- to = "<undefined>";
- BIO_printf(arg, "%s => %s\n", from, to);
- }
-}
-
-static void list_md_fn(const EVP_MD *m,
- const char *from, const char *to, void *arg)
-{
- if (m)
- BIO_printf(arg, "%s\n", EVP_MD_name(m));
- else {
- if (!from)
- from = "<undefined>";
- if (!to)
- to = "<undefined>";
- BIO_printf((BIO *)arg, "%s => %s\n", from, to);
- }
-}
-
-static void list_missing_help(void)
-{
- const FUNCTION *fp;
- const OPTIONS *o;
-
- for (fp = functions; fp->name != NULL; fp++) {
- if ((o = fp->help) == NULL) {
- BIO_printf(bio_out, "%s *\n", fp->name);
- continue;
- }
- for ( ; o->name != NULL; o++) {
- if (o->helpstr == NULL)
- BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
- }
- }
-}
-
-
-/* Unified enum for help and list commands. */
-typedef enum HELPLIST_CHOICE {
- OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
- OPT_COMMANDS, OPT_DIGEST_COMMANDS,
- OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
- OPT_PK_ALGORITHMS, OPT_DISABLED, OPT_MISSING_HELP
-} HELPLIST_CHOICE;
-
-const OPTIONS list_options[] = {
- {"help", OPT_HELP, '-', "Display this summary"},
- {"commands", OPT_COMMANDS, '-', "List of standard commands"},
- {"digest-commands", OPT_DIGEST_COMMANDS, '-',
- "List of message digest commands"},
- {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
- "List of message digest algorithms"},
- {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
- {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
- "List of cipher algorithms"},
- {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
- "List of public key algorithms"},
- {"disabled", OPT_DISABLED, '-',
- "List of disabled features"},
- {"missing-help", OPT_MISSING_HELP, '-',
- "List missing detailed help strings"},
- {NULL}
-};
-
-int list_main(int argc, char **argv)
-{
- char *prog;
- HELPLIST_CHOICE o;
- int done = 0;
-
- prog = opt_init(argc, argv, list_options);
- while ((o = opt_next()) != OPT_EOF) {
- switch (o) {
- case OPT_EOF: /* Never hit, but suppresses warning */
- case OPT_ERR:
- BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
- return 1;
- case OPT_HELP:
- opt_help(list_options);
- break;
- case OPT_COMMANDS:
- list_type(FT_general);
- break;
- case OPT_DIGEST_COMMANDS:
- list_type(FT_md);
- break;
- case OPT_DIGEST_ALGORITHMS:
- EVP_MD_do_all_sorted(list_md_fn, bio_out);
- break;
- case OPT_CIPHER_COMMANDS:
- list_type(FT_cipher);
- break;
- case OPT_CIPHER_ALGORITHMS:
- EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
- break;
- case OPT_PK_ALGORITHMS:
- list_pkey();
- break;
- case OPT_DISABLED:
- list_disabled();
- break;
- case OPT_MISSING_HELP:
- list_missing_help();
- break;
- }
- done = 1;
- }
-
- if (!done) {
- BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
- return 1;
- }
-
- return 0;
-}
-