]>
Commit | Line | Data |
---|---|---|
ce9449cf | 1 | #!/usr/local/bin/perl -w |
d02b48c6 RE |
2 | # |
3 | # generate a .def file | |
4 | # | |
5 | # It does this by parsing the header files and looking for the | |
47339f61 | 6 | # prototyped functions: it then prunes the output. |
d02b48c6 RE |
7 | # |
8 | ||
0f583f69 UM |
9 | my $crypto_num="util/libeay.num"; |
10 | my $ssl_num= "util/ssleay.num"; | |
d02b48c6 | 11 | |
47339f61 DSH |
12 | my $do_update = 0; |
13 | my $do_crypto = 0; | |
14 | my $do_ssl = 0; | |
0f583f69 UM |
15 | my $do_ctest = 0; |
16 | my $rsaref = 0; | |
47339f61 | 17 | |
0f583f69 UM |
18 | my $W32=1; |
19 | my $NT=0; | |
28a98809 | 20 | # Set this to make typesafe STACK definitions appear in DEF |
0f583f69 | 21 | my $safe_stack_def = 1; |
31ff97b2 | 22 | |
0f583f69 | 23 | my $options=""; |
31ff97b2 UM |
24 | open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n"; |
25 | while(<IN>) { | |
26 | $options=$1 if (/^OPTIONS=(.*)$/); | |
27 | } | |
ce457a54 | 28 | close(IN); |
31ff97b2 | 29 | |
0f583f69 UM |
30 | # The following ciphers may be excluded (by Configure). This means functions |
31 | # defined with ifndef(NO_XXX) are not included in the .def file, and everything | |
32 | # in directory xxx is ignored. | |
33 | my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf; | |
34 | my $no_cast; my $no_md2; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2; | |
35 | my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; | |
36 | ||
31ff97b2 | 37 | foreach (@ARGV, split(/ /, $options)) |
d02b48c6 | 38 | { |
06c68491 DSH |
39 | $W32=1 if $_ eq "32"; |
40 | $W32=0 if $_ eq "16"; | |
41 | if($_ eq "NT") { | |
42 | $W32 = 1; | |
43 | $NT = 1; | |
44 | } | |
d02b48c6 | 45 | $do_ssl=1 if $_ eq "ssleay"; |
55a9cc6e | 46 | $do_ssl=1 if $_ eq "ssl"; |
d02b48c6 | 47 | $do_crypto=1 if $_ eq "libeay"; |
55a9cc6e DSH |
48 | $do_crypto=1 if $_ eq "crypto"; |
49 | $do_update=1 if $_ eq "update"; | |
12aefe78 | 50 | $do_ctest=1 if $_ eq "ctest"; |
47339f61 | 51 | $rsaref=1 if $_ eq "rsaref"; |
8cf65228 UM |
52 | |
53 | if (/^no-rc2$/) { $no_rc2=1; } | |
54 | elsif (/^no-rc4$/) { $no_rc4=1; } | |
55 | elsif (/^no-rc5$/) { $no_rc5=1; } | |
56 | elsif (/^no-idea$/) { $no_idea=1; } | |
57 | elsif (/^no-des$/) { $no_des=1; } | |
58 | elsif (/^no-bf$/) { $no_bf=1; } | |
59 | elsif (/^no-cast$/) { $no_cast=1; } | |
60 | elsif (/^no-md2$/) { $no_md2=1; } | |
61 | elsif (/^no-md5$/) { $no_md5=1; } | |
62 | elsif (/^no-sha$/) { $no_sha=1; } | |
63 | elsif (/^no-ripemd$/) { $no_ripemd=1; } | |
64 | elsif (/^no-mdc2$/) { $no_mdc2=1; } | |
65 | elsif (/^no-rsa$/) { $no_rsa=1; } | |
66 | elsif (/^no-dsa$/) { $no_dsa=1; } | |
67 | elsif (/^no-dh$/) { $no_dh=1; } | |
68 | elsif (/^no-hmac$/) { $no_hmac=1; } | |
d02b48c6 RE |
69 | } |
70 | ||
12aefe78 | 71 | |
d02b48c6 RE |
72 | if (!$do_ssl && !$do_crypto) |
73 | { | |
47339f61 | 74 | print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n"; |
d02b48c6 RE |
75 | exit(1); |
76 | } | |
77 | ||
78 | %ssl_list=&load_numbers($ssl_num); | |
55a9cc6e | 79 | $max_ssl = $max_num; |
d02b48c6 | 80 | %crypto_list=&load_numbers($crypto_num); |
55a9cc6e | 81 | $max_crypto = $max_num; |
d02b48c6 | 82 | |
0f583f69 | 83 | my $ssl="ssl/ssl.h"; |
d02b48c6 | 84 | |
0f583f69 | 85 | my $crypto ="crypto/crypto.h"; |
8cf65228 UM |
86 | $crypto.=" crypto/des/des.h" unless $no_des; |
87 | $crypto.=" crypto/idea/idea.h" unless $no_idea; | |
88 | $crypto.=" crypto/rc4/rc4.h" unless $no_rc4; | |
89 | $crypto.=" crypto/rc5/rc5.h" unless $no_rc5; | |
90 | $crypto.=" crypto/rc2/rc2.h" unless $no_rc2; | |
91 | $crypto.=" crypto/bf/blowfish.h" unless $no_bf; | |
92 | $crypto.=" crypto/cast/cast.h" unless $no_cast; | |
93 | $crypto.=" crypto/md2/md2.h" unless $no_md2; | |
94 | $crypto.=" crypto/md5/md5.h" unless $no_md5; | |
95 | $crypto.=" crypto/mdc2/mdc2.h" unless $no_mdc2; | |
96 | $crypto.=" crypto/sha/sha.h" unless $no_sha; | |
97 | $crypto.=" crypto/ripemd/ripemd.h" unless $no_ripemd; | |
d02b48c6 RE |
98 | |
99 | $crypto.=" crypto/bn/bn.h"; | |
8cf65228 UM |
100 | $crypto.=" crypto/rsa/rsa.h" unless $no_rsa; |
101 | $crypto.=" crypto/dsa/dsa.h" unless $no_dsa; | |
102 | $crypto.=" crypto/dh/dh.h" unless $no_dh; | |
103 | $crypto.=" crypto/hmac/hmac.h" unless $no_hmac; | |
d02b48c6 RE |
104 | |
105 | $crypto.=" crypto/stack/stack.h"; | |
106 | $crypto.=" crypto/buffer/buffer.h"; | |
107 | $crypto.=" crypto/bio/bio.h"; | |
108 | $crypto.=" crypto/lhash/lhash.h"; | |
109 | $crypto.=" crypto/conf/conf.h"; | |
110 | $crypto.=" crypto/txt_db/txt_db.h"; | |
111 | ||
112 | $crypto.=" crypto/evp/evp.h"; | |
113 | $crypto.=" crypto/objects/objects.h"; | |
114 | $crypto.=" crypto/pem/pem.h"; | |
115 | #$crypto.=" crypto/meth/meth.h"; | |
116 | $crypto.=" crypto/asn1/asn1.h"; | |
117 | $crypto.=" crypto/asn1/asn1_mac.h"; | |
118 | $crypto.=" crypto/err/err.h"; | |
119 | $crypto.=" crypto/pkcs7/pkcs7.h"; | |
ee0508d4 | 120 | $crypto.=" crypto/pkcs12/pkcs12.h"; |
d02b48c6 RE |
121 | $crypto.=" crypto/x509/x509.h"; |
122 | $crypto.=" crypto/x509/x509_vfy.h"; | |
679ab7c3 | 123 | $crypto.=" crypto/x509v3/x509v3.h"; |
d02b48c6 | 124 | $crypto.=" crypto/rand/rand.h"; |
dfeab068 RE |
125 | $crypto.=" crypto/comp/comp.h"; |
126 | $crypto.=" crypto/tmdiff.h"; | |
d02b48c6 | 127 | |
0f583f69 UM |
128 | my @ssl_func = &do_defs("SSLEAY", $ssl); |
129 | my @crypto_func = &do_defs("LIBEAY", $crypto); | |
55a9cc6e | 130 | |
47339f61 | 131 | |
55a9cc6e DSH |
132 | if ($do_update) { |
133 | ||
134 | if ($do_ssl == 1) { | |
135 | open(OUT, ">>$ssl_num"); | |
136 | &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl, @ssl_func); | |
137 | close OUT; | |
138 | } | |
139 | ||
140 | if($do_crypto == 1) { | |
141 | open(OUT, ">>$crypto_num"); | |
142 | &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func); | |
143 | close OUT; | |
12aefe78 DSH |
144 | } |
145 | ||
146 | } elsif ($do_ctest) { | |
147 | ||
148 | print <<"EOF"; | |
149 | ||
150 | /* Test file to check all DEF file symbols are present by trying | |
151 | * to link to all of them. This is *not* intended to be run! | |
152 | */ | |
153 | ||
154 | int main() | |
155 | { | |
156 | EOF | |
157 | &print_test_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_func) | |
158 | if $do_ssl == 1; | |
159 | ||
160 | &print_test_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_func) | |
161 | if $do_crypto == 1; | |
162 | ||
163 | print "}\n"; | |
55a9cc6e DSH |
164 | |
165 | } else { | |
8cf65228 UM |
166 | |
167 | &print_def_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_func) | |
55a9cc6e DSH |
168 | if $do_ssl == 1; |
169 | ||
8cf65228 | 170 | &print_def_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_func) |
55a9cc6e | 171 | if $do_crypto == 1; |
8cf65228 | 172 | |
55a9cc6e | 173 | } |
d02b48c6 | 174 | |
d02b48c6 RE |
175 | |
176 | sub do_defs | |
47339f61 DSH |
177 | { |
178 | my($name,$files)=@_; | |
0f583f69 | 179 | my $file; |
47339f61 DSH |
180 | my @ret; |
181 | my %funcs; | |
0f583f69 | 182 | my $cpp; |
d02b48c6 | 183 | |
d02b48c6 RE |
184 | foreach $file (split(/\s+/,$files)) |
185 | { | |
d02b48c6 | 186 | open(IN,"<$file") || die "unable to open $file:$!\n"; |
0f583f69 | 187 | my $line = "", my $def= ""; |
47339f61 DSH |
188 | my %tag = ( |
189 | FreeBSD => 0, | |
190 | NOPROTO => 0, | |
191 | WIN16 => 0, | |
192 | PERL5 => 0, | |
193 | _WINDLL => 0, | |
194 | NO_FP_API => 0, | |
195 | CONST_STRICT => 0, | |
196 | TRUE => 1, | |
0f583f69 UM |
197 | NO_RC2 => 0, |
198 | NO_RC4 => 0, | |
199 | NO_RC5 => 0, | |
200 | NO_IDEA => 0, | |
201 | NO_DES => 0, | |
202 | NO_BF => 0, | |
203 | NO_CAST => 0, | |
204 | NO_MD2 => 0, | |
205 | NO_MD5 => 0, | |
206 | NO_SHA => 0, | |
207 | NO_RIPEMD => 0, | |
208 | NO_MDC2 => 0, | |
209 | NO_RSA => 0, | |
210 | NO_DSA => 0, | |
211 | NO_DH => 0, | |
212 | NO_HMAC => 0, | |
47339f61 DSH |
213 | ); |
214 | while(<IN>) { | |
215 | last if (/BEGIN ERROR CODES/); | |
216 | if ($line ne '') { | |
217 | $_ = $line . $_; | |
218 | $line = ''; | |
d02b48c6 | 219 | } |
47339f61 DSH |
220 | |
221 | if (/\\$/) { | |
222 | $line = $_; | |
223 | next; | |
224 | } | |
225 | ||
226 | $cpp = 1 if /^#.*ifdef.*cplusplus/; | |
227 | if ($cpp) { | |
228 | $cpp = 0 if /^#.*endif/; | |
229 | next; | |
230 | } | |
231 | ||
232 | s/\/\*.*?\*\///gs; # ignore comments | |
233 | s/{[^{}]*}//gs; # ignore {} blocks | |
234 | if (/^\#\s*ifndef (.*)/) { | |
d02b48c6 RE |
235 | push(@tag,$1); |
236 | $tag{$1}=-1; | |
237 | next; | |
47339f61 | 238 | } elsif (/^\#\s*if !defined\(([^\)]+)\)/) { |
d02b48c6 RE |
239 | push(@tag,$1); |
240 | $tag{$1}=-1; | |
241 | next; | |
47339f61 | 242 | } elsif (/^\#\s*ifdef (.*)/) { |
d02b48c6 RE |
243 | push(@tag,$1); |
244 | $tag{$1}=1; | |
245 | next; | |
47339f61 | 246 | } elsif (/^\#\s*if defined(.*)/) { |
d02b48c6 RE |
247 | push(@tag,$1); |
248 | $tag{$1}=1; | |
249 | next; | |
47339f61 | 250 | } elsif (/^\#\s*endif/) { |
d02b48c6 RE |
251 | $tag{$tag[$#tag]}=0; |
252 | pop(@tag); | |
253 | next; | |
47339f61 DSH |
254 | } elsif (/^\#\s*else/) { |
255 | my $t=$tag[$#tag]; | |
d02b48c6 RE |
256 | $tag{$t}= -$tag{$t}; |
257 | next; | |
47339f61 DSH |
258 | } elsif (/^\#\s*if\s+1/) { |
259 | # Dummy tag | |
260 | push(@tag,"TRUE"); | |
261 | $tag{"TRUE"}=1; | |
262 | next; | |
1e414935 BM |
263 | } elsif (/^\#\s*if\s+0/) { |
264 | # Dummy tag | |
265 | push(@tag,"TRUE"); | |
266 | $tag{"TRUE"}=-1; | |
267 | next; | |
47339f61 DSH |
268 | } elsif (/^\#/) { |
269 | next; | |
270 | } | |
271 | if ($safe_stack_def && | |
272 | /^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) { | |
273 | $funcs{"sk_${1}_new"} = 1; | |
274 | $funcs{"sk_${1}_new_null"} = 1; | |
275 | $funcs{"sk_${1}_free"} = 1; | |
276 | $funcs{"sk_${1}_num"} = 1; | |
277 | $funcs{"sk_${1}_value"} = 1; | |
278 | $funcs{"sk_${1}_set"} = 1; | |
279 | $funcs{"sk_${1}_zero"} = 1; | |
280 | $funcs{"sk_${1}_push"} = 1; | |
a5ab0532 | 281 | $funcs{"sk_${1}_unshift"} = 1; |
47339f61 DSH |
282 | $funcs{"sk_${1}_find"} = 1; |
283 | $funcs{"sk_${1}_delete"} = 1; | |
284 | $funcs{"sk_${1}_delete_ptr"} = 1; | |
a5ab0532 | 285 | $funcs{"sk_${1}_insert"} = 1; |
47339f61 DSH |
286 | $funcs{"sk_${1}_set_cmp_func"} = 1; |
287 | $funcs{"sk_${1}_dup"} = 1; | |
288 | $funcs{"sk_${1}_pop_free"} = 1; | |
289 | $funcs{"sk_${1}_shift"} = 1; | |
a5ab0532 | 290 | $funcs{"sk_${1}_pop"} = 1; |
f598cd13 | 291 | $funcs{"sk_${1}_sort"} = 1; |
47339f61 DSH |
292 | } elsif ($safe_stack_def && |
293 | /^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) { | |
294 | $funcs{"d2i_ASN1_SET_OF_${1}"} = 1; | |
295 | $funcs{"i2d_ASN1_SET_OF_${1}"} = 1; | |
dbd665c2 DSH |
296 | } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ || |
297 | /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) { | |
298 | if($W32) { | |
299 | $funcs{"PEM_read_${1}"} = 1; | |
300 | $funcs{"PEM_write_${1}"} = 1; | |
301 | } | |
302 | $funcs{"PEM_read_bio_${1}"} = 1; | |
303 | $funcs{"PEM_write_bio_${1}"} = 1; | |
0f583f69 | 304 | } elsif ( |
1e414935 | 305 | ($tag{'TRUE'} != -1) && |
d02b48c6 | 306 | ($tag{'FreeBSD'} != 1) && |
47339f61 | 307 | ($tag{'CONST_STRICT'} != 1) && |
06c68491 DSH |
308 | (($W32 && ($tag{'WIN16'} != 1)) || |
309 | (!$W32 && ($tag{'WIN16'} != -1))) && | |
58964a49 RE |
310 | ($tag{'PERL5'} != 1) && |
311 | # ($tag{'_WINDLL'} != -1) && | |
06c68491 DSH |
312 | ((!$W32 && $tag{'_WINDLL'} != -1) || |
313 | ($W32 && $tag{'_WINDLL'} != 1)) && | |
314 | ((($tag{'NO_FP_API'} != 1) && $W32) || | |
0f583f69 UM |
315 | (($tag{'NO_FP_API'} != -1) && !$W32)) && |
316 | ($tag{'NO_RC2'} == 0 || !$no_rc2) && | |
317 | ($tag{'NO_RC4'} == 0 || !$no_rc4) && | |
318 | ($tag{'NO_RC5'} == 0 || !$no_rc5) && | |
319 | ($tag{'NO_IDEA'} == 0 || !$no_idea) && | |
320 | ($tag{'NO_DES'} == 0 || !$no_des) && | |
321 | ($tag{'NO_BF'} == 0 || !$no_bf) && | |
322 | ($tag{'NO_CAST'} == 0 || !$no_cast) && | |
323 | ($tag{'NO_MD2'} == 0 || !$no_md2) && | |
324 | ($tag{'NO_MD5'} == 0 || !$no_md5) && | |
325 | ($tag{'NO_SHA'} == 0 || !$no_sha) && | |
326 | ($tag{'NO_RIPEMD'} == 0 || !$no_ripemd) && | |
327 | ($tag{'NO_MDC2'} == 0 || !$no_mdc2) && | |
328 | ($tag{'NO_RSA'} == 0 || !$no_rsa) && | |
329 | ($tag{'NO_DSA'} == 0 || !$no_dsa) && | |
330 | ($tag{'NO_DH'} == 0 || !$no_dh) && | |
331 | ($tag{'NO_HMAC'} == 0 || !$no_hmac)) | |
d02b48c6 | 332 | { |
47339f61 DSH |
333 | if (/{|\/\*/) { # } |
334 | $line = $_; | |
335 | } else { | |
336 | $def .= $_; | |
337 | } | |
d02b48c6 RE |
338 | } |
339 | } | |
340 | close(IN); | |
47339f61 DSH |
341 | |
342 | foreach (split /;/, $def) { | |
343 | s/^[\n\s]*//g; | |
344 | s/[\n\s]*$//g; | |
345 | next if(/typedef\W/); | |
8cf65228 UM |
346 | next if(/EVP_bf/ and $no_bf); |
347 | next if(/EVP_cast/ and $no_cast); | |
348 | next if(/EVP_des/ and $no_des); | |
349 | next if(/EVP_dss/ and $no_dsa); | |
350 | next if(/EVP_idea/ and $no_idea); | |
351 | next if(/EVP_md2/ and $no_md2); | |
352 | next if(/EVP_md5/ and $no_md5); | |
353 | next if(/EVP_rc2/ and $no_rc2); | |
354 | next if(/EVP_rc4/ and $no_rc4); | |
355 | next if(/EVP_rc5/ and $no_rc5); | |
356 | next if(/EVP_ripemd/ and $no_ripemd); | |
357 | next if(/EVP_sha/ and $no_sha); | |
47339f61 DSH |
358 | if (/\(\*(\w*)\([^\)]+/) { |
359 | $funcs{$1} = 1; | |
360 | } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) { | |
361 | # K&R C | |
362 | next; | |
363 | } elsif (/\w+\W+\w+\W*\(.*\)$/s) { | |
364 | while (not /\(\)$/s) { | |
365 | s/[^\(\)]*\)$/\)/s; | |
366 | s/\([^\(\)]*\)\)$/\)/s; | |
367 | } | |
368 | s/\(void\)//; | |
369 | /(\w+)\W*\(\)/s; | |
370 | $funcs{$1} = 1; | |
371 | } elsif (/\(/ and not (/=/)) { | |
372 | print STDERR "File $file: cannot parse: $_;\n"; | |
373 | } | |
d02b48c6 | 374 | } |
d02b48c6 RE |
375 | } |
376 | ||
47339f61 DSH |
377 | # Prune the returned functions |
378 | ||
379 | delete $funcs{"SSL_add_dir_cert_subjects_to_stack"}; | |
380 | delete $funcs{"des_crypt"}; | |
381 | delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref; | |
382 | ||
383 | if($W32) { | |
384 | delete $funcs{"BIO_s_file_internal"}; | |
385 | delete $funcs{"BIO_new_file_internal"}; | |
386 | delete $funcs{"BIO_new_fp_internal"}; | |
387 | } else { | |
388 | if(exists $funcs{"ERR_load_CRYPTO_strings"}) { | |
389 | delete $funcs{"ERR_load_CRYPTO_strings"}; | |
390 | $funcs{"ERR_load_CRYPTOlib_strings"} = 1; | |
d02b48c6 | 391 | } |
47339f61 DSH |
392 | delete $funcs{"BIO_s_file"}; |
393 | delete $funcs{"BIO_new_file"}; | |
394 | delete $funcs{"BIO_new_fp"}; | |
395 | } | |
396 | if (!$NT) { | |
397 | delete $funcs{"BIO_s_log"}; | |
d02b48c6 RE |
398 | } |
399 | ||
47339f61 | 400 | push @ret, keys %funcs; |
d02b48c6 | 401 | |
47339f61 DSH |
402 | return(@ret); |
403 | } | |
d02b48c6 | 404 | |
12aefe78 DSH |
405 | sub print_test_file |
406 | { | |
0f583f69 UM |
407 | (*OUT,my $name,*nums,my @functions)=@_; |
408 | my $n = 1; my @e; my @r; | |
409 | my $func; | |
12aefe78 DSH |
410 | |
411 | (@e)=grep(/^SSLeay/,@functions); | |
412 | (@r)=grep(!/^SSLeay/,@functions); | |
413 | @functions=((sort @e),(sort @r)); | |
414 | ||
415 | foreach $func (@functions) { | |
416 | if (!defined($nums{$func})) { | |
417 | printf STDERR "$func does not have a number assigned\n" | |
418 | if(!$do_update); | |
419 | } else { | |
420 | $n=$nums{$func}; | |
421 | print OUT "\t$func();\n"; | |
422 | } | |
423 | } | |
424 | } | |
425 | ||
d02b48c6 | 426 | sub print_def_file |
47339f61 | 427 | { |
0f583f69 UM |
428 | (*OUT,my $name,*nums,my @functions)=@_; |
429 | my $n = 1; my @e; my @r; | |
d02b48c6 | 430 | |
06c68491 | 431 | if ($W32) |
d02b48c6 RE |
432 | { $name.="32"; } |
433 | else | |
434 | { $name.="16"; } | |
435 | ||
436 | print OUT <<"EOF"; | |
437 | ; | |
9b3086fe | 438 | ; Definition file for the DLL version of the $name library from OpenSSL |
d02b48c6 RE |
439 | ; |
440 | ||
441 | LIBRARY $name | |
442 | ||
9b3086fe | 443 | DESCRIPTION 'OpenSSL $name - http://www.openssl.org/' |
d02b48c6 RE |
444 | |
445 | EOF | |
446 | ||
47339f61 | 447 | if (!$W32) { |
d02b48c6 RE |
448 | print <<"EOF"; |
449 | CODE PRELOAD MOVEABLE | |
450 | DATA PRELOAD MOVEABLE SINGLE | |
451 | ||
452 | EXETYPE WINDOWS | |
453 | ||
454 | HEAPSIZE 4096 | |
455 | STACKSIZE 8192 | |
456 | ||
457 | EOF | |
47339f61 | 458 | } |
d02b48c6 RE |
459 | |
460 | print "EXPORTS\n"; | |
461 | ||
462 | ||
463 | (@e)=grep(/^SSLeay/,@functions); | |
464 | (@r)=grep(!/^SSLeay/,@functions); | |
465 | @functions=((sort @e),(sort @r)); | |
466 | ||
47339f61 DSH |
467 | foreach $func (@functions) { |
468 | if (!defined($nums{$func})) { | |
8cf65228 UM |
469 | printf STDERR "$func does not have a number assigned\n" |
470 | if(!$do_update); | |
47339f61 | 471 | } else { |
d02b48c6 | 472 | $n=$nums{$func}; |
06c68491 | 473 | printf OUT " %s%-40s@%d\n",($W32)?"":"_",$func,$n; |
d02b48c6 | 474 | } |
d02b48c6 | 475 | } |
47339f61 DSH |
476 | printf OUT "\n"; |
477 | } | |
d02b48c6 RE |
478 | |
479 | sub load_numbers | |
47339f61 DSH |
480 | { |
481 | my($name)=@_; | |
482 | my(@a,%ret); | |
d02b48c6 | 483 | |
55a9cc6e DSH |
484 | $max_num = 0; |
485 | ||
d02b48c6 | 486 | open(IN,"<$name") || die "unable to open $name:$!\n"; |
47339f61 | 487 | while (<IN>) { |
d02b48c6 RE |
488 | chop; |
489 | s/#.*$//; | |
490 | next if /^\s*$/; | |
491 | @a=split; | |
492 | $ret{$a[0]}=$a[1]; | |
55a9cc6e | 493 | $max_num = $a[1] if $a[1] > $max_num; |
47339f61 | 494 | } |
d02b48c6 RE |
495 | close(IN); |
496 | return(%ret); | |
47339f61 | 497 | } |
55a9cc6e DSH |
498 | |
499 | sub update_numbers | |
47339f61 DSH |
500 | { |
501 | (*OUT,$name,*nums,my $start_num, my @functions)=@_; | |
55a9cc6e DSH |
502 | my $new_funcs = 0; |
503 | print STDERR "Updating $name\n"; | |
47339f61 DSH |
504 | foreach $func (@functions) { |
505 | if (!exists $nums{$func}) { | |
55a9cc6e DSH |
506 | $new_funcs++; |
507 | printf OUT "%s%-40s%d\n","",$func, ++$start_num; | |
55a9cc6e | 508 | } |
47339f61 | 509 | } |
55a9cc6e DSH |
510 | if($new_funcs) { |
511 | print STDERR "$new_funcs New Functions added\n"; | |
512 | } else { | |
513 | print STDERR "No New Functions Added\n"; | |
514 | } | |
47339f61 | 515 | } |