2 * ========================================================================
3 * Copyright 2006-2007 University of Washington
4 * Copyright 2013-2022 Eduardo Chappa
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
18 #include "../estruct.h"
23 #include "../keydefs.h"
25 #include "../../pith/charconv/filesys.h"
33 * pico_new_mail - just checks mtime and atime of mail file and notifies user
34 * if it's possible that they have new mail.
41 static time_t lastchk
= 0;
45 if((p
= (char *)getenv("MAIL")) != NULL
)
46 /* fix unsafe sprintf - noticed by petter wahlman <petter@bluezone.no> */
47 snprintf(inbox
, sizeof(inbox
), "%s", p
);
49 snprintf(inbox
, sizeof(inbox
), "%s/%s", MAILDIR
, (char *) getlogin());
51 if(our_stat(inbox
, &sbuf
) == 0){
52 ret
= sbuf
.st_atime
<= sbuf
.st_mtime
&&
53 (lastchk
< sbuf
.st_mtime
&& lastchk
< sbuf
.st_atime
);
54 lastchk
= sbuf
.st_mtime
;