diff options
author | des <des@FreeBSD.org> | 2001-03-15 20:46:04 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2001-03-15 20:46:04 +0000 |
commit | cd8d72036779073e9a559040e5b29558621cdc99 (patch) | |
tree | 3f4a6ecbb973b94f218b84036441521df917e981 /usr.bin/netstat/inet.c | |
parent | 5848bb858cf31a463c79467310f42ac79bb149a5 (diff) | |
download | FreeBSD-src-cd8d72036779073e9a559040e5b29558621cdc99.zip FreeBSD-src-cd8d72036779073e9a559040e5b29558621cdc99.tar.gz |
Add a -W flag that tells netstat not to truncate addresses even if they are
too long for the column they're printed in.
Move variable definitions out of netstat.h and into main.c.
Clean up some warnings.
Diffstat (limited to 'usr.bin/netstat/inet.c')
-rw-r--r-- | usr.bin/netstat/inet.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index b2e3c3e..185506c 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -220,7 +220,7 @@ protopr(proto, name, af) printf("%-14.14s %-22.22s\n", "Listen", "Local Address"); else - printf(Aflag ? + printf((Aflag && !Wflag) ? "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" : "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n", "Proto", "Recv-Q", "Send-Q", @@ -244,7 +244,7 @@ protopr(proto, name, af) } else continue; else { - const u_char *vchar; + const char *vchar; #ifdef INET6 if ((inp->inp_vflag & INP_IPV6) != 0) @@ -695,16 +695,22 @@ inetprint(in, port, proto,numeric) char line[80], *cp; int width; - sprintf(line, "%.*s.", (Aflag && !numeric) ? 12 : 16, inetname(in)); + if (Wflag) + sprintf(line, "%s.", inetname(in)); + else + sprintf(line, "%.*s.", (Aflag && !numeric) ? 12 : 16, inetname(in)); cp = index(line, '\0'); if (!numeric && port) sp = getservbyport((int)port, proto); if (sp || port == 0) - sprintf(cp, "%.15s", sp ? sp->s_name : "*"); + sprintf(cp, "%.15s ", sp ? sp->s_name : "*"); + else + sprintf(cp, "%d ", ntohs((u_short)port)); + width = (Aflag && !Wflag) ? 18 : 22; + if (Wflag) + printf("%-*s ", width, line); else - sprintf(cp, "%d", ntohs((u_short)port)); - width = Aflag ? 18 : 22; - printf("%-*.*s ", width, width, line); + printf("%-*.*s ", width, width, line); } /* |