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