3 #=======================================================================
5 # File ID: d2d6c67a-48f9-11e0-a72d-c3b2f04a5e88
6 # Generate GraphViz DOT files from traceroute(1) output
9 # ©opyleft 2011– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = "0.00";
37 Getopt
::Long
::Configure
("bundling");
40 "colour|c=s" => \
$Opt{'colour'},
41 "debug" => \
$Opt{'debug'},
42 "help|h" => \
$Opt{'help'},
43 "style|s=s" => \
$Opt{'style'},
44 "verbose|v+" => \
$Opt{'verbose'},
45 "version" => \
$Opt{'version'},
47 ) || die("$progname: Option error. Use -h for help.\n");
49 $Opt{'debug'} && ($Debug = 1);
50 $Opt{'help'} && usage
(0);
51 if ($Opt{'version'}) {
60 if ($Line =~ /^\s*.*?(\d+\.\d+\.\d+\d+\.\d+)\s/) {
61 push(@Hosts, sprintf("\"%s\"", $1));
65 $attr .= $Opt{'colour'} ?
" color=\"$Opt{'colour'}\"" : "";
66 $attr .= $Opt{'style'} ?
" style=\"$Opt{'style'}\"" : "";
68 length($attr) && ($attr = " [$attr]");
69 print(join(" -> ", @Hosts),
75 # Print program version {{{
76 print("$progname v$VERSION\n");
81 # Send the help message to stdout {{{
84 if ($Opt{'verbose'}) {
90 Usage: $progname [options] [file [files [...]]]
95 Use colour X on this graph.
99 Use line style X. Can contain the values
105 Increase level of verbosity. Can be repeated.
107 Print version information.
109 Print debugging messages.
117 # Print a status message to stderr based on verbosity level {{{
118 my ($verbose_level, $Txt) = @_;
120 if ($Opt{'verbose'} >= $verbose_level) {
121 print(STDERR
"$progname: $Txt\n");
127 # Print a debugging message {{{
129 my @call_info = caller;
130 chomp(my $Txt = shift);
131 my $File = $call_info[1];
133 $File =~ s
#^.*/(.*?)$#$1#;
134 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
141 # Plain Old Documentation (POD) {{{
151 [options] [file [files [...]]]
161 =item B<-h>, B<--help>
163 Print a brief help summary.
165 =item B<-v>, B<--verbose>
167 Increase level of verbosity. Can be repeated.
171 Print version information.
175 Print debugging messages.
185 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
189 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
190 This is free software; see the file F<COPYING> for legalese stuff.
194 This program is free software: you can redistribute it and/or modify it
195 under the terms of the GNU General Public License as published by the
196 Free Software Foundation, either version 2 of the License, or (at your
197 option) any later version.
199 This program is distributed in the hope that it will be useful, but
200 WITHOUT ANY WARRANTY; without even the implied warranty of
201 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
202 See the GNU General Public License for more details.
204 You should have received a copy of the GNU General Public License along
206 If not, see L<http://www.gnu.org/licenses/>.
214 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :