aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-07-18 20:28:19 -0500
committerRob Landley <rob@landley.net>2012-07-18 20:28:19 -0500
commit1af525d9f72491e68fb21573872841e5124a930d (patch)
treeb07a66db64cabf206b25ad520c143b4f97e5b6ac
parentb67a8ceaf110fe0bdad6c8da78568662cc50e5bb (diff)
downloadtoybox-1af525d9f72491e68fb21573872841e5124a930d.tar.gz
Cleanup of w command.
-rw-r--r--toys/w.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/toys/w.c b/toys/w.c
index 7e5a2964..50f2283b 100644
--- a/toys/w.c
+++ b/toys/w.c
@@ -15,7 +15,6 @@ config W
usage: w
Show who is logged on and since how long they logged in.
-
*/
#include "toys.h"
@@ -23,25 +22,15 @@ config W
void w_main(void)
{
struct utmpx *x;
- time_t time_val;
+
xprintf("USER TTY LOGIN@ FROM");
setutxent();
- x=getutxent();
- while(x!=NULL) {
- if(x->ut_type==7) {
- xprintf("\n");
- xprintf("%-9.8s",x->ut_user);
- xprintf("%-9.8s",x->ut_line);
+ while ((x=getutxent()) != NULL)
+ if (x->ut_type==7) {
+ time_t tt = x->ut_tv.tv_sec;
- xprintf(" ");
- time_val = (x->ut_tv.tv_sec);
- xprintf("%-4.24s",ctime(&time_val));
-
- xprintf(" (");
- xprintf("%-1.12s",x->ut_host);
- xprintf(")");
+ xprintf("\n%-9.8s%-9.8s %-4.24s (%-1.12s)", x->ut_user, x->ut_line,
+ ctime(&tt), x->ut_host);
}
- x=getutxent();
- }
- xprintf("\n");
+ xputc('\n');
}