From: Sami Kerola Date: Thu, 18 Aug 2016 21:22:56 +0000 (+0100) Subject: build-sys: get rid of double negative ipinfo autotools settings X-Git-Tag: v0.88~30^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c3e40954f3bf1bab94415395f4a72376e1fbf4b;p=thirdparty%2Fmtr.git build-sys: get rid of double negative ipinfo autotools settings --- diff --git a/Makefile.am b/Makefile.am index 5ee48c3..3e926cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 6566a2e..4f550a5 100644 --- a/asn.h +++ b/asn.h @@ -16,19 +16,6 @@ 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 */ diff --git a/configure.ac b/configure.ac index 5b73470..b2410df 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/curses.c b/curses.c index 4d8f436..4caa8fc 100644 --- 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 set ping bit pattern to c(0..255) or random(c<0)\n" ); printw(" Q 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 diff --git a/display.c b/display.c index 1f0d294..7cfbaa2 100644 --- 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() diff --git a/display.h b/display.h index 294f618..ec751fe 100644 --- 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 e55f489..8d4cedb 100644 --- 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 914c2b4..d6d3a4b 100644 --- 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) diff --git a/report.c b/report.c index e15e38d..83f3156 100644 --- 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); diff --git a/select.c b/select.c index c9f768d..54b7a39 100644 --- 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)