From: Roger Wolff Date: Mon, 5 Apr 2004 00:00:00 +0000 (+0000) Subject: mtr v0.56 X-Git-Tag: v0.56^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2567776d775b922a0d3a103d7b6ed808074d1c8;p=thirdparty%2Fmtr.git mtr v0.56 - Fixed compile warnings. Now compiles with -Wall. If your compiler finds things mine didn't feel free to shout. source: ftp://ftp.bitwizard.nl/mtr/mtr-0.56.tar.gz --- diff --git a/NEWS b/NEWS index 4e06bf2..de4a147 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,7 @@ WHAT'S NEW? + v0.56 Fixed compile warnings. Now compiles with -Wall. If your + compiler finds things mine didn't feel free to shout. + v0.55 Cleanup patch. I'm going to do some maintenance on MTR, but I want to be able to say: Can you see which version fixed/broke things for you, so you're going to see a diff --git a/configure.in b/configure.in index 707403a..59cba09 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,6 @@ AC_INIT(mtr.c) -AM_INIT_AUTOMAKE(mtr, 0.55) +AM_INIT_AUTOMAKE(mtr, 0.56) + AC_SUBST(GTK_OBJ) AC_SUBST(CURSES_OBJ) @@ -75,6 +76,49 @@ AC_CHECK_FUNC(res_mkquery, , AC_CHECK_FUNC(herror, , AC_DEFINE(NO_HERROR)) AC_CHECK_FUNC(strerror, , AC_DEFINE(NO_STRERROR)) + +dnl Add C flags to display more warnings +AC_MSG_CHECKING(for C flags to get more warnings) +ac_save_CFLAGS="$CFLAGS" +if test "x$ac_cv_prog_gcc" = "xyes" ; then + dnl gcc is the easiest C compiler + warning_CFLAGS="-Wall" +else + dnl Vendor supplied C compilers are a bit tricky + case "$host_os" in + dnl SGI IRIX with the MipsPRO C compiler + irix*) + CFLAGS="$CFLAGS -fullwarn" + AC_TRY_COMPILE([#include ],[printf("test");], + warning_CFLAGS="-fullwarn",) + ;; + + dnl SunOS 4.x with the SparcWorks(?) acc compiler + sunos*) + if "$CC" = "acc" ; then + CFLAGS="$CFLAGS -vc" + AC_TRY_COMPILE([#include ],[printf("test");], + warning_CFLAGS="-vc",) + fi + ;; + + dnl Unknown, do nothing + *) + warning_CFLAGS="none" + ;; + esac +fi +CFLAGS="$ac_save_CFLAGS" +if test "$warning_CFLAGS" = "none" ; then + AC_MSG_RESULT(none) +else + CFLAGS="$CFLAGS $warning_CFLAGS" + AC_MSG_RESULT($warning_CFLAGS) +fi + + + + AM_CONFIG_HEADER(config.h) AC_OUTPUT(Makefile img/Makefile) diff --git a/curses.c b/curses.c index f7f63b2..fb002e9 100644 --- a/curses.c +++ b/curses.c @@ -70,6 +70,36 @@ extern int tos; extern float WaitTime; +struct fields data_fields[MAXFLD] = { + /* Remark, Header, Format, Width, CallBackFunc */ + { ": Space between fields", " ", " ", 1, &net_drop }, /* 0 */ + { "L: Loss Ratio", "Loss%", " %4.1f%%", 6, &net_loss }, /* 1 */ + { "D: Dropped Packets", "Drop", " %4d", 5, &net_drop }, /* 2 */ + { "R: Received Packets", "Rcv", " %5d", 6, &net_returned}, /* 3 */ + { "S: Sent Packets", "Snt", " %5d", 6, &net_xmit }, /* 4 */ + { "N: Newest RTT(ms)", "Last", " %5.1f", 6, &net_last }, /* 5 */ + { "B: Min/Best RTT(ms)", "Best", " %5.1f", 6, &net_best }, /* 6 */ + { "A: Average RTT(ms)", "Avg", " %5.1f", 6, &net_avg }, /* 7 */ + { "W: Max/Worst RTT(ms)", "Wrst", " %5.1f", 6, &net_worst }, /* 8 */ + { "V: Standard Deviation", "StDev", " %5.1f", 6, &net_stdev }, /* 9 */ + { "G: Geometric Mean", "Gmean", " %5.1f", 6, &net_gmean }, /* 10 */ + { "J: Current Jitter", "Jttr", " %4.1f", 5, &net_jitter}, /* 11 */ + { "M: Jitter Mean/Avg.", "Javg", " %4.1f", 5, &net_javg }, /* 12 */ + { "X: Worst Jitter", "Jmax", " %4.1f", 5, &net_jworst}, /* 13 */ + { "I: Interarrival Jitter", "Jint", " %4.1f", 5, &net_jinta }, /* 14 */ + { 0, 0, 0, 0, 0 } +}; + + +/* keys: the value in the array is the index number in data_fields[] */ +int fld_index[] = { + 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* ' ', 0,1..9 */ + 7, 6, -1, 2, -1, -1, 10, -1, 14, 11, -1, 1, 12, /* A..M */ + 5, -1, -1, -1, 3, 4, -1, -1, 9, 8, 13, -1, -1, /* N..Z */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a..m */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* n..z */ + -1 +}; void pwcenter(char *str) { @@ -116,7 +146,7 @@ int mtr_curses_keyaction() { move(2,20); refresh(); while ( (c=getch ()) != '\n' && i= 'A' && c<= 'Z' || c==' ') { + attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh(); + if( (c>= 'A' && c<= 'Z') || c==' ') { buf[i++] = c; /* only accept [ A-Z], can be extend to [a-z0-9] */ } } diff --git a/dns.c b/dns.c index c1237bc..d9d5a1b 100644 --- a/dns.c +++ b/dns.c @@ -42,6 +42,7 @@ #include #include #include +#include #ifdef NO_STRERROR extern int sys_nerr; @@ -1087,7 +1088,7 @@ void dns_ack(){ break; if (i == _res.nscount){ sprintf(tempstring,"Resolver error: Received reply from unknown source: %s", - strlongip(from.sin_addr.s_addr)); + inet_ntoa(from.sin_addr)); restell(tempstring); } else parserespacket((byte *)resrecvbuf,r); diff --git a/gtk.c b/gtk.c index c5f9ced..52357a4 100644 --- a/gtk.c +++ b/gtk.c @@ -19,7 +19,12 @@ */ #include + +#include +#include +#include #include +#include #ifndef NO_GTK #include @@ -200,7 +205,7 @@ GtkWidget *ReportBody; GtkWidget *GetRow(int index) { int addr; - char str[256], *name; + char *name; GtkWidget *Row, *Label; Row = gtk_fixed_new(); diff --git a/net.c b/net.c index f3d0ea9..f7f5380 100644 --- a/net.c +++ b/net.c @@ -516,10 +516,11 @@ int net_send_batch() for (i=fstTTL-1;i: Space between fields", " ", " ", 1, &net_drop }, /* 0 */ - { "L: Loss Ratio", "Loss%", " %4.1f%%", 6, &net_loss }, /* 1 */ - { "D: Dropped Packets", "Drop", " %4d", 5, &net_drop }, /* 2 */ - { "R: Received Packets", "Rcv", " %5d", 6, &net_returned}, /* 3 */ - { "S: Sent Packets", "Snt", " %5d", 6, &net_xmit }, /* 4 */ - { "N: Newest RTT(ms)", "Last", " %5.1f", 6, &net_last }, /* 5 */ - { "B: Min/Best RTT(ms)", "Best", " %5.1f", 6, &net_best }, /* 6 */ - { "A: Average RTT(ms)", "Avg", " %5.1f", 6, &net_avg }, /* 7 */ - { "W: Max/Worst RTT(ms)", "Wrst", " %5.1f", 6, &net_worst }, /* 8 */ - { "V: Standard Deviation", "StDev", " %5.1f", 6, &net_stdev }, /* 9 */ - { "G: Geometric Mean", "Gmean", " %5.1f", 6, &net_gmean }, /* 10 */ - { "J: Current Jitter", "Jttr", " %4.1f", 5, &net_jitter}, /* 11 */ - { "M: Jitter Mean/Avg.", "Javg", " %4.1f", 5, &net_javg }, /* 12 */ - { "X: Worst Jitter", "Jmax", " %4.1f", 5, &net_jworst}, /* 13 */ - { "I: Interarrival Jitter", "Jint", " %4.1f", 5, &net_jinta }, /* 14 */ - { 0, 0, 0, 0, 0 } -}; +extern struct fields data_fields[MAXFLD]; + /* keys: the value in the array is the index number in data_fields[] */ -static int fld_index[] = { - 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* ' ', 0,1..9 */ - 7, 6, -1, 2, -1, -1, 10, -1, 14, 11, -1, 1, 12, /* A..M */ - 5, -1, -1, -1, 3, 4, -1, -1, 9, 8, 13, -1, -1, /* N..Z */ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a..m */ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* n..z */ - -1 -}; +extern int fld_index[]; diff --git a/raw.c b/raw.c index 42b3418..d8b112d 100644 --- a/raw.c +++ b/raw.c @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include "raw.h" @@ -30,6 +33,7 @@ static int havename[MaxHost]; +#if 0 static char *addr_to_str(int addr) { static char buf[20]; @@ -41,7 +45,7 @@ static char *addr_to_str(int addr) (addr >> 24) & 0xff); return buf; } - +#endif void raw_rawping (int host, int msec) { @@ -55,12 +59,19 @@ void raw_rawping (int host, int msec) } } printf ("p %d %d\n", host, msec); + fflush (stdout); } void raw_rawhost (int host, int ip_addr) { - printf ("h %d %s\n", host, addr_to_str (ip_addr)); + struct in_addr in; + + in.s_addr = ip_addr; + + printf ("h %d %s\n", + host, inet_ntoa(in)); + fflush (stdout); } diff --git a/select.c b/select.c index c95b13a..bd12811 100644 --- a/select.c +++ b/select.c @@ -45,7 +45,6 @@ int display_offset = 0; void select_loop() { fd_set readfd; - int action; int anyset = 0; int maxfd = 0; int dnsfd, netfd;