1#!/usr/bin/perl 2# 3# Copyright (C) 2004, 2007, 2009, 2012-2014 Internet Systems Consortium, Inc. ("ISC") 4# Copyright (C) 2001 Internet Software Consortium. 5# 6# Permission to use, copy, modify, and/or distribute this software for any 7# purpose with or without fee is hereby granted, provided that the above 8# copyright notice and this permission notice appear in all copies. 9# 10# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 11# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 13# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16# PERFORMANCE OF THIS SOFTWARE. 17 18# Id 19 20# makedefs.pl 21# This script goes through all of the lib header files and creates a .def file 22# for each DLL for Win32. It recurses as necessary through the subdirectories 23# 24# This program should only be run if it is necessary to regenerate 25# the .def files. Normally these files should be updated by hand, adding 26# new functions to the end and removing obsolete ones. 27# If you do regenerate them you will also need to modify them by hand to 28# to pick up those routines not detected by this program (like openlog). 29# 30# Search String: ^(([_a-z0-9])*( ))*prefix_[_a-z0-9]+_[a-z0-9]+( )*\( 31# List of directories 32 33@prefixlist = ("isc", "isccfg", "dns", "isccc", "bind9", "lwres", "irs"); 34@iscdirlist = ("isc/include/isc","isc/win32/include/isc","isc/include/pk11", 35 "isc/include/pkcs11","isc/win32/include/pkcs11"); 36@iscprefixlist = ("isc", "pk11", "pkcs"); 37 38@isccfgdirlist = ("isccfg/include/isccfg"); 39@isccfgprefixlist = ("cfg"); 40 41@iscccdirlist = ("isccc/include/isccc"); 42@iscccprefixlist = ("isccc"); 43 44@dnsdirlist = ("dns/include/dns","dns/include/dst"); 45@dnsprefixlist = ("dns", "dst"); 46 47@lwresdirlist = ("lwres/include/lwres","lwres/win32/include/lwres"); 48@lwresprefixlist = ("lwres"); 49 50@bind9dirlist = ("bind9/include/bind9"); 51@bind9prefixlist = ("bind9"); 52 53@irsdirlist = ("irs/include/irs","irs/win32/include/irs"); 54@irsprefixlist = ("irs"); 55 56# Run the changes for each directory in the directory list 57 58$ind = 0; 59createoutfile($iscprefixlist[0]); 60foreach $dir (@iscdirlist) { 61 createdeffile($dir, $iscprefixlist[$ind]); 62 $ind++; 63} 64close OUTDEFFILE; 65 66$ind = 0; 67createoutfile($isccfgprefixlist[0]); 68foreach $dir (@isccfgdirlist) { 69 createdeffile($dir, $isccfgprefixlist[$ind]); 70 $ind++; 71} 72close OUTDEFFILE; 73 74$ind = 0; 75createoutfile($dnsprefixlist[0]); 76foreach $dir (@dnsdirlist) { 77 createdeffile($dir, $dnsprefixlist[$ind]); 78 $ind++; 79} 80close OUTDEFFILE; 81 82$ind = 0; 83createoutfile($iscccprefixlist[0]); 84foreach $dir (@iscccdirlist) { 85 createdeffile($dir, $iscccprefixlist[$ind]); 86 $ind++; 87} 88close OUTDEFFILE; 89 90$ind = 0; 91createoutfile($lwresprefixlist[0]); 92foreach $dir (@lwresdirlist) { 93 createdeffile($dir, $lwresprefixlist[$ind]); 94 $ind++; 95} 96close OUTDEFFILE; 97 98$ind = 0; 99createoutfile($bind9prefixlist[0]); 100foreach $dir (@bind9dirlist) { 101 createdeffile($dir, $bind9prefixlist[$ind]); 102 $ind++; 103} 104close OUTDEFFILE; 105 106$ind = 0; 107createoutfile($irsprefixlist[0]); 108foreach $dir (@irsdirlist) { 109 createdeffile($dir, $irsprefixlist[$ind]); 110 $ind++; 111} 112close OUTDEFFILE; 113 114exit; 115 116# 117# Subroutines 118# 119sub createdeffile { 120 $xdir = $_[0]; 121 122 # 123 # Get the List of files in the directory to be processed. 124 # 125 #^(([_a-z0-9])*( ))*prefix_[_a-z]+_[a-z]+( )*\( 126 $prefix = $_[1]; 127 $pattern = "\^\(\(\[\_a\-z0\-9\]\)\*\( \)\)\*\(\\*\( \)\+\)\*$prefix"; 128 $pattern = "$pattern\_\[\_a\-z0\-9\]\+_\[a\-z0\-9\]\+\( \)\*\\\("; 129 130 opendir(DIR,$xdir) || die "No Directory: $!"; 131 @files = grep(/\.h$/i, readdir(DIR)); 132 closedir(DIR); 133 134 foreach $filename (sort @files) { 135 # 136 # Open the file and locate the pattern. 137 # 138 open (HFILE, "$xdir/$filename") || 139 die "Can't open file $filename : $!"; 140 141 while (<HFILE>) { 142 if(/$pattern/) { 143 $func = $&; 144 chop($func); 145 $space = rindex($func, " ") + 1; 146 if($space >= 0) { 147 # strip out return values 148 $func = substr($func, $space, 100); 149 } 150 print OUTDEFFILE "$func\n"; 151 } 152 } 153 # Set up the Patterns 154 close(HFILE); 155 } 156} 157 158# This is the routine that applies the changes 159 160# output the result to the platform specific directory. 161sub createoutfile { 162 $outfile = "lib$_[0].def"; 163 164 open (OUTDEFFILE, ">$outfile") 165 || die "Can't open output file $outfile: $!"; 166 print OUTDEFFILE "LIBRARY lib$_[0]\n"; 167 print OUTDEFFILE "\n"; 168 print OUTDEFFILE "; Exported Functions\n"; 169 print OUTDEFFILE "EXPORTS\n"; 170 print OUTDEFFILE "\n"; 171} 172