progs.pl 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. typedef struct {
  12. int type;
  13. const char *name;
  14. int (*func)(int argc,char *argv[]);
  15. } FUNCTION;
  16. FUNCTION functions[] = {
  17. EOF
  18. foreach (@ARGV)
  19. {
  20. push(@files,$_);
  21. $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
  22. if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
  23. { print "#if !defined(OPENSSL_NO_SOCK) && !(defined(OPENSSL_NO_SSL2) && defined(OPENSSL_NO_SSL3))\n${str}#endif\n"; }
  24. elsif ( ($_ =~ /^speed$/))
  25. { print "#ifndef OPENSSL_NO_SPEED\n${str}#endif\n"; }
  26. elsif ( ($_ =~ /^engine$/))
  27. { print "#ifndef OPENSSL_NO_ENGINE\n${str}#endif\n"; }
  28. elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) || ($_ =~ /^rsautl$/))
  29. { print "#ifndef OPENSSL_NO_RSA\n${str}#endif\n"; }
  30. elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
  31. { print "#ifndef OPENSSL_NO_DSA\n${str}#endif\n"; }
  32. elsif ( ($_ =~ /^ec$/) || ($_ =~ /^ecparam$/))
  33. { print "#ifndef OPENSSL_NO_EC\n${str}#endif\n";}
  34. elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/) || ($_ =~ /^dhparam$/))
  35. { print "#ifndef OPENSSL_NO_DH\n${str}#endif\n"; }
  36. elsif ( ($_ =~ /^pkcs12$/))
  37. { print "#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)\n${str}#endif\n"; }
  38. elsif ( ($_ =~ /^cms$/))
  39. { print "#ifndef OPENSSL_NO_CMS\n${str}#endif\n"; }
  40. else
  41. { print $str; }
  42. }
  43. foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160")
  44. {
  45. push(@files,$_);
  46. printf "#ifndef OPENSSL_NO_".uc($_)."\n\t{FUNC_TYPE_MD,\"".$_."\",dgst_main},\n#endif\n";
  47. }
  48. foreach (
  49. "aes-128-cbc", "aes-128-ecb",
  50. "aes-192-cbc", "aes-192-ecb",
  51. "aes-256-cbc", "aes-256-ecb",
  52. "camellia-128-cbc", "camellia-128-ecb",
  53. "camellia-192-cbc", "camellia-192-ecb",
  54. "camellia-256-cbc", "camellia-256-ecb",
  55. "base64",
  56. "des", "des3", "desx", "idea", "seed", "rc4", "rc4-40",
  57. "rc2", "bf", "cast", "rc5",
  58. "des-ecb", "des-ede", "des-ede3",
  59. "des-cbc", "des-ede-cbc","des-ede3-cbc",
  60. "des-cfb", "des-ede-cfb","des-ede3-cfb",
  61. "des-ofb", "des-ede-ofb","des-ede3-ofb",
  62. "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
  63. "seed-cbc","seed-ecb", "seed-cfb", "seed-ofb",
  64. "rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
  65. "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
  66. "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
  67. "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb")
  68. {
  69. push(@files,$_);
  70. $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
  71. if ($_ =~ /des/) { $t="#ifndef OPENSSL_NO_DES\n${t}#endif\n"; }
  72. elsif ($_ =~ /aes/) { $t="#ifndef OPENSSL_NO_AES\n${t}#endif\n"; }
  73. elsif ($_ =~ /camellia/) { $t="#ifndef OPENSSL_NO_CAMELLIA\n${t}#endif\n"; }
  74. elsif ($_ =~ /idea/) { $t="#ifndef OPENSSL_NO_IDEA\n${t}#endif\n"; }
  75. elsif ($_ =~ /seed/) { $t="#ifndef OPENSSL_NO_SEED\n${t}#endif\n"; }
  76. elsif ($_ =~ /rc4/) { $t="#ifndef OPENSSL_NO_RC4\n${t}#endif\n"; }
  77. elsif ($_ =~ /rc2/) { $t="#ifndef OPENSSL_NO_RC2\n${t}#endif\n"; }
  78. elsif ($_ =~ /bf/) { $t="#ifndef OPENSSL_NO_BF\n${t}#endif\n"; }
  79. elsif ($_ =~ /cast/) { $t="#ifndef OPENSSL_NO_CAST\n${t}#endif\n"; }
  80. elsif ($_ =~ /rc5/) { $t="#ifndef OPENSSL_NO_RC5\n${t}#endif\n"; }
  81. print $t;
  82. }
  83. print "\t{0,NULL,NULL}\n\t};\n";