diff options
author | Rob Landley <rob@landley.net> | 2012-07-18 20:28:19 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-07-18 20:28:19 -0500 |
commit | 1af525d9f72491e68fb21573872841e5124a930d (patch) | |
tree | b07a66db64cabf206b25ad520c143b4f97e5b6ac /toys/w.c | |
parent | b67a8ceaf110fe0bdad6c8da78568662cc50e5bb (diff) | |
download | toybox-1af525d9f72491e68fb21573872841e5124a930d.tar.gz |
Cleanup of w command.
Diffstat (limited to 'toys/w.c')
-rw-r--r-- | toys/w.c | 25 |
1 files changed, 7 insertions, 18 deletions
@@ -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'); } |