Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!aggedor.rmit.EDU.AU!goanna.cs.rmit.oz.au!yallara!lm From: lm@yallara.cs.rmit.OZ.AU (Luke Mewburn) Newsgroups: comp.unix.bsd Subject: adding host info to short finger(1) display Date: 4 Apr 1994 02:49:04 GMT Organization: Technical Services Group, Dept. of Computer Science, RMIT Lines: 303 Message-ID: <2nnv70$9jc@goanna.cs.rmit.oz.au> Reply-To: lm@rmit.edu.au NNTP-Posting-Host: yallara.cs.rmit.oz.au NNTP-Posting-User: lm This patch does two things to finger: - adds an option - `-h' - which displays the remote host instead of the office info in the short listing - prints the day name instead of the month/day combination for the login time if it was less than 6 days ago. It also patches fingerd to use -h by default. (This is for the version of finger with NetBSD-current, which is basically Net/2 finger with a previous `mail status' patch that I wrote a few months ago.) Luke. *** finger.orig/finger.1 Tue Feb 15 21:19:28 1994 --- usr.bin/finger/finger.1 Tue Mar 29 23:21:23 1994 *************** *** 32,38 **** .\" from: @(#)finger.1 6.14 (Berkeley) 7/27/91 .\" $Id: finger.1,v 1.4 1994/02/14 19:07:33 cgd Exp $ .\" ! .Dd July 27, 1991 .Dt FINGER 1 .Os BSD 4 .Sh NAME --- 32,38 ---- .\" from: @(#)finger.1 6.14 (Berkeley) 7/27/91 .\" $Id: finger.1,v 1.4 1994/02/14 19:07:33 cgd Exp $ .\" ! .Dd March 29, 1994 .Dt FINGER 1 .Os BSD 4 .Sh NAME *************** *** 40,46 **** .Nd user information lookup program .Sh SYNOPSIS .Nm finger ! .Op Fl lmsp .Op Ar user ... .Op Ar user@host ... .Sh DESCRIPTION --- 40,46 ---- .Nd user information lookup program .Sh SYNOPSIS .Nm finger ! .Op Fl lmsph .Op Ar user ... .Op Ar user@host ... .Sh DESCRIPTION *************** *** 55,67 **** displays the user's login name, real name, terminal name and write status (as a ``*'' before the terminal name if write permission is denied), idle time, login time, office location and office phone ! number. .Pp Idle time is in minutes if it is a single integer, hours and minutes if a ``:'' is present, or days if a ``d'' is present. ! Login time is displayed as month, day, hours and minutes, unless ! more than six months ago, in which case the year is displayed rather ! than the hours and minutes. .Pp Unknown devices as well as nonexistent idle and login times are displayed as single asterisks. --- 55,69 ---- displays the user's login name, real name, terminal name and write status (as a ``*'' before the terminal name if write permission is denied), idle time, login time, office location and office phone ! number. If ! .Fl h ! is also given, the remote host is printed instead of the office information. .Pp Idle time is in minutes if it is a single integer, hours and minutes if a ``:'' is present, or days if a ``d'' is present. ! Login time is displayed as dayname if less than 6 days, else month, ! day; hours and minutes, unless more than six months ago, in which ! case the year is displayed rather than the hours and minutes. .Pp Unknown devices as well as nonexistent idle and login times are displayed as single asterisks. *************** *** 99,104 **** --- 101,111 ---- at their mailbox since new mail arriving, or ``New mail received ...'', `` Unread since ...'' if they have new mail. .Pp + .It Fl h + When used in conjunction with the + .Fl s + option, the remote host information is displayed instead of the office + location and office phone. .It Fl p Prevents the *************** *** 164,166 **** --- 171,175 ---- .Nm finger command appeared in .Bx 3.0 . + Luke Mewburn (lm@rmit.edu.au) added mail status reporting, and the + optional remote host printing. *** finger.orig/finger.c Fri Dec 17 18:11:10 1993 --- usr.bin/finger/finger.c Tue Mar 29 10:41:04 1994 *************** *** 35,41 **** */ /* ! * Mail status reporting added 931007 by Luke Mewburn, <zak@rmit.edu.au>. */ #ifndef lint --- 35,42 ---- */ /* ! * Mail status reporting added 931007 by Luke Mewburn, <lm@rmit.edu.au>. ! * Host/office toggling added 940329 by Luke Mewburn, <lm@rmit.edu.au>. */ #ifndef lint *************** *** 60,65 **** --- 61,67 ---- * and office location/phone number. The long format gives the same * information (in a more legible format) as well as home directory, shell, * mail info, and .plan/.project files. + * If -h is used with -s, the office info is replaced by the remote host info. */ #include <sys/param.h> *************** *** 69,74 **** --- 71,77 ---- time_t now; int lflag, sflag, mflag, pplan; + int hflag; char tbuf[1024]; main(argc, argv) *************** *** 79,85 **** int ch; time_t time(); ! while ((ch = getopt(argc, argv, "lmps")) != EOF) switch(ch) { case 'l': lflag = 1; /* long format */ --- 82,88 ---- int ch; time_t time(); ! while ((ch = getopt(argc, argv, "lmpsh")) != EOF) switch(ch) { case 'l': lflag = 1; /* long format */ *************** *** 93,102 **** case 's': sflag = 1; /* short format */ break; case '?': default: (void)fprintf(stderr, ! "usage: finger [-lmps] [login ...]\n"); exit(1); } argc -= optind; --- 96,108 ---- case 's': sflag = 1; /* short format */ break; + case 'h': + hflag = 1; /* print host, not office */ + break; case '?': default: (void)fprintf(stderr, ! "usage: finger [-lmpsh] [login ...]\n"); exit(1); } argc -= optind; *** finger.orig/sprint.c Fri Dec 17 18:11:12 1993 --- usr.bin/finger/sprint.c Tue Mar 29 23:20:53 1994 *************** *** 50,55 **** --- 50,56 ---- sflag_print() { extern time_t now; + extern int hflag; register PERSON *pn; register WHERE *w; register int cnt; *************** *** 67,80 **** * 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 */ #define MAXREALNAME 20 ! (void)printf("%-*s %-*s %s\n", UT_NAMESIZE, "Login", MAXREALNAME, ! "Name", "Tty Idle Login Time Office Office Phone"); for (cnt = 0; cnt < entries; ++cnt) { pn = list[cnt]; for (w = pn->whead; w != NULL; w = w->next) { --- 68,88 ---- * 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 months, ! * show year instead of time. If < 6 days, ! * show day name instead of month & day. ! * if (-h) given: ! * remote host ! * else ! * office location ! * office phone */ #define MAXREALNAME 20 ! #define MAXHOSTNAME 20 ! /* "Name", "Tty Idle Login Time Office Office Phone"); */ ! (void)printf("%-*s %-*s %s %s\n", UT_NAMESIZE, "Login", MAXREALNAME, ! "Name", "Tty Idle Login Time", (hflag) ? " Where" ! : "Office Office Phone"); for (cnt = 0; cnt < entries; ++cnt) { pn = list[cnt]; for (w = pn->whead; w != NULL; w = w->next) { *************** *** 99,116 **** } else (void)printf(" * "); p = ctime(&w->loginat); ! (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) ! (void)printf(" %-10.10s", pn->office); ! else if (pn->officephone) ! (void)printf(" %-10.10s", " "); ! if (pn->officephone) ! (void)printf(" %-.15s", ! prphone(pn->officephone)); putchar('\n'); } } --- 107,132 ---- } else (void)printf(" * "); p = ctime(&w->loginat); ! 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 (hflag) ! (void)printf(" %.*s", MAXHOSTNAME, w->host); ! else { ! 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)); ! } putchar('\n'); } } *** fingerd.c.orig Tue Mar 29 23:28:06 1994 --- libexec/fingerd/fingerd.c Tue Mar 29 23:29:47 1994 *************** *** 68,74 **** exit(1); av[0] = "finger"; ! for (lp = line, ap = &av[1];;) { *ap = strtok(lp, " \t\r\n"); if (!*ap) break; --- 68,75 ---- exit(1); av[0] = "finger"; ! av[1] = "-h"; ! for (lp = line, ap = &av[2];;) { *ap = strtok(lp, " \t\r\n"); if (!*ap) break;