Return to BSD News archive
Xref: sserve comp.os.386bsd.development:1293 comp.os.386bsd.bugs:1560 comp.unix.bsd:12719
Path: sserve!newshost.anu.edu.au!munnari.oz.au!goanna.cs.rmit.oz.au!yallara!lm
From: lm@yallara.cs.rmit.OZ.AU (Luke Mewburn)
Newsgroups: comp.os.386bsd.development,comp.os.386bsd.bugs,comp.unix.bsd
Subject: [Net/2] minor enhancements to finger
Date: 7 Oct 1993 07:55:04 GMT
Organization: Support staff, Dept. of Computer Science, RMIT
Lines: 239
Message-ID: <290i0o$fpr@goanna.cs.rmit.oz.au>
Reply-To: zak@rmit.edu.au
NNTP-Posting-Host: yallara.cs.rmit.oz.au
Summary: added mail status and fixed man pages
Keywords: net/2, bsd, finger, mail status, typo
Whilst hacking the Net/2 version of finger to work on Solaris 2.2 (we
needed a finger on that platform which grokked the office/phone # GCOS
info), I decided to put mail status in (as the solaris version has
that).
The attached patch adds:
- manual page typos fixed: finger doesn't scan .forward, contrary to
what the man page says (and really shouldn't either, IMHO - that's
what telnet host SMTP & VRFY are for :)
- added a mail check (printed between login info and the project).
three different messages possible:
- if you have no mail:
No Mail.
- if you have mail, but there's no unread mail:
Mail last read DDD MMM ## HH:MM (TZ)
- if you have new mail:
New mail received DDD MMM ## HH:MM (TZ)
Unread since DDD MMM ## HH:MM (TZ)
- fixed the manual page.
Luke.
--- cut here --- file: finger.dif
diff -c finger-net2/finger.1 finger/finger.1
*** finger-net2/finger.1 Tue Aug 6 04:13:56 1991
--- finger/finger.1 Thu Oct 7 17:21:21 1993
***************
*** 70,77 ****
described for the
.Fl s
option as well as the user's home directory, home phone number, login
! shell, and the contents of the files
! .Dq Pa .forward ,
.Dq Pa .plan
and
.Dq Pa .project
--- 70,76 ----
described for the
.Fl s
option as well as the user's home directory, home phone number, login
! shell, mail status, and the contents of the files
.Dq Pa .plan
and
.Dq Pa .project
***************
*** 85,90 ****
--- 84,90 ----
Numbers specified as ten or seven digits are printed as the appropriate
subset of that string.
Numbers specified as five digits are printed as ``xN-NNNN''.
+ Numbers specified as four digits are printed as ``xNNNN''.
.Pp
If write permission is denied to the device, the phrase ``(messages off)''
is appended to the line containing the device name.
***************
*** 93,98 ****
--- 93,103 ----
option; if a user is logged on multiple times, terminal information
is repeated once per login.
.Pp
+ Mail status is shown as ``No Mail.'' if there is no mail at all,
+ ``Mail last read DDD MMM ## HH:MM YYYY (TZ)'' if the person has looked
+ at their mailbox since new mail arriving, or ``New mail received ...'',
+ `` Unread since ...'' if they have new mail.
+ .Pp
.It Fl p
Prevents
the
***************
*** 100,106 ****
option of
.Nm finger
from displaying the contents of the
- .Dq Pa .forward ,
.Dq Pa .plan
and
.Dq Pa .project
--- 105,110 ----
diff -c finger-net2/finger.c finger/finger.c
*** finger-net2/finger.c Thu Apr 18 10:47:49 1991
--- finger/finger.c Thu Oct 7 17:22:17 1993
***************
*** 34,39 ****
--- 34,43 ----
* SUCH DAMAGE.
*/
+ /*
+ * Mail status reporting added 931007 by Luke Mewburn, <zak@rmit.edu.au>.
+ */
+
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
diff -c finger-net2/finger.h finger/finger.h
*** finger-net2/finger.h Thu Apr 18 10:47:49 1991
--- finger/finger.h Thu Oct 7 10:27:03 1993
***************
*** 39,44 ****
--- 39,46 ----
#include <pwd.h>
#include <utmp.h>
+ #define _PATH_MAILSPOOL "/var/mail"
+
/*
* All unique persons are linked in a list headed by "head" and linkd
* by the "next" field, as well as kept in a hash table.
***************
*** 55,60 ****
--- 57,64 ----
char *officephone; /* pointer to office phone no. */
char *realname; /* pointer to full name */
char *shell; /* user's shell */
+ time_t mailread; /* last time mail was read */
+ time_t mailrecv; /* last time mail was read */
struct where *whead, *wtail; /* list of where he is or has been */
} PERSON;
diff -c finger-net2/lprint.c finger/lprint.c
*** finger-net2/lprint.c Thu Apr 18 10:47:49 1991
--- finger/lprint.c Thu Oct 7 10:37:09 1993
***************
*** 197,202 ****
--- 197,219 ----
}
putchar('\n');
}
+ if (pn->mailrecv == -1)
+ printf("No Mail.\n");
+ else if (pn->mailrecv > pn->mailread) {
+ tp = localtime(&pn->mailrecv);
+ t = asctime(tp);
+ tzn = tp->tm_zone;
+ printf("New mail received %.16s %.4s (%s)\n", t, t + 20, tzn);
+ tp = localtime(&pn->mailread);
+ t = asctime(tp);
+ tzn = tp->tm_zone;
+ printf(" Unread since %.16s %.4s (%s)\n", t, t + 20, tzn);
+ } else {
+ tp = localtime(&pn->mailread);
+ t = asctime(tp);
+ tzn = tp->tm_zone;
+ printf("Mail last read %.16s %.4s (%s)\n", t, t + 20, tzn);
+ }
}
demi_print(str, oddfield)
diff -c finger-net2/util.c finger/util.c
*** finger-net2/util.c Thu Apr 18 10:47:50 1991
--- finger/util.c Thu Oct 7 10:30:52 1993
***************
*** 45,50 ****
--- 45,51 ----
#include <ctype.h>
#include <string.h>
#include <paths.h>
+ #include <errno.h>
#include "finger.h"
find_idle_and_ttywrite(w)
***************
*** 71,77 ****
--- 72,81 ----
register PERSON *pn;
register struct passwd *pw;
{
+ extern time_t now;
register char *p, *t;
+ struct stat sb;
+ extern int errno;
char *bp, name[1024];
pn->realname = pn->office = pn->officephone = pn->homephone = NULL;
***************
*** 105,110 ****
--- 109,126 ----
strdup(p) : NULL;
pn->homephone = ((p = strsep(&bp, ",")) && *p) ?
strdup(p) : NULL;
+ (void)sprintf(tbuf, "%s/%s", _PATH_MAILSPOOL, pw->pw_name);
+ pn->mailrecv = -1; /* -1 == not_valid */
+ if (stat(tbuf, &sb) < 0) {
+ if (errno != ENOENT) {
+ (void)fprintf(stderr,
+ "finger: %s: %s\n", tbuf, strerror(errno));
+ return;
+ }
+ } else if (sb.st_size != 0) {
+ pn->mailrecv = sb.st_mtime;
+ pn->mailread = sb.st_atime;
+ }
}
match(pw, user)
***************
*** 318,331 ****
*p++ = *num++;
break;
case 5: /* x0-1234 */
*p++ = 'x';
*p++ = *num++;
break;
default:
return(num);
}
! *p++ = '-';
! *p++ = *num++;
*p++ = *num++;
*p++ = *num++;
*p++ = *num++;
--- 334,350 ----
*p++ = *num++;
break;
case 5: /* x0-1234 */
+ case 4: /* x1234 */
*p++ = 'x';
*p++ = *num++;
break;
default:
return(num);
}
! if (len != 4) {
! *p++ = '-';
! *p++ = *num++;
! }
*p++ = *num++;
*p++ = *num++;
*p++ = *num++;
--- cut here ---
--
`Aah ... Yes, and how does madam wish to pay?' Luke Mewburn [Zak]
She slapped her credit card on the counter. <zak@rmit.edu.au>
`Eventually.'
- Lady Sharrow, in Iain M. Banks' `Against a Dark Background'