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; my $no_krb5;
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; }
153 elsif (/^no-krb5$/) { $no_krb5=1; }
157 # If no platform is given, assume WIN32
158 if ($W32 + $W16 + $VMS == 0) {
162 # Add extra knowledge
167 if (!$do_ssl && !$do_crypto)
169 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ]\n";
173 %ssl_list=&load_numbers($ssl_num);
175 %crypto_list=&load_numbers($crypto_num);
176 $max_crypto = $max_num;
181 my $crypto ="crypto/crypto.h";
182 $crypto.=" crypto/des/des.h" unless $no_des;
183 $crypto.=" crypto/idea/idea.h" unless $no_idea;
184 $crypto.=" crypto/rc4/rc4.h" unless $no_rc4;
185 $crypto.=" crypto/rc5/rc5.h" unless $no_rc5;
186 $crypto.=" crypto/rc2/rc2.h" unless $no_rc2;
187 $crypto.=" crypto/bf/blowfish.h" unless $no_bf;
188 $crypto.=" crypto/cast/cast.h" unless $no_cast;
189 $crypto.=" crypto/md2/md2.h" unless $no_md2;
190 $crypto.=" crypto/md4/md4.h" unless $no_md4;
191 $crypto.=" crypto/md5/md5.h" unless $no_md5;
192 $crypto.=" crypto/mdc2/mdc2.h" unless $no_mdc2;
193 $crypto.=" crypto/sha/sha.h" unless $no_sha;
194 $crypto.=" crypto/ripemd/ripemd.h" unless $no_ripemd;
195 $crypto.=" crypto/rijndael/rijndael.h" unless $no_aes;
196 $crypto.=" crypto/rijndael/rd_fst.h" unless $no_aes;
198 $crypto.=" crypto/bn/bn.h";
199 $crypto.=" crypto/rsa/rsa.h" unless $no_rsa;
200 $crypto.=" crypto/dsa/dsa.h" unless $no_dsa;
201 $crypto.=" crypto/dh/dh.h" unless $no_dh;
202 $crypto.=" crypto/hmac/hmac.h" unless $no_hmac;
204 $crypto.=" crypto/engine/engine.h";
205 $crypto.=" crypto/stack/stack.h" unless $no_stack;
206 $crypto.=" crypto/buffer/buffer.h" unless $no_buffer;
207 $crypto.=" crypto/bio/bio.h" unless $no_bio;
208 $crypto.=" crypto/dso/dso.h" unless $no_dso;
209 $crypto.=" crypto/lhash/lhash.h" unless $no_lhash;
210 $crypto.=" crypto/conf/conf.h";
211 $crypto.=" crypto/txt_db/txt_db.h";
213 $crypto.=" crypto/evp/evp.h" unless $no_evp;
214 $crypto.=" crypto/objects/objects.h";
215 $crypto.=" crypto/pem/pem.h";
216 #$crypto.=" crypto/meth/meth.h";
217 $crypto.=" crypto/asn1/asn1.h";
218 $crypto.=" crypto/asn1/asn1t.h";
219 $crypto.=" crypto/asn1/asn1_mac.h";
220 $crypto.=" crypto/err/err.h" unless $no_err;
221 $crypto.=" crypto/pkcs7/pkcs7.h";
222 $crypto.=" crypto/pkcs12/pkcs12.h";
223 $crypto.=" crypto/x509/x509.h";
224 $crypto.=" crypto/x509/x509_vfy.h";
225 $crypto.=" crypto/x509v3/x509v3.h";
226 $crypto.=" crypto/rand/rand.h";
227 $crypto.=" crypto/comp/comp.h" unless $no_comp;
228 $crypto.=" crypto/ocsp/ocsp.h";
229 $crypto.=" crypto/tmdiff.h";
231 my $symhacks="crypto/symhacks.h";
233 my @ssl_symbols = &do_defs("SSLEAY", $ssl, $symhacks);
234 my @crypto_symbols = &do_defs("LIBEAY", $crypto, $symhacks);
240 &maybe_add_info("SSLEAY",*ssl_list,@ssl_symbols);
241 if ($do_rewrite == 1) {
242 open(OUT, ">$ssl_num");
243 &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols);
246 open(OUT, ">>$ssl_num");
248 &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl,@ssl_symbols);
252 if($do_crypto == 1) {
254 &maybe_add_info("LIBEAY",*crypto_list,@crypto_symbols);
255 if ($do_rewrite == 1) {
256 open(OUT, ">$crypto_num");
257 &rewrite_numbers(*OUT,"LIBEAY",*crypto_list,@crypto_symbols);
259 open(OUT, ">>$crypto_num");
261 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto,@crypto_symbols);
265 } elsif ($do_checkexist) {
266 &check_existing(*ssl_list, @ssl_symbols)
268 &check_existing(*crypto_list, @crypto_symbols)
270 } elsif ($do_ctest || $do_ctestall) {
274 /* Test file to check all DEF file symbols are present by trying
275 * to link to all of them. This is *not* intended to be run!
281 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,$do_ctestall,@ssl_symbols)
284 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,$do_ctestall,@crypto_symbols)
291 &print_def_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_symbols)
294 &print_def_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_symbols)
302 my($name,$files,$symhacksfile)=@_;
306 my %platform; # For anything undefined, we assume ""
307 my %kind; # For anything undefined, we assume "FUNCTION"
308 my %algorithm; # For anything undefined, we assume ""
311 my %unknown_algorithms = ();
313 foreach $file (split(/\s+/,$symhacksfile." ".$files))
315 open(IN,"<$file") || die "unable to open $file:$!\n";
316 my $line = "", my $def= "";
318 (map { $_ => 0 } @known_platforms),
319 (map { "NO_".$_ => 0 } @known_algorithms),
326 my $symhacking = $file eq $symhacksfile;
327 my @current_platforms = ();
328 my @current_algorithms = ();
331 last if (/BEGIN ERROR CODES/);
342 $cpp = 1 if /^\#.*ifdef.*cplusplus/;
344 $cpp = 0 if /^\#.*endif/;
348 s/\/\*.*?\*\///gs; # ignore comments
349 s/{[^{}]*}//gs; # ignore {} blocks
350 #print STDERR "DEBUG: \$_=\"$_\"\n";
351 if (/^\#\s*ifndef\s+(.*)/) {
354 } elsif (/^\#\s*if\s+!defined\(([^\)]+)\)/) {
357 } elsif (/^\#\s*ifdef\s+(.*)/) {
360 } elsif (/^\#\s*if\s+defined\(([^\)]+)\)/) {
363 } elsif (/^\#\s*error\s+(\w+) is disabled\./) {
364 if ($tag[$#tag] eq "NO_".$1) {
367 } elsif (/^\#\s*endif/) {
368 my $oldtag=$tag[$#tag];
369 #print STDERR "DEBUG: \$oldtag=\"$oldtag\"\n";
370 if ($tag{$tag[$#tag]}==2) {
371 $tag{$tag[$#tag]}=-1;
376 if ($oldtag =~ /^NO_([A-Z0-9_]+)$/) {
382 && !grep(/^$oldtag$/, @known_algorithms)) {
383 $unknown_algorithms{$oldtag} = 1;
384 #print STDERR "DEBUG: Added as unknown algorithm: $oldtag\n";
386 } elsif (/^\#\s*else/) {
389 } elsif (/^\#\s*if\s+1/) {
393 } elsif (/^\#\s*if\s+0/) {
397 } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/
401 $2.":".join(",", grep(!/^$/,
402 map { $tag{$_} == 1 ?
410 map { $tag{$_} == 1 ? $_ :
411 $tag{$_} == -1 ? "!".$_ : "" }
413 @current_algorithms =
415 map { $tag{"NO_".$_} == -1 ? $_ : "" }
419 .join(',',@current_platforms).":"
420 .join(',',@current_algorithms).";";
423 if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
425 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
426 $def .= "int d2i_$3(void);";
427 $def .= "int i2d_$3(void);";
428 $def .= "OPENSSL_EXTERN int $2_it;";
430 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_fname\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
431 $def .= "int d2i_$3(void);";
432 $def .= "int i2d_$3(void);";
433 $def .= "int $3_free(void);";
434 $def .= "int $3_new(void);";
435 $def .= "OPENSSL_EXTERN int $2_it;";
436 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS\s*\(\s*(\w*)\s*\)/ ||
437 /^\s*DECLARE_ASN1_FUNCTIONS_const\s*\(\s*(\w*)\s*\)/) {
438 $def .= "int d2i_$1(void);";
439 $def .= "int i2d_$1(void);";
440 $def .= "int $1_free(void);";
441 $def .= "int $1_new(void);";
442 $def .= "OPENSSL_EXTERN int $1_it;";
444 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS_const\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
445 $def .= "int d2i_$2(void);";
446 $def .= "int i2d_$2(void);";
447 $def .= "OPENSSL_EXTERN int $2_it;";
449 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
450 $def .= "int d2i_$2(void);";
451 $def .= "int i2d_$2(void);";
452 $def .= "int $2_free(void);";
453 $def .= "int $2_new(void);";
454 $def .= "OPENSSL_EXTERN int $2_it;";
456 } elsif (/^\s*DECLARE_ASN1_ITEM\s*\(\s*(\w*)\s*,(\w*)\s*\)/) {
457 $def .= "OPENSSL_EXTERN int $1_it;";
459 } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
461 } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
463 } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
464 /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) {
465 # Things not in Win16
468 .join(',',"!WIN16",@current_platforms).":"
469 .join(',',@current_algorithms).";";
470 $def .= "int PEM_read_$1(void);";
471 $def .= "int PEM_write_$1(void);";
474 .join(',',@current_platforms).":"
475 .join(',',@current_algorithms).";";
476 # Things that are everywhere
477 $def .= "int PEM_read_bio_$1(void);";
478 $def .= "int PEM_write_bio_$1(void);";
479 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
480 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
481 # Things not in Win16
484 .join(',',"!WIN16",@current_platforms).":"
485 .join(',',@current_algorithms).";";
486 $def .= "int PEM_write_$1(void);";
489 .join(',',@current_platforms).":"
490 .join(',',@current_algorithms).";";
491 # Things that are everywhere
492 $def .= "int PEM_write_bio_$1(void);";
493 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
494 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
495 # Things not in Win16
498 .join(',',"!WIN16",@current_platforms).":"
499 .join(',',@current_algorithms).";";
500 $def .= "int PEM_read_$1(void);";
503 .join(',',@current_platforms).":"
504 .join(',',@current_algorithms).";";
505 # Things that are everywhere
506 $def .= "int PEM_read_bio_$1(void);";
509 && ($tag{'CONST_STRICT'} != 1)
512 if (/\{|\/\*|\([^\)]*$/) {
524 foreach (split /;/, $def) {
525 my $s; my $k = "FUNCTION"; my $p; my $a;
529 next if(/typedef\W/);
532 if (/^\#INFO:([^:]*):(.*)$/) {
536 } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+)(\[[0-9]*\])*\s*$/) {
539 } elsif (/\(\*(\w*)\([^\)]+/) {
541 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) {
544 } elsif (/\w+\W+\w+\W*\(.*\)$/s) {
545 while (not /\(\)$/s) {
547 s/\([^\(\)]*\)\)$/\)/s;
552 } elsif (/\(/ and not (/=/)) {
553 print STDERR "File $file: cannot parse: $_;\n";
564 $a .= ",BF" if($s =~ /EVP_bf/);
565 $a .= ",CAST" if($s =~ /EVP_cast/);
566 $a .= ",DES" if($s =~ /EVP_des/);
567 $a .= ",DSA" if($s =~ /EVP_dss/);
568 $a .= ",IDEA" if($s =~ /EVP_idea/);
569 $a .= ",MD2" if($s =~ /EVP_md2/);
570 $a .= ",MD4" if($s =~ /EVP_md4/);
571 $a .= ",MD5" if($s =~ /EVP_md5/);
572 $a .= ",RC2" if($s =~ /EVP_rc2/);
573 $a .= ",RC4" if($s =~ /EVP_rc4/);
574 $a .= ",RC5" if($s =~ /EVP_rc5/);
575 $a .= ",RIPEMD" if($s =~ /EVP_ripemd/);
576 $a .= ",SHA" if($s =~ /EVP_sha/);
577 $a .= ",RSA" if($s =~ /EVP_(Open|Seal)(Final|Init)/);
578 $a .= ",RSA" if($s =~ /PEM_Seal(Final|Init|Update)/);
579 $a .= ",RSA" if($s =~ /RSAPrivateKey/);
580 $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/);
582 $platform{$s} .= ','.$p;
583 $algorithm{$s} .= ','.$a;
585 if (defined($rename{$s})) {
586 (my $r, my $p) = split(/:/,$rename{$s});
587 my @ip = map { /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p;
589 $kind{$r} = $kind{$s}."(".$s.")";
590 $algorithm{$r} = $algorithm{$s};
591 $platform{$r} = $platform{$s}.",".$p;
592 $platform{$s} .= ','.join(',', @ip).','.join(',', @ip);
597 # Prune the returned symbols
599 $platform{"crypt"} .= ",!PERL5,!__FreeBSD__,!NeXT";
601 delete $syms{"SSL_add_dir_cert_subjects_to_stack"};
602 delete $syms{"bn_dump1"};
604 $platform{"BIO_s_file_internal"} .= ",WIN16";
605 $platform{"BIO_new_file_internal"} .= ",WIN16";
606 $platform{"BIO_new_fp_internal"} .= ",WIN16";
608 $platform{"BIO_s_file"} .= ",!WIN16";
609 $platform{"BIO_new_file"} .= ",!WIN16";
610 $platform{"BIO_new_fp"} .= ",!WIN16";
612 $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
614 if(exists $syms{"ERR_load_CRYPTO_strings"}) {
615 $platform{"ERR_load_CRYPTO_strings"} .= ",!VMS,!WIN16";
616 $syms{"ERR_load_CRYPTOlib_strings"} = 1;
617 $platform{"ERR_load_CRYPTOlib_strings"} .= ",VMS,WIN16";
622 push @ret, map { $_."\\".&info_string($_,"EXIST",
625 $algorithm{$_}) } keys %syms;
627 if (keys %unknown_algorithms) {
628 print STDERR "WARNING: mkdef.pl doesn't know the following algorithms:\n";
629 print STDERR "\t",join("\n\t",keys %unknown_algorithms),"\n";
635 (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_;
637 my %a = defined($algorithms) ?
638 map { $_ => 1 } split /,/, $algorithms : ();
639 my $pl = defined($platforms) ? $platforms : "";
640 my %p = map { $_ => 0 } split /,/, $pl;
641 my $k = defined($kind) ? $kind : "FUNCTION";
644 # We do this, because if there's code like the following, it really
645 # means the function exists in all cases and should therefore be
646 # everywhere. By increasing and decreasing, we may attain 0:
653 foreach $platform (split /,/, $pl) {
654 if ($platform =~ /^!(.*)$/) {
660 foreach $platform (keys %p) {
661 if ($p{$platform} == 0) { delete $p{$platform}; }
668 $ret .= ":".join(',',map { $p{$_} < 0 ? "!".$_ : $_ } keys %p);
670 $ret .= ":".join(',',keys %a);
675 (my $name, *nums, my @symbols) = @_;
680 print STDERR "Updating $name info\n";
681 foreach $sym (@symbols) {
682 (my $s, my $i) = split /\\/, $sym;
683 $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
684 if (defined($nums{$s})) {
685 (my $n, my $dummy) = split /\\/, $nums{$s};
686 if (!defined($dummy) || $i ne $dummy) {
687 $nums{$s} = $n."\\".$i;
689 #print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n";
695 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
697 (my $n, my $i) = split /\\/, $nums{$sym};
698 if (!defined($syms{sym})) {
700 #print STDERR "DEBUG: maybe_add_info for $sym: -> undefined\n";
704 print STDERR "$new_info old symbols got an info update\n";
706 print STDERR "You should do a rewrite to fix this.\n";
709 print STDERR "No old symbols needed info update\n";
715 (*OUT,my $name,*nums,my @symbols)=@_;
716 my $n = 1; my @e; my @r;
717 my $sym; my $prev = ""; my $prefSSLeay;
719 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
720 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
721 @symbols=((sort @e),(sort @r));
723 foreach $sym (@symbols) {
724 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
726 if (!defined($nums{$s})) {
727 printf STDERR "Warning: $s does not have a number assigned\n"
731 print OUT "\t$s();\n";
734 $prev = $s; # To avoid duplicates...
740 (*OUT,my $name,*nums,my @symbols)=@_;
741 my $n = 1; my @e; my @r; my @v;
750 ; Definition file for the DLL version of the $name library from OpenSSL
755 DESCRIPTION 'OpenSSL $name - http://www.openssl.org/'
761 CODE PRELOAD MOVEABLE
762 DATA PRELOAD MOVEABLE SINGLE
774 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
775 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols);
776 (@v)=grep(/^\w+\\.*?:.*?:VARIABLE/,@symbols);
777 @symbols=((sort @e),(sort @r), (sort @v));
780 foreach $sym (@symbols) {
781 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
783 $v = 1 if $sym=~ /^\w+\\.*?:.*?:VARIABLE/;
784 if (!defined($nums{$s})) {
785 printf STDERR "Warning: $s does not have a number assigned\n"
788 (my $n, my $i) = split /\\/, $nums{$s};
790 my @p = split(/,/, ($i =~ /^[^:]*:([^:]*):/,$1));
791 my @a = split(/,/, ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1));
792 # @p_purged must contain hardware platforms only
795 push @p_purged, $ptmp;
797 my $negatives = !!grep(/^!/,@p);
798 # It is very important to check NT before W32
799 if ((($NT && (!@p_purged
800 || (!$negatives && grep(/^WINNT$/,@p))
801 || ($negatives && !grep(/^!WINNT$/,@p))))
802 || ($W32 && (!@p_purged
803 || (!$negatives && grep(/^WIN32$/,@p))
804 || ($negatives && !grep(/^!WIN32$/,@p))))
805 || ($W16 && (!@p_purged
806 || (!$negatives && grep(/^WIN16$/,@p))
807 || ($negatives && !grep(/^!WIN16$/,@p)))))
808 && (!@a || (!$no_rc2 || !grep(/^RC2$/,@a)))
809 && (!@a || (!$no_rc4 || !grep(/^RC4$/,@a)))
810 && (!@a || (!$no_rc5 || !grep(/^RC5$/,@a)))
811 && (!@a || (!$no_idea || !grep(/^IDEA$/,@a)))
812 && (!@a || (!$no_des || !grep(/^DES$/,@a)))
813 && (!@a || (!$no_bf || !grep(/^BF$/,@a)))
814 && (!@a || (!$no_cast || !grep(/^CAST$/,@a)))
815 && (!@a || (!$no_md2 || !grep(/^MD2$/,@a)))
816 && (!@a || (!$no_md4 || !grep(/^MD4$/,@a)))
817 && (!@a || (!$no_md5 || !grep(/^MD5$/,@a)))
818 && (!@a || (!$no_sha || !grep(/^SHA$/,@a)))
819 && (!@a || (!$no_ripemd || !grep(/^RIPEMD$/,@a)))
820 && (!@a || (!$no_mdc2 || !grep(/^MDC2$/,@a)))
821 && (!@a || (!$no_rsa || !grep(/^RSA$/,@a)))
822 && (!@a || (!$no_dsa || !grep(/^DSA$/,@a)))
823 && (!@a || (!$no_dh || !grep(/^DH$/,@a)))
824 && (!@a || (!$no_hmac || !grep(/^HMAC$/,@a)))
825 && (!@a || (!$no_aes || !grep(/^AES$/,@a)))
826 && (!@a || (!$no_krb5 || !grep(/^KRB5$/,@a)))
827 && (!@a || (!$no_fp_api || !grep(/^FP_API$/,@a)))
830 printf OUT " %s%-40s@%-8d DATA\n",($W32)?"":"_",$s,$n;
832 printf OUT " %s%-40s@%d\n",($W32)?"":"_",$s,$n;
835 # print STDERR "DEBUG: \"$sym\" (@p):",
838 # && ($rsaref || !grep(/^RSAREF$/,@p)))
840 # && (!$rsaref || !grep(/^!RSAREF$/,@p))))?1:0,
841 # " 16:", !!($W16 && (!@p_purged
842 # || (!$negatives && grep(/^WIN16$/,@p))
843 # || ($negatives && !grep(/^!WIN16$/,@p)))),
844 # " 32:", !!($W32 && (!@p_purged
845 # || (!$negatives && grep(/^WIN32$/,@p))
846 # || ($negatives && !grep(/^!WIN32$/,@p)))),
847 # " NT:", !!($NT && (!@p_purged
848 # || (!$negatives && grep(/^WINNT$/,@p))
849 # || ($negatives && !grep(/^!WINNT$/,@p)))),
866 open(IN,"<$name") || die "unable to open $name:$!\n";
872 if (defined $ret{$a[0]}) {
873 print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n";
875 if ($max_num > $a[1]) {
876 print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n";
878 if ($max_num == $a[1]) {
879 # This is actually perfectly OK
880 #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n";
883 # Existence will be proven later, in do_defs
887 $ret{$a[0]}=$a[1]."\\".$a[2]; # \\ is a special marker
889 $max_num = $a[1] if $a[1] > $max_num;
893 print STDERR "Warning: $num_noinfo symbols were without info.";
895 printf STDERR " The rewrite will fix this.\n";
897 printf STDERR " You should do a rewrite to fix this.\n";
906 (my $str, my $what) = @_;
907 (my $n, my $i) = split(/\\/,$str);
917 (*OUT,$name,*nums,@symbols)=@_;
920 print STDERR "Rewriting $name\n";
922 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols);
923 my $r; my %r; my %rsyms;
925 (my $s, my $i) = split /\\/, $r;
926 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
927 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
933 foreach $_ (@symbols) {
934 (my $n, my $i) = split /\\/;
938 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
940 (my $n, my $i) = split /\\/, $nums{$sym};
941 next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/;
942 next if defined($rsyms{$sym});
943 $i="NOEXIST::FUNCTION:"
944 if !defined($i) || $i eq "" || !defined($syms{$sym});
945 printf OUT "%s%-40s%d\t%s\n","",$sym,$n,$i;
946 if (exists $r{$sym}) {
947 (my $s, $i) = split /\\/,$r{$sym};
948 printf OUT "%s%-40s%d\t%s\n","",$s,$n,$i;
955 (*OUT,$name,*nums,my $start_num, my @symbols)=@_;
958 print STDERR "Updating $name numbers\n";
960 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols);
961 my $r; my %r; my %rsyms;
963 (my $s, my $i) = split /\\/, $r;
964 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
965 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
970 foreach $sym (@symbols) {
971 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
972 next if $i =~ /^.*?:.*?:\w+\(\w+\)/;
973 next if defined($rsyms{$sym});
974 die "ERROR: Symbol $sym had no info attached to it."
976 if (!exists $nums{$s}) {
978 printf OUT "%s%-40s%d\t%s\n","",$s, ++$start_num,$i;
980 ($s, $i) = split /\\/,$r{$s};
981 printf OUT "%s%-40s%d\t%s\n","",$s, $start_num,$i;
986 print STDERR "$new_syms New symbols added\n";
988 print STDERR "No New symbols Added\n";
994 (*nums, my @symbols)=@_;
995 my %existing; my @remaining;
997 foreach $sym (@symbols) {
998 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1001 foreach $sym (keys %nums) {
1002 if (!exists $existing{$sym}) {
1003 push @remaining, $sym;
1007 print STDERR "The following symbols do not seem to exist:\n";
1008 foreach $sym (@remaining) {
1009 print STDERR "\t",$sym,"\n";