digcomp.pl revision 02fdafbf53f712ee72ef50c4fa537f97082d8114
#
# Copyright (C) 1999, 2000 Internet Software Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
# Compare two files, each with the output from dig, for differences.
# Ignore "unimportant" differences, like ordering of NS lines, TTL's,
# etc...
$count = 0;
$firstname = "";
$status = 0;
while (<FILE1>) {
chomp;
next if (/^;/);
if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
$name = $1;
$class = $2;
$type = $3;
$value = $4;
if ($type eq "SOA") {
$name = "$name$count";
$count++;
}
}
print ("Duplicate entry:\n> $_\n< $line\n");
} else {
$entry{"$name ; $class.$type ; $value"} = $_;
}
}
}
close (FILE1);
$printed = 0;
while (<FILE2>) {
chomp;
next if (/^;/);
if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
$name = $1;
$class = $2;
$type = $3;
$value = $4;
$count--;
$name = "$name$count";
}
} else {
print ("> $_\n");
$printed++;
$status = 1;
}
}
}
close (FILE2);
$printed = 0;
print ("< $entry{$key}\n");
$status = 1;
$printed++;
}
}
exit($status);