Deleted Added
sdiff udiff text old ( 10553 ) new ( 11386 )
full compact
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

54
55void
56sflag_print()
57{
58 extern time_t now;
59 extern int oflag;
60 register PERSON *pn;
61 register WHERE *w;
62 register int sflag, r, namelen;
63 char p[80];
64 DBT data, key;
65
66 /*
67 * short format --
68 * login name
69 * real name
70 * terminal name (the XX of ttyXX)

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

75 * If > 6 months, show year instead of time.
76 * if (-o)
77 * office location
78 * office phone
79 * else
80 * remote host
81 */
82#define MAXREALNAME 20
83#define MAXHOSTNAME 20 /* in reality, hosts are never longer than 16 */
84 (void)printf("%-*s %-*s%s %s\n", UT_NAMESIZE, "Login", MAXREALNAME,
85 "Name", " TTY Idle Login Time",
86 oflag ? " Office Office Phone" : " Where");
87
88 for (sflag = R_FIRST;; sflag = R_NEXT) {
89 r = (*db->seq)(db, &key, &data, sflag);
90 if (r == -1)
91 err("db seq: %s", strerror(errno));
92 if (r == 1)
93 break;
94 pn = *(PERSON **)data.data;
95
96 for (w = pn->whead; w != NULL; w = w->next) {
97 namelen = MAXREALNAME;
98 if (w->info == LOGGEDIN && !w->writable)
99 --namelen; /* leave space before `*' */
100 (void)printf("%-*.*s %-*.*s", UT_NAMESIZE, UT_NAMESIZE,
101 pn->name, MAXREALNAME, namelen,
102 pn->realname ? pn->realname : "");
103 if (!w->loginat) {
104 (void)printf(" * * No logins ");
105 goto office;
106 }
107 (void)putchar(w->info == LOGGEDIN && !w->writable ?
108 '*' : ' ');
109 if (*w->tty)
110 (void)printf("%-3.3s ",

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

131 else
132 (void)printf(" %.5s", p + 11);
133office: if (oflag) {
134 if (pn->office)
135 (void)printf(" %-10.10s", pn->office);
136 else if (pn->officephone)
137 (void)printf(" %-10.10s", " ");
138 if (pn->officephone)
139 (void)printf(" %-.15s",
140 prphone(pn->officephone));
141 } else
142 (void)printf(" %.*s", MAXHOSTNAME, w->host);
143 putchar('\n');
144 }
145 }
146}
147

--- 19 unchanged lines hidden ---