progs.pl 3.7 KB

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