1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: newmail.c 769 2007-10-24 00:15:40Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2006-2007 University of Washington
8 * Copyright 2013-2015 Eduardo Chappa
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
22 #include "../estruct.h"
27 #include "../keydefs.h"
29 #include "../../pith/charconv/filesys.h"
37 * pico_new_mail - just checks mtime and atime of mail file and notifies user
38 * if it's possible that they have new mail.
45 static time_t lastchk
= 0;
49 if((p
= (char *)getenv("MAIL")) != NULL
)
50 /* fix unsafe sprintf - noticed by petter wahlman <petter@bluezone.no> */
51 snprintf(inbox
, sizeof(inbox
), "%s", p
);
53 snprintf(inbox
, sizeof(inbox
), "%s/%s", MAILDIR
, (char *) getlogin());
55 if(our_stat(inbox
, &sbuf
) == 0){
56 ret
= sbuf
.st_atime
<= sbuf
.st_mtime
&&
57 (lastchk
< sbuf
.st_mtime
&& lastchk
< sbuf
.st_atime
);
58 lastchk
= sbuf
.st_mtime
;