]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
build-sys: get rid of double negative ipinfo autotools settings
authorSami Kerola <kerolasa@iki.fi>
Thu, 18 Aug 2016 21:22:56 +0000 (22:22 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 21 Aug 2016 14:51:42 +0000 (15:51 +0100)
Makefile.am
asn.h
configure.ac
curses.c
display.c
display.h
gtk.c
mtr.c
report.c
select.c

index 5ee48c3dc1e42b6a25885d2de55d1e76025a8ea2..3e926cdb0f62fe4e27f6fda0648042e7da0ae6a2 100644 (file)
@@ -19,7 +19,7 @@ mtr_SOURCES = mtr.c mtr.h \
               img/mtr_icon.xpm \
               mtr-gtk.h
 
-if IPINFO
+if WITH_IPINFO
 mtr_SOURCES += asn.c asn.h
 endif
 
diff --git a/asn.h b/asn.h
index 6566a2e69256bcca46eb0743cc5ecec9dbde2045..4f550a5068982489df50aa6ec450a0d40337e13e 100644 (file)
--- a/asn.h
+++ b/asn.h
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-// The autoconf system provides us with the NO_IPINFO define. 
-// Littering the code with #ifndef NO_IPINFO (double negative)
-// does not benefit readability. So here we invert the sense of the
-// define. 
-//
-// Similarly, this include file should be included unconditionally. 
-// It will evaluate to nothing if we don't need it. 
-
-#ifndef NO_IPINFO
-
-#ifndef IPINFO
-#define IPINFO
-
 extern int ipinfo_no;
 extern int ipinfo_max;
 extern int iiwidth_len;
@@ -38,6 +25,3 @@ void asn_close();
 char *fmt_ipinfo(ip_t *addr);
 int get_iiwidth(void);
 int is_printii(void);
-
-#endif /* IPINFO */
-#endif /* NO_IPINFO */
index 5b73470603976ab8c4d60a2e71d3f2debbb07bd4..b2410dfe7beb2874d76a2b278d2eeeb43135979d 100644 (file)
@@ -87,9 +87,9 @@ AM_CONDITIONAL([WITH_NCURSES], [test "x$with_ncurses" = xyes])
 AC_ARG_WITH([ipinfo],
   [AS_HELP_STRING([--without-ipinfo], [Do not try to use ipinfo lookup at all])],
   [], [with_ipinfo=yes])
-AM_CONDITIONAL([IPINFO], [test "x$with_ipinfo" = "xyes"])
-AS_IF([test "x$with_ipinfo" = "xno"], [
-  AC_DEFINE([NO_IPINFO], [1], [Define to disable ipinfo lookup])
+AM_CONDITIONAL([WITH_IPINFO], [test "x$with_ipinfo" = "xyes"])
+AS_IF([test "x$with_ipinfo" = "xyes"], [
+  AC_DEFINE([HAVE_IPINFO], [1], [Define when ipinfo lookups are in use])
 ])
 
 AC_ARG_ENABLE([ipv6],
index 4d8f43606acb5513281f3547c1986518755c1261..4caa8fcdca8b998edbac189a6a5a0995de54364c 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -150,7 +150,7 @@ int mtr_curses_keyaction(void)
     return ActionMPLS;
   if (tolower(c) == 'n')
     return ActionDNS;
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
   if (tolower(c) == 'y')
     return ActionII;
   if (tolower(c) == 'z')
@@ -333,7 +333,7 @@ int mtr_curses_keyaction(void)
     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("  u       switch between ICMP ECHO and UDP datagrams\n" );
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     printw("  y       switching IP info\n");
     printw("  z       toggle ASN info on/off\n");
     pressanykey_row += 2;
@@ -388,7 +388,7 @@ void mtr_curses_hosts(int startstat)
       name = dns_lookup(addr);
       if (! net_up(at))
        attron(A_BOLD);
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
       if (is_printii())
         printw(fmt_ipinfo(addr));
 #endif
@@ -437,7 +437,7 @@ void mtr_curses_hosts(int startstat)
         name = dns_lookup(addrs);
         if (! net_up(at)) attron(A_BOLD);
         printw("\n    ");
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
         if (is_printii())
           printw(fmt_ipinfo(addrs));
 #endif
@@ -600,7 +600,7 @@ void mtr_curses_graph(int startstat, int cols)
                if (! net_up(at))
                        attron(A_BOLD);
                if (addrcmp((void *) addr, (void *) &unspec_addr, af)) {
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
                        if (is_printii())
                                printw(fmt_ipinfo(addr));
 #endif
@@ -690,7 +690,7 @@ void mtr_curses_redraw(void)
   } else {
     char msg[80];
     int padding = 30;
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     if (is_printii())
       padding += get_iiwidth();
 #endif
index 1f0d294f221aff5f65eee5ab4cbdb8c708dd0ae3..7cfbaa215079d2fa22c9e9b24676de3e93c355f8 100644 (file)
--- a/display.c
+++ b/display.c
@@ -66,7 +66,7 @@ extern int DisplayMode;
 #include "split.h"
 #endif
 
-#ifndef IPINFO
+#ifndef HAVE_IPINFO
 // No support for IPINFO allow the calls to remain in the main code.
 #define asn_open()
 #define asn_close()
index 294f6184fb5cfb5b5abb1ca2d6d633b1fa55c4eb..ec751fe4b644a8d0392cd977bfbb4327484b2f2b 100644 (file)
--- a/display.h
+++ b/display.h
@@ -22,7 +22,7 @@
    (notably the one on Irix 5.2) do not like that. */ 
 enum { ActionNone,  ActionQuit,  ActionReset,  ActionDisplay, 
        ActionClear, ActionPause, ActionResume, ActionMPLS, ActionDNS, 
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
        ActionII, ActionAS,
 #endif
        ActionScrollDown, ActionScrollUp  };
diff --git a/gtk.c b/gtk.c
index e55f48934a6a8a3049b7cfd25ca6623d6fa488d4..8d4cedb894f24f12cf0e840bf14886debcdb413b 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -287,7 +287,7 @@ static GtkWidget *ReportTreeView;
 static GtkListStore *ReportStore;
 
 enum {
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
   COL_ASN,
 #endif
   COL_HOSTNAME,
@@ -343,7 +343,7 @@ void TreeViewCreate(void)
   GtkTreeViewColumn *column;
 
   ReportStore = gtk_list_store_new(N_COLS,
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     G_TYPE_STRING,
 #endif
     G_TYPE_STRING,
@@ -363,7 +363,7 @@ void TreeViewCreate(void)
   g_signal_connect(GTK_OBJECT(ReportTreeView), "button_press_event", 
                    G_CALLBACK(ReportTreeView_clicked),NULL);
 
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
   if (is_printii()) {
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes ("ASN",
@@ -491,7 +491,7 @@ void update_tree_row(int row, GtkTreeIter *iter)
     COL_COLOR, net_up(row) ? "black" : "red",
 
     -1);
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
   if (is_printii())
     gtk_list_store_set(ReportStore, iter, COL_ASN, fmt_ipinfo(addr), -1);
 #endif
diff --git a/mtr.c b/mtr.c
index 914c2b4171645b237df6577bab599b0dd076f9cf..d6d3a4b3e18abba07a5cee4f0cd14ed8e73302ac 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -340,7 +340,7 @@ void parse_arg (int argc, char **argv)
     { "no-dns",         0, NULL, 'n' },
     { "show-ips",       0, NULL, 'b' },
     { "order",          1, NULL, 'o' }, /* fields to display & their order */
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     { "ipinfo",         1, NULL, 'y' }, /* IP info lookup */
     { "aslookup",       0, NULL, 'z' }, /* Do AS lookup (--ipinfo 0) */
 #endif
@@ -570,7 +570,7 @@ void parse_arg (int argc, char **argv)
       fprintf( stderr, "IPv6 not enabled.\n" );
       break;
 #endif
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     case 'y':
       ipinfo_no = atoi (optarg);
       if (ipinfo_no < 0)
index e15e38d2eee57312887f62ecfe9a1f25a1c31413..83f315684b054703f86794ba57f8c9d155e4b5ac 100644 (file)
--- a/report.c
+++ b/report.c
@@ -71,7 +71,7 @@ static size_t snprint_addr(char *dst, size_t dst_len, ip_t *addr)
 }
 
 
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
 void print_mpls(struct mplslen *mpls) {
   int k;
   for (k=0; k < mpls->labels; k++)
@@ -106,7 +106,7 @@ void report_close(void)
     }
   }
   
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
   int len_tmp = len_hosts;
   if (ipinfo_no >= 0) {
     ipinfo_no %= iiwidth_len;
@@ -140,7 +140,7 @@ void report_close(void)
     mpls = net_mpls(at);
     snprint_addr(name, sizeof(name), addr);
 
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     if (is_printii()) {
       snprintf(fmt, sizeof(fmt), " %%2d. %%s%%-%zus", len_hosts);
       snprintf(buf, sizeof(buf), fmt, at+1, fmt_ipinfo(addr), name);
@@ -148,7 +148,7 @@ void report_close(void)
 #endif
     snprintf( fmt, sizeof(fmt), " %%2d.|-- %%-%zus", len_hosts);
     snprintf(buf, sizeof(buf), fmt, at+1, name);
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     }
 #endif
     len = reportwide ? strlen(buf) : len_hosts;  
@@ -186,7 +186,7 @@ void report_close(void)
 
       if (!found) {
   
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
         if (is_printii()) {
           if (mpls->labels && z == 1 && enablempls)
             print_mpls(mpls);
@@ -215,14 +215,14 @@ void report_close(void)
           }
         }
 #endif
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
         }
 #endif
       }
     }
 
     /* No multipath */
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     if (is_printii()) {
       if (mpls->labels && z == 1 && enablempls)
         print_mpls(mpls);
@@ -235,7 +235,7 @@ void report_close(void)
       }
     }
 #endif
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     }
 #endif
   }
@@ -437,7 +437,7 @@ void csv_close(time_t now)
 
     if (at == net_min()) {
       printf("Mtr_Version,Start_Time,Status,Host,Hop,Ip,");
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
       if(!ipinfo_no) {
        printf("Asn,");
       }
@@ -450,7 +450,7 @@ void csv_close(time_t now)
       printf("\n");
     }
 
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
     if(!ipinfo_no) {
       char* fmtinfo = fmt_ipinfo(addr);
       fmtinfo = trim(fmtinfo);
index c9f768d0fea08ba43b638c8a048ae19970b9a26b..54b7a399756bf17c88efd87c8743ac0ae340de77 100644 (file)
--- a/select.c
+++ b/select.c
@@ -237,7 +237,7 @@ void select_loop(void) {
          display_clear();
        }
        break;
-#ifdef IPINFO
+#ifdef HAVE_IPINFO
       case ActionII:
        ipinfo_no++;
        if (ipinfo_no > ipinfo_max)