progs.pl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/usr/local/bin/perl
  2. # Generate progs.h file from list of "programs" passed on the command line.
  3. print <<'EOF';
  4. /*
  5. * Automatically generated by progs.pl for openssl.c
  6. * Copyright (c) 2008 The OpenSSL Project. All rights reserved.
  7. * See the openssl.c for copyright details.
  8. */
  9. typedef enum FUNC_TYPE {
  10. FT_none, FT_general, FT_md, FT_cipher, FT_pkey,
  11. FT_md_alg, FT_cipher_alg
  12. } FUNC_TYPE;
  13. typedef struct function_st {
  14. FUNC_TYPE type;
  15. const char *name;
  16. int (*func)(int argc,char *argv[]);
  17. const OPTIONS *help;
  18. } FUNCTION;
  19. DEFINE_LHASH_OF(FUNCTION);
  20. EOF
  21. grep(s/\.o//, @ARGV);
  22. grep(s/^asn1pars$/asn1parse/, @ARGV);
  23. grep(s/^crl2p7$/crl2pkcs7/, @ARGV);
  24. push @ARGV, 'list';
  25. push @ARGV, 'help';
  26. push @ARGV, 'exit';
  27. foreach (@ARGV) {
  28. printf "extern int %s_main(int argc, char *argv[]);\n", $_;
  29. }
  30. print "\n";
  31. foreach (@ARGV) {
  32. printf "extern OPTIONS %s_options[];\n", $_;
  33. }
  34. print "\n#ifdef INCLUDE_FUNCTION_TABLE\n";
  35. print "static FUNCTION functions[] = {\n";
  36. foreach (@ARGV) {
  37. $str=" { FT_general, \"$_\", ${_}_main, ${_}_options },\n";
  38. if (/^s_/ || /^ciphers$/) {
  39. print "#if !defined(OPENSSL_NO_SOCK)\n${str}#endif\n";
  40. } elsif (/^engine$/) {
  41. print "#ifndef OPENSSL_NO_ENGINE\n${str}#endif\n";
  42. } elsif (/^rsa$/ || /^genrsa$/ || /^rsautl$/) {
  43. print "#ifndef OPENSSL_NO_RSA\n${str}#endif\n";
  44. } elsif (/^dsa$/ || /^gendsa$/ || /^dsaparam$/) {
  45. print "#ifndef OPENSSL_NO_DSA\n${str}#endif\n";
  46. } elsif (/^ec$/ || /^ecparam$/) {
  47. print "#ifndef OPENSSL_NO_EC\n${str}#endif\n";
  48. } elsif (/^dh$/ || /^gendh$/ || /^dhparam$/) {
  49. print "#ifndef OPENSSL_NO_DH\n${str}#endif\n";
  50. } elsif (/^pkcs12$/) {
  51. print "#if !defined(OPENSSL_NO_DES)\n${str}#endif\n";
  52. } elsif (/^cms$/) {
  53. print "#ifndef OPENSSL_NO_CMS\n${str}#endif\n";
  54. } elsif (/^ocsp$/) {
  55. print "#ifndef OPENSSL_NO_OCSP\n${str}#endif\n";
  56. } elsif (/^srp$/) {
  57. print "#ifndef OPENSSL_NO_SRP\n${str}#endif\n";
  58. } else {
  59. print $str;
  60. }
  61. }
  62. foreach (
  63. "md2", "md4", "md5",
  64. "md_ghost94",
  65. "sha", "sha1", "sha224", "sha256", "sha384", "sha512",
  66. "mdc2", "rmd160"
  67. ) {
  68. printf "#ifndef OPENSSL_NO_".uc($_)."\n" if ! /sha/;
  69. printf " { FT_md, \"".$_."\", dgst_main},\n";
  70. printf "#endif\n" if ! /sha/;
  71. }
  72. foreach (
  73. "aes-128-cbc", "aes-128-ecb",
  74. "aes-192-cbc", "aes-192-ecb",
  75. "aes-256-cbc", "aes-256-ecb",
  76. "camellia-128-cbc", "camellia-128-ecb",
  77. "camellia-192-cbc", "camellia-192-ecb",
  78. "camellia-256-cbc", "camellia-256-ecb",
  79. "base64", "zlib",
  80. "des", "des3", "desx", "idea", "seed", "rc4", "rc4-40",
  81. "rc2", "bf", "cast", "rc5",
  82. "des-ecb", "des-ede", "des-ede3",
  83. "des-cbc", "des-ede-cbc","des-ede3-cbc",
  84. "des-cfb", "des-ede-cfb","des-ede3-cfb",
  85. "des-ofb", "des-ede-ofb","des-ede3-ofb",
  86. "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
  87. "seed-cbc","seed-ecb", "seed-cfb", "seed-ofb",
  88. "rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
  89. "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
  90. "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
  91. "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb"
  92. ) {
  93. $str=" { FT_cipher, \"$_\", enc_main, enc_options },\n";
  94. if (/des/) {
  95. printf "#ifndef OPENSSL_NO_DES\n${str}#endif\n";
  96. } elsif (/aes/) {
  97. printf "#ifndef OPENSSL_NO_AES\n${str}#endif\n";
  98. } elsif (/camellia/) {
  99. printf "#ifndef OPENSSL_NO_CAMELLIA\n${str}#endif\n";
  100. } elsif (/idea/) {
  101. printf "#ifndef OPENSSL_NO_IDEA\n${str}#endif\n";
  102. } elsif (/seed/) {
  103. printf "#ifndef OPENSSL_NO_SEED\n${str}#endif\n";
  104. } elsif (/rc4/) {
  105. printf "#ifndef OPENSSL_NO_RC4\n${str}#endif\n";
  106. } elsif (/rc2/) {
  107. printf "#ifndef OPENSSL_NO_RC2\n${str}#endif\n";
  108. } elsif (/bf/) {
  109. printf "#ifndef OPENSSL_NO_BF\n${str}#endif\n";
  110. } elsif (/cast/) {
  111. printf "#ifndef OPENSSL_NO_CAST\n${str}#endif\n";
  112. } elsif (/rc5/) {
  113. printf "#ifndef OPENSSL_NO_RC5\n${str}#endif\n";
  114. } elsif (/zlib/) {
  115. printf "#ifdef ZLIB\n${str}#endif\n";
  116. } else {
  117. print $str;
  118. }
  119. }
  120. print " { 0, NULL, NULL}\n};\n";
  121. printf "#endif\n";