2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-FileCopyrightText: 1989 - 1991, Julianne Frances Haugh
|
|
|
|
* SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz
|
|
|
|
* SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
|
|
|
|
* SPDX-FileCopyrightText: 2008 , Nicolas François
|
2007-10-07 17:14:02 +05:30
|
|
|
*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "prototypes.h"
|
|
|
|
#include "defines.h"
|
2009-04-28 01:39:18 +05:30
|
|
|
#include <assert.h>
|
2007-10-07 17:14:02 +05:30
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2023-02-05 03:11:18 +05:30
|
|
|
#include "alloc.h"
|
2007-10-07 17:14:02 +05:30
|
|
|
#include "getdef.h"
|
|
|
|
|
2007-11-11 05:16:11 +05:30
|
|
|
#ident "$Id$"
|
2007-10-07 17:17:01 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:15:23 +05:30
|
|
|
void mailcheck (void)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
char *mailbox;
|
|
|
|
|
2008-08-31 00:01:56 +05:30
|
|
|
if (!getdef_bool ("MAIL_CHECK_ENAB")) {
|
2007-10-07 17:14:02 +05:30
|
|
|
return;
|
2008-08-31 00:01:56 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* Check incoming mail in Maildir format - J.
|
|
|
|
*/
|
2008-05-26 05:29:05 +05:30
|
|
|
mailbox = getenv ("MAILDIR");
|
|
|
|
if (NULL != mailbox) {
|
2007-10-07 17:14:02 +05:30
|
|
|
char *newmail;
|
2009-04-25 03:52:57 +05:30
|
|
|
size_t len = strlen (mailbox) + 5;
|
2009-04-25 04:16:06 +05:30
|
|
|
int wlen;
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2023-02-05 03:11:18 +05:30
|
|
|
newmail = XMALLOCARRAY (len, char);
|
2009-04-25 04:16:06 +05:30
|
|
|
wlen = snprintf (newmail, len, "%s/new", mailbox);
|
|
|
|
assert (wlen == (int) len - 1);
|
|
|
|
|
2007-10-07 17:15:23 +05:30
|
|
|
if (stat (newmail, &statbuf) != -1 && statbuf.st_size != 0) {
|
2007-10-07 17:14:02 +05:30
|
|
|
if (statbuf.st_mtime > statbuf.st_atime) {
|
2007-10-07 17:15:23 +05:30
|
|
|
free (newmail);
|
2009-04-25 03:52:57 +05:30
|
|
|
(void) puts (_("You have new mail."));
|
2007-10-07 17:14:02 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-10-07 17:15:23 +05:30
|
|
|
free (newmail);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
2008-08-31 00:01:56 +05:30
|
|
|
mailbox = getenv ("MAIL");
|
|
|
|
if (NULL == mailbox) {
|
2007-10-07 17:14:02 +05:30
|
|
|
return;
|
2008-08-31 00:01:56 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-08-31 00:01:56 +05:30
|
|
|
if ( (stat (mailbox, &statbuf) == -1)
|
|
|
|
|| (statbuf.st_size == 0)) {
|
2009-04-25 03:52:57 +05:30
|
|
|
(void) puts (_("No mail."));
|
2008-08-31 00:01:56 +05:30
|
|
|
} else if (statbuf.st_atime > statbuf.st_mtime) {
|
2009-04-25 03:52:57 +05:30
|
|
|
(void) puts (_("You have mail."));
|
2008-08-31 00:01:56 +05:30
|
|
|
} else {
|
2009-04-25 03:52:57 +05:30
|
|
|
(void) puts (_("You have new mail."));
|
2008-08-31 00:01:56 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-08-31 00:01:56 +05:30
|
|
|
|