w.c (245633) | w.c (245635) |
---|---|
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 --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> 31 | 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 --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> 31 |
32__FBSDID("$FreeBSD: head/usr.bin/w/w.c 245633 2013-01-18 23:54:27Z delphij $"); | 32__FBSDID("$FreeBSD: head/usr.bin/w/w.c 245635 2013-01-19 00:21:55Z jhb $"); |
33 34#ifndef lint 35static const char copyright[] = 36"@(#) Copyright (c) 1980, 1991, 1993, 1994\n\ 37 The Regents of the University of California. All rights reserved.\n"; 38#endif 39 40#ifndef lint --- 50 unchanged lines hidden (view full) --- 91static time_t now; /* the current time of day */ 92static int ttywidth; /* width of tty */ 93static int argwidth; /* width of tty */ 94static int header = 1; /* true if -h flag: don't print heading */ 95static int nflag; /* true if -n flag: don't convert addrs */ 96static int dflag; /* true if -d flag: output debug info */ 97static int sortidle; /* sort by idle time */ 98int use_ampm; /* use AM/PM time */ | 33 34#ifndef lint 35static const char copyright[] = 36"@(#) Copyright (c) 1980, 1991, 1993, 1994\n\ 37 The Regents of the University of California. All rights reserved.\n"; 38#endif 39 40#ifndef lint --- 50 unchanged lines hidden (view full) --- 91static time_t now; /* the current time of day */ 92static int ttywidth; /* width of tty */ 93static int argwidth; /* width of tty */ 94static int header = 1; /* true if -h flag: don't print heading */ 95static int nflag; /* true if -n flag: don't convert addrs */ 96static int dflag; /* true if -d flag: output debug info */ 97static int sortidle; /* sort by idle time */ 98int use_ampm; /* use AM/PM time */ |
99int showthreads = 0;/* will threads be shown? */ | |
100static int use_comma; /* use comma as floats separator */ 101static char **sel_users; /* login array of particular users selected */ 102 103/* 104 * One of these per active utmp entry. 105 */ 106static struct entry { 107 struct entry *next; --- 11 unchanged lines hidden (view full) --- 119#define W_DISPLINESIZE 8 120#define W_DISPHOSTSIZE 24 121 122static void pr_header(time_t *, int); 123static struct stat *ttystat(char *); 124static void usage(int); 125static int this_is_uptime(const char *s); 126 | 99static int use_comma; /* use comma as floats separator */ 100static char **sel_users; /* login array of particular users selected */ 101 102/* 103 * One of these per active utmp entry. 104 */ 105static struct entry { 106 struct entry *next; --- 11 unchanged lines hidden (view full) --- 118#define W_DISPLINESIZE 8 119#define W_DISPHOSTSIZE 24 120 121static void pr_header(time_t *, int); 122static struct stat *ttystat(char *); 123static void usage(int); 124static int this_is_uptime(const char *s); 125 |
127char *fmt_argv(char **, char *, int); /* ../../bin/ps/fmt.c */ | 126char *fmt_argv(char **, char *, char *, size_t); /* ../../bin/ps/fmt.c */ |
128 129int 130main(int argc, char *argv[]) 131{ 132 struct kinfo_proc *kp; 133 struct kinfo_proc *dkp; 134 struct stat *stp; 135 time_t touched; --- 180 unchanged lines hidden (view full) --- 316 if (argwidth < 4) 317 argwidth = 8; 318 for (ep = ehead; ep != NULL; ep = ep->next) { 319 if (ep->kp == NULL) { 320 ep->args = strdup("-"); 321 continue; 322 } 323 ep->args = fmt_argv(kvm_getargv(kd, ep->kp, argwidth), | 127 128int 129main(int argc, char *argv[]) 130{ 131 struct kinfo_proc *kp; 132 struct kinfo_proc *dkp; 133 struct stat *stp; 134 time_t touched; --- 180 unchanged lines hidden (view full) --- 315 if (argwidth < 4) 316 argwidth = 8; 317 for (ep = ehead; ep != NULL; ep = ep->next) { 318 if (ep->kp == NULL) { 319 ep->args = strdup("-"); 320 continue; 321 } 322 ep->args = fmt_argv(kvm_getargv(kd, ep->kp, argwidth), |
324 ep->kp->ki_comm, MAXCOMLEN); | 323 ep->kp->ki_comm, NULL, MAXCOMLEN); |
325 if (ep->args == NULL) 326 err(1, NULL); 327 } 328 /* sort by idle time */ 329 if (sortidle && ehead != NULL) { 330 struct entry *from, *save; 331 332 from = ehead; --- 67 unchanged lines hidden (view full) --- 400 (void)snprintf(buf, sizeof(buf), "%s:%s", p, x_suffix); 401 p = buf; 402 } 403 if (dflag) { 404 for (dkp = ep->dkp; dkp != NULL; dkp = debugproc(dkp)) { 405 const char *ptr; 406 407 ptr = fmt_argv(kvm_getargv(kd, dkp, argwidth), | 324 if (ep->args == NULL) 325 err(1, NULL); 326 } 327 /* sort by idle time */ 328 if (sortidle && ehead != NULL) { 329 struct entry *from, *save; 330 331 from = ehead; --- 67 unchanged lines hidden (view full) --- 399 (void)snprintf(buf, sizeof(buf), "%s:%s", p, x_suffix); 400 p = buf; 401 } 402 if (dflag) { 403 for (dkp = ep->dkp; dkp != NULL; dkp = debugproc(dkp)) { 404 const char *ptr; 405 406 ptr = fmt_argv(kvm_getargv(kd, dkp, argwidth), |
408 dkp->ki_comm, MAXCOMLEN); | 407 dkp->ki_comm, NULL, MAXCOMLEN); |
409 if (ptr == NULL) 410 ptr = "-"; 411 (void)printf("\t\t%-9d %s\n", 412 dkp->ki_pid, ptr); 413 } 414 } 415 (void)printf("%-*.*s %-*.*s %-*.*s ", 416 W_DISPUSERSIZE, W_DISPUSERSIZE, ep->utmp.ut_user, --- 113 unchanged lines hidden --- | 408 if (ptr == NULL) 409 ptr = "-"; 410 (void)printf("\t\t%-9d %s\n", 411 dkp->ki_pid, ptr); 412 } 413 } 414 (void)printf("%-*.*s %-*.*s %-*.*s ", 415 W_DISPUSERSIZE, W_DISPUSERSIZE, ep->utmp.ut_user, --- 113 unchanged lines hidden --- |