1 #!/usr/local/bin/perl -w
5 # It does this by parsing the header files and looking for the
6 # prototyped functions: it then prunes the output.
8 # Intermediary files are created, call libeay.num and ssleay.num,...
9 # Previously, they had the following format:
13 # But that isn't enough for a number of reasons, the first on being that
14 # this format is (needlessly) very Win32-centric, and even then...
15 # One of the biggest problems is that there's no information about what
16 # routines should actually be used, which varies with what crypto algorithms
17 # are disabled. Also, some operating systems (for example VMS with VAX C)
18 # need to keep track of the global variables as well as the functions.
20 # So, a remake of this script is done so as to include information on the
21 # kind of symbol it is (function or variable) and what algorithms they're
22 # part of. This will allow easy translating to .def files or the corresponding
23 # file in other operating systems (a .opt file for VMS, possibly with a .mar
26 # The format now becomes:
28 # routine-name nnnn info
30 # and the "info" part is actually a colon-separated string of fields with
31 # the following meaning:
33 # existence:platform:kind:algorithms
35 # - "existence" can be "EXIST" or "NOEXIST" depending on if the symbol is
36 # found somewhere in the source,
37 # - "platforms" is empty if it exists on all platforms, otherwise it contains
38 # comma-separated list of the platform, just as they are if the symbol exists
39 # for those platforms, or prepended with a "!" if not. This helps resolve
40 # symbol name replacements for platforms where the names are too long for the
41 # compiler or linker, or if the systems is case insensitive and there is a
42 # clash. This script assumes those redefinitions are place in the file
44 # The semantics for the platforms list is a bit complicated. The rule of
45 # thumb is that the list is exclusive, but it seems to mean different things.
46 # So, if the list is all negatives (like "!VMS,!WIN16"), the symbol exists
47 # on all platforms except those listed. If the list is all positives (like
48 # "VMS,WIN16"), the symbol exists only on those platforms and nowhere else.
49 # The combination of positives and negatives will act as if the positives
51 # - "kind" is "FUNCTION" or "VARIABLE". The meaning of that is obvious.
52 # - "algorithms" is a comma-separated list of algorithm names. This helps
53 # exclude symbols that are part of an algorithm that some user wants to
57 my $crypto_num= "util/libeay.num";
58 my $ssl_num= "util/ssleay.num";
66 my $do_checkexist = 0;
72 # Set this to make typesafe STACK definitions appear in DEF
73 my $safe_stack_def = 0;
75 my @known_platforms = ( "__FreeBSD__", "VMS", "WIN16", "WIN32",
76 "WINNT", "PERL5", "NeXT" );
77 my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
78 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
80 "MDC2", "RSA", "DSA", "DH", "HMAC", "AES",
81 # Envelope "algorithms"
82 "EVP", "X509", "ASN1_TYPEDEFS",
84 "BIO", "COMP", "BUFFER", "LHASH", "STACK", "ERR",
86 # External "algorithms"
87 "FP_API", "STDIO", "SOCK", "KRB5" );
90 open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
92 $options=$1 if (/^OPTIONS=(.*)$/);
96 # The following ciphers may be excluded (by Configure). This means functions
97 # defined with ifndef(NO_XXX) are not included in the .def file, and everything
98 # in directory xxx is ignored.
99 my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
101 my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
102 my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes;
105 foreach (@ARGV, split(/ /, $options))
107 $W32=1 if $_ eq "32";
108 $W16=1 if $_ eq "16";
113 $VMS=1 if $_ eq "VMS";
115 $do_ssl=1 if $_ eq "ssleay";
116 $do_ssl=1 if $_ eq "ssl";
117 $do_crypto=1 if $_ eq "libeay";
118 $do_crypto=1 if $_ eq "crypto";
119 $do_update=1 if $_ eq "update";
120 $do_rewrite=1 if $_ eq "rewrite";
121 $do_ctest=1 if $_ eq "ctest";
122 $do_ctestall=1 if $_ eq "ctestall";
123 $do_checkexist=1 if $_ eq "exist";
124 #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK";
126 if (/^no-rc2$/) { $no_rc2=1; }
127 elsif (/^no-rc4$/) { $no_rc4=1; }
128 elsif (/^no-rc5$/) { $no_rc5=1; }
129 elsif (/^no-idea$/) { $no_idea=1; }
130 elsif (/^no-des$/) { $no_des=1; $no_mdc2=1; }
131 elsif (/^no-bf$/) { $no_bf=1; }
132 elsif (/^no-cast$/) { $no_cast=1; }
133 elsif (/^no-md2$/) { $no_md2=1; }
134 elsif (/^no-md4$/) { $no_md4=1; }
135 elsif (/^no-md5$/) { $no_md5=1; }
136 elsif (/^no-sha$/) { $no_sha=1; }
137 elsif (/^no-ripemd$/) { $no_ripemd=1; }
138 elsif (/^no-mdc2$/) { $no_mdc2=1; }
139 elsif (/^no-rsa$/) { $no_rsa=1; }
140 elsif (/^no-dsa$/) { $no_dsa=1; }
141 elsif (/^no-dh$/) { $no_dh=1; }
142 elsif (/^no-hmac$/) { $no_hmac=1; }
143 elsif (/^no-aes$/) { $no_aes=1; }
144 elsif (/^no-evp$/) { $no_evp=1; }
145 elsif (/^no-lhash$/) { $no_lhash=1; }
146 elsif (/^no-stack$/) { $no_stack=1; }
147 elsif (/^no-err$/) { $no_err=1; }
148 elsif (/^no-buffer$/) { $no_buffer=1; }
149 elsif (/^no-bio$/) { $no_bio=1; }
150 #elsif (/^no-locking$/) { $no_locking=1; }
151 elsif (/^no-comp$/) { $no_comp=1; }
152 elsif (/^no-dso$/) { $no_dso=1; }
156 # If no platform is given, assume WIN32
157 if ($W32 + $W16 + $VMS == 0) {
161 # Add extra knowledge
166 if (!$do_ssl && !$do_crypto)
168 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ]\n";
172 %ssl_list=&load_numbers($ssl_num);
174 %crypto_list=&load_numbers($crypto_num);
175 $max_crypto = $max_num;
180 my $crypto ="crypto/crypto.h";
181 $crypto.=" crypto/des/des.h" unless $no_des;
182 $crypto.=" crypto/idea/idea.h" unless $no_idea;
183 $crypto.=" crypto/rc4/rc4.h" unless $no_rc4;
184 $crypto.=" crypto/rc5/rc5.h" unless $no_rc5;
185 $crypto.=" crypto/rc2/rc2.h" unless $no_rc2;
186 $crypto.=" crypto/bf/blowfish.h" unless $no_bf;
187 $crypto.=" crypto/cast/cast.h" unless $no_cast;
188 $crypto.=" crypto/md2/md2.h" unless $no_md2;
189 $crypto.=" crypto/md4/md4.h" unless $no_md4;
190 $crypto.=" crypto/md5/md5.h" unless $no_md5;
191 $crypto.=" crypto/mdc2/mdc2.h" unless $no_mdc2;
192 $crypto.=" crypto/sha/sha.h" unless $no_sha;
193 $crypto.=" crypto/ripemd/ripemd.h" unless $no_ripemd;
194 $crypto.=" crypto/rijndael/rijndael.h" unless $no_aes;
195 $crypto.=" crypto/rijndael/rd_fst.h" unless $no_aes;
197 $crypto.=" crypto/bn/bn.h";
198 $crypto.=" crypto/rsa/rsa.h" unless $no_rsa;
199 $crypto.=" crypto/dsa/dsa.h" unless $no_dsa;
200 $crypto.=" crypto/dh/dh.h" unless $no_dh;
201 $crypto.=" crypto/hmac/hmac.h" unless $no_hmac;
203 $crypto.=" crypto/engine/engine.h";
204 $crypto.=" crypto/stack/stack.h" unless $no_stack;
205 $crypto.=" crypto/buffer/buffer.h" unless $no_buffer;
206 $crypto.=" crypto/bio/bio.h" unless $no_bio;
207 $crypto.=" crypto/dso/dso.h" unless $no_dso;
208 $crypto.=" crypto/lhash/lhash.h" unless $no_lhash;
209 $crypto.=" crypto/conf/conf.h";
210 $crypto.=" crypto/txt_db/txt_db.h";
212 $crypto.=" crypto/evp/evp.h" unless $no_evp;
213 $crypto.=" crypto/objects/objects.h";
214 $crypto.=" crypto/pem/pem.h";
215 #$crypto.=" crypto/meth/meth.h";
216 $crypto.=" crypto/asn1/asn1.h";
217 $crypto.=" crypto/asn1/asn1t.h";
218 $crypto.=" crypto/asn1/asn1_mac.h";
219 $crypto.=" crypto/err/err.h" unless $no_err;
220 $crypto.=" crypto/pkcs7/pkcs7.h";
221 $crypto.=" crypto/pkcs12/pkcs12.h";
222 $crypto.=" crypto/x509/x509.h";
223 $crypto.=" crypto/x509/x509_vfy.h";
224 $crypto.=" crypto/x509v3/x509v3.h";
225 $crypto.=" crypto/rand/rand.h";
226 $crypto.=" crypto/comp/comp.h" unless $no_comp;
227 $crypto.=" crypto/ocsp/ocsp.h";
228 $crypto.=" crypto/tmdiff.h";
230 my $symhacks="crypto/symhacks.h";
232 my @ssl_symbols = &do_defs("SSLEAY", $ssl, $symhacks);
233 my @crypto_symbols = &do_defs("LIBEAY", $crypto, $symhacks);
239 &maybe_add_info("SSLEAY",*ssl_list,@ssl_symbols);
240 if ($do_rewrite == 1) {
241 open(OUT, ">$ssl_num");
242 &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols);
245 open(OUT, ">>$ssl_num");
247 &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl,@ssl_symbols);
251 if($do_crypto == 1) {
253 &maybe_add_info("LIBEAY",*crypto_list,@crypto_symbols);
254 if ($do_rewrite == 1) {
255 open(OUT, ">$crypto_num");
256 &rewrite_numbers(*OUT,"LIBEAY",*crypto_list,@crypto_symbols);
258 open(OUT, ">>$crypto_num");
260 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto,@crypto_symbols);
264 } elsif ($do_checkexist) {
265 &check_existing(*ssl_list, @ssl_symbols)
267 &check_existing(*crypto_list, @crypto_symbols)
269 } elsif ($do_ctest || $do_ctestall) {
273 /* Test file to check all DEF file symbols are present by trying
274 * to link to all of them. This is *not* intended to be run!
280 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,$do_ctestall,@ssl_symbols)
283 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,$do_ctestall,@crypto_symbols)
290 &print_def_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_symbols)
293 &print_def_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_symbols)
301 my($name,$files,$symhacksfile)=@_;
305 my %platform; # For anything undefined, we assume ""
306 my %kind; # For anything undefined, we assume "FUNCTION"
307 my %algorithm; # For anything undefined, we assume ""
310 my %unknown_algorithms = ();
312 foreach $file (split(/\s+/,$symhacksfile." ".$files))
314 open(IN,"<$file") || die "unable to open $file:$!\n";
315 my $line = "", my $def= "";
317 (map { $_ => 0 } @known_platforms),
318 (map { "NO_".$_ => 0 } @known_algorithms),
325 my $symhacking = $file eq $symhacksfile;
327 last if (/BEGIN ERROR CODES/);
338 $cpp = 1 if /^\#.*ifdef.*cplusplus/;
340 $cpp = 0 if /^\#.*endif/;
344 s/\/\*.*?\*\///gs; # ignore comments
345 s/{[^{}]*}//gs; # ignore {} blocks
346 #print STDERR "DEBUG: \$_=\"$_\"\n";
347 if (/^\#\s*ifndef\s+(.*)/) {
350 } elsif (/^\#\s*if\s+!defined\(([^\)]+)\)/) {
353 } elsif (/^\#\s*ifdef\s+(.*)/) {
356 } elsif (/^\#\s*if\s+defined\(([^\)]+)\)/) {
359 } elsif (/^\#\s*error\s+(\w+) is disabled\./) {
360 if ($tag[$#tag] eq "NO_".$1) {
363 } elsif (/^\#\s*endif/) {
364 my $oldtag=$tag[$#tag];
365 #print STDERR "DEBUG: \$oldtag=\"$oldtag\"\n";
366 if ($tag{$tag[$#tag]}==2) {
367 $tag{$tag[$#tag]}=-1;
372 if ($oldtag =~ /^NO_([A-Z0-9_]+)$/) {
378 && !grep(/^$oldtag$/, @known_algorithms)) {
379 $unknown_algorithms{$oldtag} = 1;
380 #print STDERR "DEBUG: Added as unknown algorithm: $oldtag\n";
382 } elsif (/^\#\s*else/) {
385 } elsif (/^\#\s*if\s+1/) {
389 } elsif (/^\#\s*if\s+0/) {
393 } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/
397 $2.":".join(",", grep(!/^$/,
398 map { $tag{$_} == 1 ?
405 map { $tag{$_} == 1 ? $_ :
406 $tag{$_} == -1 ? "!".$_ : "" }
409 map { $tag{"NO_".$_} == -1 ? $_ : "" }
411 $def .= "#INFO:".join(',',@p).":".join(',',@a).";";
414 if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
416 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
420 $kind{"$2_it"} = "VARIABLE";
422 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_fname\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
426 $syms{"$3_free"} = 1;
428 $kind{"$2_it"} = "VARIABLE";
429 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS\s*\(\s*(\w*)\s*\)/ ||
430 /^\s*DECLARE_ASN1_FUNCTIONS_const\s*\(\s*(\w*)\s*\)/) {
434 $syms{"$1_free"} = 1;
436 $kind{"$1_it"} = "VARIABLE";
438 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS_const\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
442 $kind{"$2_it"} = "VARIABLE";
444 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
448 $syms{"$2_free"} = 1;
450 $kind{"$2_it"} = "VARIABLE";
452 } elsif (/^\s*DECLARE_ASN1_ITEM\s*\(\s*(\w*)\s*,(\w*)\s*\)/) {
454 $kind{"$1_it"} = "VARIABLE";
456 } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
458 } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
460 } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
461 /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) {
462 # Things not in Win16
463 $syms{"PEM_read_${1}"} = 1;
464 $platform{"PEM_read_${1}"} = "!WIN16";
465 $syms{"PEM_write_${1}"} = 1;
466 $platform{"PEM_write_${1}"} = "!WIN16";
467 # Things that are everywhere
468 $syms{"PEM_read_bio_${1}"} = 1;
469 $syms{"PEM_write_bio_${1}"} = 1;
470 if ($1 eq "RSAPrivateKey" ||
471 $1 eq "RSAPublicKey" ||
472 $1 eq "RSA_PUBKEY") {
473 $algorithm{"PEM_read_${1}"} = "RSA";
474 $algorithm{"PEM_write_${1}"} = "RSA";
475 $algorithm{"PEM_read_bio_${1}"} = "RSA";
476 $algorithm{"PEM_write_bio_${1}"} = "RSA";
478 elsif ($1 eq "DSAPrivateKey" ||
480 $1 eq "RSA_PUBKEY") {
481 $algorithm{"PEM_read_${1}"} = "DSA";
482 $algorithm{"PEM_write_${1}"} = "DSA";
483 $algorithm{"PEM_read_bio_${1}"} = "DSA";
484 $algorithm{"PEM_write_bio_${1}"} = "DSA";
486 elsif ($1 eq "DHparams") {
487 $algorithm{"PEM_read_${1}"} = "DH";
488 $algorithm{"PEM_write_${1}"} = "DH";
489 $algorithm{"PEM_read_bio_${1}"} = "DH";
490 $algorithm{"PEM_write_bio_${1}"} = "DH";
492 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
493 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
494 # Things not in Win16
495 $syms{"PEM_write_${1}"} = 1;
496 $platform{"PEM_write_${1}"} .= ",!WIN16";
497 # Things that are everywhere
498 $syms{"PEM_write_bio_${1}"} = 1;
499 if ($1 eq "RSAPrivateKey" ||
500 $1 eq "RSAPublicKey" ||
501 $1 eq "RSA_PUBKEY") {
502 $algorithm{"PEM_write_${1}"} = "RSA";
503 $algorithm{"PEM_write_bio_${1}"} = "RSA";
505 elsif ($1 eq "DSAPrivateKey" ||
507 $1 eq "RSA_PUBKEY") {
508 $algorithm{"PEM_write_${1}"} = "DSA";
509 $algorithm{"PEM_write_bio_${1}"} = "DSA";
511 elsif ($1 eq "DHparams") {
512 $algorithm{"PEM_write_${1}"} = "DH";
513 $algorithm{"PEM_write_bio_${1}"} = "DH";
515 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
516 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
517 # Things not in Win16
518 $syms{"PEM_read_${1}"} = 1;
519 $platform{"PEM_read_${1}"} .= ",!WIN16";
520 # Things that are everywhere
521 $syms{"PEM_read_bio_${1}"} = 1;
524 && ($tag{'CONST_STRICT'} != 1)
527 if (/\{|\/\*|\([^\)]*$/) {
539 foreach (split /;/, $def) {
540 my $s; my $k = "FUNCTION"; my $p; my $a;
544 next if(/typedef\W/);
547 if (/^\#INFO:([^:]*):(.*)$/) {
551 } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+)(\[[0-9]*\])*\s*$/) {
554 } elsif (/\(\*(\w*)\([^\)]+/) {
556 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) {
559 } elsif (/\w+\W+\w+\W*\(.*\)$/s) {
560 while (not /\(\)$/s) {
562 s/\([^\(\)]*\)\)$/\)/s;
567 } elsif (/\(/ and not (/=/)) {
568 print STDERR "File $file: cannot parse: $_;\n";
579 $a .= ",BF" if($s =~ /EVP_bf/);
580 $a .= ",CAST" if($s =~ /EVP_cast/);
581 $a .= ",DES" if($s =~ /EVP_des/);
582 $a .= ",DSA" if($s =~ /EVP_dss/);
583 $a .= ",IDEA" if($s =~ /EVP_idea/);
584 $a .= ",MD2" if($s =~ /EVP_md2/);
585 $a .= ",MD4" if($s =~ /EVP_md4/);
586 $a .= ",MD5" if($s =~ /EVP_md5/);
587 $a .= ",RC2" if($s =~ /EVP_rc2/);
588 $a .= ",RC4" if($s =~ /EVP_rc4/);
589 $a .= ",RC5" if($s =~ /EVP_rc5/);
590 $a .= ",RIPEMD" if($s =~ /EVP_ripemd/);
591 $a .= ",SHA" if($s =~ /EVP_sha/);
592 $a .= ",RSA" if($s =~ /EVP_(Open|Seal)(Final|Init)/);
593 $a .= ",RSA" if($s =~ /PEM_Seal(Final|Init|Update)/);
594 $a .= ",RSA" if($s =~ /RSAPrivateKey/);
595 $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/);
597 $platform{$s} .= ','.$p;
598 $algorithm{$s} .= ','.$a;
600 if (defined($rename{$s})) {
601 (my $r, my $p) = split(/:/,$rename{$s});
602 my @ip = map { /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p;
604 $kind{$r} = $kind{$s}."(".$s.")";
605 $algorithm{$r} = $algorithm{$s};
606 $platform{$r} = $platform{$s}.",".$p;
607 $platform{$s} .= ','.join(',', @ip).','.join(',', @ip);
612 # Prune the returned symbols
614 $platform{"crypt"} .= ",!PERL5,!__FreeBSD__,!NeXT";
616 delete $syms{"SSL_add_dir_cert_subjects_to_stack"};
617 delete $syms{"bn_dump1"};
619 $platform{"BIO_s_file_internal"} .= ",WIN16";
620 $platform{"BIO_new_file_internal"} .= ",WIN16";
621 $platform{"BIO_new_fp_internal"} .= ",WIN16";
623 $platform{"BIO_s_file"} .= ",!WIN16";
624 $platform{"BIO_new_file"} .= ",!WIN16";
625 $platform{"BIO_new_fp"} .= ",!WIN16";
627 $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
629 if(exists $syms{"ERR_load_CRYPTO_strings"}) {
630 $platform{"ERR_load_CRYPTO_strings"} .= ",!VMS,!WIN16";
631 $syms{"ERR_load_CRYPTOlib_strings"} = 1;
632 $platform{"ERR_load_CRYPTOlib_strings"} .= ",VMS,WIN16";
637 push @ret, map { $_."\\".&info_string($_,"EXIST",
640 $algorithm{$_}) } keys %syms;
642 if (keys %unknown_algorithms) {
643 print STDERR "WARNING: mkdef.pl doesn't know the following algorithms:\n";
644 print STDERR "\t",join("\n\t",keys %unknown_algorithms),"\n";
650 (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_;
652 my %a = defined($algorithms) ?
653 map { $_ => 1 } split /,/, $algorithms : ();
654 my $pl = defined($platforms) ? $platforms : "";
655 my %p = map { $_ => 0 } split /,/, $pl;
656 my $k = defined($kind) ? $kind : "FUNCTION";
659 # We do this, because if there's code like the following, it really
660 # means the function exists in all cases and should therefore be
661 # everywhere. By increasing and decreasing, we may attain 0:
668 foreach $platform (split /,/, $pl) {
669 if ($platform =~ /^!(.*)$/) {
675 foreach $platform (keys %p) {
676 if ($p{$platform} == 0) { delete $p{$platform}; }
683 $ret .= ":".join(',',map { $p{$_} < 0 ? "!".$_ : $_ } keys %p);
685 $ret .= ":".join(',',keys %a);
690 (my $name, *nums, my @symbols) = @_;
695 print STDERR "Updating $name info\n";
696 foreach $sym (@symbols) {
697 (my $s, my $i) = split /\\/, $sym;
698 $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
699 if (defined($nums{$s})) {
700 (my $n, my $dummy) = split /\\/, $nums{$s};
701 if (!defined($dummy) || $i ne $dummy) {
702 $nums{$s} = $n."\\".$i;
704 #print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n";
710 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
712 (my $n, my $i) = split /\\/, $nums{$sym};
713 if (!defined($syms{sym})) {
715 #print STDERR "DEBUG: maybe_add_info for $sym: -> undefined\n";
719 print STDERR "$new_info old symbols got an info update\n";
721 print STDERR "You should do a rewrite to fix this.\n";
724 print STDERR "No old symbols needed info update\n";
730 (*OUT,my $name,*nums,my @symbols)=@_;
731 my $n = 1; my @e; my @r;
732 my $sym; my $prev = ""; my $prefSSLeay;
734 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
735 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
736 @symbols=((sort @e),(sort @r));
738 foreach $sym (@symbols) {
739 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
741 if (!defined($nums{$sym})) {
742 printf STDERR "Warning: $sym does not have a number assigned\n"
746 print OUT "\t$s();\n";
749 $prev = $s; # To avoid duplicates...
755 (*OUT,my $name,*nums,my @symbols)=@_;
756 my $n = 1; my @e; my @r; my @v;
765 ; Definition file for the DLL version of the $name library from OpenSSL
770 DESCRIPTION 'OpenSSL $name - http://www.openssl.org/'
776 CODE PRELOAD MOVEABLE
777 DATA PRELOAD MOVEABLE SINGLE
789 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
790 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
791 (@v)=grep(/^\w+\\.*?:.*?:VARIABLE/,@symbols);
792 @symbols=((sort @e),(sort @r), (sort @v));
795 foreach $sym (@symbols) {
796 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
798 $v = 1 if $sym=~ /^\w+\\.*?:.*?:VARIABLE/;
799 if (!defined($nums{$s})) {
800 printf STDERR "Warning: $s does not have a number assigned\n"
803 (my $n, my $i) = split /\\/, $nums{$s};
805 my @p = split(/,/, ($i =~ /^[^:]*:([^:]*):/,$1));
806 my @a = split(/,/, ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1));
807 # @p_purged must contain hardware platforms only
810 push @p_purged, $ptmp;
812 my $negatives = !!grep(/^!/,@p);
813 # It is very important to check NT before W32
814 if ((($NT && (!@p_purged
815 || (!$negatives && grep(/^WINNT$/,@p))
816 || ($negatives && !grep(/^!WINNT$/,@p))))
817 || ($W32 && (!@p_purged
818 || (!$negatives && grep(/^WIN32$/,@p))
819 || ($negatives && !grep(/^!WIN32$/,@p))))
820 || ($W16 && (!@p_purged
821 || (!$negatives && grep(/^WIN16$/,@p))
822 || ($negatives && !grep(/^!WIN16$/,@p)))))
823 && (!@a || (!$no_rc2 || !grep(/^RC2$/,@a)))
824 && (!@a || (!$no_rc4 || !grep(/^RC4$/,@a)))
825 && (!@a || (!$no_rc5 || !grep(/^RC5$/,@a)))
826 && (!@a || (!$no_idea || !grep(/^IDEA$/,@a)))
827 && (!@a || (!$no_des || !grep(/^DES$/,@a)))
828 && (!@a || (!$no_bf || !grep(/^BF$/,@a)))
829 && (!@a || (!$no_cast || !grep(/^CAST$/,@a)))
830 && (!@a || (!$no_md2 || !grep(/^MD2$/,@a)))
831 && (!@a || (!$no_md4 || !grep(/^MD4$/,@a)))
832 && (!@a || (!$no_md5 || !grep(/^MD5$/,@a)))
833 && (!@a || (!$no_sha || !grep(/^SHA$/,@a)))
834 && (!@a || (!$no_ripemd || !grep(/^RIPEMD$/,@a)))
835 && (!@a || (!$no_mdc2 || !grep(/^MDC2$/,@a)))
836 && (!@a || (!$no_rsa || !grep(/^RSA$/,@a)))
837 && (!@a || (!$no_dsa || !grep(/^DSA$/,@a)))
838 && (!@a || (!$no_dh || !grep(/^DH$/,@a)))
839 && (!@a || (!$no_hmac || !grep(/^HMAC$/,@a)))
840 && (!@a || (!$no_aes || !grep(/^AES$/,@a)))
841 && (!@a || (!$no_fp_api || !grep(/^FP_API$/,@a)))
844 printf OUT " %s%-40s@%-8d DATA\n",($W32)?"":"_",$s,$n;
846 printf OUT " %s%-40s@%d\n",($W32)?"":"_",$s,$n;
849 # print STDERR "DEBUG: \"$sym\" (@p):",
852 # && ($rsaref || !grep(/^RSAREF$/,@p)))
854 # && (!$rsaref || !grep(/^!RSAREF$/,@p))))?1:0,
855 # " 16:", !!($W16 && (!@p_purged
856 # || (!$negatives && grep(/^WIN16$/,@p))
857 # || ($negatives && !grep(/^!WIN16$/,@p)))),
858 # " 32:", !!($W32 && (!@p_purged
859 # || (!$negatives && grep(/^WIN32$/,@p))
860 # || ($negatives && !grep(/^!WIN32$/,@p)))),
861 # " NT:", !!($NT && (!@p_purged
862 # || (!$negatives && grep(/^WINNT$/,@p))
863 # || ($negatives && !grep(/^!WINNT$/,@p)))),
880 open(IN,"<$name") || die "unable to open $name:$!\n";
886 if (defined $ret{$a[0]}) {
887 print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n";
889 if ($max_num > $a[1]) {
890 print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n";
892 if ($max_num == $a[1]) {
893 # This is actually perfectly OK
894 #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n";
897 # Existence will be proven later, in do_defs
901 $ret{$a[0]}=$a[1]."\\".$a[2]; # \\ is a special marker
903 $max_num = $a[1] if $a[1] > $max_num;
907 print STDERR "Warning: $num_noinfo symbols were without info.";
909 printf STDERR " The rewrite will fix this.\n";
911 printf STDERR " You should do a rewrite to fix this.\n";
920 (my $str, my $what) = @_;
921 (my $n, my $i) = split(/\\/,$str);
931 (*OUT,$name,*nums,@symbols)=@_;
934 print STDERR "Rewriting $name\n";
936 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols);
937 my $r; my %r; my %rsyms;
939 (my $s, my $i) = split /\\/, $r;
940 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
941 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
947 foreach $_ (@symbols) {
948 (my $n, my $i) = split /\\/;
952 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
954 (my $n, my $i) = split /\\/, $nums{$sym};
955 next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/;
956 next if defined($rsyms{$sym});
957 $i="NOEXIST::FUNCTION:"
958 if !defined($i) || $i eq "" || !defined($syms{$sym});
959 printf OUT "%s%-40s%d\t%s\n","",$sym,$n,$i;
960 if (exists $r{$sym}) {
961 (my $s, $i) = split /\\/,$r{$sym};
962 printf OUT "%s%-40s%d\t%s\n","",$s,$n,$i;
969 (*OUT,$name,*nums,my $start_num, my @symbols)=@_;
972 print STDERR "Updating $name numbers\n";
974 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols);
975 my $r; my %r; my %rsyms;
977 (my $s, my $i) = split /\\/, $r;
978 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
979 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
984 foreach $sym (@symbols) {
985 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
986 next if $i =~ /^.*?:.*?:\w+\(\w+\)/;
987 next if defined($rsyms{$sym});
988 die "ERROR: Symbol $sym had no info attached to it."
990 if (!exists $nums{$s}) {
992 printf OUT "%s%-40s%d\t%s\n","",$s, ++$start_num,$i;
994 ($s, $i) = split /\\/,$r{$s};
995 printf OUT "%s%-40s%d\t%s\n","",$s, $start_num,$i;
1000 print STDERR "$new_syms New symbols added\n";
1002 print STDERR "No New symbols Added\n";
1008 (*nums, my @symbols)=@_;
1009 my %existing; my @remaining;
1011 foreach $sym (@symbols) {
1012 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1015 foreach $sym (keys %nums) {
1016 if (!exists $existing{$sym}) {
1017 push @remaining, $sym;
1021 print STDERR "The following symbols do not seem to exist:\n";
1022 foreach $sym (@remaining) {
1023 print STDERR "\t",$sym,"\n";