Subject: mtr: Sub-second interval patch
Package: mtr
Version: 0.72
Severity: wishlist
Tags: patch

Hi,

In the current version of mtr, intervals smaller than 1 second are only
supported when specified on the command line. The attached patch
modifies mtr to allow for specifying an interval between 0 and 1
seconds via the GUI.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (600, 'unstable'), (500, 'oldstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.18-4-486
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages mtr depends on:
ii  libc6                     2.7-9          GNU C Library: Shared
libraries ii  libglib1.2                1.2.10-17      The GLib library
of C routines ii  libgtk1.2                 1.2.10-18      The GIMP
Toolkit set of widgets fo ii  libncurses5               5.6+20080308-1
Shared libraries for terminal hand pn  xlibs
<none>         (no description available)

mtr recommends no packages.
diff -Naur mtr-0.72.orig/curses.c mtr-0.72/curses.c
--- mtr-0.72.orig/curses.c	2006-09-29 21:40:09.000000000 +0200
+++ mtr-0.72/curses.c	2008-03-24 16:11:40.000000000 +0100
@@ -19,6 +19,7 @@
 
 #include <config.h>
 #include <strings.h>
+#include <unistd.h>
 
 #ifndef NO_CURSES
 #include <ctype.h>
@@ -93,6 +94,7 @@
 {
   int c = getch();
   int i=0;
+  float f = 0.0;
   char buf[MAXFLD+1];
 
   if(c == 'q')
@@ -169,10 +171,13 @@
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
-    i = atoi( buf );
 
-    if ( i < 1 ) return ActionNone;
-    WaitTime = (float) i;
+    f = atof( buf );
+
+    if (f <= 0.0) return ActionNone;
+    if (getuid() != 0 && f < 1.0)
+      return ActionNone;
+    WaitTime = f;
 
     return ActionNone;
   }

Reply via email to