windows support

This commit is contained in:
Nishi 2025-11-25 11:16:05 +09:00
commit ad6df6e3fd
Signed by: nishi
GPG key ID: 27EF69B208EB9343
6 changed files with 52 additions and 54 deletions

View file

@ -4,16 +4,17 @@ static time_t last = 0;
static char* mailpath;
void init_mail(void) {
struct stat s;
struct passwd* pwd = getpwuid(getuid());
struct stat s;
char* name = MDEUsersGetUsername();
if(getenv("MAIL") != NULL) {
mailpath = malloc(strlen(getenv("MAIL")) + strlen(pwd->pw_name) + 1);
sprintf(mailpath, getenv("MAIL"), pwd->pw_name);
mailpath = malloc(strlen(getenv("MAIL")) + strlen(name) + 1);
sprintf(mailpath, getenv("MAIL"), name);
} else {
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(pwd->pw_name) + 1);
sprintf(mailpath, _PATH_MAILDIR "/%s", pwd->pw_name);
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(name) + 1);
sprintf(mailpath, _PATH_MAILDIR "/%s", name);
}
free(name);
if(stat(mailpath, &s) == 0) {
last = s.st_mtime;

View file

@ -11,8 +11,6 @@
/* Standard */
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>