progs.pl 3.0 KB

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