Mercurial > hg > toybox
view toys/other/w.c @ 1539:3e85af1f7e22 draft
First batch of sed tests.
Only good for TEST_HOST=1 at the moment because the test infrastructure itself
depends on sed, so if an unfinished sed is in the $PATH it goes boing. But
hey, corner cases!
I have... more.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 29 Oct 2014 18:44:33 -0500 |
parents | 786841fdb1e0 |
children | 685a0da6ca59 |
line wrap: on
line source
/* w.c - shows logged in users * * Copyright 2012 Gaurang Shastri <gmshastri@gmail.com> USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN)) config W bool "w" default y help usage: w Show who is logged on and since how long they logged in. */ #include "toys.h" void w_main(void) { struct utmpx *x; xprintf("USER TTY LOGIN@ FROM"); setutxent(); while ((x=getutxent()) != NULL) { if (x->ut_type==7) { time_t tt = x->ut_tv.tv_sec; xprintf("\n%-9.8s%-9.8s %-4.24s (%-1.12s)", x->ut_user, x->ut_line, ctime(&tt), x->ut_host); } } xputc('\n'); }