2015-06-02 08:45:50 +02:00
|
|
|
---
|
2017-04-26 14:46:29 +02:00
|
|
|
w.1 | 3 +++
|
2023-08-18 11:10:18 +02:00
|
|
|
w.c | 19 ++++++++++++++++---
|
|
|
|
2 files changed, 19 insertions(+), 3 deletions(-)
|
2015-06-02 08:45:50 +02:00
|
|
|
|
2017-04-26 14:46:29 +02:00
|
|
|
--- w.1
|
2023-08-18 11:10:18 +02:00
|
|
|
+++ w.1 2023-08-18 08:21:51.764340794 +0000
|
2021-02-10 11:58:18 +01:00
|
|
|
@@ -40,6 +40,9 @@ and a
|
2017-04-26 14:46:29 +02:00
|
|
|
\fB\-s\fR, \fB\-\-short\fR
|
|
|
|
Use the short format. Don't print the login time, JCPU or PCPU times.
|
|
|
|
.TP
|
|
|
|
+\fB\-n\fR, \fB\-\-no\-truncat\fR
|
|
|
|
+Do not truncate the output format. This option might become renamed in future versions.
|
|
|
|
+.TP
|
|
|
|
\fB\-f\fR, \fB\-\-from\fR
|
|
|
|
Toggle printing the
|
|
|
|
.B from
|
2014-05-20 18:01:01 +02:00
|
|
|
--- w.c
|
2023-08-18 11:10:18 +02:00
|
|
|
+++ w.c 2023-08-18 08:37:32.143482035 +0000
|
2022-04-14 17:23:21 +02:00
|
|
|
@@ -394,7 +394,7 @@ static const proc_t *getproc(const utmp_
|
|
|
|
}
|
2015-06-02 08:45:50 +02:00
|
|
|
|
2022-04-14 17:23:21 +02:00
|
|
|
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)
|
2015-06-02 08:45:50 +02:00
|
|
|
{
|
2022-04-14 17:23:21 +02:00
|
|
|
unsigned long long jcpu;
|
|
|
|
int ut_pid_found;
|
2023-08-18 11:10:18 +02:00
|
|
|
@@ -424,7 +424,14 @@ static void showinfo(utmp_t * u, int for
|
2022-04-14 17:23:21 +02:00
|
|
|
strncpy(uname, u->ut_user, UT_NAMESIZE);
|
2015-06-02 08:45:50 +02:00
|
|
|
|
2022-04-14 17:23:21 +02:00
|
|
|
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);
|
2023-08-18 11:10:18 +02:00
|
|
|
+ maxcmd = MAX_CMD_WIDTH;
|
2022-04-14 17:23:21 +02:00
|
|
|
+ }
|
|
|
|
+ printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, u->ut_line);
|
|
|
|
if (from)
|
|
|
|
print_from(u, ip_addresses, fromlen);
|
2021-02-10 11:58:18 +01:00
|
|
|
#ifdef HAVE_UTMPX_H
|
2023-08-18 11:10:18 +02:00
|
|
|
@@ -478,6 +485,7 @@ static void __attribute__ ((__noreturn__
|
2014-05-20 18:01:01 +02:00
|
|
|
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);
|
2023-08-18 11:10:18 +02:00
|
|
|
@@ -514,6 +522,7 @@ int main(int argc, char **argv)
|
2014-05-20 18:01:01 +02:00
|
|
|
{"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'},
|
2023-08-18 11:10:18 +02:00
|
|
|
@@ -535,7 +544,7 @@ int main(int argc, char **argv)
|
2015-06-02 08:45:50 +02:00
|
|
|
#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;
|
2023-08-18 11:10:18 +02:00
|
|
|
@@ -546,6 +555,10 @@ int main(int argc, char **argv)
|
2015-06-02 08:45:50 +02:00
|
|
|
case 's':
|
|
|
|
longform = 0;
|
|
|
|
break;
|
|
|
|
+ case 'n':
|
|
|
|
+ longform = 2;
|
|
|
|
+ header = 0;
|
|
|
|
+ break;
|
|
|
|
case 'f':
|
|
|
|
from = !from;
|
|
|
|
break;
|