comparison toys/other/w.c @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <rob@landley.net>
date Tue, 13 Nov 2012 17:14:08 -0600
parents 6df4ccc0acbe
children 685a0da6ca59
comparison
equal deleted inserted replaced
693:4a5a250e0633 694:786841fdb1e0
1 /* vi: set sw=4 ts=4: 1 /* w.c - shows logged in users
2 *
3 * w.c - shows logged in users
4 * 2 *
5 * Copyright 2012 Gaurang Shastri <gmshastri@gmail.com> 3 * Copyright 2012 Gaurang Shastri <gmshastri@gmail.com>
6 4
7 USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN)) 5 USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN))
8 6
9 config W 7 config W
10 bool "w" 8 bool "w"
11 default y 9 default y
12 help 10 help
13 usage: w 11 usage: w
14 12
15 Show who is logged on and since how long they logged in. 13 Show who is logged on and since how long they logged in.
16 */ 14 */
17 15
18 #include "toys.h" 16 #include "toys.h"
19 17
20 void w_main(void) 18 void w_main(void)
21 { 19 {
22 struct utmpx *x; 20 struct utmpx *x;
23 21
24 xprintf("USER TTY LOGIN@ FROM"); 22 xprintf("USER TTY LOGIN@ FROM");
25 setutxent(); 23 setutxent();
26 while ((x=getutxent()) != NULL) 24 while ((x=getutxent()) != NULL) {
27 if (x->ut_type==7) { 25 if (x->ut_type==7) {
28 time_t tt = x->ut_tv.tv_sec; 26 time_t tt = x->ut_tv.tv_sec;
29 27
30 xprintf("\n%-9.8s%-9.8s %-4.24s (%-1.12s)", x->ut_user, x->ut_line, 28 xprintf("\n%-9.8s%-9.8s %-4.24s (%-1.12s)", x->ut_user, x->ut_line,
31 ctime(&tt), x->ut_host); 29 ctime(&tt), x->ut_host);
32 } 30 }
33 xputc('\n'); 31 }
32 xputc('\n');
34 } 33 }