annotate toys/other/w.c @ 944:b4faf2ae39e8

This inlines CRC64, and nothing more. The functions involved were called only once.
author Isaac Dunham <idunham@lavabit.com>
date Sat, 06 Jul 2013 11:26:15 -0500
parents 786841fdb1e0
children 685a0da6ca59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
1 /* w.c - shows logged in users
630
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 * Copyright 2012 Gaurang Shastri <gmshastri@gmail.com>
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN))
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 config W
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
8 bool "w"
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
9 default y
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
10 help
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
11 usage: w
630
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
12
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
13 Show who is logged on and since how long they logged in.
630
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 */
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 #include "toys.h"
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
17
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 void w_main(void)
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 {
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
20 struct utmpx *x;
631
7c1a825f5afb Cleanup of w command.
Rob Landley <rob@landley.net>
parents: 630
diff changeset
21
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
22 xprintf("USER TTY LOGIN@ FROM");
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
23 setutxent();
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
24 while ((x=getutxent()) != NULL) {
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
25 if (x->ut_type==7) {
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
26 time_t tt = x->ut_tv.tv_sec;
630
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
28 xprintf("\n%-9.8s%-9.8s %-4.24s (%-1.12s)", x->ut_user, x->ut_line,
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
29 ctime(&tt), x->ut_host);
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
30 }
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
31 }
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
32 xputc('\n');
630
03f18afb4b44 Add w command by Gaurang Shastri.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 }