- status = 0;
- }
- else {
- if (notifysw & NT_NMAI)
- printf (personal ? "You don't %s%s" : "%s doesn't %s",
- personal ? "" : user, "have any mail waiting");
- else
- notifysw = 0;
-
- status = 1;
- }
-
- if (notifysw)
- if (datesw && st.st_atime)
- printf ("; last read on %s", dtime (&st.st_atime, 1));
- if (notifysw)
- printf ("\n");
-
- return status;
-}
-
-
-#ifdef POP
-extern char response[];
-
-static int
-remotemail (char *host, char *user, int rpop, int kpop, int notifysw, int personal, int snoop)
-{
- int nmsgs, nbytes, status;
- char *pass = NULL;
-
- if (user == NULL)
- user = getusername ();
- if (kpop || (rpop > 0))
- pass = getusername ();
- else
- ruserpass (host, &user, &pass);
-
- /* open the POP connection */
- if (pop_init (host, user, pass, snoop, kpop ? 1 : rpop, kpop) == NOTOK
- || pop_stat (&nmsgs, &nbytes) == NOTOK /* check for messages */
- || pop_quit () == NOTOK) { /* quit POP connection */
- advise (NULL, "%s", response);
- return 1;
- }
-
- if (nmsgs) {
- if (notifysw & NT_MAIL) {
- printf (personal ? "You have " : "%s has ", user);
- printf ("%d message%s (%d bytes)",
- nmsgs, nmsgs != 1 ? "s" : "", nbytes);
+ if (datesw) {
+ st.st_size = 0;
+ st.st_atime = st.st_mtime = 0;
+ }
+ mf = (stat(buffer, &st) == NOTOK || st.st_size == 0) ? NONEOK
+ : st.st_atime <= st.st_mtime ? MAILNEW : MAILOLD;
+
+ if (mf & MAILOK) {
+ if (notifysw & NT_MAIL) {
+ if (personal) {
+ printf("You have ");
+ } else {
+ printf("%s has ", user);
+ }
+ if (mf & MAILOK)
+ printf(mf & MAILOLD ? "old" : "new");
+ printf(" mail waiting");
+ } else {
+ notifysw = 0;
+ }
+ status = 0;
+ } else {
+ if (notifysw & NT_NMAI) {
+ if (personal) {
+ printf("You don't have any mail waiting");
+ } else {
+ printf("%s doesn't have any mail waiting",
+ user);
+ }
+ } else {
+ notifysw = 0;
+ }
+ status = 1;