]>
Commit | Line | Data |
---|---|---|
0109e030 | 1 | /* |
aff636a4 | 2 | * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. |
0109e030 RL |
3 | * |
4 | * Licensed under the Apache License 2.0 (the "License"). You may not use | |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
8 | */ | |
9 | ||
10 | #include <openssl/crypto.h> | |
11 | #include "apps.h" | |
12 | #include "progs.h" | |
13 | ||
14 | typedef enum OPTION_choice { | |
b0f96018 | 15 | OPT_COMMON, |
0109e030 | 16 | OPT_CONFIGDIR, OPT_ENGINESDIR, OPT_MODULESDIR, OPT_DSOEXT, OPT_DIRNAMESEP, |
363e941e | 17 | OPT_LISTSEP, OPT_SEEDS, OPT_CPUSETTINGS |
0109e030 RL |
18 | } OPTION_CHOICE; |
19 | ||
20 | const OPTIONS info_options[] = { | |
5388f986 RS |
21 | |
22 | OPT_SECTION("General"), | |
0109e030 | 23 | {"help", OPT_HELP, '-', "Display this summary"}, |
5388f986 RS |
24 | |
25 | OPT_SECTION("Output"), | |
0109e030 | 26 | {"configdir", OPT_CONFIGDIR, '-', "Default configuration file directory"}, |
0109e030 | 27 | {"enginesdir", OPT_ENGINESDIR, '-', "Default engine module directory"}, |
0773687a | 28 | {"modulesdir", OPT_MODULESDIR, '-', |
0109e030 RL |
29 | "Default module directory (other than engine modules)"}, |
30 | {"dsoext", OPT_DSOEXT, '-', "Configured extension for modules"}, | |
31 | {"dirnamesep", OPT_DIRNAMESEP, '-', "Directory-filename separator"}, | |
32 | {"listsep", OPT_LISTSEP, '-', "List separator character"}, | |
096978f0 | 33 | {"seeds", OPT_SEEDS, '-', "Seed sources"}, |
363e941e | 34 | {"cpusettings", OPT_CPUSETTINGS, '-', "CPU settings info"}, |
0109e030 RL |
35 | {NULL} |
36 | }; | |
37 | ||
38 | int info_main(int argc, char **argv) | |
39 | { | |
40 | int ret = 1, dirty = 0, type = 0; | |
41 | char *prog; | |
42 | OPTION_CHOICE o; | |
43 | ||
44 | prog = opt_init(argc, argv, info_options); | |
45 | while ((o = opt_next()) != OPT_EOF) { | |
46 | switch (o) { | |
0dc6bf3c | 47 | default: |
0109e030 RL |
48 | opthelp: |
49 | BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); | |
50 | goto end; | |
51 | case OPT_HELP: | |
52 | opt_help(info_options); | |
53 | ret = 0; | |
54 | goto end; | |
55 | case OPT_CONFIGDIR: | |
56 | type = OPENSSL_INFO_CONFIG_DIR; | |
57 | dirty++; | |
58 | break; | |
59 | case OPT_ENGINESDIR: | |
60 | type = OPENSSL_INFO_ENGINES_DIR; | |
61 | dirty++; | |
62 | break; | |
63 | case OPT_MODULESDIR: | |
64 | type = OPENSSL_INFO_MODULES_DIR; | |
65 | dirty++; | |
66 | break; | |
67 | case OPT_DSOEXT: | |
68 | type = OPENSSL_INFO_DSO_EXTENSION; | |
69 | dirty++; | |
70 | break; | |
71 | case OPT_DIRNAMESEP: | |
72 | type = OPENSSL_INFO_DIR_FILENAME_SEPARATOR; | |
73 | dirty++; | |
74 | break; | |
75 | case OPT_LISTSEP: | |
76 | type = OPENSSL_INFO_LIST_SEPARATOR; | |
77 | dirty++; | |
78 | break; | |
096978f0 RL |
79 | case OPT_SEEDS: |
80 | type = OPENSSL_INFO_SEED_SOURCE; | |
81 | dirty++; | |
82 | break; | |
363e941e BE |
83 | case OPT_CPUSETTINGS: |
84 | type = OPENSSL_INFO_CPU_SETTINGS; | |
85 | dirty++; | |
86 | break; | |
0109e030 RL |
87 | } |
88 | } | |
d9f07357 | 89 | if (!opt_check_rest_arg(NULL)) |
0109e030 | 90 | goto opthelp; |
0109e030 RL |
91 | if (dirty > 1) { |
92 | BIO_printf(bio_err, "%s: Only one item allowed\n", prog); | |
93 | goto opthelp; | |
94 | } | |
95 | if (dirty == 0) { | |
96 | BIO_printf(bio_err, "%s: No items chosen\n", prog); | |
97 | goto opthelp; | |
98 | } | |
99 | ||
100 | BIO_printf(bio_out, "%s\n", OPENSSL_info(type)); | |
101 | ret = 0; | |
102 | end: | |
103 | return ret; | |
104 | } |