wip
This commit is contained in:
parent
e453c5b8f4
commit
f91f5042cb
5 changed files with 239 additions and 1 deletions
32
mbiff/mail.c
Normal file
32
mbiff/mail.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "mbiff.h"
|
||||
|
||||
static time_t last = 0;
|
||||
static char* mailpath;
|
||||
|
||||
void init_mail(void){
|
||||
struct stat s;
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
|
||||
if(getenv("MAIL") != NULL){
|
||||
mailpath = malloc(strlen(getenv("MAIL")) + strlen(pwd->pw_name) + 1);
|
||||
sprintf(mailpath, getenv("MAIL"), pwd->pw_name);
|
||||
}else{
|
||||
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(pwd->pw_name) + 1);
|
||||
sprintf(mailpath, _PATH_MAILDIR "/%s", pwd->pw_name);
|
||||
}
|
||||
|
||||
if(stat(mailpath, &s) == 0){
|
||||
last = s.st_mtime;
|
||||
}
|
||||
}
|
||||
|
||||
void check_mail(void){
|
||||
struct stat s;
|
||||
if(stat(mailpath, &s) == 0){
|
||||
if(s.st_mtime > last){
|
||||
printf("!\n");
|
||||
}
|
||||
|
||||
last = s.st_mtime;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue