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", $_;
70 print "\n#ifdef INCLUDE_FUNCTION_TABLE\n";
71 print "static FUNCTION functions[] = {\n";
83 foreach my $cmd (@ARGV) {
84 my $str=" { FT_general, \"$cmd\", ${cmd}_main, ${cmd}_options },\n";
86 print "#ifndef OPENSSL_NO_SOCK\n${str}#endif\n";
87 } elsif (grep { $cmd eq $_ } @disablables) {
88 print "#ifndef OPENSSL_NO_".uc($cmd)."\n${str}#endif\n";
89 } elsif (my $disabler = $cmd_disabler{$cmd}) {
90 print "#ifndef OPENSSL_NO_".uc($disabler)."\n${str}#endif\n";
102 blake2b512 => "blake2",
103 blake2s256 => "blake2",
108 "sha1", "sha224", "sha256", "sha384", "sha512",
109 "mdc2", "rmd160", "blake2b512", "blake2s256"
111 my $str = " { FT_md, \"".$cmd."\", dgst_main},\n";
112 if (grep { $cmd eq $_ } @disablables) {
113 print "#ifndef OPENSSL_NO_".uc($cmd)."\n${str}#endif\n";
114 } elsif (my $disabler = $md_disabler{$cmd}) {
115 print "#ifndef OPENSSL_NO_".uc($disabler)."\n${str}#endif\n";
117 print "#ifndef OPENSSL_NO_".uc($cmd)."\n${str}#endif\n";
121 my %cipher_disabler = (
127 "aes-128-cbc", "aes-128-ecb",
128 "aes-192-cbc", "aes-192-ecb",
129 "aes-256-cbc", "aes-256-ecb",
130 "camellia-128-cbc", "camellia-128-ecb",
131 "camellia-192-cbc", "camellia-192-ecb",
132 "camellia-256-cbc", "camellia-256-ecb",
134 "des", "des3", "desx", "idea", "seed", "rc4", "rc4-40",
135 "rc2", "bf", "cast", "rc5",
136 "des-ecb", "des-ede", "des-ede3",
137 "des-cbc", "des-ede-cbc","des-ede3-cbc",
138 "des-cfb", "des-ede-cfb","des-ede3-cfb",
139 "des-ofb", "des-ede-ofb","des-ede3-ofb",
140 "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
141 "seed-cbc","seed-ecb", "seed-cfb", "seed-ofb",
142 "rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
143 "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
144 "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
145 "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb"
147 my $str=" { FT_cipher, \"$cmd\", enc_main, enc_options },\n";
148 (my $algo= $cmd) =~ s/-.*//g;
149 if ($cmd eq "zlib") {
150 print "#ifdef ZLIB\n${str}#endif\n";
151 } elsif (grep { $algo eq $_ } @disablables) {
152 print "#ifndef OPENSSL_NO_".uc($algo)."\n${str}#endif\n";
153 } elsif (my $disabler = $cipher_disabler{$algo}) {
154 print "#ifndef OPENSSL_NO_".uc($disabler)."\n${str}#endif\n";
160 print " { 0, NULL, NULL}\n};\n";