63 lines
2.0 KiB
Diff
63 lines
2.0 KiB
Diff
|
--- w.c
|
||
|
+++ w.c 2012-06-01 14:11:59.508510289 +0000
|
||
|
@@ -239,7 +239,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)
|
||
|
+ int userlen, int fromlen)
|
||
|
{
|
||
|
unsigned long long jcpu;
|
||
|
int ut_pid_found;
|
||
|
@@ -269,7 +269,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 = UT_NAMESIZE;
|
||
|
+ fromlen = UT_HOSTSIZE;
|
||
|
+ utlnlen = UT_LINESIZE;
|
||
|
+ }
|
||
|
+ printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, u->ut_line);
|
||
|
if (from)
|
||
|
print_host(u->ut_host, UT_HOSTSIZE, fromlen);
|
||
|
print_logintime(u->ut_time, stdout);
|
||
|
@@ -319,6 +325,7 @@ static void __attribute__ ((__noreturn__
|
||
|
fputs(_(" -h, --no-header do not print header\n"
|
||
|
" -u, --no-current ignore current process username\n"
|
||
|
" -s, --short short format\n"
|
||
|
+ " -n, --no-truncat non truncated listing (large)\n"
|
||
|
" -f, --from show remote hostname field\n"
|
||
|
" -o, --old-style old style output\n"), out);
|
||
|
fputs(USAGE_SEPARATOR, out);
|
||
|
@@ -347,6 +354,7 @@ int main(int argc, char **argv)
|
||
|
{"no-header", no_argument, NULL, 'h'},
|
||
|
{"no-current", no_argument, NULL, 'u'},
|
||
|
{"sort", no_argument, NULL, 's'},
|
||
|
+ {"no-truncat", no_argument, NULL, 'n'},
|
||
|
{"from", no_argument, NULL, 'f'},
|
||
|
{"old-style", no_argument, NULL, 'o'},
|
||
|
{"help", no_argument, NULL, HELP_OPTION},
|
||
|
@@ -365,7 +373,7 @@ int main(int argc, char **argv)
|
||
|
#endif
|
||
|
|
||
|
while ((ch =
|
||
|
- getopt_long(argc, argv, "husfoV", longopts, NULL)) != -1)
|
||
|
+ getopt_long(argc, argv, "husnfoV", longopts, NULL)) != -1)
|
||
|
switch (ch) {
|
||
|
case 'h':
|
||
|
header = 0;
|
||
|
@@ -376,6 +384,10 @@ int main(int argc, char **argv)
|
||
|
case 's':
|
||
|
longform = 0;
|
||
|
break;
|
||
|
+ case 'n':
|
||
|
+ longform = 2;
|
||
|
+ header = 0;
|
||
|
+ break;
|
||
|
case 'f':
|
||
|
from = !from;
|
||
|
break;
|