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