From: Pauli Date: Tue, 3 Jun 2025 03:22:14 +0000 (+1000) Subject: paramnames: add new function to handle names and types. X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=973322d6729c8bd255a17938e1caac98f378e72f;p=thirdparty%2Fopenssl.git paramnames: add new function to handle names and types. The help generates the ettable table and the TRIE based name decode function. Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27747) --- diff --git a/util/perl/OpenSSL/paramnames.pm b/util/perl/OpenSSL/paramnames.pm index 3c560ba3302..9e8991b8e91 100644 --- a/util/perl/OpenSSL/paramnames.pm +++ b/util/perl/OpenSSL/paramnames.pm @@ -15,7 +15,8 @@ require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(generate_public_macros generate_internal_macros - produce_decoder); + produce_decoder + produce_param_list); my $case_sensitive = 1; @@ -798,3 +799,32 @@ sub produce_decoder { print " return -1;\n}\n"; return $s; } + +sub produce_param_list { + my $static_array = shift; + my $array_name = shift; + my $static_func = shift; + my $func_name = shift; + my @params = @_; + my @keys = (); + my $s; + + open local *STDOUT, '>', \$s; + print $static_array . ' ' if $static_array ne ''; + printf "const OSSL_PARAM %s[] = {\n", $array_name; + for (my $i = 0; $i <= $#params; $i++) { + my $pname = $params[$i][0]; + my $ptype = $params[$i][1]; + + print " OSSL_PARAM_$ptype(OSSL_$pname, NULL"; + print ", 0" if $ptype eq "octet_string" || $ptype eq "octet_ptr" + || $ptype eq "utf8_string" || $ptype eq "utf8_ptr"; + printf "),\n"; + + push(@keys, $pname); + } + print " OSSL_PARAM_END\n};\n\n"; + + print $static_func . ' ' if $static_func ne ''; + return $s . produce_decoder($func_name, @keys); +}