Turn on OPENSSL_NO_DEPRECATED by default.
[openssl.git] / util / mkdef.pl
index 0f42504f97ef2af90198a412b7d85b678bef4eff..fa3f3dbe76ceadf1f554d9d994d06291ed3ae1bb 100755 (executable)
@@ -106,8 +106,8 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
                         "CMS",
                         # CryptoAPI Engine
                         "CAPIENG",
-                        # SSL v2
-                        "SSL2",
+                        # SSL v3 method
+                        "SSL3_METHOD",
                         # JPAKE
                         "JPAKE",
                         # NEXTPROTONEG
@@ -142,9 +142,9 @@ my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
 my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw;
 my $no_fp_api; my $no_static_engine=1; my $no_gmp; my $no_deprecated;
 my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng;
-my $no_jpake; my $no_srp; my $no_ssl2; my $no_ec2m; my $no_nistp_gcc; 
+my $no_jpake; my $no_srp; my $no_ec2m; my $no_nistp_gcc; 
 my $no_nextprotoneg; my $no_sctp; my $no_srtp; my $no_ssl_trace;
-my $no_unit_test;
+my $no_unit_test; my $no_ssl3_method;
 
 my $fips;
 
@@ -238,7 +238,7 @@ foreach (@ARGV, split(/ /, $options))
        elsif (/^no-ec2m$/)     { $no_ec2m=1; }
        elsif (/^no-ec-nistp224-64-gcc-128$/)   { $no_nistp_gcc=1; }
        elsif (/^no-nextprotoneg$/)     { $no_nextprotoneg=1; }
-       elsif (/^no-ssl2$/)     { $no_ssl2=1; }
+       elsif (/^no-ssl3-method$/) { $no_ssl3_method=1; }
        elsif (/^no-ssl-trace$/) { $no_ssl_trace=1; }
        elsif (/^no-capieng$/)  { $no_capieng=1; }
        elsif (/^no-jpake$/)    { $no_jpake=1; }
@@ -350,7 +350,6 @@ $crypto.=" crypto/cms/cms.h";
 $crypto.=" crypto/jpake/jpake.h";
 $crypto.=" crypto/srp/srp.h";
 $crypto.=" crypto/modes/modes.h";
-#$crypto.=" fips/fips.h fips/rand/fips_rand.h";
 
 my $symhacks="crypto/symhacks.h";
 
@@ -434,6 +433,7 @@ sub do_defs
                                # is the same name as the original.
        my $cpp;
        my %unknown_algorithms = ();
+       my $parens = 0;
 
        foreach $file (split(/\s+/,$symhacksfile." ".$files))
                {
@@ -444,6 +444,7 @@ sub do_defs
                        (map { $_ => 0 } @known_platforms),
                        (map { "OPENSSL_SYS_".$_ => 0 } @known_ossl_platforms),
                        (map { "OPENSSL_NO_".$_ => 0 } @known_algorithms),
+                       (map { "OPENSSL_USE_".$_ => 0 } @known_algorithms),
                        NOPROTO         => 0,
                        PERL5           => 0,
                        _WINDLL         => 0,
@@ -506,6 +507,11 @@ sub do_defs
 
                print STDERR "DEBUG: parsing ----------\n" if $debug;
                while(<IN>) {
+                       if($parens > 0) {
+                               #Inside a DECLARE_DEPRECATED
+                               $parens += count_parens($_);
+                               next;
+                       }
                        if (/\/\* Error codes for the \w+ functions\. \*\//)
                                {
                                undef @tag;
@@ -609,6 +615,8 @@ sub do_defs
                                        pop(@tag);
                                        if ($t =~ /^OPENSSL_NO_([A-Z0-9_]+)$/) {
                                                $t=$1;
+                                       } elsif($t =~ /^OPENSSL_USE_([A-Z0-9_]+)$/) {
+                                               $t=$1;
                                        } else {
                                                $t="";
                                        }
@@ -658,10 +666,15 @@ sub do_defs
                                           map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ :
                                                     $tag{"OPENSSL_SYS_".$_} == -1 ? "!".$_  : "" }
                                           @known_ossl_platforms);
+                               @current_algorithms = ();
                                @current_algorithms =
                                    grep(!/^$/,
                                         map { $tag{"OPENSSL_NO_".$_} == -1 ? $_ : "" }
                                         @known_algorithms);
+                               push @current_algorithms
+                                   , grep(!/^$/,
+                                        map { $tag{"OPENSSL_USE_".$_} == 1 ? $_ : "" }
+                                        @known_algorithms);
                                $def .=
                                    "#INFO:"
                                        .join(',',@current_platforms).":"
@@ -892,6 +905,10 @@ sub do_defs
                                        &$make_variant("_shadow_$2","_shadow_$2",
                                                      "EXPORT_VAR_AS_FUNCTION",
                                                      "FUNCTION");
+                               } elsif (/^\s*DECLARE_DEPRECATED\s*\(\s*(\w*(\s|\*|\w)*)/) {
+                                       $def .= "$1(void);";
+                                       $parens = count_parens($_);
+                                       next;
                                } elsif ($tag{'CONST_STRICT'} != 1) {
                                        if (/\{|\/\*|\([^\)]*$/) {
                                                $line = $_;
@@ -1209,7 +1226,7 @@ sub is_valid
                                        { return 0; }
                        if ($keyword eq "EC2M" && $no_ec2m) { return 0; }
                        if ($keyword eq "NEXTPROTONEG" && $no_nextprotoneg) { return 0; }
-                       if ($keyword eq "SSL2" && $no_ssl2) { return 0; }
+                       if ($keyword eq "SSL3_METHOD" && $no_ssl3_method) { return 0; }
                        if ($keyword eq "SSL_TRACE" && $no_ssl_trace) { return 0; }
                        if ($keyword eq "CAPIENG" && $no_capieng) { return 0; }
                        if ($keyword eq "JPAKE" && $no_jpake) { return 0; }
@@ -1550,3 +1567,13 @@ sub check_existing
        }
 }
 
+sub count_parens
+{
+       my $line = shift(@_);
+
+       my $open = $line =~ tr/\(//;
+       my $close = $line =~ tr/\)//;
+
+       return $open - $close;
+}
+