]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
paramnames: add new function to handle names and types.
authorPauli <ppzgs1@gmail.com>
Tue, 3 Jun 2025 03:22:14 +0000 (13:22 +1000)
committerTomas Mraz <tomas@openssl.org>
Wed, 4 Jun 2025 14:48:59 +0000 (16:48 +0200)
The help generates the ettable table and the TRIE based name decode function.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27747)

util/perl/OpenSSL/paramnames.pm

index 3c560ba3302221daf336913e5f39d7993aabf767..9e8991b8e9184fa98e90c35cfcfd2c9fc8058c71 100644 (file)
@@ -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);
+}