1 diff -urN epic4-1.0.1.orig/source/mail.c epic4-1.0.1/source/mail.c
2 --- epic4-1.0.1.orig/source/mail.c Tue Dec 5 01:11:57 2000
3 +++ epic4-1.0.1/source/mail.c Sun Apr 14 12:28:16 2002
5 * Written by Jeremy Nelson
6 * Copyright 1996 EPIC Software Labs
10 + * Maildirs are also supported.
11 + * Written by Olgierd Pieczul <wojrus@pld.org.pl>
23 static char *mail_path = (char *) 0;
27 static time_t old_stat = 0;
29 struct stat * stat_buf;
32 stat_buf = (struct stat *)ptr;
35 if (!(tmp_mail_path = getenv("MAIL")))
36 tmp_mail_path = path_search(username, mail_path_list);
39 + if (tmp_mail_path) {
40 mail_path = m_strdup(tmp_mail_path);
42 + if (stat(mail_path, stat_buf) == -1)
44 + /* Check whether mailbox is a directory (Maildir) and add "new/" suffix */
45 + if ((stat_buf->st_mode & S_IFMT) == S_IFDIR)
46 + mail_path = m_2dup(mail_path, "/new/");
49 mail_path = m_strdup("<unknown>");
53 old_stat = stat_buf->st_ctime;
54 if (stat_buf->st_size)
60 * If there is something in the mailbox
62 - if (stat_buf->st_size)
65 + if (stat_buf->st_size) {
66 + /* if maildir - how many files */
67 + if ((stat_buf->st_mode & S_IFMT) == S_IFDIR) {
70 + if ((dir = opendir(mail_path)) == NULL)
72 + while (readdir(dir) != NULL)
83 * The mailbox is empty.
90 * check_mail: report on status of inbox.
100 static int old_count = 0;
101 static char ret_str[12];
103 @@ -152,34 +175,43 @@
107 - if (!(mail = fopen(mail_path, "r")))
110 - while (fgets(buffer, 254, mail))
111 - if (!strncmp("From ", buffer, 5))
118 + if ((stat_buf.st_mode & S_IFMT) == S_IFDIR) {
119 + if ((dir = opendir(mail_path)) == NULL)
121 + while (readdir(dir) != NULL)
128 + if (!(mail = fopen(mail_path, "r")))
131 + while (fgets(buffer, 254, mail))
132 + if (!strncmp("From ", buffer, 5))
138 - /* XXX Ew. Evil. Gross. */
139 - ts.actime = stat_buf.st_atime;
140 - ts.modtime = stat_buf.st_mtime;
141 - utime(mail_path, &ts); /* XXX Ick. Gross */
142 + /* XXX Ew. Evil. Gross. */
143 + ts.actime = stat_buf.st_atime;
144 + ts.modtime = stat_buf.st_mtime;
145 + utime(mail_path, &ts); /* XXX Ick. Gross */
148 - if (count > old_count)
150 - if (do_hook(MAIL_LIST, "%d %d",
151 - count - old_count, count))
153 - int lastlog_level =
154 + if (count > old_count)
156 + if (do_hook(MAIL_LIST, "%d %d",
157 + count - old_count, count))
159 + int lastlog_level =
160 set_lastlog_msg_level(LOG_CRAP);
161 say("You have new email.");
162 set_lastlog_msg_level(lastlog_level);
168 sprintf(ret_str, "%d", old_count);