New functions to enumerate digests and ciphers.
[openssl.git] / apps / progs.pl
1 #!/usr/local/bin/perl
2
3 print "/* apps/progs.h */\n";
4 print "/* automatically generated by progs.pl for openssl.c */\n\n";
5
6 grep(s/^asn1pars$/asn1parse/,@ARGV);
7
8 foreach (@ARGV)
9         { printf "extern int %s_main(int argc,char *argv[]);\n",$_; }
10
11 print <<'EOF';
12
13 #define FUNC_TYPE_GENERAL       1
14 #define FUNC_TYPE_MD            2
15 #define FUNC_TYPE_CIPHER        3
16 #define FUNC_TYPE_PKEY          4
17 #define FUNC_TYPE_MD_ALG        5
18 #define FUNC_TYPE_CIPHER_ALG    6
19
20 typedef struct {
21         int type;
22         const char *name;
23         int (*func)(int argc,char *argv[]);
24         } FUNCTION;
25
26 FUNCTION functions[] = {
27 EOF
28
29 foreach (@ARGV)
30         {
31         push(@files,$_);
32         $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
33         if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
34                 { print "#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))\n${str}#endif\n"; } 
35         elsif ( ($_ =~ /^speed$/))
36                 { print "#ifndef OPENSSL_NO_SPEED\n${str}#endif\n"; }
37         elsif ( ($_ =~ /^engine$/))
38                 { print "#ifndef OPENSSL_NO_ENGINE\n${str}#endif\n"; }
39         elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) || ($_ =~ /^rsautl$/)) 
40                 { print "#ifndef OPENSSL_NO_RSA\n${str}#endif\n";  }
41         elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
42                 { print "#ifndef OPENSSL_NO_DSA\n${str}#endif\n"; }
43         elsif ( ($_ =~ /^ec$/) || ($_ =~ /^ecparam$/))
44                 { print "#ifndef OPENSSL_NO_EC\n${str}#endif\n";}
45         elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/) || ($_ =~ /^dhparam$/))
46                 { print "#ifndef OPENSSL_NO_DH\n${str}#endif\n"; }
47         elsif ( ($_ =~ /^pkcs12$/))
48                 { print "#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)\n${str}#endif\n"; }
49         else
50                 { print $str; }
51         }
52
53 foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160")
54         {
55         push(@files,$_);
56         printf "#ifndef OPENSSL_NO_".uc($_)."\n\t{FUNC_TYPE_MD,\"".$_."\",dgst_main},\n#endif\n";
57         }
58
59 foreach (
60         "aes-128-cbc", "aes-128-ecb",
61         "aes-192-cbc", "aes-192-ecb",
62         "aes-256-cbc", "aes-256-ecb",
63         "camellia-128-cbc", "camellia-128-ecb",
64         "camellia-192-cbc", "camellia-192-ecb",
65         "camellia-256-cbc", "camellia-256-ecb",
66         "base64",
67         "des", "des3", "desx", "idea", "rc4", "rc4-40",
68         "rc2", "bf", "cast", "rc5",
69         "des-ecb", "des-ede",    "des-ede3",
70         "des-cbc", "des-ede-cbc","des-ede3-cbc",
71         "des-cfb", "des-ede-cfb","des-ede3-cfb",
72         "des-ofb", "des-ede-ofb","des-ede3-ofb",
73         "idea-cbc","idea-ecb",   "idea-cfb", "idea-ofb",
74         "rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
75         "bf-cbc",  "bf-ecb",     "bf-cfb",   "bf-ofb",
76         "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
77         "cast-cbc", "rc5-cbc",   "rc5-ecb",  "rc5-cfb",  "rc5-ofb")
78         {
79         push(@files,$_);
80
81         $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
82         if    ($_ =~ /des/)  { $t="#ifndef OPENSSL_NO_DES\n${t}#endif\n"; }
83         elsif ($_ =~ /aes/)  { $t="#ifndef OPENSSL_NO_AES\n${t}#endif\n"; }
84         elsif ($_ =~ /camellia/)  { $t="#ifndef OPENSSL_NO_CAMELLIA\n${t}#endif\n"; }
85         elsif ($_ =~ /idea/) { $t="#ifndef OPENSSL_NO_IDEA\n${t}#endif\n"; }
86         elsif ($_ =~ /rc4/)  { $t="#ifndef OPENSSL_NO_RC4\n${t}#endif\n"; }
87         elsif ($_ =~ /rc2/)  { $t="#ifndef OPENSSL_NO_RC2\n${t}#endif\n"; }
88         elsif ($_ =~ /bf/)   { $t="#ifndef OPENSSL_NO_BF\n${t}#endif\n"; }
89         elsif ($_ =~ /cast/) { $t="#ifndef OPENSSL_NO_CAST\n${t}#endif\n"; }
90         elsif ($_ =~ /rc5/)  { $t="#ifndef OPENSSL_NO_RC5\n${t}#endif\n"; }
91         print $t;
92         }
93
94 print "\t{0,NULL,NULL}\n\t};\n";