etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / win32utils / legacy / makedefs.pl
blobb49ab8754483c75376ad2a9cd7308ccec1455bd8
1 #!/usr/bin/perl
3 # Copyright (C) 2004, 2007, 2009, 2012-2014 Internet Systems Consortium, Inc. ("ISC")
4 # Copyright (C) 2001 Internet Software Consortium.
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.
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.
18 # Id
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
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).
30 # Search String: ^(([_a-z0-9])*( ))*prefix_[_a-z0-9]+_[a-z0-9]+( )*\(
31 # List of directories
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");
38 @isccfgdirlist = ("isccfg/include/isccfg");
39 @isccfgprefixlist = ("cfg");
41 @iscccdirlist = ("isccc/include/isccc");
42 @iscccprefixlist = ("isccc");
44 @dnsdirlist = ("dns/include/dns","dns/include/dst");
45 @dnsprefixlist = ("dns", "dst");
47 @lwresdirlist = ("lwres/include/lwres","lwres/win32/include/lwres");
48 @lwresprefixlist = ("lwres");
50 @bind9dirlist = ("bind9/include/bind9");
51 @bind9prefixlist = ("bind9");
53 @irsdirlist = ("irs/include/irs","irs/win32/include/irs");
54 @irsprefixlist = ("irs");
56 # Run the changes for each directory in the directory list
58 $ind = 0;
59 createoutfile($iscprefixlist[0]);
60 foreach $dir (@iscdirlist) {
61 createdeffile($dir, $iscprefixlist[$ind]);
62 $ind++;
64 close OUTDEFFILE;
66 $ind = 0;
67 createoutfile($isccfgprefixlist[0]);
68 foreach $dir (@isccfgdirlist) {
69 createdeffile($dir, $isccfgprefixlist[$ind]);
70 $ind++;
72 close OUTDEFFILE;
74 $ind = 0;
75 createoutfile($dnsprefixlist[0]);
76 foreach $dir (@dnsdirlist) {
77 createdeffile($dir, $dnsprefixlist[$ind]);
78 $ind++;
80 close OUTDEFFILE;
82 $ind = 0;
83 createoutfile($iscccprefixlist[0]);
84 foreach $dir (@iscccdirlist) {
85 createdeffile($dir, $iscccprefixlist[$ind]);
86 $ind++;
88 close OUTDEFFILE;
90 $ind = 0;
91 createoutfile($lwresprefixlist[0]);
92 foreach $dir (@lwresdirlist) {
93 createdeffile($dir, $lwresprefixlist[$ind]);
94 $ind++;
96 close OUTDEFFILE;
98 $ind = 0;
99 createoutfile($bind9prefixlist[0]);
100 foreach $dir (@bind9dirlist) {
101 createdeffile($dir, $bind9prefixlist[$ind]);
102 $ind++;
104 close OUTDEFFILE;
106 $ind = 0;
107 createoutfile($irsprefixlist[0]);
108 foreach $dir (@irsdirlist) {
109 createdeffile($dir, $irsprefixlist[$ind]);
110 $ind++;
112 close OUTDEFFILE;
114 exit;
117 # Subroutines
119 sub createdeffile {
120 $xdir = $_[0];
123 # Get the List of files in the directory to be processed.
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\]\+\( \)\*\\\(";
130 opendir(DIR,$xdir) || die "No Directory: $!";
131 @files = grep(/\.h$/i, readdir(DIR));
132 closedir(DIR);
134 foreach $filename (sort @files) {
136 # Open the file and locate the pattern.
138 open (HFILE, "$xdir/$filename") ||
139 die "Can't open file $filename : $!";
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);
150 print OUTDEFFILE "$func\n";
153 # Set up the Patterns
154 close(HFILE);
158 # This is the routine that applies the changes
160 # output the result to the platform specific directory.
161 sub createoutfile {
162 $outfile = "lib$_[0].def";
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";