3 # Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
5 # Licensed under the OpenSSL licenses, (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 # https://www.openssl.org/source/license.html
9 # or in the file LICENSE in the source distribution.
11 # Generate progs.h file by looking for command mains in list of C files
12 # passed on the command line.
16 use configdata qw/@disablables/;
19 my $cmdre = qr/^\s*int\s+([a-z_][a-z0-9_]*)_main\(\s*int\s+argc\s*,/;
21 foreach my $filename (@ARGV) {
22 open F, $filename or die "Coudn't open $_: $!\n";
23 foreach (grep /$cmdre/, <F>) {
30 @ARGV = sort keys %commands;
34 * Automatically generated by progs.pl for openssl.c
35 * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
37 * Licensed under the OpenSSL licenses, (the "License");
38 * you may not use this file except in compliance with the License.
39 * You may obtain a copy of the License at
40 * https://www.openssl.org/source/license.html
41 * or in the file LICENSE in the source distribution.
44 typedef enum FUNC_TYPE {
45 FT_none, FT_general, FT_md, FT_cipher, FT_pkey,
46 FT_md_alg, FT_cipher_alg
49 typedef struct function_st {
52 int (*func)(int argc,char *argv[]);
56 DEFINE_LHASH_OF(FUNCTION);
61 printf "extern int %s_main(int argc, char *argv[]);\n", $_;
67 printf "extern OPTIONS %s_options[];\n", $_;
81 print "\nstatic FUNCTION functions[] = {\n";
82 foreach my $cmd (@ARGV) {
83 my $str=" { FT_general, \"$cmd\", ${cmd}_main, ${cmd}_options },\n";
85 print "#ifndef OPENSSL_NO_SOCK\n${str}#endif\n";
86 } elsif (grep { $cmd eq $_ } @disablables) {
87 print "#ifndef OPENSSL_NO_".uc($cmd)."\n${str}#endif\n";
88 } elsif (my $disabler = $cmd_disabler{$cmd}) {
89 print "#ifndef OPENSSL_NO_".uc($disabler)."\n${str}#endif\n";
101 blake2b512 => "blake2",
102 blake2s256 => "blake2",
107 "sha1", "sha224", "sha256", "sha384", "sha512",
108 "mdc2", "rmd160", "blake2b512", "blake2s256"
110 my $str = " { FT_md, \"".$cmd."\", dgst_main},\n";
111 if (grep { $cmd eq $_ } @disablables) {
112 print "#ifndef OPENSSL_NO_".uc($cmd)."\n${str}#endif\n";
113 } elsif (my $disabler = $md_disabler{$cmd}) {
114 print "#ifndef OPENSSL_NO_".uc($disabler)."\n${str}#endif\n";
116 print "#ifndef OPENSSL_NO_".uc($cmd)."\n${str}#endif\n";
120 my %cipher_disabler = (
126 "aes-128-cbc", "aes-128-ecb",
127 "aes-192-cbc", "aes-192-ecb",
128 "aes-256-cbc", "aes-256-ecb",
129 "camellia-128-cbc", "camellia-128-ecb",
130 "camellia-192-cbc", "camellia-192-ecb",
131 "camellia-256-cbc", "camellia-256-ecb",
133 "des", "des3", "desx", "idea", "seed", "rc4", "rc4-40",
134 "rc2", "bf", "cast", "rc5",
135 "des-ecb", "des-ede", "des-ede3",
136 "des-cbc", "des-ede-cbc","des-ede3-cbc",
137 "des-cfb", "des-ede-cfb","des-ede3-cfb",
138 "des-ofb", "des-ede-ofb","des-ede3-ofb",
139 "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
140 "seed-cbc","seed-ecb", "seed-cfb", "seed-ofb",
141 "rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
142 "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
143 "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
144 "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb"
146 my $str=" { FT_cipher, \"$cmd\", enc_main, enc_options },\n";
147 (my $algo= $cmd) =~ s/-.*//g;
148 if ($cmd eq "zlib") {
149 print "#ifdef ZLIB\n${str}#endif\n";
150 } elsif (grep { $algo eq $_ } @disablables) {
151 print "#ifndef OPENSSL_NO_".uc($algo)."\n${str}#endif\n";
152 } elsif (my $disabler = $cipher_disabler{$algo}) {
153 print "#ifndef OPENSSL_NO_".uc($disabler)."\n${str}#endif\n";
159 print " { 0, NULL, NULL}\n};\n";