summaryrefslogtreecommitdiff
path: root/configdata.pm.in
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-04-26 19:41:54 +0200
committerRichard Levitte <levitte@openssl.org>2021-05-04 11:29:56 +0200
commit841a438c7f67f697dd6710b26cc6536dd76a420a (patch)
tree1abeb8c0f7412ef735961edda3a9838e39fa3f23 /configdata.pm.in
parent02669b677e6263b3d337ceb526b8b030477fe26b (diff)
downloadopenssl-new-841a438c7f67f697dd6710b26cc6536dd76a420a.tar.gz
Add OpenSSL::Config::Query and use it in configdata.pm
OpenSSL::Config::Query is a configuration querying tool that's meant to make it easier to query the diverse configuration data for info. That's much easier than to dig through all the parts of %unified_info. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8871)
Diffstat (limited to 'configdata.pm.in')
-rw-r--r--configdata.pm.in26
1 files changed, 24 insertions, 2 deletions
diff --git a/configdata.pm.in b/configdata.pm.in
index 279b8f75c9..3481eab277 100644
--- a/configdata.pm.in
+++ b/configdata.pm.in
@@ -112,13 +112,14 @@ unless (caller) {
use File::Basename;
use Pod::Usage;
+ use lib '{- sourcedir('util', 'perl') -}';
+ use OpenSSL::fallback '{- sourcefile('external', 'perl', 'MODULES.txt') -}';
+
my $here = dirname($0);
if (scalar @ARGV == 0) {
# With no arguments, re-create the build file
- use lib '{- sourcedir('util', 'perl') -}';
- use OpenSSL::fallback '{- sourcefile('external', 'perl', 'MODULES.txt') -}';
use OpenSSL::Template;
my $prepend = <<'_____';
@@ -172,6 +173,7 @@ _____
my $buildparams = undef;
my $reconf = undef;
my $verbose = undef;
+ my $query = undef;
my $help = undef;
my $man = undef;
GetOptions('dump|d' => \$dump,
@@ -183,6 +185,7 @@ _____
'build-parameters|b' => \$buildparams,
'reconfigure|reconf|r' => \$reconf,
'verbose|v' => \$verbose,
+ 'query|q=s' => \$query,
'help' => \$help,
'man' => \$man)
or die "Errors in command line arguments\n";
@@ -320,6 +323,25 @@ _____
chdir $here;
exec $^X,catfile($config{sourcedir}, 'Configure'),'reconf';
}
+ if ($query) {
+ use OpenSSL::Config::Query;
+
+ my $confquery = OpenSSL::Config::Query->new(info => \%unified_info,
+ config => \%config);
+ my $result = eval "\$confquery->$query";
+
+ # We may need a result class with a printing function at some point.
+ # Until then, we assume that we get a scalar, or a list or a hash table
+ # with scalar values and simply print them in some orderly fashion.
+ if (ref $result eq 'ARRAY') {
+ print "$_\n" foreach @$result;
+ } elsif (ref $result eq 'HASH') {
+ print "$_ : \\\n ", join(" \\\n ", @{$result->{$_}}), "\n"
+ foreach sort keys %$result;
+ } elsif (ref $result eq 'SCALAR') {
+ print "$$result\n";
+ }
+ }
}
1;