summaryrefslogtreecommitdiffstats
path: root/usr.bin/finger/sprint.c
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1994-09-07 07:22:41 +0000
committerpst <pst@FreeBSD.org>1994-09-07 07:22:41 +0000
commit72c244e5533a91ef34a3fac2404611a46ee6874a (patch)
treeef10cc8b732e94b450f8199f8c72cfd130652b5a /usr.bin/finger/sprint.c
parent62391009757751f11deb63fb9ed07fab5976c86c (diff)
downloadFreeBSD-src-72c244e5533a91ef34a3fac2404611a46ee6874a.zip
FreeBSD-src-72c244e5533a91ef34a3fac2404611a46ee6874a.tar.gz
Install Luke's enhancements for finger.
By default, behave like the old ugly 4.4bsd finger and print office information instead of remote login information. It's an easy one line fix to make it behave like most other vendor's fingers if we decide to change the default. Reviewed by: pst
Diffstat (limited to 'usr.bin/finger/sprint.c')
-rw-r--r--usr.bin/finger/sprint.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c
index 68deb76..a59fdd0 100644
--- a/usr.bin/finger/sprint.c
+++ b/usr.bin/finger/sprint.c
@@ -57,6 +57,7 @@ void
sflag_print()
{
extern time_t now;
+ extern int oflag;
register PERSON *pn;
register WHERE *w;
register int sflag, r;
@@ -71,14 +72,19 @@ sflag_print()
* if terminal writeable (add an '*' to the terminal name
* if not)
* if logged in show idle time and day logged in, else
- * show last login date and time. If > 6 moths,
- * show year instead of time.
- * office location
- * office phone
+ * show last login date and time.
+ * If > 6 months, show year instead of time.
+ * if (-o)
+ * office location
+ * office phone
+ * else
+ * remote host
*/
#define MAXREALNAME 20
- (void)printf("%-*s %-*s %s\n", UT_NAMESIZE, "Login", MAXREALNAME,
- "Name", "Tty Idle Login Time Office Office Phone");
+#define MAXHOSTNAME 20
+ (void)printf("%-*s %-*s %s %s\n", UT_NAMESIZE, "Login", MAXREALNAME,
+ "Name", "TTY Idle Login Time",
+ oflag ? " Office Office Phone" : " Where");
for (sflag = R_FIRST;; sflag = R_NEXT) {
r = (*db->seq)(db, &key, &data, sflag);
@@ -110,18 +116,24 @@ sflag_print()
} else
(void)printf(" * ");
p = ctime(&w->loginat);
- (void)printf("%.6s", p + 4);
+ if (now - w->loginat < SECSPERDAY * (DAYSPERWEEK - 1))
+ (void)printf("%.3s ", p);
+ else
+ (void)printf("%.6s", p + 4);
if (now - w->loginat >= SECSPERDAY * DAYSPERNYEAR / 2)
(void)printf(" %.4s", p + 20);
else
(void)printf(" %.5s", p + 11);
-office: if (pn->office)
+office: if (oflag) {
+ if (pn->office)
(void)printf(" %-10.10s", pn->office);
else if (pn->officephone)
(void)printf(" %-10.10s", " ");
if (pn->officephone)
(void)printf(" %-.15s",
prphone(pn->officephone));
+ } else
+ (void)printf(" %.*s", MAXHOSTNAME, w->host);
putchar('\n');
}
}
OpenPOWER on IntegriCloud