Deleted Added
full compact
w.c (201611) w.c (202199)
1/*-
2 * Copyright (c) 1980, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
1/*-
2 * Copyright (c) 1980, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
36__FBSDID("$FreeBSD: head/usr.bin/w/w.c 201611 2010-01-05 21:00:23Z dwmalone $");
36__FBSDID("$FreeBSD: head/usr.bin/w/w.c 202199 2010-01-13 18:09:21Z ed $");
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1980, 1991, 1993, 1994\n\
41 The Regents of the University of California. All rights reserved.\n";
42#endif
43
44#ifndef lint

--- 33 unchanged lines hidden (view full) ---

78#include <netdb.h>
79#include <nlist.h>
80#include <paths.h>
81#include <resolv.h>
82#include <stdio.h>
83#include <stdlib.h>
84#include <string.h>
85#include <timeconv.h>
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1980, 1991, 1993, 1994\n\
41 The Regents of the University of California. All rights reserved.\n";
42#endif
43
44#ifndef lint

--- 33 unchanged lines hidden (view full) ---

78#include <netdb.h>
79#include <nlist.h>
80#include <paths.h>
81#include <resolv.h>
82#include <stdio.h>
83#include <stdlib.h>
84#include <string.h>
85#include <timeconv.h>
86#define _ULOG_POSIX_NAMES
87#include <ulog.h>
88#include <unistd.h>
86#include <unistd.h>
87#include <utmpx.h>
89#include <vis.h>
90
91#include "extern.h"
92
93struct timeval boottime;
94struct utmpx *utmp;
95struct winsize ws;
96kvm_t *kd;

--- 181 unchanged lines hidden (view full) ---

278 W_DISPLINESIZE, W_DISPLINESIZE, HEADER_TTY,
279 W_DISPHOSTSIZE, W_DISPHOSTSIZE, HEADER_FROM,
280 HEADER_LOGIN_IDLE HEADER_WHAT);
281 }
282
283 if ((kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nentries)) == NULL)
284 err(1, "%s", kvm_geterr(kd));
285 for (i = 0; i < nentries; i++, kp++) {
88#include <vis.h>
89
90#include "extern.h"
91
92struct timeval boottime;
93struct utmpx *utmp;
94struct winsize ws;
95kvm_t *kd;

--- 181 unchanged lines hidden (view full) ---

277 W_DISPLINESIZE, W_DISPLINESIZE, HEADER_TTY,
278 W_DISPHOSTSIZE, W_DISPHOSTSIZE, HEADER_FROM,
279 HEADER_LOGIN_IDLE HEADER_WHAT);
280 }
281
282 if ((kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nentries)) == NULL)
283 err(1, "%s", kvm_geterr(kd));
284 for (i = 0; i < nentries; i++, kp++) {
286 if (kp->ki_stat == SIDL || kp->ki_stat == SZOMB)
285 if (kp->ki_stat == SIDL || kp->ki_stat == SZOMB ||
286 kp->ki_tdev == NODEV)
287 continue;
288 for (ep = ehead; ep != NULL; ep = ep->next) {
289 if (ep->tdev == kp->ki_tdev) {
290 /*
291 * proc is associated with this terminal
292 */
293 if (ep->kp == NULL && kp->ki_pgid == kp->ki_tpgid) {
294 /*

--- 118 unchanged lines hidden (view full) ---

413 ptr = "-";
414 (void)printf("\t\t%-9d %s\n",
415 dkp->ki_pid, ptr);
416 }
417 }
418 (void)printf("%-*.*s %-*.*s %-*.*s ",
419 W_DISPUSERSIZE, W_DISPUSERSIZE, ep->utmp.ut_user,
420 W_DISPLINESIZE, W_DISPLINESIZE,
287 continue;
288 for (ep = ehead; ep != NULL; ep = ep->next) {
289 if (ep->tdev == kp->ki_tdev) {
290 /*
291 * proc is associated with this terminal
292 */
293 if (ep->kp == NULL && kp->ki_pgid == kp->ki_tpgid) {
294 /*

--- 118 unchanged lines hidden (view full) ---

413 ptr = "-";
414 (void)printf("\t\t%-9d %s\n",
415 dkp->ki_pid, ptr);
416 }
417 }
418 (void)printf("%-*.*s %-*.*s %-*.*s ",
419 W_DISPUSERSIZE, W_DISPUSERSIZE, ep->utmp.ut_user,
420 W_DISPLINESIZE, W_DISPLINESIZE,
421 strncmp(ep->utmp.ut_line, "tty", 3) &&
421 *ep->utmp.ut_line ?
422 (strncmp(ep->utmp.ut_line, "tty", 3) &&
422 strncmp(ep->utmp.ut_line, "cua", 3) ?
423 strncmp(ep->utmp.ut_line, "cua", 3) ?
423 ep->utmp.ut_line : ep->utmp.ut_line + 3,
424 ep->utmp.ut_line : ep->utmp.ut_line + 3) : "-",
424 W_DISPHOSTSIZE, W_DISPHOSTSIZE, *p ? p : "-");
425 t = ep->utmp.ut_tv.tv_sec;
426 longattime = pr_attime(&t, &now);
427 longidle = pr_idle(ep->idle);
428 (void)printf("%.*s\n", argwidth - longidle - longattime,
429 ep->args);
430 }
431 (void)kvm_close(kd);

--- 100 unchanged lines hidden ---
425 W_DISPHOSTSIZE, W_DISPHOSTSIZE, *p ? p : "-");
426 t = ep->utmp.ut_tv.tv_sec;
427 longattime = pr_attime(&t, &now);
428 longidle = pr_idle(ep->idle);
429 (void)printf("%.*s\n", argwidth - longidle - longattime,
430 ep->args);
431 }
432 (void)kvm_close(kd);

--- 100 unchanged lines hidden ---