fprintf(fp, "There are no options, is FILE2 is not given, standard input is read\n");
fprintf(fp, "\nOUTPUT FORMAT:\n");
fprintf(fp, " Line based output format, each record consists of 4 lines:\n");
- fprintf(fp, " 1. xxx\t\tdecimal sequence number\n");
+ fprintf(fp, " 1. xxx:yyy\t\tdecimal sequence numbers\n");
fprintf(fp, " 2. hex dump\t\tquery in hex, network order\n");
fprintf(fp, " 3. hex dump\t\tanswer of FILE 1 in hex, network order\n");
fprintf(fp, " 4. hex dump\t\tanswer of FILE 2 in hex, network order\n\n");
fprintf(fp, " If a difference in the query is spotted the sequence nmuber\n");
fprintf(fp, " is prefixed by a 'q: ' and the query data is printed:\n");
- fprintf(fp, " 1. q: xxx\t\tdecimal sequence number\n");
+ fprintf(fp, " 1. q: xxx:yyy\tdecimal sequence numbers\n");
fprintf(fp, " 2. hex dump\t\tquery in hex, network order\n");
fprintf(fp, " 3. hex dump\t\tquery of FILE 1 in hex, network order\n");
fprintf(fp, " 4. hex dump\t\tquery of FILE 2 in hex, network order\n");
# seperated by comma's
# -v reverse
-%numbers = ();
-$reverse = 0;
+use strict;
-foreach $r (@ARGV) {
+my %numbers = ();
+my $reverse = 0;
+my $i;
+my $k;
+
+foreach my $r (@ARGV) {
if ($r eq "-v") {
$reverse = 1;
}
if ($r =~ /-/) {
- ($s, $e) = split /-/, $r;
+ my ($s, $e) = split /-/, $r;
if ($s > $e) {
next;
}
# read in the input, pcat style
+my $line; my $left; my $right;
$i = 1;
-LINE: while(<STDIN>) {
+my $print = 0;
+while(<STDIN>) {
if ($i % 4 == 1) {
($left, $right) = split /:/, $_;
-
- if ($reverse == 0) {
- foreach $k (keys %numbers) {
- if ($k == $left) {
- print $_;
- print <STDIN>;
- print <STDIN>;
- print <STDIN>;
- $i++;
- next LINE;
- }
+ foreach $k (keys %numbers) {
+ if ($k == $left) {
+ $print = 1;
+ last;
}
- <STDIN>;
- <STDIN>;
- <STDIN>;
- } else {
- foreach $k (keys %numbers) {
- if ($k == $left) {
- <STDIN>;
- <STDIN>;
- <STDIN>;
- $i++;
- next LINE;
- }
- }
- print $_;
- print <STDIN>;
- print <STDIN>;
- print <STDIN>;
+ $print = 0;
}
+ }
+ if ($print == 1) {
+ print $_;
+ }
+ if ($i % 4 == 0) {
+ $print = 0;
}
$i++;
}