*** empty log message ***
[openssl.git] / util / up_ver.pl
1 #!/usr/local/bin/perl
2 #
3 # Up the version numbers in the files.
4 #
5
6 @files=(
7         "crypto/crypto.h",
8         "crypto/des/ecb_enc.c",
9         "crypto/idea/i_ecb.c",
10         "crypto/lhash/lhash.c",
11         "crypto/conf/conf.c",
12         "crypto/md2/md2_dgst.c",
13         "crypto/md5/md5_dgst.c",
14         "crypto/ripemd/rmd_dgst.c",
15         "crypto/pem/pem_lib.c",
16         "crypto/bn/bn_lib.c",
17         "crypto/dh/dh_lib.c",
18         "crypto/rc2/rc2_ecb.c",
19         "crypto/rc4/rc4_skey.c",
20         "crypto/rc5/rc5_ecb.c",
21         "crypto/bf/bf_ecb.c",
22         "crypto/cast/c_ecb.c",
23         "crypto/rsa/rsa_lib.c",
24         "crypto/dsa/dsa_lib.c",
25         "crypto/sha/sha1dgst.c",
26         "crypto/sha/sha_dgst.c",
27         "crypto/asn1/asn1_lib.c",
28         "crypto/x509/x509_vfy.c",
29         "crypto/evp/evp_enc.c",
30         "crypto/rand/md_rand.c",
31         "crypto/stack/stack.c",
32         "crypto/txt_db/txt_db.c",
33         "crypto/cversion.c",
34         "ssl/ssl_lib.c",
35         "ssl/s2_lib.c",
36         "ssl/s3_lib.c",
37         "ssl/s23_lib.c",
38         "ssl/t1_lib.c",
39         "README",
40         );
41
42 @month=('Jan','Feb','Mar','Apr','May','Jun',
43         'Jul','Aug','Sep','Oct','Nov','Dec');
44 @a=localtime(time());
45 $time=sprintf("%02d-%s-%04d",$a[3],$month[$a[4]],$a[5]+1900);
46
47 $ver=$ARGV[0];
48 ($ver ne "") || die "no version number specified\n";
49 ($a,$b,$c,$d)=unpack('axaxac',$ver);
50 $d=defined($d)?$d-96:0;
51 $xver=sprintf("%x%x%x%x",$a,$b,$c,$d);
52
53 foreach $file (@files)
54         {
55         open(IN,"<$file") || die "unable to open $file:$!\n";
56         open(OUT,">$file.new") || die "unable to open $file.new:$!\n";
57         $found=0;
58
59         print STDERR "$file:";
60
61         while (<IN>)
62                 {
63                 if ((s/(SSLeay|OpenSSL|SSLeay\/OpenSSL) \d\.\d.\d[^"]*(\"|\s)/OpenSSL $ver $time\2/) ||
64                         s/^(\#define\s+OPENSSL_VERSION_NUMBER\s+0x)[0-9a-zA-Z]+(.*)$/$1$xver$2/)
65                         {
66                         print STDERR " Done";
67                         $found++;
68                         print OUT;
69                         while (<IN>) { print OUT; }
70                         last;
71                         }
72                 print OUT;
73                 }
74         print STDERR "\n";
75         close(IN);
76         close(OUT);
77         (!$found) && die "unable to update the version number in $file\n";
78         rename($file,"$file.bak") || die "unable to rename $file:$!\n";
79         rename("$file.new",$file) || die "unable to rename $file.new:$!\n";
80         }