]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr v0.41 v0.41
authorRoger Wolff <r.e.wolff@bitwizard.nl>
Thu, 19 Aug 1999 00:00:00 +0000 (00:00 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 3 Feb 2013 20:45:37 +0000 (20:45 +0000)
 - Added afr's patch to allow disabling of gtk without Robn's hack.
 - Made report mode report the newly added extra resolution.

source: ftp://ftp.bitwizard.nl/mtr/mtr-0.41.tar.gz

NEWS
configure.in
mtr.c
report.c

diff --git a/NEWS b/NEWS
index a555962bf26e898d3e6bed7e6ad59a45384a60fd..4f083f7427fa7c3a876b668a85f68fb033181ceb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 WHAT'S NEW?
 
+  v0.41 Added afr's patch to allow disabeling of gtk without Robn's hack. 
+        Made report mode report the newly added extra resolution. 
+
   v0.40 Fixed some problems with HPUX and SunOS.
        Included Olav Kvittem's patch to do packetsize option.
        Made the timekeeping in micro seconds.
index b4ec4e659c6580d3f64d36a1e20bc0631f679131..840d3df782fd1d84b8612c4c41703f6ea075bace 100644 (file)
@@ -1,5 +1,5 @@
 AC_INIT(mtr.c)
-AM_INIT_AUTOMAKE(mtr, 0.40)
+AM_INIT_AUTOMAKE(mtr, 0.41)
 
 AC_SUBST(GTK_OBJ)
 AC_SUBST(CURSES_OBJ)
diff --git a/mtr.c b/mtr.c
index 10df43e9f755f1989b6a8ba2fe006f6c9d89cd53..8234b1ba04709afd4fb692cf8d00b2b443e96363 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -45,7 +45,7 @@ float WaitTime = 1.0;
 char *Hostname = NULL;
 char LocalHostname[128];
 int dns = 1;
-int packetsize = 64;
+int packetsize = MINPACKET;
 
 void parse_arg(int argc, char **argv) {
   int opt;
@@ -116,10 +116,13 @@ void parse_arg(int argc, char **argv) {
   if(DisplayMode == DisplayReport)
     Interactive = 0;
 
-  if(optind != argc - 1)
+  if(optind > argc - 1)
     return;
 
-  Hostname = argv[optind];
+  Hostname = argv[optind++];
+
+  if (argc > optind) 
+    packetsize = atoi(argv[optind]);
 
 }
 
@@ -181,7 +184,8 @@ int main(int argc, char **argv) {
     printf("usage: %s [-hvrctglsni] [--help] [--version] [--report]\n"
           "\t\t[--report-cycles=COUNT] [--curses] [--gtk]\n"
            "\t\t[--raw] [--split] [--no-dns]\n"      /* BL */
-          "\t\t[--interval=SECONDS] HOSTNAME\n", argv[0]);
+           "\t\t[--psize=bytes/-p=bytes]\n"            /* ok */
+          "\t\t[--interval=SECONDS] HOSTNAME [PACKETSIZE]\n", argv[0]);
     exit(0);
   }
   if (Hostname == NULL) Hostname = "localhost";
index b6953a9cb53823392dba4c769f0936f8881fe918..96c1f3158c193f70650a3390915c76f3ea78eb79 100644 (file)
--- a/report.c
+++ b/report.c
@@ -31,7 +31,7 @@
 extern int dns;
 
 void report_open() {
-  printf("%-40s LOSS  RCVD  SENT BEST   AVG  WORST\n", "HOST");
+  printf("%-38s  LOSS  RCVD SENT    BEST     AVG   WORST\n", "HOST");
   fflush(stdout);
 }
 
@@ -62,10 +62,20 @@ void report_close() {
       }
     }
 
-    printf("%-40s%5d%%%6d%5d%6d%6d%6d\n", name,     
+    /* Coding tip: 
+
+       NEVER EVER use a format like "%6d%6d%6d". This will nicely
+       format your three numbers in 18 spaces just like " %5d %5d %5d"
+       and save you three bytes of static string space. However, when
+       the numbers suddenly become a bit larger than you expected
+       you'll end up with unexpected results: just one huge number
+       instead of three separate numbers. This especially matters if
+       the reader of the info is a program and not human.  */
+
+    printf("%-38s %4d%% %5d %4d %7.2f %7.2f %7.2f\n", name,     
             net_percent(at),
              net_returned(at), net_xmit(at),
-             net_best(at)/1000, net_avg(at)/1000, net_worst(at)/1000);
+             net_best(at)/1000.0, net_avg(at)/1000.0, net_worst(at)/1000.0);
   }
 }