5 # It does this by parsing the header files and looking for the
6 # prototyped functions: it then prunes the output.
9 $crypto_num="util/libeay.num";
10 $ssl_num= "util/ssleay.num";
19 # Set this to make typesafe STACK definitions appear in DEF
29 $do_ssl=1 if $_ eq "ssleay";
30 $do_ssl=1 if $_ eq "ssl";
31 $do_crypto=1 if $_ eq "libeay";
32 $do_crypto=1 if $_ eq "crypto";
33 $do_update=1 if $_ eq "update";
34 $rsaref=1 if $_ eq "rsaref";
37 if (!$do_ssl && !$do_crypto)
39 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n";
43 %ssl_list=&load_numbers($ssl_num);
45 %crypto_list=&load_numbers($crypto_num);
46 $max_crypto = $max_num;
50 $crypto ="crypto/crypto.h";
51 $crypto.=" crypto/des/des.h";
52 $crypto.=" crypto/idea/idea.h";
53 $crypto.=" crypto/rc4/rc4.h";
54 $crypto.=" crypto/rc5/rc5.h";
55 $crypto.=" crypto/rc2/rc2.h";
56 $crypto.=" crypto/bf/blowfish.h";
57 $crypto.=" crypto/cast/cast.h";
58 $crypto.=" crypto/md2/md2.h";
59 $crypto.=" crypto/md5/md5.h";
60 $crypto.=" crypto/mdc2/mdc2.h";
61 $crypto.=" crypto/sha/sha.h";
62 $crypto.=" crypto/ripemd/ripemd.h";
64 $crypto.=" crypto/bn/bn.h";
65 $crypto.=" crypto/rsa/rsa.h";
66 $crypto.=" crypto/dsa/dsa.h";
67 $crypto.=" crypto/dh/dh.h";
69 $crypto.=" crypto/stack/stack.h";
70 $crypto.=" crypto/buffer/buffer.h";
71 $crypto.=" crypto/bio/bio.h";
72 $crypto.=" crypto/lhash/lhash.h";
73 $crypto.=" crypto/conf/conf.h";
74 $crypto.=" crypto/txt_db/txt_db.h";
76 $crypto.=" crypto/evp/evp.h";
77 $crypto.=" crypto/objects/objects.h";
78 $crypto.=" crypto/pem/pem.h";
79 #$crypto.=" crypto/meth/meth.h";
80 $crypto.=" crypto/asn1/asn1.h";
81 $crypto.=" crypto/asn1/asn1_mac.h";
82 $crypto.=" crypto/err/err.h";
83 $crypto.=" crypto/pkcs7/pkcs7.h";
84 $crypto.=" crypto/pkcs12/pkcs12.h";
85 $crypto.=" crypto/x509/x509.h";
86 $crypto.=" crypto/x509/x509_vfy.h";
87 $crypto.=" crypto/x509v3/x509v3.h";
88 $crypto.=" crypto/rand/rand.h";
89 $crypto.=" crypto/hmac/hmac.h";
90 $crypto.=" crypto/comp/comp.h";
91 $crypto.=" crypto/tmdiff.h";
93 @ssl_func = &do_defs("SSLEAY", $ssl);
94 @crypto_func = &do_defs("LIBEAY", $crypto);
100 open(OUT, ">>$ssl_num");
101 &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl, @ssl_func);
105 if($do_crypto == 1) {
106 open(OUT, ">>$crypto_num");
107 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func);
113 $err += &print_def_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_func)
116 $err += &print_def_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_func)
128 foreach $file (split(/\s+/,$files))
130 open(IN,"<$file") || die "unable to open $file:$!\n";
132 my $line = "", $def= "";
144 last if (/BEGIN ERROR CODES/);
155 $cpp = 1 if /^#.*ifdef.*cplusplus/;
157 $cpp = 0 if /^#.*endif/;
161 s/\/\*.*?\*\///gs; # ignore comments
162 s/{[^{}]*}//gs; # ignore {} blocks
163 if (/^\#\s*ifndef (.*)/) {
167 } elsif (/^\#\s*if !defined\(([^\)]+)\)/) {
171 } elsif (/^\#\s*ifdef (.*)/) {
175 } elsif (/^\#\s*if defined(.*)/) {
179 } elsif (/^\#\s*endif/) {
183 } elsif (/^\#\s*else/) {
187 } elsif (/^\#\s*if\s+1/) {
195 if ($safe_stack_def &&
196 /^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
197 $funcs{"sk_${1}_new"} = 1;
198 $funcs{"sk_${1}_new_null"} = 1;
199 $funcs{"sk_${1}_free"} = 1;
200 $funcs{"sk_${1}_num"} = 1;
201 $funcs{"sk_${1}_value"} = 1;
202 $funcs{"sk_${1}_set"} = 1;
203 $funcs{"sk_${1}_zero"} = 1;
204 $funcs{"sk_${1}_push"} = 1;
205 $funcs{"sk_${1}_pop"} = 1;
206 $funcs{"sk_${1}_find"} = 1;
207 $funcs{"sk_${1}_delete"} = 1;
208 $funcs{"sk_${1}_delete_ptr"} = 1;
209 $funcs{"sk_${1}_set_cmp_func"} = 1;
210 $funcs{"sk_${1}_dup"} = 1;
211 $funcs{"sk_${1}_pop_free"} = 1;
212 $funcs{"sk_${1}_shift"} = 1;
213 } elsif ($safe_stack_def &&
214 /^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
215 $funcs{"d2i_ASN1_SET_OF_${1}"} = 1;
216 $funcs{"i2d_ASN1_SET_OF_${1}"} = 1;
218 ($tag{'FreeBSD'} != 1) &&
219 ($tag{'CONST_STRICT'} != 1) &&
220 (($W32 && ($tag{'WIN16'} != 1)) ||
221 (!$W32 && ($tag{'WIN16'} != -1))) &&
222 ($tag{'PERL5'} != 1) &&
223 # ($tag{'_WINDLL'} != -1) &&
224 ((!$W32 && $tag{'_WINDLL'} != -1) ||
225 ($W32 && $tag{'_WINDLL'} != 1)) &&
226 ((($tag{'NO_FP_API'} != 1) && $W32) ||
227 (($tag{'NO_FP_API'} != -1) && !$W32)))
238 foreach (split /;/, $def) {
241 next if(/typedef\W/);
242 if (/\(\*(\w*)\([^\)]+/) {
244 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) {
247 } elsif (/\w+\W+\w+\W*\(.*\)$/s) {
248 while (not /\(\)$/s) {
250 s/\([^\(\)]*\)\)$/\)/s;
255 } elsif (/\(/ and not (/=/)) {
256 print STDERR "File $file: cannot parse: $_;\n";
261 # Prune the returned functions
263 delete $funcs{"SSL_add_dir_cert_subjects_to_stack"};
264 delete $funcs{"des_crypt"};
265 delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref;
268 delete $funcs{"BIO_s_file_internal"};
269 delete $funcs{"BIO_new_file_internal"};
270 delete $funcs{"BIO_new_fp_internal"};
272 if(exists $funcs{"ERR_load_CRYPTO_strings"}) {
273 delete $funcs{"ERR_load_CRYPTO_strings"};
274 $funcs{"ERR_load_CRYPTOlib_strings"} = 1;
276 delete $funcs{"BIO_s_file"};
277 delete $funcs{"BIO_new_file"};
278 delete $funcs{"BIO_new_fp"};
281 delete $funcs{"BIO_s_log"};
284 push @ret, keys %funcs;
291 (*OUT,my $name,*nums,@functions)=@_;
302 ; Definition file for the DLL version of the $name library from OpenSSL
307 DESCRIPTION 'OpenSSL $name - http://www.openssl.org/'
313 CODE PRELOAD MOVEABLE
314 DATA PRELOAD MOVEABLE SINGLE
327 (@e)=grep(/^SSLeay/,@functions);
328 (@r)=grep(!/^SSLeay/,@functions);
329 @functions=((sort @e),(sort @r));
331 foreach $func (@functions) {
332 if (!defined($nums{$func})) {
334 printf STDERR "$func does not have a number assigned\n";
339 printf OUT " %s%-40s@%d\n",($W32)?"":"_",$func,$n;
353 open(IN,"<$name") || die "unable to open $name:$!\n";
360 $max_num = $a[1] if $a[1] > $max_num;
368 (*OUT,$name,*nums,my $start_num, my @functions)=@_;
370 print STDERR "Updating $name\n";
371 foreach $func (@functions) {
372 if (!exists $nums{$func}) {
374 printf OUT "%s%-40s%d\n","",$func, ++$start_num;
378 print STDERR "$new_funcs New Functions added\n";
380 print STDERR "No New Functions Added\n";