mkdef.pl 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501
  1. #!/usr/local/bin/perl -w
  2. #
  3. # generate a .def file
  4. #
  5. # It does this by parsing the header files and looking for the
  6. # prototyped functions: it then prunes the output.
  7. #
  8. # Intermediary files are created, call libeay.num and ssleay.num,...
  9. # Previously, they had the following format:
  10. #
  11. # routine-name nnnn
  12. #
  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.
  19. #
  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
  24. # file).
  25. #
  26. # The format now becomes:
  27. #
  28. # routine-name nnnn info
  29. #
  30. # and the "info" part is actually a colon-separated string of fields with
  31. # the following meaning:
  32. #
  33. # existence:platform:kind:algorithms
  34. #
  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 variants 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, or the symbol is implemented differently (see
  43. # EXPORT_VAR_AS_FUNCTION). This script assumes renaming of symbols is found
  44. # in the file crypto/symhacks.h.
  45. # The semantics for the platforms is that every item is checked against the
  46. # environment. For the negative items ("!FOO"), if any of them is false
  47. # (i.e. "FOO" is true) in the environment, the corresponding symbol can't be
  48. # used. For the positive itms, if all of them are false in the environment,
  49. # the corresponding symbol can't be used. Any combination of positive and
  50. # negative items are possible, and of course leave room for some redundancy.
  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
  54. # exclude.
  55. #
  56. my $debug=0;
  57. my $crypto_num= "util/libeay.num";
  58. my $ssl_num= "util/ssleay.num";
  59. my $libname;
  60. my $do_update = 0;
  61. my $do_rewrite = 1;
  62. my $do_crypto = 0;
  63. my $do_ssl = 0;
  64. my $do_ctest = 0;
  65. my $do_ctestall = 0;
  66. my $do_checkexist = 0;
  67. my $VMSVAX=0;
  68. my $VMSNonVAX=0;
  69. my $VMS=0;
  70. my $W32=0;
  71. my $W16=0;
  72. my $NT=0;
  73. my $OS2=0;
  74. # Set this to make typesafe STACK definitions appear in DEF
  75. my $safe_stack_def = 0;
  76. my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
  77. "EXPORT_VAR_AS_FUNCTION", "ZLIB" );
  78. my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
  79. my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
  80. "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
  81. "SHA256", "SHA512", "RIPEMD",
  82. "MDC2", "WHIRLPOOL", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA",
  83. "HMAC", "AES", "CAMELLIA", "SEED", "GOST",
  84. # Envelope "algorithms"
  85. "EVP", "X509", "ASN1_TYPEDEFS",
  86. # Helper "algorithms"
  87. "BIO", "COMP", "BUFFER", "LHASH", "STACK", "ERR",
  88. "LOCKING",
  89. # External "algorithms"
  90. "FP_API", "STDIO", "SOCK", "KRB5", "DGRAM",
  91. # Engines
  92. "STATIC_ENGINE", "ENGINE", "HW", "GMP",
  93. # RFC3779
  94. "RFC3779",
  95. # TLS
  96. "TLSEXT", "PSK",
  97. # CMS
  98. "CMS",
  99. # CryptoAPI Engine
  100. "CAPIENG",
  101. # SSL v2
  102. "SSL2",
  103. # JPAKE
  104. "JPAKE",
  105. # Deprecated functions
  106. "DEPRECATED" );
  107. my $options="";
  108. open(IN,"<Makefile") || die "unable to open Makefile!\n";
  109. while(<IN>) {
  110. $options=$1 if (/^OPTIONS=(.*)$/);
  111. }
  112. close(IN);
  113. # The following ciphers may be excluded (by Configure). This means functions
  114. # defined with ifndef(NO_XXX) are not included in the .def file, and everything
  115. # in directory xxx is ignored.
  116. my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
  117. my $no_cast; my $no_whirlpool; my $no_camellia; my $no_seed;
  118. my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
  119. my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
  120. my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw;
  121. my $no_fp_api; my $no_static_engine=1; my $no_gmp; my $no_deprecated;
  122. my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng;
  123. my $no_jpake; my $no_ssl2;
  124. my $zlib;
  125. foreach (@ARGV, split(/ /, $options))
  126. {
  127. $debug=1 if $_ eq "debug";
  128. $W32=1 if $_ eq "32";
  129. $W16=1 if $_ eq "16";
  130. if($_ eq "NT") {
  131. $W32 = 1;
  132. $NT = 1;
  133. }
  134. if ($_ eq "VMS-VAX") {
  135. $VMS=1;
  136. $VMSVAX=1;
  137. }
  138. if ($_ eq "VMS-NonVAX") {
  139. $VMS=1;
  140. $VMSNonVAX=1;
  141. }
  142. $VMS=1 if $_ eq "VMS";
  143. $OS2=1 if $_ eq "OS2";
  144. if ($_ eq "zlib" || $_ eq "enable-zlib" || $_ eq "zlib-dynamic"
  145. || $_ eq "enable-zlib-dynamic") {
  146. $zlib = 1;
  147. }
  148. $do_ssl=1 if $_ eq "ssleay";
  149. if ($_ eq "ssl") {
  150. $do_ssl=1;
  151. $libname=$_
  152. }
  153. $do_crypto=1 if $_ eq "libeay";
  154. if ($_ eq "crypto") {
  155. $do_crypto=1;
  156. $libname=$_;
  157. }
  158. $no_static_engine=1 if $_ eq "no-static-engine";
  159. $no_static_engine=0 if $_ eq "enable-static-engine";
  160. $do_update=1 if $_ eq "update";
  161. $do_rewrite=1 if $_ eq "rewrite";
  162. $do_ctest=1 if $_ eq "ctest";
  163. $do_ctestall=1 if $_ eq "ctestall";
  164. $do_checkexist=1 if $_ eq "exist";
  165. #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK";
  166. if (/^no-rc2$/) { $no_rc2=1; }
  167. elsif (/^no-rc4$/) { $no_rc4=1; }
  168. elsif (/^no-rc5$/) { $no_rc5=1; }
  169. elsif (/^no-idea$/) { $no_idea=1; }
  170. elsif (/^no-des$/) { $no_des=1; $no_mdc2=1; }
  171. elsif (/^no-bf$/) { $no_bf=1; }
  172. elsif (/^no-cast$/) { $no_cast=1; }
  173. elsif (/^no-whirlpool$/) { $no_whirlpool=1; }
  174. elsif (/^no-md2$/) { $no_md2=1; }
  175. elsif (/^no-md4$/) { $no_md4=1; }
  176. elsif (/^no-md5$/) { $no_md5=1; }
  177. elsif (/^no-sha$/) { $no_sha=1; }
  178. elsif (/^no-ripemd$/) { $no_ripemd=1; }
  179. elsif (/^no-mdc2$/) { $no_mdc2=1; }
  180. elsif (/^no-rsa$/) { $no_rsa=1; }
  181. elsif (/^no-dsa$/) { $no_dsa=1; }
  182. elsif (/^no-dh$/) { $no_dh=1; }
  183. elsif (/^no-ec$/) { $no_ec=1; }
  184. elsif (/^no-ecdsa$/) { $no_ecdsa=1; }
  185. elsif (/^no-ecdh$/) { $no_ecdh=1; }
  186. elsif (/^no-hmac$/) { $no_hmac=1; }
  187. elsif (/^no-aes$/) { $no_aes=1; }
  188. elsif (/^no-camellia$/) { $no_camellia=1; }
  189. elsif (/^no-seed$/) { $no_seed=1; }
  190. elsif (/^no-evp$/) { $no_evp=1; }
  191. elsif (/^no-lhash$/) { $no_lhash=1; }
  192. elsif (/^no-stack$/) { $no_stack=1; }
  193. elsif (/^no-err$/) { $no_err=1; }
  194. elsif (/^no-buffer$/) { $no_buffer=1; }
  195. elsif (/^no-bio$/) { $no_bio=1; }
  196. #elsif (/^no-locking$/) { $no_locking=1; }
  197. elsif (/^no-comp$/) { $no_comp=1; }
  198. elsif (/^no-dso$/) { $no_dso=1; }
  199. elsif (/^no-krb5$/) { $no_krb5=1; }
  200. elsif (/^no-engine$/) { $no_engine=1; }
  201. elsif (/^no-hw$/) { $no_hw=1; }
  202. elsif (/^no-gmp$/) { $no_gmp=1; }
  203. elsif (/^no-rfc3779$/) { $no_rfc3779=1; }
  204. elsif (/^no-tlsext$/) { $no_tlsext=1; }
  205. elsif (/^no-cms$/) { $no_cms=1; }
  206. elsif (/^no-ssl2$/) { $no_ssl2=1; }
  207. elsif (/^no-capieng$/) { $no_capieng=1; }
  208. elsif (/^no-jpake$/) { $no_jpake=1; }
  209. }
  210. if (!$libname) {
  211. if ($do_ssl) {
  212. $libname="SSLEAY";
  213. }
  214. if ($do_crypto) {
  215. $libname="LIBEAY";
  216. }
  217. }
  218. # If no platform is given, assume WIN32
  219. if ($W32 + $W16 + $VMS + $OS2 == 0) {
  220. $W32 = 1;
  221. }
  222. # Add extra knowledge
  223. if ($W16) {
  224. $no_fp_api=1;
  225. }
  226. if (!$do_ssl && !$do_crypto)
  227. {
  228. print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT | OS2 ]\n";
  229. exit(1);
  230. }
  231. %ssl_list=&load_numbers($ssl_num);
  232. $max_ssl = $max_num;
  233. %crypto_list=&load_numbers($crypto_num);
  234. $max_crypto = $max_num;
  235. my $ssl="ssl/ssl.h";
  236. $ssl.=" ssl/kssl.h";
  237. $ssl.=" ssl/tls1.h";
  238. my $crypto ="crypto/crypto.h";
  239. $crypto.=" crypto/o_dir.h";
  240. $crypto.=" crypto/des/des.h crypto/des/des_old.h" ; # unless $no_des;
  241. $crypto.=" crypto/idea/idea.h" ; # unless $no_idea;
  242. $crypto.=" crypto/rc4/rc4.h" ; # unless $no_rc4;
  243. $crypto.=" crypto/rc5/rc5.h" ; # unless $no_rc5;
  244. $crypto.=" crypto/rc2/rc2.h" ; # unless $no_rc2;
  245. $crypto.=" crypto/bf/blowfish.h" ; # unless $no_bf;
  246. $crypto.=" crypto/cast/cast.h" ; # unless $no_cast;
  247. $crypto.=" crypto/whrlpool/whrlpool.h" ;
  248. $crypto.=" crypto/md2/md2.h" ; # unless $no_md2;
  249. $crypto.=" crypto/md4/md4.h" ; # unless $no_md4;
  250. $crypto.=" crypto/md5/md5.h" ; # unless $no_md5;
  251. $crypto.=" crypto/mdc2/mdc2.h" ; # unless $no_mdc2;
  252. $crypto.=" crypto/sha/sha.h" ; # unless $no_sha;
  253. $crypto.=" crypto/ripemd/ripemd.h" ; # unless $no_ripemd;
  254. $crypto.=" crypto/aes/aes.h" ; # unless $no_aes;
  255. $crypto.=" crypto/camellia/camellia.h" ; # unless $no_camellia;
  256. $crypto.=" crypto/seed/seed.h"; # unless $no_seed;
  257. $crypto.=" crypto/bn/bn.h";
  258. $crypto.=" crypto/rsa/rsa.h" ; # unless $no_rsa;
  259. $crypto.=" crypto/dsa/dsa.h" ; # unless $no_dsa;
  260. $crypto.=" crypto/dh/dh.h" ; # unless $no_dh;
  261. $crypto.=" crypto/ec/ec.h" ; # unless $no_ec;
  262. $crypto.=" crypto/ecdsa/ecdsa.h" ; # unless $no_ecdsa;
  263. $crypto.=" crypto/ecdh/ecdh.h" ; # unless $no_ecdh;
  264. $crypto.=" crypto/hmac/hmac.h" ; # unless $no_hmac;
  265. $crypto.=" crypto/engine/engine.h"; # unless $no_engine;
  266. $crypto.=" crypto/stack/stack.h" ; # unless $no_stack;
  267. $crypto.=" crypto/buffer/buffer.h" ; # unless $no_buffer;
  268. $crypto.=" crypto/bio/bio.h" ; # unless $no_bio;
  269. $crypto.=" crypto/dso/dso.h" ; # unless $no_dso;
  270. $crypto.=" crypto/lhash/lhash.h" ; # unless $no_lhash;
  271. $crypto.=" crypto/conf/conf.h";
  272. $crypto.=" crypto/txt_db/txt_db.h";
  273. $crypto.=" crypto/evp/evp.h" ; # unless $no_evp;
  274. $crypto.=" crypto/objects/objects.h";
  275. $crypto.=" crypto/pem/pem.h";
  276. #$crypto.=" crypto/meth/meth.h";
  277. $crypto.=" crypto/asn1/asn1.h";
  278. $crypto.=" crypto/asn1/asn1t.h";
  279. $crypto.=" crypto/asn1/asn1_mac.h";
  280. $crypto.=" crypto/err/err.h" ; # unless $no_err;
  281. $crypto.=" crypto/pkcs7/pkcs7.h";
  282. $crypto.=" crypto/pkcs12/pkcs12.h";
  283. $crypto.=" crypto/x509/x509.h";
  284. $crypto.=" crypto/x509/x509_vfy.h";
  285. $crypto.=" crypto/x509v3/x509v3.h";
  286. $crypto.=" crypto/ts/ts.h";
  287. $crypto.=" crypto/rand/rand.h";
  288. $crypto.=" crypto/comp/comp.h" ; # unless $no_comp;
  289. $crypto.=" crypto/ocsp/ocsp.h";
  290. $crypto.=" crypto/ui/ui.h crypto/ui/ui_compat.h";
  291. $crypto.=" crypto/krb5/krb5_asn.h";
  292. #$crypto.=" crypto/store/store.h";
  293. $crypto.=" crypto/pqueue/pqueue.h";
  294. $crypto.=" crypto/cms/cms.h";
  295. $crypto.=" crypto/jpake/jpake.h";
  296. $crypto.=" crypto/modes/modes.h";
  297. my $symhacks="crypto/symhacks.h";
  298. my @ssl_symbols = &do_defs("SSLEAY", $ssl, $symhacks);
  299. my @crypto_symbols = &do_defs("LIBEAY", $crypto, $symhacks);
  300. if ($do_update) {
  301. if ($do_ssl == 1) {
  302. &maybe_add_info("SSLEAY",*ssl_list,@ssl_symbols);
  303. if ($do_rewrite == 1) {
  304. open(OUT, ">$ssl_num");
  305. &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols);
  306. } else {
  307. open(OUT, ">>$ssl_num");
  308. }
  309. &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl,@ssl_symbols);
  310. close OUT;
  311. }
  312. if($do_crypto == 1) {
  313. &maybe_add_info("LIBEAY",*crypto_list,@crypto_symbols);
  314. if ($do_rewrite == 1) {
  315. open(OUT, ">$crypto_num");
  316. &rewrite_numbers(*OUT,"LIBEAY",*crypto_list,@crypto_symbols);
  317. } else {
  318. open(OUT, ">>$crypto_num");
  319. }
  320. &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto,@crypto_symbols);
  321. close OUT;
  322. }
  323. } elsif ($do_checkexist) {
  324. &check_existing(*ssl_list, @ssl_symbols)
  325. if $do_ssl == 1;
  326. &check_existing(*crypto_list, @crypto_symbols)
  327. if $do_crypto == 1;
  328. } elsif ($do_ctest || $do_ctestall) {
  329. print <<"EOF";
  330. /* Test file to check all DEF file symbols are present by trying
  331. * to link to all of them. This is *not* intended to be run!
  332. */
  333. int main()
  334. {
  335. EOF
  336. &print_test_file(*STDOUT,"SSLEAY",*ssl_list,$do_ctestall,@ssl_symbols)
  337. if $do_ssl == 1;
  338. &print_test_file(*STDOUT,"LIBEAY",*crypto_list,$do_ctestall,@crypto_symbols)
  339. if $do_crypto == 1;
  340. print "}\n";
  341. } else {
  342. &print_def_file(*STDOUT,$libname,*ssl_list,@ssl_symbols)
  343. if $do_ssl == 1;
  344. &print_def_file(*STDOUT,$libname,*crypto_list,@crypto_symbols)
  345. if $do_crypto == 1;
  346. }
  347. sub do_defs
  348. {
  349. my($name,$files,$symhacksfile)=@_;
  350. my $file;
  351. my @ret;
  352. my %syms;
  353. my %platform; # For anything undefined, we assume ""
  354. my %kind; # For anything undefined, we assume "FUNCTION"
  355. my %algorithm; # For anything undefined, we assume ""
  356. my %variant;
  357. my %variant_cnt; # To be able to allocate "name{n}" if "name"
  358. # is the same name as the original.
  359. my $cpp;
  360. my %unknown_algorithms = ();
  361. foreach $file (split(/\s+/,$symhacksfile." ".$files))
  362. {
  363. print STDERR "DEBUG: starting on $file:\n" if $debug;
  364. open(IN,"<$file") || die "unable to open $file:$!\n";
  365. my $line = "", my $def= "";
  366. my %tag = (
  367. (map { $_ => 0 } @known_platforms),
  368. (map { "OPENSSL_SYS_".$_ => 0 } @known_ossl_platforms),
  369. (map { "OPENSSL_NO_".$_ => 0 } @known_algorithms),
  370. NOPROTO => 0,
  371. PERL5 => 0,
  372. _WINDLL => 0,
  373. CONST_STRICT => 0,
  374. TRUE => 1,
  375. );
  376. my $symhacking = $file eq $symhacksfile;
  377. my @current_platforms = ();
  378. my @current_algorithms = ();
  379. # params: symbol, alias, platforms, kind
  380. # The reason to put this subroutine in a variable is that
  381. # it will otherwise create it's own, unshared, version of
  382. # %tag and %variant...
  383. my $make_variant = sub
  384. {
  385. my ($s, $a, $p, $k) = @_;
  386. my ($a1, $a2);
  387. print STDERR "DEBUG: make_variant: Entered with ",$s,", ",$a,", ",(defined($p)?$p:""),", ",(defined($k)?$k:""),"\n" if $debug;
  388. if (defined($p))
  389. {
  390. $a1 = join(",",$p,
  391. grep(!/^$/,
  392. map { $tag{$_} == 1 ? $_ : "" }
  393. @known_platforms));
  394. }
  395. else
  396. {
  397. $a1 = join(",",
  398. grep(!/^$/,
  399. map { $tag{$_} == 1 ? $_ : "" }
  400. @known_platforms));
  401. }
  402. $a2 = join(",",
  403. grep(!/^$/,
  404. map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ : "" }
  405. @known_ossl_platforms));
  406. print STDERR "DEBUG: make_variant: a1 = $a1; a2 = $a2\n" if $debug;
  407. if ($a1 eq "") { $a1 = $a2; }
  408. elsif ($a1 ne "" && $a2 ne "") { $a1 .= ",".$a2; }
  409. if ($a eq $s)
  410. {
  411. if (!defined($variant_cnt{$s}))
  412. {
  413. $variant_cnt{$s} = 0;
  414. }
  415. $variant_cnt{$s}++;
  416. $a .= "{$variant_cnt{$s}}";
  417. }
  418. my $toadd = $a.":".$a1.(defined($k)?":".$k:"");
  419. my $togrep = $s.'(\{[0-9]+\})?:'.$a1.(defined($k)?":".$k:"");
  420. if (!grep(/^$togrep$/,
  421. split(/;/, defined($variant{$s})?$variant{$s}:""))) {
  422. if (defined($variant{$s})) { $variant{$s} .= ";"; }
  423. $variant{$s} .= $toadd;
  424. }
  425. print STDERR "DEBUG: make_variant: Exit with variant of ",$s," = ",$variant{$s},"\n" if $debug;
  426. };
  427. print STDERR "DEBUG: parsing ----------\n" if $debug;
  428. while(<IN>) {
  429. if (/\/\* Error codes for the \w+ functions\. \*\//)
  430. {
  431. undef @tag;
  432. last;
  433. }
  434. if ($line ne '') {
  435. $_ = $line . $_;
  436. $line = '';
  437. }
  438. if (/\\$/) {
  439. chomp; # remove eol
  440. chop; # remove ending backslash
  441. $line = $_;
  442. next;
  443. }
  444. if(/\/\*/) {
  445. if (not /\*\//) { # multiline comment...
  446. $line = $_; # ... just accumulate
  447. next;
  448. } else {
  449. s/\/\*.*?\*\///gs;# wipe it
  450. }
  451. }
  452. if ($cpp) {
  453. $cpp++ if /^#\s*if/;
  454. $cpp-- if /^#\s*endif/;
  455. next;
  456. }
  457. $cpp = 1 if /^#.*ifdef.*cplusplus/;
  458. s/{[^{}]*}//gs; # ignore {} blocks
  459. print STDERR "DEBUG: \$def=\"$def\"\n" if $debug && $def ne "";
  460. print STDERR "DEBUG: \$_=\"$_\"\n" if $debug;
  461. if (/^\#\s*ifndef\s+(.*)/) {
  462. push(@tag,"-");
  463. push(@tag,$1);
  464. $tag{$1}=-1;
  465. print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
  466. } elsif (/^\#\s*if\s+!defined\(([^\)]+)\)/) {
  467. push(@tag,"-");
  468. if (/^\#\s*if\s+(!defined\(([^\)]+)\)(\s+\&\&\s+!defined\(([^\)]+)\))*)$/) {
  469. my $tmp_1 = $1;
  470. my $tmp_;
  471. foreach $tmp_ (split '\&\&',$tmp_1) {
  472. $tmp_ =~ /!defined\(([^\)]+)\)/;
  473. print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
  474. push(@tag,$1);
  475. $tag{$1}=-1;
  476. }
  477. } else {
  478. print STDERR "Warning: $file: complicated expression: $_" if $debug; # because it is O...
  479. print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
  480. push(@tag,$1);
  481. $tag{$1}=-1;
  482. }
  483. } elsif (/^\#\s*ifdef\s+(\S*)/) {
  484. push(@tag,"-");
  485. push(@tag,$1);
  486. $tag{$1}=1;
  487. print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
  488. } elsif (/^\#\s*if\s+defined\(([^\)]+)\)/) {
  489. push(@tag,"-");
  490. if (/^\#\s*if\s+(defined\(([^\)]+)\)(\s+\|\|\s+defined\(([^\)]+)\))*)$/) {
  491. my $tmp_1 = $1;
  492. my $tmp_;
  493. foreach $tmp_ (split '\|\|',$tmp_1) {
  494. $tmp_ =~ /defined\(([^\)]+)\)/;
  495. print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
  496. push(@tag,$1);
  497. $tag{$1}=1;
  498. }
  499. } else {
  500. print STDERR "Warning: $file: complicated expression: $_\n" if $debug; # because it is O...
  501. print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
  502. push(@tag,$1);
  503. $tag{$1}=1;
  504. }
  505. } elsif (/^\#\s*error\s+(\w+) is disabled\./) {
  506. my $tag_i = $#tag;
  507. while($tag[$tag_i] ne "-") {
  508. if ($tag[$tag_i] eq "OPENSSL_NO_".$1) {
  509. $tag{$tag[$tag_i]}=2;
  510. print STDERR "DEBUG: $file: chaged tag $1 = 2\n" if $debug;
  511. }
  512. $tag_i--;
  513. }
  514. } elsif (/^\#\s*endif/) {
  515. my $tag_i = $#tag;
  516. while($tag_i > 0 && $tag[$tag_i] ne "-") {
  517. my $t=$tag[$tag_i];
  518. print STDERR "DEBUG: \$t=\"$t\"\n" if $debug;
  519. if ($tag{$t}==2) {
  520. $tag{$t}=-1;
  521. } else {
  522. $tag{$t}=0;
  523. }
  524. print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
  525. pop(@tag);
  526. if ($t =~ /^OPENSSL_NO_([A-Z0-9_]+)$/) {
  527. $t=$1;
  528. } else {
  529. $t="";
  530. }
  531. if ($t ne ""
  532. && !grep(/^$t$/, @known_algorithms)) {
  533. $unknown_algorithms{$t} = 1;
  534. #print STDERR "DEBUG: Added as unknown algorithm: $t\n" if $debug;
  535. }
  536. $tag_i--;
  537. }
  538. pop(@tag);
  539. } elsif (/^\#\s*else/) {
  540. my $tag_i = $#tag;
  541. while($tag[$tag_i] ne "-") {
  542. my $t=$tag[$tag_i];
  543. $tag{$t}= -$tag{$t};
  544. print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
  545. $tag_i--;
  546. }
  547. } elsif (/^\#\s*if\s+1/) {
  548. push(@tag,"-");
  549. # Dummy tag
  550. push(@tag,"TRUE");
  551. $tag{"TRUE"}=1;
  552. print STDERR "DEBUG: $file: found 1\n" if $debug;
  553. } elsif (/^\#\s*if\s+0/) {
  554. push(@tag,"-");
  555. # Dummy tag
  556. push(@tag,"TRUE");
  557. $tag{"TRUE"}=-1;
  558. print STDERR "DEBUG: $file: found 0\n" if $debug;
  559. } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/
  560. && $symhacking && $tag{'TRUE'} != -1) {
  561. # This is for aliasing. When we find an alias,
  562. # we have to invert
  563. &$make_variant($1,$2);
  564. print STDERR "DEBUG: $file: defined $1 = $2\n" if $debug;
  565. }
  566. if (/^\#/) {
  567. @current_platforms =
  568. grep(!/^$/,
  569. map { $tag{$_} == 1 ? $_ :
  570. $tag{$_} == -1 ? "!".$_ : "" }
  571. @known_platforms);
  572. push @current_platforms
  573. , grep(!/^$/,
  574. map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ :
  575. $tag{"OPENSSL_SYS_".$_} == -1 ? "!".$_ : "" }
  576. @known_ossl_platforms);
  577. @current_algorithms =
  578. grep(!/^$/,
  579. map { $tag{"OPENSSL_NO_".$_} == -1 ? $_ : "" }
  580. @known_algorithms);
  581. $def .=
  582. "#INFO:"
  583. .join(',',@current_platforms).":"
  584. .join(',',@current_algorithms).";";
  585. next;
  586. }
  587. if ($tag{'TRUE'} != -1) {
  588. if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
  589. next;
  590. } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
  591. $def .= "int d2i_$3(void);";
  592. $def .= "int i2d_$3(void);";
  593. # Variant for platforms that do not
  594. # have to access globale variables
  595. # in shared libraries through functions
  596. $def .=
  597. "#INFO:"
  598. .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
  599. .join(',',@current_algorithms).";";
  600. $def .= "OPENSSL_EXTERN int $2_it;";
  601. $def .=
  602. "#INFO:"
  603. .join(',',@current_platforms).":"
  604. .join(',',@current_algorithms).";";
  605. # Variant for platforms that have to
  606. # access globale variables in shared
  607. # libraries through functions
  608. &$make_variant("$2_it","$2_it",
  609. "EXPORT_VAR_AS_FUNCTION",
  610. "FUNCTION");
  611. next;
  612. } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_fname\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
  613. $def .= "int d2i_$3(void);";
  614. $def .= "int i2d_$3(void);";
  615. $def .= "int $3_free(void);";
  616. $def .= "int $3_new(void);";
  617. # Variant for platforms that do not
  618. # have to access globale variables
  619. # in shared libraries through functions
  620. $def .=
  621. "#INFO:"
  622. .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
  623. .join(',',@current_algorithms).";";
  624. $def .= "OPENSSL_EXTERN int $2_it;";
  625. $def .=
  626. "#INFO:"
  627. .join(',',@current_platforms).":"
  628. .join(',',@current_algorithms).";";
  629. # Variant for platforms that have to
  630. # access globale variables in shared
  631. # libraries through functions
  632. &$make_variant("$2_it","$2_it",
  633. "EXPORT_VAR_AS_FUNCTION",
  634. "FUNCTION");
  635. next;
  636. } elsif (/^\s*DECLARE_ASN1_FUNCTIONS\s*\(\s*(\w*)\s*\)/ ||
  637. /^\s*DECLARE_ASN1_FUNCTIONS_const\s*\(\s*(\w*)\s*\)/) {
  638. $def .= "int d2i_$1(void);";
  639. $def .= "int i2d_$1(void);";
  640. $def .= "int $1_free(void);";
  641. $def .= "int $1_new(void);";
  642. # Variant for platforms that do not
  643. # have to access globale variables
  644. # in shared libraries through functions
  645. $def .=
  646. "#INFO:"
  647. .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
  648. .join(',',@current_algorithms).";";
  649. $def .= "OPENSSL_EXTERN int $1_it;";
  650. $def .=
  651. "#INFO:"
  652. .join(',',@current_platforms).":"
  653. .join(',',@current_algorithms).";";
  654. # Variant for platforms that have to
  655. # access globale variables in shared
  656. # libraries through functions
  657. &$make_variant("$1_it","$1_it",
  658. "EXPORT_VAR_AS_FUNCTION",
  659. "FUNCTION");
  660. next;
  661. } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS_const\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
  662. $def .= "int d2i_$2(void);";
  663. $def .= "int i2d_$2(void);";
  664. # Variant for platforms that do not
  665. # have to access globale variables
  666. # in shared libraries through functions
  667. $def .=
  668. "#INFO:"
  669. .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
  670. .join(',',@current_algorithms).";";
  671. $def .= "OPENSSL_EXTERN int $2_it;";
  672. $def .=
  673. "#INFO:"
  674. .join(',',@current_platforms).":"
  675. .join(',',@current_algorithms).";";
  676. # Variant for platforms that have to
  677. # access globale variables in shared
  678. # libraries through functions
  679. &$make_variant("$2_it","$2_it",
  680. "EXPORT_VAR_AS_FUNCTION",
  681. "FUNCTION");
  682. next;
  683. } elsif (/^\s*DECLARE_ASN1_ALLOC_FUNCTIONS\s*\(\s*(\w*)\s*\)/) {
  684. $def .= "int $1_free(void);";
  685. $def .= "int $1_new(void);";
  686. next;
  687. } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
  688. $def .= "int d2i_$2(void);";
  689. $def .= "int i2d_$2(void);";
  690. $def .= "int $2_free(void);";
  691. $def .= "int $2_new(void);";
  692. # Variant for platforms that do not
  693. # have to access globale variables
  694. # in shared libraries through functions
  695. $def .=
  696. "#INFO:"
  697. .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
  698. .join(',',@current_algorithms).";";
  699. $def .= "OPENSSL_EXTERN int $2_it;";
  700. $def .=
  701. "#INFO:"
  702. .join(',',@current_platforms).":"
  703. .join(',',@current_algorithms).";";
  704. # Variant for platforms that have to
  705. # access globale variables in shared
  706. # libraries through functions
  707. &$make_variant("$2_it","$2_it",
  708. "EXPORT_VAR_AS_FUNCTION",
  709. "FUNCTION");
  710. next;
  711. } elsif (/^\s*DECLARE_ASN1_ITEM\s*\(\s*(\w*)\s*\)/) {
  712. # Variant for platforms that do not
  713. # have to access globale variables
  714. # in shared libraries through functions
  715. $def .=
  716. "#INFO:"
  717. .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
  718. .join(',',@current_algorithms).";";
  719. $def .= "OPENSSL_EXTERN int $1_it;";
  720. $def .=
  721. "#INFO:"
  722. .join(',',@current_platforms).":"
  723. .join(',',@current_algorithms).";";
  724. # Variant for platforms that have to
  725. # access globale variables in shared
  726. # libraries through functions
  727. &$make_variant("$1_it","$1_it",
  728. "EXPORT_VAR_AS_FUNCTION",
  729. "FUNCTION");
  730. next;
  731. } elsif (/^\s*DECLARE_ASN1_NDEF_FUNCTION\s*\(\s*(\w*)\s*\)/) {
  732. $def .= "int i2d_$1_NDEF(void);";
  733. } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
  734. next;
  735. } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION\s*\(\s*(\w*)\s*\)/) {
  736. $def .= "int $1_print_ctx(void);";
  737. next;
  738. } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
  739. $def .= "int $2_print_ctx(void);";
  740. next;
  741. } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
  742. next;
  743. } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
  744. /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ||
  745. /^DECLARE_PEM_rw_const\s*\(\s*(\w*)\s*,/ ) {
  746. # Things not in Win16
  747. $def .=
  748. "#INFO:"
  749. .join(',',"!WIN16",@current_platforms).":"
  750. .join(',',@current_algorithms).";";
  751. $def .= "int PEM_read_$1(void);";
  752. $def .= "int PEM_write_$1(void);";
  753. $def .=
  754. "#INFO:"
  755. .join(',',@current_platforms).":"
  756. .join(',',@current_algorithms).";";
  757. # Things that are everywhere
  758. $def .= "int PEM_read_bio_$1(void);";
  759. $def .= "int PEM_write_bio_$1(void);";
  760. next;
  761. } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
  762. /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
  763. # Things not in Win16
  764. $def .=
  765. "#INFO:"
  766. .join(',',"!WIN16",@current_platforms).":"
  767. .join(',',@current_algorithms).";";
  768. $def .= "int PEM_write_$1(void);";
  769. $def .=
  770. "#INFO:"
  771. .join(',',@current_platforms).":"
  772. .join(',',@current_algorithms).";";
  773. # Things that are everywhere
  774. $def .= "int PEM_write_bio_$1(void);";
  775. next;
  776. } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
  777. /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
  778. # Things not in Win16
  779. $def .=
  780. "#INFO:"
  781. .join(',',"!WIN16",@current_platforms).":"
  782. .join(',',@current_algorithms).";";
  783. $def .= "int PEM_read_$1(void);";
  784. $def .=
  785. "#INFO:"
  786. .join(',',@current_platforms).":"
  787. .join(',',@current_algorithms).";";
  788. # Things that are everywhere
  789. $def .= "int PEM_read_bio_$1(void);";
  790. next;
  791. } elsif (/^OPENSSL_DECLARE_GLOBAL\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
  792. # Variant for platforms that do not
  793. # have to access globale variables
  794. # in shared libraries through functions
  795. $def .=
  796. "#INFO:"
  797. .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
  798. .join(',',@current_algorithms).";";
  799. $def .= "OPENSSL_EXTERN int _shadow_$2;";
  800. $def .=
  801. "#INFO:"
  802. .join(',',@current_platforms).":"
  803. .join(',',@current_algorithms).";";
  804. # Variant for platforms that have to
  805. # access globale variables in shared
  806. # libraries through functions
  807. &$make_variant("_shadow_$2","_shadow_$2",
  808. "EXPORT_VAR_AS_FUNCTION",
  809. "FUNCTION");
  810. } elsif ($tag{'CONST_STRICT'} != 1) {
  811. if (/\{|\/\*|\([^\)]*$/) {
  812. $line = $_;
  813. } else {
  814. $def .= $_;
  815. }
  816. }
  817. }
  818. }
  819. close(IN);
  820. my $algs;
  821. my $plays;
  822. print STDERR "DEBUG: postprocessing ----------\n" if $debug;
  823. foreach (split /;/, $def) {
  824. my $s; my $k = "FUNCTION"; my $p; my $a;
  825. s/^[\n\s]*//g;
  826. s/[\n\s]*$//g;
  827. next if(/\#undef/);
  828. next if(/typedef\W/);
  829. next if(/\#define/);
  830. # Reduce argument lists to empty ()
  831. # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {}
  832. while(/\(.*\)/s) {
  833. s/\([^\(\)]+\)/\{\}/gs;
  834. s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs; #(*f{}) -> f
  835. }
  836. # pretend as we didn't use curly braces: {} -> ()
  837. s/\{\}/\(\)/gs;
  838. s/STACK_OF\(\)/void/gs;
  839. s/LHASH_OF\(\)/void/gs;
  840. print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug;
  841. if (/^\#INFO:([^:]*):(.*)$/) {
  842. $plats = $1;
  843. $algs = $2;
  844. print STDERR "DEBUG: found info on platforms ($plats) and algorithms ($algs)\n" if $debug;
  845. next;
  846. } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+(\{[0-9]+\})?)(\[[0-9]*\])*\s*$/) {
  847. $s = $1;
  848. $k = "VARIABLE";
  849. print STDERR "DEBUG: found external variable $s\n" if $debug;
  850. } elsif (/TYPEDEF_\w+_OF/s) {
  851. next;
  852. } elsif (/(\w+)\s*\(\).*/s) { # first token prior [first] () is
  853. $s = $1; # a function name!
  854. print STDERR "DEBUG: found function $s\n" if $debug;
  855. } elsif (/\(/ and not (/=/)) {
  856. print STDERR "File $file: cannot parse: $_;\n";
  857. next;
  858. } else {
  859. next;
  860. }
  861. $syms{$s} = 1;
  862. $kind{$s} = $k;
  863. $p = $plats;
  864. $a = $algs;
  865. $a .= ",BF" if($s =~ /EVP_bf/);
  866. $a .= ",CAST" if($s =~ /EVP_cast/);
  867. $a .= ",DES" if($s =~ /EVP_des/);
  868. $a .= ",DSA" if($s =~ /EVP_dss/);
  869. $a .= ",IDEA" if($s =~ /EVP_idea/);
  870. $a .= ",MD2" if($s =~ /EVP_md2/);
  871. $a .= ",MD4" if($s =~ /EVP_md4/);
  872. $a .= ",MD5" if($s =~ /EVP_md5/);
  873. $a .= ",RC2" if($s =~ /EVP_rc2/);
  874. $a .= ",RC4" if($s =~ /EVP_rc4/);
  875. $a .= ",RC5" if($s =~ /EVP_rc5/);
  876. $a .= ",RIPEMD" if($s =~ /EVP_ripemd/);
  877. $a .= ",SHA" if($s =~ /EVP_sha/);
  878. $a .= ",RSA" if($s =~ /EVP_(Open|Seal)(Final|Init)/);
  879. $a .= ",RSA" if($s =~ /PEM_Seal(Final|Init|Update)/);
  880. $a .= ",RSA" if($s =~ /RSAPrivateKey/);
  881. $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/);
  882. $platform{$s} =
  883. &reduce_platforms((defined($platform{$s})?$platform{$s}.',':"").$p);
  884. $algorithm{$s} .= ','.$a;
  885. if (defined($variant{$s})) {
  886. foreach $v (split /;/,$variant{$s}) {
  887. (my $r, my $p, my $k) = split(/:/,$v);
  888. my $ip = join ',',map({ /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p);
  889. $syms{$r} = 1;
  890. if (!defined($k)) { $k = $kind{$s}; }
  891. $kind{$r} = $k."(".$s.")";
  892. $algorithm{$r} = $algorithm{$s};
  893. $platform{$r} = &reduce_platforms($platform{$s}.",".$p.",".$p);
  894. $platform{$s} = &reduce_platforms($platform{$s}.','.$ip.','.$ip);
  895. print STDERR "DEBUG: \$variant{\"$s\"} = ",$v,"; \$r = $r; \$p = ",$platform{$r},"; \$a = ",$algorithm{$r},"; \$kind = ",$kind{$r},"\n" if $debug;
  896. }
  897. }
  898. print STDERR "DEBUG: \$s = $s; \$p = ",$platform{$s},"; \$a = ",$algorithm{$s},"; \$kind = ",$kind{$s},"\n" if $debug;
  899. }
  900. }
  901. # Prune the returned symbols
  902. delete $syms{"bn_dump1"};
  903. $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
  904. $platform{"PEM_read_NS_CERT_SEQ"} = "VMS";
  905. $platform{"PEM_write_NS_CERT_SEQ"} = "VMS";
  906. $platform{"PEM_read_P8_PRIV_KEY_INFO"} = "VMS";
  907. $platform{"PEM_write_P8_PRIV_KEY_INFO"} = "VMS";
  908. $platform{"EVP_sha384"} = "!VMSVAX";
  909. $platform{"EVP_sha512"} = "!VMSVAX";
  910. $platform{"SHA384_Init"} = "!VMSVAX";
  911. $platform{"SHA384_Transform"} = "!VMSVAX";
  912. $platform{"SHA384_Update"} = "!VMSVAX";
  913. $platform{"SHA384_Final"} = "!VMSVAX";
  914. $platform{"SHA384"} = "!VMSVAX";
  915. $platform{"SHA512_Init"} = "!VMSVAX";
  916. $platform{"SHA512_Transform"} = "!VMSVAX";
  917. $platform{"SHA512_Update"} = "!VMSVAX";
  918. $platform{"SHA512_Final"} = "!VMSVAX";
  919. $platform{"SHA512"} = "!VMSVAX";
  920. # Info we know about
  921. push @ret, map { $_."\\".&info_string($_,"EXIST",
  922. $platform{$_},
  923. $kind{$_},
  924. $algorithm{$_}) } keys %syms;
  925. if (keys %unknown_algorithms) {
  926. print STDERR "WARNING: mkdef.pl doesn't know the following algorithms:\n";
  927. print STDERR "\t",join("\n\t",keys %unknown_algorithms),"\n";
  928. }
  929. return(@ret);
  930. }
  931. # Param: string of comma-separated platform-specs.
  932. sub reduce_platforms
  933. {
  934. my ($platforms) = @_;
  935. my $pl = defined($platforms) ? $platforms : "";
  936. my %p = map { $_ => 0 } split /,/, $pl;
  937. my $ret;
  938. print STDERR "DEBUG: Entered reduce_platforms with \"$platforms\"\n"
  939. if $debug;
  940. # We do this, because if there's code like the following, it really
  941. # means the function exists in all cases and should therefore be
  942. # everywhere. By increasing and decreasing, we may attain 0:
  943. #
  944. # ifndef WIN16
  945. # int foo();
  946. # else
  947. # int _fat foo();
  948. # endif
  949. foreach $platform (split /,/, $pl) {
  950. if ($platform =~ /^!(.*)$/) {
  951. $p{$1}--;
  952. } else {
  953. $p{$platform}++;
  954. }
  955. }
  956. foreach $platform (keys %p) {
  957. if ($p{$platform} == 0) { delete $p{$platform}; }
  958. }
  959. delete $p{""};
  960. $ret = join(',',sort(map { $p{$_} < 0 ? "!".$_ : $_ } keys %p));
  961. print STDERR "DEBUG: Exiting reduce_platforms with \"$ret\"\n"
  962. if $debug;
  963. return $ret;
  964. }
  965. sub info_string {
  966. (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_;
  967. my %a = defined($algorithms) ?
  968. map { $_ => 1 } split /,/, $algorithms : ();
  969. my $k = defined($kind) ? $kind : "FUNCTION";
  970. my $ret;
  971. my $p = &reduce_platforms($platforms);
  972. delete $a{""};
  973. $ret = $exist;
  974. $ret .= ":".$p;
  975. $ret .= ":".$k;
  976. $ret .= ":".join(',',sort keys %a);
  977. return $ret;
  978. }
  979. sub maybe_add_info {
  980. (my $name, *nums, my @symbols) = @_;
  981. my $sym;
  982. my $new_info = 0;
  983. my %syms=();
  984. print STDERR "Updating $name info\n";
  985. foreach $sym (@symbols) {
  986. (my $s, my $i) = split /\\/, $sym;
  987. if (defined($nums{$s})) {
  988. $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
  989. (my $n, my $dummy) = split /\\/, $nums{$s};
  990. if (!defined($dummy) || $i ne $dummy) {
  991. $nums{$s} = $n."\\".$i;
  992. $new_info++;
  993. print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n" if $debug;
  994. }
  995. }
  996. $syms{$s} = 1;
  997. }
  998. my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
  999. foreach $sym (@s) {
  1000. (my $n, my $i) = split /\\/, $nums{$sym};
  1001. if (!defined($syms{$sym}) && $i !~ /^NOEXIST:/) {
  1002. $new_info++;
  1003. print STDERR "DEBUG: maybe_add_info for $sym: -> undefined\n" if $debug;
  1004. }
  1005. }
  1006. if ($new_info) {
  1007. print STDERR "$new_info old symbols got an info update\n";
  1008. if (!$do_rewrite) {
  1009. print STDERR "You should do a rewrite to fix this.\n";
  1010. }
  1011. } else {
  1012. print STDERR "No old symbols needed info update\n";
  1013. }
  1014. }
  1015. # Param: string of comma-separated keywords, each possibly prefixed with a "!"
  1016. sub is_valid
  1017. {
  1018. my ($keywords_txt,$platforms) = @_;
  1019. my (@keywords) = split /,/,$keywords_txt;
  1020. my ($falsesum, $truesum) = (0, 1);
  1021. # Param: one keyword
  1022. sub recognise
  1023. {
  1024. my ($keyword,$platforms) = @_;
  1025. if ($platforms) {
  1026. # platforms
  1027. if ($keyword eq "VMSVAX" && $VMSVAX) { return 1; }
  1028. if ($keyword eq "VMSNonVAX" && $VMSNonVAX) { return 1; }
  1029. if ($keyword eq "VMS" && $VMS) { return 1; }
  1030. if ($keyword eq "WIN32" && $W32) { return 1; }
  1031. if ($keyword eq "WIN16" && $W16) { return 1; }
  1032. if ($keyword eq "WINNT" && $NT) { return 1; }
  1033. if ($keyword eq "OS2" && $OS2) { return 1; }
  1034. # Special platforms:
  1035. # EXPORT_VAR_AS_FUNCTION means that global variables
  1036. # will be represented as functions. This currently
  1037. # only happens on VMS-VAX.
  1038. if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) {
  1039. return 1;
  1040. }
  1041. if ($keyword eq "ZLIB" && $zlib) { return 1; }
  1042. return 0;
  1043. } else {
  1044. # algorithms
  1045. if ($keyword eq "RC2" && $no_rc2) { return 0; }
  1046. if ($keyword eq "RC4" && $no_rc4) { return 0; }
  1047. if ($keyword eq "RC5" && $no_rc5) { return 0; }
  1048. if ($keyword eq "IDEA" && $no_idea) { return 0; }
  1049. if ($keyword eq "DES" && $no_des) { return 0; }
  1050. if ($keyword eq "BF" && $no_bf) { return 0; }
  1051. if ($keyword eq "CAST" && $no_cast) { return 0; }
  1052. if ($keyword eq "MD2" && $no_md2) { return 0; }
  1053. if ($keyword eq "MD4" && $no_md4) { return 0; }
  1054. if ($keyword eq "MD5" && $no_md5) { return 0; }
  1055. if ($keyword eq "SHA" && $no_sha) { return 0; }
  1056. if ($keyword eq "RIPEMD" && $no_ripemd) { return 0; }
  1057. if ($keyword eq "MDC2" && $no_mdc2) { return 0; }
  1058. if ($keyword eq "WHIRLPOOL" && $no_whirlpool) { return 0; }
  1059. if ($keyword eq "RSA" && $no_rsa) { return 0; }
  1060. if ($keyword eq "DSA" && $no_dsa) { return 0; }
  1061. if ($keyword eq "DH" && $no_dh) { return 0; }
  1062. if ($keyword eq "EC" && $no_ec) { return 0; }
  1063. if ($keyword eq "ECDSA" && $no_ecdsa) { return 0; }
  1064. if ($keyword eq "ECDH" && $no_ecdh) { return 0; }
  1065. if ($keyword eq "HMAC" && $no_hmac) { return 0; }
  1066. if ($keyword eq "AES" && $no_aes) { return 0; }
  1067. if ($keyword eq "CAMELLIA" && $no_camellia) { return 0; }
  1068. if ($keyword eq "SEED" && $no_seed) { return 0; }
  1069. if ($keyword eq "EVP" && $no_evp) { return 0; }
  1070. if ($keyword eq "LHASH" && $no_lhash) { return 0; }
  1071. if ($keyword eq "STACK" && $no_stack) { return 0; }
  1072. if ($keyword eq "ERR" && $no_err) { return 0; }
  1073. if ($keyword eq "BUFFER" && $no_buffer) { return 0; }
  1074. if ($keyword eq "BIO" && $no_bio) { return 0; }
  1075. if ($keyword eq "COMP" && $no_comp) { return 0; }
  1076. if ($keyword eq "DSO" && $no_dso) { return 0; }
  1077. if ($keyword eq "KRB5" && $no_krb5) { return 0; }
  1078. if ($keyword eq "ENGINE" && $no_engine) { return 0; }
  1079. if ($keyword eq "HW" && $no_hw) { return 0; }
  1080. if ($keyword eq "FP_API" && $no_fp_api) { return 0; }
  1081. if ($keyword eq "STATIC_ENGINE" && $no_static_engine) { return 0; }
  1082. if ($keyword eq "GMP" && $no_gmp) { return 0; }
  1083. if ($keyword eq "RFC3779" && $no_rfc3779) { return 0; }
  1084. if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; }
  1085. if ($keyword eq "PSK" && $no_psk) { return 0; }
  1086. if ($keyword eq "CMS" && $no_cms) { return 0; }
  1087. if ($keyword eq "SSL2" && $no_ssl2) { return 0; }
  1088. if ($keyword eq "CAPIENG" && $no_capieng) { return 0; }
  1089. if ($keyword eq "JPAKE" && $no_jpake) { return 0; }
  1090. if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; }
  1091. # Nothing recognise as true
  1092. return 1;
  1093. }
  1094. }
  1095. foreach $k (@keywords) {
  1096. if ($k =~ /^!(.*)$/) {
  1097. $falsesum += &recognise($1,$platforms);
  1098. } else {
  1099. $truesum *= &recognise($k,$platforms);
  1100. }
  1101. }
  1102. print STDERR "DEBUG: [",$#keywords,",",$#keywords < 0,"] is_valid($keywords_txt) => (\!$falsesum) && $truesum = ",(!$falsesum) && $truesum,"\n" if $debug;
  1103. return (!$falsesum) && $truesum;
  1104. }
  1105. sub print_test_file
  1106. {
  1107. (*OUT,my $name,*nums,my $testall,my @symbols)=@_;
  1108. my $n = 1; my @e; my @r;
  1109. my $sym; my $prev = ""; my $prefSSLeay;
  1110. (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
  1111. (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:.*/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
  1112. @symbols=((sort @e),(sort @r));
  1113. foreach $sym (@symbols) {
  1114. (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
  1115. my $v = 0;
  1116. $v = 1 if $i=~ /^.*?:.*?:VARIABLE/;
  1117. my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
  1118. my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
  1119. if (!defined($nums{$s})) {
  1120. print STDERR "Warning: $s does not have a number assigned\n"
  1121. if(!$do_update);
  1122. } elsif (is_valid($p,1) && is_valid($a,0)) {
  1123. my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
  1124. if ($prev eq $s2) {
  1125. print OUT "\t/* The following has already appeared previously */\n";
  1126. print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
  1127. }
  1128. $prev = $s2; # To warn about duplicates...
  1129. ($nn,$ni)=($nums{$s2} =~ /^(.*?)\\(.*)$/);
  1130. if ($v) {
  1131. print OUT "\textern int $s2; /* type unknown */ /* $nn $ni */\n";
  1132. } else {
  1133. print OUT "\textern int $s2(); /* type unknown */ /* $nn $ni */\n";
  1134. }
  1135. }
  1136. }
  1137. }
  1138. sub get_version {
  1139. local *MF;
  1140. my $v = '?';
  1141. open MF, 'Makefile' or return $v;
  1142. while (<MF>) {
  1143. $v = $1, last if /^VERSION=(.*?)\s*$/;
  1144. }
  1145. close MF;
  1146. return $v;
  1147. }
  1148. sub print_def_file
  1149. {
  1150. (*OUT,my $name,*nums,my @symbols)=@_;
  1151. my $n = 1; my @e; my @r; my @v; my $prev="";
  1152. my $liboptions="";
  1153. my $libname = $name;
  1154. my $http_vendor = 'www.openssl.org/';
  1155. my $version = get_version();
  1156. my $what = "OpenSSL: implementation of Secure Socket Layer";
  1157. my $description = "$what $version, $name - http://$http_vendor";
  1158. if ($W32)
  1159. { $libname.="32"; }
  1160. elsif ($W16)
  1161. { $libname.="16"; }
  1162. elsif ($OS2)
  1163. { # DLL names should not clash on the whole system.
  1164. # However, they should not have any particular relationship
  1165. # to the name of the static library. Chose descriptive names
  1166. # (must be at most 8 chars).
  1167. my %translate = (ssl => 'open_ssl', crypto => 'cryptssl');
  1168. $libname = $translate{$name} || $name;
  1169. $liboptions = <<EOO;
  1170. INITINSTANCE
  1171. DATA MULTIPLE NONSHARED
  1172. EOO
  1173. # Vendor field can't contain colon, drat; so we omit http://
  1174. $description = "\@#$http_vendor:$version#\@$what; DLL for library $name. Build for EMX -Zmtd";
  1175. }
  1176. print OUT <<"EOF";
  1177. ;
  1178. ; Definition file for the DLL version of the $name library from OpenSSL
  1179. ;
  1180. LIBRARY $libname $liboptions
  1181. EOF
  1182. if ($W16) {
  1183. print <<"EOF";
  1184. CODE PRELOAD MOVEABLE
  1185. DATA PRELOAD MOVEABLE SINGLE
  1186. EXETYPE WINDOWS
  1187. HEAPSIZE 4096
  1188. STACKSIZE 8192
  1189. EOF
  1190. }
  1191. print "EXPORTS\n";
  1192. (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
  1193. (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:FUNCTION/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
  1194. (@v)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:VARIABLE/,@symbols);
  1195. @symbols=((sort @e),(sort @r), (sort @v));
  1196. foreach $sym (@symbols) {
  1197. (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
  1198. my $v = 0;
  1199. $v = 1 if $i =~ /^.*?:.*?:VARIABLE/;
  1200. if (!defined($nums{$s})) {
  1201. printf STDERR "Warning: $s does not have a number assigned\n"
  1202. if(!$do_update);
  1203. } else {
  1204. (my $n, my $dummy) = split /\\/, $nums{$s};
  1205. my %pf = ();
  1206. my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
  1207. my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
  1208. if (is_valid($p,1) && is_valid($a,0)) {
  1209. my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
  1210. if ($prev eq $s2) {
  1211. print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
  1212. }
  1213. $prev = $s2; # To warn about duplicates...
  1214. if($v && !$OS2) {
  1215. printf OUT " %s%-39s @%-8d DATA\n",($W32)?"":"_",$s2,$n;
  1216. } else {
  1217. printf OUT " %s%-39s @%d\n",($W32||$OS2)?"":"_",$s2,$n;
  1218. }
  1219. }
  1220. }
  1221. }
  1222. printf OUT "\n";
  1223. }
  1224. sub load_numbers
  1225. {
  1226. my($name)=@_;
  1227. my(@a,%ret);
  1228. $max_num = 0;
  1229. $num_noinfo = 0;
  1230. $prev = "";
  1231. $prev_cnt = 0;
  1232. open(IN,"<$name") || die "unable to open $name:$!\n";
  1233. while (<IN>) {
  1234. chop;
  1235. s/#.*$//;
  1236. next if /^\s*$/;
  1237. @a=split;
  1238. if (defined $ret{$a[0]}) {
  1239. # This is actually perfectly OK
  1240. #print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n";
  1241. }
  1242. if ($max_num > $a[1]) {
  1243. print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n";
  1244. }
  1245. elsif ($max_num == $a[1]) {
  1246. # This is actually perfectly OK
  1247. #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n";
  1248. if ($a[0] eq $prev) {
  1249. $prev_cnt++;
  1250. $a[0] .= "{$prev_cnt}";
  1251. }
  1252. }
  1253. else {
  1254. $prev_cnt = 0;
  1255. }
  1256. if ($#a < 2) {
  1257. # Existence will be proven later, in do_defs
  1258. $ret{$a[0]}=$a[1];
  1259. $num_noinfo++;
  1260. } else {
  1261. $ret{$a[0]}=$a[1]."\\".$a[2]; # \\ is a special marker
  1262. }
  1263. $max_num = $a[1] if $a[1] > $max_num;
  1264. $prev=$a[0];
  1265. }
  1266. if ($num_noinfo) {
  1267. print STDERR "Warning: $num_noinfo symbols were without info.";
  1268. if ($do_rewrite) {
  1269. printf STDERR " The rewrite will fix this.\n";
  1270. } else {
  1271. printf STDERR " You should do a rewrite to fix this.\n";
  1272. }
  1273. }
  1274. close(IN);
  1275. return(%ret);
  1276. }
  1277. sub parse_number
  1278. {
  1279. (my $str, my $what) = @_;
  1280. (my $n, my $i) = split(/\\/,$str);
  1281. if ($what eq "n") {
  1282. return $n;
  1283. } else {
  1284. return $i;
  1285. }
  1286. }
  1287. sub rewrite_numbers
  1288. {
  1289. (*OUT,$name,*nums,@symbols)=@_;
  1290. my $thing;
  1291. print STDERR "Rewriting $name\n";
  1292. my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
  1293. my $r; my %r; my %rsyms;
  1294. foreach $r (@r) {
  1295. (my $s, my $i) = split /\\/, $r;
  1296. my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
  1297. $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
  1298. $r{$a} = $s."\\".$i;
  1299. $rsyms{$s} = 1;
  1300. }
  1301. my %syms = ();
  1302. foreach $_ (@symbols) {
  1303. (my $n, my $i) = split /\\/;
  1304. $syms{$n} = 1;
  1305. }
  1306. my @s=sort {
  1307. &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n")
  1308. || $a cmp $b
  1309. } keys %nums;
  1310. foreach $sym (@s) {
  1311. (my $n, my $i) = split /\\/, $nums{$sym};
  1312. next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/;
  1313. next if defined($rsyms{$sym});
  1314. print STDERR "DEBUG: rewrite_numbers for sym = ",$sym,": i = ",$i,", n = ",$n,", rsym{sym} = ",$rsyms{$sym},"syms{sym} = ",$syms{$sym},"\n" if $debug;
  1315. $i="NOEXIST::FUNCTION:"
  1316. if !defined($i) || $i eq "" || !defined($syms{$sym});
  1317. my $s2 = $sym;
  1318. $s2 =~ s/\{[0-9]+\}$//;
  1319. printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
  1320. if (exists $r{$sym}) {
  1321. (my $s, $i) = split /\\/,$r{$sym};
  1322. my $s2 = $s;
  1323. $s2 =~ s/\{[0-9]+\}$//;
  1324. printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
  1325. }
  1326. }
  1327. }
  1328. sub update_numbers
  1329. {
  1330. (*OUT,$name,*nums,my $start_num, my @symbols)=@_;
  1331. my $new_syms = 0;
  1332. print STDERR "Updating $name numbers\n";
  1333. my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
  1334. my $r; my %r; my %rsyms;
  1335. foreach $r (@r) {
  1336. (my $s, my $i) = split /\\/, $r;
  1337. my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
  1338. $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
  1339. $r{$a} = $s."\\".$i;
  1340. $rsyms{$s} = 1;
  1341. }
  1342. foreach $sym (@symbols) {
  1343. (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
  1344. next if $i =~ /^.*?:.*?:\w+\(\w+\)/;
  1345. next if defined($rsyms{$sym});
  1346. die "ERROR: Symbol $sym had no info attached to it."
  1347. if $i eq "";
  1348. if (!exists $nums{$s}) {
  1349. $new_syms++;
  1350. my $s2 = $s;
  1351. $s2 =~ s/\{[0-9]+\}$//;
  1352. printf OUT "%s%-39s %d\t%s\n","",$s2, ++$start_num,$i;
  1353. if (exists $r{$s}) {
  1354. ($s, $i) = split /\\/,$r{$s};
  1355. $s =~ s/\{[0-9]+\}$//;
  1356. printf OUT "%s%-39s %d\t%s\n","",$s, $start_num,$i;
  1357. }
  1358. }
  1359. }
  1360. if($new_syms) {
  1361. print STDERR "$new_syms New symbols added\n";
  1362. } else {
  1363. print STDERR "No New symbols Added\n";
  1364. }
  1365. }
  1366. sub check_existing
  1367. {
  1368. (*nums, my @symbols)=@_;
  1369. my %existing; my @remaining;
  1370. @remaining=();
  1371. foreach $sym (@symbols) {
  1372. (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
  1373. $existing{$s}=1;
  1374. }
  1375. foreach $sym (keys %nums) {
  1376. if (!exists $existing{$sym}) {
  1377. push @remaining, $sym;
  1378. }
  1379. }
  1380. if(@remaining) {
  1381. print STDERR "The following symbols do not seem to exist:\n";
  1382. foreach $sym (@remaining) {
  1383. print STDERR "\t",$sym,"\n";
  1384. }
  1385. }
  1386. }