tests: Use here-doc kadmin in Java test
[heimdal.git] / cf / w32-check-exported-symbols.pl
blob5de49ff403b2d05ac31726b722e9312ca4b575ea
1 ########################################################################
3 # Copyright (c) 2010, Secure Endpoints Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
10 # - Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
13 # - Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in
15 # the documentation and/or other materials provided with the
16 # distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
32 use Getopt::Long;
33 use Pod::Usage;
34 use feature "switch";
36 my $def_name = '';
37 my $vs_name = '';
38 my $show_help = 0;
40 my %syms;
42 my $def_only = 0;
43 my $vs_only = 0;
45 GetOptions ("def=s" => \$def_name,
46 "vs=s" => \$vs_name,
47 "help|?" => \$show_help) or pod2usage( -exitval => 2,
48 -verbose => 3 );
49 pod2usage( -exitval => 1,
50 -verbose => 3 ) if $show_help or !$def_name or !$vs_name;
52 open (my $def, '<', $def_name) or die $!;
53 open (my $vs, '<', $vs_name) or die $!;
55 # First go through the version-script
57 my $global = 0;
59 while(<$vs>)
61 next unless m/^([^#]+)/;
63 @a = split(/\s+|(\{|})/,$1);
65 for $f (@a) {
66 given ($f) {
67 when (/global\:/) { $global = 1; }
68 when (/{|}|.*\:/) { $global = 0; }
69 when (/(.*)\;/ and $global == 1) {
70 $syms{$1} = 1;
76 while(<$def>)
78 next if m/^#/;
79 next unless m/^;!([^;]+)/ or m/^([^;]+);?(!?)/;
81 @a = split(/\s+/, $1);
83 for $f (@a) {
84 next if $f =~ /EXPORTS/ or $f =~ /DATA/ or not $f;
86 if (not exists $syms{$f} and not $2) {
87 print "$f: Only in DEF\n";
88 ++$def_only;
90 delete $syms{$f};
94 #while (($k,$v) = each %syms) {
95 for $k (sort keys %syms) {
96 print "$k: Only in VS\n";
97 ++$vs_only;
100 close($def);
101 close($vs);
103 if ($def_only or $vs_only) {
104 print "\nMismatches found.\n";
105 exit(1);
108 __END__
110 =head1 NAME
112 w32-sync-exported-symbols.pl - Synchronize Windows .def with version-script
114 =head1 SYNOPSIS
116 w32-sync-exported-symbols.pl {options}
118 Options:
119 --def Name of .def file
120 --vs Name of version-script file
122 =head1 DESCRIPTION
124 Verifies that all the symbols exported by the version-script is also
125 accounted for in the .def file. Also checks that no extra symbols are
126 exported by the .def file unless they are marked as safe.
128 =cut