Debian Codegraph @

bin/getrc

raw
1 eval 'exec perl -I ./bin -S $0 ${1+"$@"}' #-*-Perl-*-
2 if 0;
3
4 require 5.001;
5
6 ($progname) = ($0 =~ m!([^/]+)$!);
7 sub usage {
8 die <<ENDUSAGE;
9 usage: $progname -s node1 [options] [trace file...]
10
11 get trace files that match certain criteria related to source, dest or flow-id
12
13 options:
14 -o outfile write subset trace to output file
15 -b bi-directional, i.e. gather lines
16 -d node2 specify destination
17 -f flowid specify flow id
18 -e get event-trace
19 ENDUSAGE
20 }
21
22 $usage = "usage: $progname [-b] [-e] [-o outfile] -s node1 [-d node2] [-f flowid] [trace files...]\n";
23
24 $opt_s = -1;
25 $opt_d = -1;
26 $opt_b = 0;
27 $opt_f = -1;
28 $opt_e = 0;
29
30 use Getopt::Std;
31 #require 'getopts.pl';
32 (getopts('bo:s:d:ef:') && $opt_s != -1) || usage;
33 #(&Getopts('bo:s:d:ef:') && $opt_s != -1) || usage;
34
35 open(STDOUT, ">$opt_o") if ($opt_o);
36 while (<>) {
37 /^v/ && do {
38 print $_;
39 next;
40 };
41 @F = split;
42
43 if ($F[2] == $opt_s) { # if src matches
44 if (($opt_f != -1) && $F[7] != $opt_f) {
45 next;
46 }
47 print $_ unless (($opt_d != -1) && $F[3] != $opt_d); # print unless dst & !match
48 next;
49 }
50 if ($opt_b && $F[3] == $opt_s) { # else if bi && dst fld mch
51 if (($opt_f != -1) && $F[7] != $opt_f) {
52 next;
53 }
54 print $_ unless (($opt_d != -1) && $F[2] != $opt_d); # prt unless dst & !mch sfld
55 next;
56 }
57 if ($opt_e) {
58 print $_ unless !($F[0] eq 'E');
59 next;
60 }
61
62 }
63 close(STDOUT);
64 exit;
65