Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/netstat don't truncate IPv4 entries on -i (with -v)....



details:   https://anonhg.NetBSD.org/src/rev/7d49ba867926
branches:  trunk
changeset: 481281:7d49ba867926
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Jan 25 15:56:55 2000 +0000

description:
don't truncate IPv4 entries on -i (with -v).  it is mainly for
"Network" column (13 digits, it will be 18 digits in maximum).

diffstat:

 usr.bin/netstat/if.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (45 lines):

diff -r 911a4cff29fe -r 7d49ba867926 usr.bin/netstat/if.c
--- a/usr.bin/netstat/if.c      Tue Jan 25 15:44:21 2000 +0000
+++ b/usr.bin/netstat/if.c      Tue Jan 25 15:56:55 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.35 2000/01/17 18:24:37 itojun Exp $   */
+/*     $NetBSD: if.c,v 1.36 2000/01/25 15:56:55 itojun Exp $   */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
 #else
-__RCSID("$NetBSD: if.c,v 1.35 2000/01/17 18:24:37 itojun Exp $");
+__RCSID("$NetBSD: if.c,v 1.36 2000/01/25 15:56:55 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -206,13 +206,20 @@
                                printf("%-13.13s ", netname(in.s_addr,
                                    ifaddr.in.ia_subnetmask));
 #else
-                               printf("%-13.13s ",
-                                   netname(ifaddr.in.ia_subnet,
-                                   ifaddr.in.ia_subnetmask));
+                               cp = netname(ifaddr.in.ia_subnet,
+                                   ifaddr.in.ia_subnetmask);
+                               if (vflag)
+                                       n = strlen(cp) < 13 ? 13 : strlen(cp);
+                               else
+                                       n = 13;
+                               printf("%-*.*s ", n, n, cp);
 #endif
-                               printf("%-17.17s ",
-                                   routename(sin->sin_addr.s_addr));
-
+                               cp = routename(sin->sin_addr.s_addr);
+                               if (vflag)
+                                       n = strlen(cp) < 17 ? 17 : strlen(cp);
+                               else
+                                       n = 17;
+                               printf("%-*.*s ", n, n, cp);
                                if (aflag) {
                                        u_long multiaddr;
                                        struct in_multi inm;



Home | Main Index | Thread Index | Old Index