aboutsummaryrefslogtreecommitdiff
path: root/networking/netstat.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-30 01:59:53 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-30 01:59:53 +0000
commitd3c042fc605737643c265a7f86fc7a77c88f629e (patch)
treea1850a3ca6493fb6409e8df0a24baf1331d325f6 /networking/netstat.c
parentfcd878efcd6df8a8d052cef753305c34c1297267 (diff)
downloadbusybox-d3c042fc605737643c265a7f86fc7a77c88f629e.tar.gz
libbb: introduce fputc_printable (from ed)
netstat: print control chars as ^C etc vi: style fixlet function old new delta fputc_printable - 100 +100 unix_do_one 451 487 +36 printLines 258 190 -68 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 136/-68) Total: 68 bytes
Diffstat (limited to 'networking/netstat.c')
-rw-r--r--networking/netstat.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/networking/netstat.c b/networking/netstat.c
index 29c2384a4..348abd8ad 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -349,13 +349,9 @@ static int unix_do_one(int nr, char *line)
const char *ss_proto, *ss_state, *ss_type;
char ss_flags[32];
- /* TODO: currently we stop at first NUL byte. Is it a problem? */
-
if (nr == 0)
return 0; /* skip header */
- *strchrnul(line, '\n') = '\0';
-
/* 2.6.15 may report lines like "... @/tmp/fam-user-^@^@^@^@^@^@^@..."
* Other users report long lines filled by NUL bytes.
* (those ^@ are NUL bytes too). We see them as empty lines. */
@@ -443,9 +439,16 @@ static int unix_do_one(int nr, char *line)
strcat(ss_flags, "N ");
strcat(ss_flags, "]");
- printf("%-5s %-6ld %-11s %-10s %-13s %6lu %s\n",
- ss_proto, refcnt, ss_flags, ss_type, ss_state, inode,
- line + path_ofs);
+ printf("%-5s %-6ld %-11s %-10s %-13s %6lu ",
+ ss_proto, refcnt, ss_flags, ss_type, ss_state, inode
+ );
+
+ /* TODO: currently we stop at first NUL byte. Is it a problem? */
+ line += path_ofs;
+ *strchrnul(line, '\n') = '\0';
+ while (*line)
+ fputc_printable(*line++, stdout);
+ bb_putchar('\n');
return 0;
}