da42a29a8592e0203cda35b12226748194af0b27
[swift-upb.git] / mfold / swlognm
1 #!/usr/bin/perl -w
2
3 #
4 #   This script detects handshake patterns
5 #   and changes channel numbers for host names
6 #
7 #0_05_01_981_298 node309 #45 +hs f33dff82
8 #0_05_02_039_313 lossy #16 -hs f33dff82
9 my %HSSRC = ();
10 my %CH = ();
11
12 while (<>) {
13     / (\S+) (\#\d+)/ || next;
14     my $src = $1;
15     my $ch = $2;
16     if ( exists $CH{"$src$ch"} ){
17         s/$ch/$CH{"$src$ch"}$ch/ or die $_;
18     } elsif (/[\+\-]hs ([a-f0-9]+)$/) {
19         if ( exists $HSSRC{$1} ) {
20             $CH{"$src$ch"} = $HSSRC{$1};
21             my $srckey = $HSSRC{$1}.$HSSRCCH{$1};
22             $CH{$srckey} = $src;
23         } else {
24             $HSSRC{$1} = $src;
25             $HSSRCCH{$1} = $ch;
26         }
27     }
28     print;
29 }