Diff for /embedaddon/mtr/curses.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2013/07/21 23:43:42 version 1.1.1.2, 2016/11/01 09:33:48
Line 16 Line 16
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */  */
   
#include <config.h>#include "config.h"
 
 #include <strings.h>  #include <strings.h>
 #include <unistd.h>  #include <unistd.h>
   
Line 60 Line 61
   
 #include "mtr.h"  #include "mtr.h"
 #include "mtr-curses.h"  #include "mtr-curses.h"
 #include "display.h"  
 #include "net.h"  #include "net.h"
 #include "dns.h"  #include "dns.h"
 #ifndef NO_IPINFO  
 #include "asn.h"  #include "asn.h"
#endif#include "display.h"
 
 #include "version.h"  #include "version.h"
 #endif  #endif
   
Line 121  int mtr_curses_keyaction(void) Line 121  int mtr_curses_keyaction(void)
     return ActionMPLS;      return ActionMPLS;
   if (tolower(c) == 'n')    if (tolower(c) == 'n')
     return ActionDNS;      return ActionDNS;
#ifndef NO_IPINFO#ifdef IPINFO
   if (tolower(c) == 'y')    if (tolower(c) == 'y')
     return ActionII;      return ActionII;
   if (tolower(c) == 'z')    if (tolower(c) == 'z')
Line 304  int mtr_curses_keyaction(void) Line 304  int mtr_curses_keyaction(void)
     printw("  b <c>   set ping bit pattern to c(0..255) or random(c<0)\n" );      printw("  b <c>   set ping bit pattern to c(0..255) or random(c<0)\n" );
     printw("  Q <t>   set ping packet's TOS to t\n" );      printw("  Q <t>   set ping packet's TOS to t\n" );
     printw("  u       switch between ICMP ECHO and UDP datagrams\n" );      printw("  u       switch between ICMP ECHO and UDP datagrams\n" );
#ifndef NO_IPINFO#ifdef IPINFO
     printw("  y       switching IP info\n");      printw("  y       switching IP info\n");
     printw("  z       toggle ASN info on/off\n");      printw("  z       toggle ASN info on/off\n");
     pressanykey_row += 2;      pressanykey_row += 2;
Line 344  void mtr_curses_hosts(int startstat)  Line 344  void mtr_curses_hosts(int startstat) 
       name = dns_lookup(addr);        name = dns_lookup(addr);
       if (! net_up(at))        if (! net_up(at))
         attron(A_BOLD);          attron(A_BOLD);
#ifndef NO_IPINFO#ifdef IPINFO
       if (is_printii())        if (is_printii())
         printw(fmt_ipinfo(addr));          printw(fmt_ipinfo(addr));
 #endif  #endif
Line 401  void mtr_curses_hosts(int startstat)  Line 401  void mtr_curses_hosts(int startstat) 
         name = dns_lookup(addrs);          name = dns_lookup(addrs);
         if (! net_up(at)) attron(A_BOLD);          if (! net_up(at)) attron(A_BOLD);
         printw("\n    ");          printw("\n    ");
#ifndef NO_IPINFO#ifdef IPINFO
         if (is_printii())          if (is_printii())
           printw(fmt_ipinfo(addrs));            printw(fmt_ipinfo(addrs));
 #endif  #endif
Line 490  void mtr_curses_init() { Line 490  void mtr_curses_init() {
 }  }
   
   
   static int block_col[NUM_FACTORS+1] =
   {       // 1:black 2:red 3:green 4:brown/yellow 5:blue 6:magenta 7:cyan 8:white
           COLOR_PAIR(2)|A_BOLD,
           A_NORMAL,
           COLOR_PAIR(3),
           COLOR_PAIR(3)|A_BOLD,
           COLOR_PAIR(4)|A_BOLD,
           COLOR_PAIR(6)|A_BOLD,
           COLOR_PAIR(6),
           COLOR_PAIR(2),
           COLOR_PAIR(2)|A_BOLD
   };
   
 void mtr_print_scaled(int ms)   void mtr_print_scaled(int ms) 
 {  {
         int i;          int i;
   
         for (i = 0; i < NUM_FACTORS; i++) {          for (i = 0; i < NUM_FACTORS; i++) {
                 if (ms <= scale[i]) {                  if (ms <= scale[i]) {
                           attrset(block_col[i+1]);
                         printw("%c", block_map[i]);                          printw("%c", block_map[i]);
                           attrset(A_NORMAL);
                         return;                          return;
                 }                  }
         }          }
Line 514  void mtr_fill_graph(int at, int cols)  Line 529  void mtr_fill_graph(int at, int cols) 
                 if (saved[i] == -2) {                  if (saved[i] == -2) {
                         printw(" ");                          printw(" ");
                 } else if (saved[i] == -1) {                  } else if (saved[i] == -1) {
                        attron(A_BOLD);                        attrset(block_col[0]);
                        printw("?");                        printw("%c", '?');
                        attroff(A_BOLD);                        attrset(A_NORMAL);
                 } else {                  } else {
                         if (display_mode == 1) {                          if (display_mode == 1) {
                                 if (saved[i] > scale[6]) {                                  if (saved[i] > scale[6]) {
Line 552  void mtr_curses_graph(int startstat, int cols)  Line 567  void mtr_curses_graph(int startstat, int cols) 
                 if (! net_up(at))                  if (! net_up(at))
                         attron(A_BOLD);                          attron(A_BOLD);
                 if (addrcmp((void *) addr, (void *) &unspec_addr, af)) {                  if (addrcmp((void *) addr, (void *) &unspec_addr, af)) {
#ifndef NO_IPINFO#ifdef IPINFO
                         if (is_printii())                          if (is_printii())
                                 printw(fmt_ipinfo(addr));                                  printw(fmt_ipinfo(addr));
 #endif  #endif
Line 642  void mtr_curses_redraw(void) Line 657  void mtr_curses_redraw(void)
   } else {    } else {
     char msg[80];      char msg[80];
     int padding = 30;      int padding = 30;
#ifndef NO_IPINFO#ifdef IPINFO
     if (is_printii())      if (is_printii())
       padding += get_iiwidth();        padding += get_iiwidth();
 #endif  #endif
Line 664  void mtr_curses_redraw(void) Line 679  void mtr_curses_redraw(void)
     attroff(A_BOLD);      attroff(A_BOLD);
           
     for (i = 0; i < NUM_FACTORS-1; i++) {      for (i = 0; i < NUM_FACTORS-1; i++) {
      printw("  %c:%d ms", block_map[i], scale[i]/1000);      printw("  ");
       attrset(block_col[i+1]);
       printw("%c", block_map[i]);
       attrset(A_NORMAL);
       printw(":%d ms", scale[i]/1000);
     }      }
       printw("  ");
       attrset(block_col[NUM_FACTORS]);
       printw("%c", block_map[NUM_FACTORS-1]);
       attrset(A_NORMAL);
   }    }
   
   refresh();    refresh();
Line 677  void mtr_curses_open(void) Line 700  void mtr_curses_open(void)
   initscr();    initscr();
   raw();    raw();
   noecho();     noecho(); 
     start_color();
     int i;
     for (i = 0; i < 8; i++)
         init_pair(i+1, i, 0);
   
   mtr_curses_init();    mtr_curses_init();
   mtr_curses_redraw();    mtr_curses_redraw();

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>