67 lines
2.3 KiB
Diff
67 lines
2.3 KiB
Diff
---
|
|
w.c | 18 +++++++++++++++---
|
|
1 file changed, 15 insertions(+), 3 deletions(-)
|
|
|
|
--- w.c
|
|
+++ w.c 2016-07-11 12:47:59.444256012 +0000
|
|
@@ -375,7 +375,7 @@ static const proc_t *getproc(const utmp_
|
|
}
|
|
|
|
static void showinfo(utmp_t * u, int formtype, int maxcmd, int from,
|
|
- const int userlen, const int fromlen, const int ip_addresses)
|
|
+ int userlen, int fromlen, const int ip_addresses)
|
|
{
|
|
unsigned long long jcpu;
|
|
int ut_pid_found;
|
|
@@ -405,7 +405,13 @@ static void showinfo(utmp_t * u, int for
|
|
strncpy(uname, u->ut_user, UT_NAMESIZE);
|
|
|
|
if (formtype) {
|
|
- printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, u->ut_line);
|
|
+ int utlnlen = 8;
|
|
+ if (formtype > 1) {
|
|
+ userlen = strnlen(uname, UT_NAMESIZE);
|
|
+ fromlen = strnlen(u->ut_host, UT_HOSTSIZE);
|
|
+ utlnlen = strnlen(u->ut_line, UT_LINESIZE);
|
|
+ }
|
|
+ printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, u->ut_line);
|
|
if (from)
|
|
print_from(u, ip_addresses, fromlen);
|
|
print_logintime(u->ut_time, stdout);
|
|
@@ -455,6 +461,7 @@ static void __attribute__ ((__noreturn__
|
|
fputs(_(" -h, --no-header do not print header\n"),out);
|
|
fputs(_(" -u, --no-current ignore current process username\n"),out);
|
|
fputs(_(" -s, --short short format\n"),out);
|
|
+ fputs(_(" -n, --no-truncat non truncated listing (large)\n"),out);
|
|
fputs(_(" -f, --from show remote hostname field\n"),out);
|
|
fputs(_(" -o, --old-style old style output\n"),out);
|
|
fputs(_(" -i, --ip-addr display IP address instead of hostname (if possible)\n"), out);
|
|
@@ -491,6 +498,7 @@ int main(int argc, char **argv)
|
|
{"no-header", no_argument, NULL, 'h'},
|
|
{"no-current", no_argument, NULL, 'u'},
|
|
{"short", no_argument, NULL, 's'},
|
|
+ {"no-truncat", no_argument, NULL, 'n'},
|
|
{"from", no_argument, NULL, 'f'},
|
|
{"old-style", no_argument, NULL, 'o'},
|
|
{"ip-addr", no_argument, NULL, 'i'},
|
|
@@ -512,7 +520,7 @@ int main(int argc, char **argv)
|
|
#endif
|
|
|
|
while ((ch =
|
|
- getopt_long(argc, argv, "husfoVi", longopts, NULL)) != -1)
|
|
+ getopt_long(argc, argv, "husnfoVi", longopts, NULL)) != -1)
|
|
switch (ch) {
|
|
case 'h':
|
|
header = 0;
|
|
@@ -523,6 +531,10 @@ int main(int argc, char **argv)
|
|
case 's':
|
|
longform = 0;
|
|
break;
|
|
+ case 'n':
|
|
+ longform = 2;
|
|
+ header = 0;
|
|
+ break;
|
|
case 'f':
|
|
from = !from;
|
|
break;
|