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";
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", "RIPEMD",
79 "MDC2", "RSA", "DSA", "DH", "HMAC", "FP_API",
83 open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
85 $options=$1 if (/^OPTIONS=(.*)$/);
89 # The following ciphers may be excluded (by Configure). This means functions
90 # defined with ifndef(NO_XXX) are not included in the .def file, and everything
91 # in directory xxx is ignored.
92 my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
94 my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
95 my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_rijndael;
98 foreach (@ARGV, split(/ /, $options))
100 $W32=1 if $_ eq "32";
101 $W16=1 if $_ eq "16";
106 $VMS=1 if $_ eq "VMS";
107 #$rsaref=1 if $_ eq "rsaref";
109 $do_ssl=1 if $_ eq "ssleay";
110 $do_ssl=1 if $_ eq "ssl";
111 $do_crypto=1 if $_ eq "libeay";
112 $do_crypto=1 if $_ eq "crypto";
113 $do_update=1 if $_ eq "update";
114 $do_rewrite=1 if $_ eq "rewrite";
115 $do_ctest=1 if $_ eq "ctest";
116 $do_ctestall=1 if $_ eq "ctestall";
117 #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK";
119 if (/^no-rc2$/) { $no_rc2=1; }
120 elsif (/^no-rc4$/) { $no_rc4=1; }
121 elsif (/^no-rc5$/) { $no_rc5=1; }
122 elsif (/^no-idea$/) { $no_idea=1; }
123 elsif (/^no-des$/) { $no_des=1; $no_mdc2=1; }
124 elsif (/^no-bf$/) { $no_bf=1; }
125 elsif (/^no-cast$/) { $no_cast=1; }
126 elsif (/^no-md2$/) { $no_md2=1; }
127 elsif (/^no-md4$/) { $no_md4=1; }
128 elsif (/^no-md5$/) { $no_md5=1; }
129 elsif (/^no-sha$/) { $no_sha=1; }
130 elsif (/^no-ripemd$/) { $no_ripemd=1; }
131 elsif (/^no-mdc2$/) { $no_mdc2=1; }
132 elsif (/^no-rsa$/) { $no_rsa=1; }
133 elsif (/^no-dsa$/) { $no_dsa=1; }
134 elsif (/^no-dh$/) { $no_dh=1; }
135 elsif (/^no-hmac$/) { $no_hmac=1; }
136 elsif (/^no-rijndael$/) { $no_rijndael=1; }
140 # If no platform is given, assume WIN32
141 if ($W32 + $W16 + $VMS == 0) {
145 # Add extra knowledge
150 if (!$do_ssl && !$do_crypto)
152 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ]\n";
156 %ssl_list=&load_numbers($ssl_num);
158 %crypto_list=&load_numbers($crypto_num);
159 $max_crypto = $max_num;
163 my $crypto ="crypto/crypto.h";
164 $crypto.=" crypto/des/des.h" unless $no_des;
165 $crypto.=" crypto/idea/idea.h" unless $no_idea;
166 $crypto.=" crypto/rc4/rc4.h" unless $no_rc4;
167 $crypto.=" crypto/rc5/rc5.h" unless $no_rc5;
168 $crypto.=" crypto/rc2/rc2.h" unless $no_rc2;
169 $crypto.=" crypto/bf/blowfish.h" unless $no_bf;
170 $crypto.=" crypto/cast/cast.h" unless $no_cast;
171 $crypto.=" crypto/md2/md2.h" unless $no_md2;
172 $crypto.=" crypto/md4/md4.h" unless $no_md4;
173 $crypto.=" crypto/md5/md5.h" unless $no_md5;
174 $crypto.=" crypto/mdc2/mdc2.h" unless $no_mdc2;
175 $crypto.=" crypto/sha/sha.h" unless $no_sha;
176 $crypto.=" crypto/ripemd/ripemd.h" unless $no_ripemd;
177 $crypto.=" crypto/rijndael/rijndael.h" unless $no_rijndael;
178 $crypto.=" crypto/rijndael/rd_fst.h" unless $no_rijndael;
180 $crypto.=" crypto/bn/bn.h";
181 $crypto.=" crypto/rsa/rsa.h" unless $no_rsa;
182 $crypto.=" crypto/dsa/dsa.h" unless $no_dsa;
183 $crypto.=" crypto/dh/dh.h" unless $no_dh;
184 $crypto.=" crypto/hmac/hmac.h" unless $no_hmac;
186 $crypto.=" crypto/engine/engine.h";
187 $crypto.=" crypto/stack/stack.h";
188 $crypto.=" crypto/buffer/buffer.h";
189 $crypto.=" crypto/bio/bio.h";
190 $crypto.=" crypto/dso/dso.h";
191 $crypto.=" crypto/lhash/lhash.h";
192 $crypto.=" crypto/conf/conf.h";
193 $crypto.=" crypto/txt_db/txt_db.h";
195 $crypto.=" crypto/evp/evp.h";
196 $crypto.=" crypto/objects/objects.h";
197 $crypto.=" crypto/pem/pem.h";
198 #$crypto.=" crypto/meth/meth.h";
199 $crypto.=" crypto/asn1/asn1.h";
200 $crypto.=" crypto/asn1/asn1_mac.h";
201 $crypto.=" crypto/err/err.h";
202 $crypto.=" crypto/pkcs7/pkcs7.h";
203 $crypto.=" crypto/pkcs12/pkcs12.h";
204 $crypto.=" crypto/x509/x509.h";
205 $crypto.=" crypto/x509/x509_vfy.h";
206 $crypto.=" crypto/x509v3/x509v3.h";
207 $crypto.=" crypto/rand/rand.h";
208 $crypto.=" crypto/comp/comp.h";
209 $crypto.=" crypto/ocsp/ocsp.h";
210 $crypto.=" crypto/tmdiff.h";
212 my $symhacks="crypto/symhacks.h";
214 my @ssl_symbols = &do_defs("SSLEAY", $ssl, $symhacks);
215 my @crypto_symbols = &do_defs("LIBEAY", $crypto, $symhacks);
221 &maybe_add_info("SSLEAY",*ssl_list,@ssl_symbols);
222 if ($do_rewrite == 1) {
223 open(OUT, ">$ssl_num");
224 &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols);
227 open(OUT, ">>$ssl_num");
229 &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl,@ssl_symbols);
233 if($do_crypto == 1) {
235 &maybe_add_info("LIBEAY",*crypto_list,@crypto_symbols);
236 if ($do_rewrite == 1) {
237 open(OUT, ">$crypto_num");
238 &rewrite_numbers(*OUT,"LIBEAY",*crypto_list,@crypto_symbols);
240 open(OUT, ">>$crypto_num");
242 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto,@crypto_symbols);
246 } elsif ($do_ctest || $do_ctestall) {
250 /* Test file to check all DEF file symbols are present by trying
251 * to link to all of them. This is *not* intended to be run!
257 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,$do_ctestall,@ssl_symbols)
260 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,$do_ctestall,@crypto_symbols)
267 &print_def_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_symbols)
270 &print_def_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_symbols)
278 my($name,$files,$symhacksfile)=@_;
282 my %platform; # For anything undefined, we assume ""
283 my %kind; # For anything undefined, we assume "FUNCTION"
284 my %algorithm; # For anything undefined, we assume ""
288 foreach $file (split(/\s+/,$symhacksfile." ".$files))
290 open(IN,"<$file") || die "unable to open $file:$!\n";
291 my $line = "", my $def= "";
293 (map { $_ => 0 } @known_platforms),
294 (map { "NO_".$_ => 0 } @known_algorithms),
301 my $symhacking = $file eq $symhacksfile;
303 last if (/BEGIN ERROR CODES/);
314 $cpp = 1 if /^\#.*ifdef.*cplusplus/;
316 $cpp = 0 if /^\#.*endif/;
320 s/\/\*.*?\*\///gs; # ignore comments
321 s/{[^{}]*}//gs; # ignore {} blocks
322 if (/^\#\s*ifndef (.*)/) {
325 } elsif (/^\#\s*if !defined\(([^\)]+)\)/) {
328 } elsif (/^\#\s*ifdef (.*)/) {
331 } elsif (/^\#\s*if defined\(([^\)]+)\)/) {
334 } elsif (/^\#\s*error\s+(\w+) is disabled\./) {
335 if ($tag[$#tag] eq "NO_".$1) {
338 } elsif (/^\#\s*endif/) {
339 if ($tag{$tag[$#tag]}==2) {
340 $tag{$tag[$#tag]}=-1;
345 } elsif (/^\#\s*else/) {
348 } elsif (/^\#\s*if\s+1/) {
352 } elsif (/^\#\s*if\s+0/) {
356 } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/
360 $2.":".join(",", grep(!/^$/,
361 map { $tag{$_} == 1 ?
368 map { $tag{$_} == 1 ? $_ :
369 $tag{$_} == -1 ? "!".$_ : "" }
372 map { $tag{"NO_".$_} == -1 ? $_ : "" }
374 $def .= "#INFO:".join(',',@p).":".join(',',@a).";";
377 if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
379 } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
381 } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
383 } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
384 /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) {
385 # Things not in Win16
386 $syms{"PEM_read_${1}"} = 1;
387 $platform{"PEM_read_${1}"} = "!WIN16";
388 $syms{"PEM_write_${1}"} = 1;
389 $platform{"PEM_write_${1}"} = "!WIN16";
390 # Things that are everywhere
391 $syms{"PEM_read_bio_${1}"} = 1;
392 $syms{"PEM_write_bio_${1}"} = 1;
393 if ($1 eq "RSAPrivateKey" ||
394 $1 eq "RSAPublicKey" ||
395 $1 eq "RSA_PUBKEY") {
396 $algorithm{"PEM_read_${1}"} = "RSA";
397 $algorithm{"PEM_write_${1}"} = "RSA";
398 $algorithm{"PEM_read_bio_${1}"} = "RSA";
399 $algorithm{"PEM_write_bio_${1}"} = "RSA";
401 elsif ($1 eq "DSAPrivateKey" ||
403 $1 eq "RSA_PUBKEY") {
404 $algorithm{"PEM_read_${1}"} = "DSA";
405 $algorithm{"PEM_write_${1}"} = "DSA";
406 $algorithm{"PEM_read_bio_${1}"} = "DSA";
407 $algorithm{"PEM_write_bio_${1}"} = "DSA";
409 elsif ($1 eq "DHparams") {
410 $algorithm{"PEM_read_${1}"} = "DH";
411 $algorithm{"PEM_write_${1}"} = "DH";
412 $algorithm{"PEM_read_bio_${1}"} = "DH";
413 $algorithm{"PEM_write_bio_${1}"} = "DH";
415 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
416 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
417 # Things not in Win16
418 $syms{"PEM_write_${1}"} = 1;
419 $platform{"PEM_write_${1}"} .= ",!WIN16";
420 # Things that are everywhere
421 $syms{"PEM_write_bio_${1}"} = 1;
422 if ($1 eq "RSAPrivateKey" ||
423 $1 eq "RSAPublicKey" ||
424 $1 eq "RSA_PUBKEY") {
425 $algorithm{"PEM_write_${1}"} = "RSA";
426 $algorithm{"PEM_write_bio_${1}"} = "RSA";
428 elsif ($1 eq "DSAPrivateKey" ||
430 $1 eq "RSA_PUBKEY") {
431 $algorithm{"PEM_write_${1}"} = "DSA";
432 $algorithm{"PEM_write_bio_${1}"} = "DSA";
434 elsif ($1 eq "DHparams") {
435 $algorithm{"PEM_write_${1}"} = "DH";
436 $algorithm{"PEM_write_bio_${1}"} = "DH";
438 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
439 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
440 # Things not in Win16
441 $syms{"PEM_read_${1}"} = 1;
442 $platform{"PEM_read_${1}"} .= ",!WIN16";
443 # Things that are everywhere
444 $syms{"PEM_read_bio_${1}"} = 1;
447 && ($tag{'CONST_STRICT'} != 1)
450 if (/\{|\/\*|\([^\)]*$/) {
462 foreach (split /;/, $def) {
463 my $s; my $k = "FUNCTION"; my $p; my $a;
467 next if(/typedef\W/);
470 if (/^\#INFO:([^:]*):(.*)$/) {
474 } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+)(\[[0-9]*\])*\s*$/) {
477 } elsif (/\(\*(\w*)\([^\)]+/) {
479 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) {
482 } elsif (/\w+\W+\w+\W*\(.*\)$/s) {
483 while (not /\(\)$/s) {
485 s/\([^\(\)]*\)\)$/\)/s;
490 } elsif (/\(/ and not (/=/)) {
491 print STDERR "File $file: cannot parse: $_;\n";
502 $a .= ",BF" if($s =~ /EVP_bf/);
503 $a .= ",CAST" if($s =~ /EVP_cast/);
504 $a .= ",DES" if($s =~ /EVP_des/);
505 $a .= ",DSA" if($s =~ /EVP_dss/);
506 $a .= ",IDEA" if($s =~ /EVP_idea/);
507 $a .= ",MD2" if($s =~ /EVP_md2/);
508 $a .= ",MD4" if($s =~ /EVP_md4/);
509 $a .= ",MD5" if($s =~ /EVP_md5/);
510 $a .= ",RC2" if($s =~ /EVP_rc2/);
511 $a .= ",RC4" if($s =~ /EVP_rc4/);
512 $a .= ",RC5" if($s =~ /EVP_rc5/);
513 $a .= ",RIPEMD" if($s =~ /EVP_ripemd/);
514 $a .= ",SHA" if($s =~ /EVP_sha/);
515 $a .= ",RSA" if($s =~ /EVP_(Open|Seal)(Final|Init)/);
516 $a .= ",RSA" if($s =~ /PEM_Seal(Final|Init|Update)/);
517 $a .= ",RSA" if($s =~ /RSAPrivateKey/);
518 $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/);
520 $platform{$s} .= ','.$p;
521 $algorithm{$s} .= ','.$a;
523 if (defined($rename{$s})) {
524 (my $r, my $p) = split(/:/,$rename{$s});
525 my @ip = map { /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p;
527 $kind{$r} = $kind{$s}."(".$s.")";
528 $algorithm{$r} = $algorithm{$s};
529 $platform{$r} = $platform{$s}.",".$p;
530 $platform{$s} .= ','.join(',', @ip).','.join(',', @ip);
535 # Prune the returned symbols
537 $platform{"crypt"} .= ",!PERL5,!__FreeBSD__,!NeXT";
539 delete $syms{"SSL_add_dir_cert_subjects_to_stack"};
540 delete $syms{"bn_dump1"};
542 $platform{"BIO_s_file_internal"} .= ",WIN16";
543 $platform{"BIO_new_file_internal"} .= ",WIN16";
544 $platform{"BIO_new_fp_internal"} .= ",WIN16";
546 $platform{"BIO_s_file"} .= ",!WIN16";
547 $platform{"BIO_new_file"} .= ",!WIN16";
548 $platform{"BIO_new_fp"} .= ",!WIN16";
550 $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
552 if(exists $syms{"ERR_load_CRYPTO_strings"}) {
553 $platform{"ERR_load_CRYPTO_strings"} .= ",!VMS,!WIN16";
554 $syms{"ERR_load_CRYPTOlib_strings"} = 1;
555 $platform{"ERR_load_CRYPTOlib_strings"} .= ",VMS,WIN16";
560 $platform{"RSA_PKCS1_RSAref"} = "RSAREF";
561 $algorithm{"RSA_PKCS1_RSAref"} = "RSA";
563 push @ret, map { $_."\\".&info_string($_,"EXIST",
566 $algorithm{$_}) } keys %syms;
572 (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_;
574 my %a = defined($algorithms) ?
575 map { $_ => 1 } split /,/, $algorithms : ();
576 my $pl = defined($platforms) ? $platforms : "";
577 my %p = map { $_ => 0 } split /,/, $pl;
578 my $k = defined($kind) ? $kind : "FUNCTION";
581 # We do this, because if there's code like the following, it really
582 # means the function exists in all cases and should therefore be
583 # everywhere. By increasing and decreasing, we may attain 0:
590 foreach $platform (split /,/, $pl) {
591 if ($platform =~ /^!(.*)$/) {
597 foreach $platform (keys %p) {
598 if ($p{$platform} == 0) { delete $p{$platform}; }
605 $ret .= ":".join(',',map { $p{$_} < 0 ? "!".$_ : $_ } keys %p);
607 $ret .= ":".join(',',keys %a);
612 (my $name, *nums, my @symbols) = @_;
617 print STDERR "Updating $name info\n";
618 foreach $sym (@symbols) {
619 (my $s, my $i) = split /\\/, $sym;
620 $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
621 if (defined($nums{$s})) {
622 (my $n, my $dummy) = split /\\/, $nums{$s};
623 if (!defined($dummy) || $i ne $dummy) {
624 $nums{$s} = $n."\\".$i;
626 #print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n";
632 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
634 (my $n, my $i) = split /\\/, $nums{$sym};
635 if (!defined($syms{sym})) {
637 #print STDERR "DEBUG: maybe_add_info for $sym: -> undefined\n";
641 print STDERR "$new_info old symbols got an info update\n";
643 print STDERR "You should do a rewrite to fix this.\n";
646 print STDERR "No old symbols needed info update\n";
652 (*OUT,my $name,*nums,my @symbols)=@_;
653 my $n = 1; my @e; my @r;
654 my $sym; my $prev = ""; my $prefSSLeay;
656 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
657 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
658 @symbols=((sort @e),(sort @r));
660 foreach $sym (@symbols) {
661 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
663 if (!defined($nums{$sym})) {
664 printf STDERR "Warning: $sym does not have a number assigned\n"
668 print OUT "\t$s();\n";
671 $prev = $s; # To avoid duplicates...
677 (*OUT,my $name,*nums,my @symbols)=@_;
678 my $n = 1; my @e; my @r;
687 ; Definition file for the DLL version of the $name library from OpenSSL
692 DESCRIPTION 'OpenSSL $name - http://www.openssl.org/'
698 CODE PRELOAD MOVEABLE
699 DATA PRELOAD MOVEABLE SINGLE
711 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
712 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
713 @symbols=((sort @e),(sort @r));
716 foreach $sym (@symbols) {
717 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
718 if (!defined($nums{$s})) {
719 printf STDERR "Warning: $s does not have a number assigned\n"
722 (my $n, my $i) = split /\\/, $nums{$s};
724 my @p = split(/,/, ($i =~ /^[^:]*:([^:]*):/,$1));
725 my @a = split(/,/, ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1));
726 # @p_purged must contain hardware platforms only
729 next if $ptmp =~ /^!?RSAREF$/;
730 push @p_purged, $ptmp;
732 my $negatives = !!grep(/^!/,@p);
733 # It is very important to check NT before W32
734 if ((($NT && (!@p_purged
735 || (!$negatives && grep(/^WINNT$/,@p))
736 || ($negatives && !grep(/^!WINNT$/,@p))))
737 || ($W32 && (!@p_purged
738 || (!$negatives && grep(/^WIN32$/,@p))
739 || ($negatives && !grep(/^!WIN32$/,@p))))
740 || ($W16 && (!@p_purged
741 || (!$negatives && grep(/^WIN16$/,@p))
742 || ($negatives && !grep(/^!WIN16$/,@p)))))
745 && ($rsaref || !grep(/^RSAREF$/,@p)))
747 && (!$rsaref || !grep(/^!RSAREF$/,@p))))
748 && (!@a || (!$no_rc2 || !grep(/^RC2$/,@a)))
749 && (!@a || (!$no_rc4 || !grep(/^RC4$/,@a)))
750 && (!@a || (!$no_rc5 || !grep(/^RC5$/,@a)))
751 && (!@a || (!$no_idea || !grep(/^IDEA$/,@a)))
752 && (!@a || (!$no_des || !grep(/^DES$/,@a)))
753 && (!@a || (!$no_bf || !grep(/^BF$/,@a)))
754 && (!@a || (!$no_cast || !grep(/^CAST$/,@a)))
755 && (!@a || (!$no_md2 || !grep(/^MD2$/,@a)))
756 && (!@a || (!$no_md4 || !grep(/^MD4$/,@a)))
757 && (!@a || (!$no_md5 || !grep(/^MD5$/,@a)))
758 && (!@a || (!$no_sha || !grep(/^SHA$/,@a)))
759 && (!@a || (!$no_ripemd || !grep(/^RIPEMD$/,@a)))
760 && (!@a || (!$no_mdc2 || !grep(/^MDC2$/,@a)))
761 && (!@a || (!$no_rsa || !grep(/^RSA$/,@a)))
762 && (!@a || (!$no_dsa || !grep(/^DSA$/,@a)))
763 && (!@a || (!$no_dh || !grep(/^DH$/,@a)))
764 && (!@a || (!$no_hmac || !grep(/^HMAC$/,@a)))
765 && (!@a || (!$no_rijndael || !grep(/^RIJNDAEL$/,@a)))
766 && (!@a || (!$no_fp_api || !grep(/^FP_API$/,@a)))
768 printf OUT " %s%-40s@%d\n",($W32)?"":"_",$s,$n;
770 # print STDERR "DEBUG: \"$sym\" (@p):",
773 # && ($rsaref || !grep(/^RSAREF$/,@p)))
775 # && (!$rsaref || !grep(/^!RSAREF$/,@p))))?1:0,
776 # " 16:", !!($W16 && (!@p_purged
777 # || (!$negatives && grep(/^WIN16$/,@p))
778 # || ($negatives && !grep(/^!WIN16$/,@p)))),
779 # " 32:", !!($W32 && (!@p_purged
780 # || (!$negatives && grep(/^WIN32$/,@p))
781 # || ($negatives && !grep(/^!WIN32$/,@p)))),
782 # " NT:", !!($NT && (!@p_purged
783 # || (!$negatives && grep(/^WINNT$/,@p))
784 # || ($negatives && !grep(/^!WINNT$/,@p)))),
801 open(IN,"<$name") || die "unable to open $name:$!\n";
807 if (defined $ret{$a[0]}) {
808 print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n";
810 if ($max_num > $a[1]) {
811 print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n";
813 if ($max_num == $a[1]) {
814 # This is actually perfectly OK
815 #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n";
818 # Existence will be proven later, in do_defs
822 $ret{$a[0]}=$a[1]."\\".$a[2]; # \\ is a special marker
824 $max_num = $a[1] if $a[1] > $max_num;
828 print STDERR "Warning: $num_noinfo symbols were without info.";
830 printf STDERR " The rewrite will fix this.\n";
832 printf STDERR " You should do a rewrite to fix this.\n";
841 (my $str, my $what) = @_;
842 (my $n, my $i) = split(/\\/,$str);
852 (*OUT,$name,*nums,@symbols)=@_;
855 print STDERR "Rewriting $name\n";
857 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols);
858 my $r; my %r; my %rsyms;
860 (my $s, my $i) = split /\\/, $r;
861 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
862 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
868 foreach $_ (@symbols) {
869 (my $n, my $i) = split /\\/;
873 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
875 (my $n, my $i) = split /\\/, $nums{$sym};
876 next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/;
877 next if defined($rsyms{$sym});
878 $i="NOEXIST::FUNCTION:"
879 if !defined($i) || $i eq "" || !defined($syms{$sym});
880 printf OUT "%s%-40s%d\t%s\n","",$sym,$n,$i;
881 if (exists $r{$sym}) {
882 (my $s, $i) = split /\\/,$r{$sym};
883 printf OUT "%s%-40s%d\t%s\n","",$s,$n,$i;
890 (*OUT,$name,*nums,my $start_num, my @symbols)=@_;
893 print STDERR "Updating $name numbers\n";
895 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols);
896 my $r; my %r; my %rsyms;
898 (my $s, my $i) = split /\\/, $r;
899 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
900 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
905 foreach $sym (@symbols) {
906 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
907 next if $i =~ /^.*?:.*?:\w+\(\w+\)/;
908 next if defined($rsyms{$sym});
909 die "ERROR: Symbol $sym had no info attached to it."
911 if (!exists $nums{$s}) {
913 printf OUT "%s%-40s%d\t%s\n","",$s, ++$start_num,$i;
915 ($s, $i) = split /\\/,$r{$s};
916 printf OUT "%s%-40s%d\t%s\n","",$s, $start_num,$i;
921 print STDERR "$new_syms New symbols added\n";
923 print STDERR "No New symbols Added\n";
929 (*nums, my @symbols)=@_;
930 my %existing; my @remaining;
932 foreach $sym (@symbols) {
933 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
936 foreach $sym (keys %nums) {
937 if (!exists $existing{$sym}) {
938 push @remaining, $sym;
942 print STDERR "The following symbols do not seem to exist:\n";
943 foreach $sym (@remaining) {
944 print STDERR "\t",$sym,"\n";