EPIC4 maildir patch
Sunday, March 30. 2014
I'm in the IRC 24/7. For the "idling" on my favorite channel I have used EPIC4 for a very long time. Couple of decades, in fact. The project is in a bad shape. Anything IRC-related is. For the record: I'll be the last dinosaur to punch the clock for the last time and turn off the lights when I notice that I'll be idling there alone. It won't come for another couple of decades, though.
Based on epicsol.org website, there is actually nobody to contact about EPIC4 bugs, no mailing list anymore (last one died 2009) nor any contact e-mail or a form. So, there literally is nobody who I could notify about anything. Writing on my own blog about it is pretty much all I can do for the project.
Back to business... My Linux-box is a mail-host and whenever something new arrives, it is really nice to get notified about that while doing absolutely nothing on the channel. However, when I stopped using mbox for storing the mail in my box, my favorite IRC-client stopped doing the notifying. It didn't not have the code for the more effective Maildir format. It does now.
My stuff is at http://opensource.hqcodeshop.com/EPIC/4/
It contains 64-bit RPM for Fedora 20 and the .src.rpm if you want to do the build by yourself. Note that my version is the latest EPIC4 2.10.4, not the Fedora-boxed 2.10.2.
To start using the Maildir-mode, say:
set mail_type maildir
in your .ircrc-file. The thing relies on $MAIL-environment variable to know where your mail is stored at.
Update 31th March 2014:
I actually got hold of Mr. Jeremy Nelson, the author or EPIC4 and EPIC5. He took my patch and said that it will be released in 2.10.5. We had a brief conversation in #epic-channel and he also said, that he is about to publish the EPIC5 project in Github.
My patch (epic4-2.10.1-maildir.patch) is as follows:
diff -aur epic4-2.10.1/include/config.h epic4-2.10.1.JT/include/config.h
--- epic4-2.10.1/include/config.h 2006-06-18 20:33:51.000000000 +0300
+++ epic4-2.10.1.JT/include/config.h 2012-08-30 13:22:20.319515332 +0300
@@ -412,7 +412,7 @@
#define DEFAULT_LOGFILE "irc.log"
#define DEFAULT_MAIL 2
#define DEFAULT_MAIL_INTERVAL 60
-/ #define DEFAULT_MAIL_TYPE "mbox" /
+#define DEFAULT_MAIL_TYPE "mbox"
#define DEFAULT_MAX_RECONNECTS 4
#define DEFAULT_METRIC_TIME 0
#define DEFAULT_MODE_STRIPPER 0
diff -aur epic4-2.10.1/include/vars.h epic4-2.10.1.JT/include/vars.h
--- epic4-2.10.1/include/vars.h 2006-06-18 20:33:51.000000000 +0300
+++ epic4-2.10.1.JT/include/vars.h 2012-08-30 13:24:19.719723226 +0300
@@ -93,7 +93,7 @@
LOG_REWRITE_VAR,
MAIL_VAR,
MAIL_INTERVAL_VAR,
- / MAIL_TYPE_VAR, /
+ MAIL_TYPE_VAR,
MANGLE_INBOUND_VAR,
MANGLE_LOGFILES_VAR,
MANGLE_OUTBOUND_VAR,
diff -aur epic4-2.10.1/source/mail.c epic4-2.10.1.JT/source/mail.c
--- epic4-2.10.1/source/mail.c 2006-06-18 20:33:51.000000000 +0300
+++ epic4-2.10.1.JT/source/mail.c 2012-08-30 15:25:05.568641118 +0300
@@ -353,7 +353,7 @@
return 0;
}
- maildir_path = malloc_strdup(tmp_maildir_path);
+ maildir_path = malloc_strdup(maildir);
maildir_last_changed = -1;
return 1;
}
@@ -375,13 +375,29 @@
{
int count = 0;
DIR dir;
+ Filename tmp_maildir_path;
+ struct dirent* dir_data;
- if ((dir = opendir(maildir_path)))
+ strlcpy(tmp_maildir_path, maildir_path, sizeof(Filename));
+ strlcat(tmp_maildir_path, "/new", sizeof(Filename));
+ if ((dir = opendir(tmp_maildir_path)))
{
- while (readdir(dir) != NULL)
- count++;
+ while ((dir_data = readdir(dir)) != NULL) {
+ if (dir_data->d_name[0] != '.')
+ count++;
+ }
+ closedir(dir);
+ }
+
+ strlcpy(tmp_maildir_path, maildir_path, sizeof(Filename));
+ strlcat(tmp_maildir_path, "/cur", sizeof(Filename));
+ if ((dir = opendir(tmp_maildir_path)))
+ {
+ while ((dir_data = readdir(dir)) != NULL) {
+ if (dir_data->d_name[0] != '.')
+ count++;
+ }
closedir(dir);
- count -= 2; / Don't count . or .. /
}
return count;
@@ -398,6 +414,7 @@
{
Stat sb;
Stat stat_buf;
+ Filename tmp_maildir_path;
if (ptr)
stat_buf = (Stat )ptr;
@@ -408,8 +425,11 @@
if (!init_maildir_checking())
return 0; / Can't find maildir /
+ strlcpy(tmp_maildir_path, maildir_path, sizeof(Filename));
+ strlcat(tmp_maildir_path, "/new", sizeof(Filename));
+
/ If there is no mailbox, there is no mail! /
- if (stat(maildir_path, stat_buf) == -1)
+ if (stat(tmp_maildir_path, stat_buf) == -1)
return 0;
/
@@ -547,6 +567,10 @@
update_mail_level2_maildir();
if (status == 2)
{
+ Filename tmp_maildir_path;
+ strlcpy(tmp_maildir_path, maildir_path, sizeof(Filename));
+ strlcat(tmp_maildir_path, "/new", sizeof(Filename));
+
/ XXX Ew. Evil. Gross. /
ts.actime = stat_buf.st_atime;
ts.modtime = stat_buf.st_mtime;
@@ -642,6 +666,27 @@
void set_mail_type (const void stuff)
{
- / EPIC4 cannot switch mailbox types (yet) /
+ const char value;
+ struct mail_checker new_checker;
+ char old_mailval[16];
+
+ value = (const char )stuff;
+
+ if (value == NULL)
+ new_checker = NULL;
+ else if (!my_stricmp(value, "MBOX"))
+ new_checker = &mail_types[0];
+ else if (!my_stricmp(value, "MAILDIR"))
+ new_checker = &mail_types[1];
+ else
+ {
+ say("/SET MAIL_TYPE must be MBOX or MAILDIR.");
+ return;
+ }
+
+ snprintf(old_mailval, sizeof(old_mailval), "%d", get_int_var(MAIL_VAR));
+ set_var_value(MAIL_VAR, zero);
+ checkmail = new_checker;
+ set_var_value(MAIL_VAR, old_mailval);
}
diff -aur epic4-2.10.1/source/vars.c epic4-2.10.1.JT/source/vars.c
--- epic4-2.10.1/source/vars.c 2008-03-17 05:42:46.000000000 +0200
+++ epic4-2.10.1.JT/source/vars.c 2012-08-30 13:14:54.801014647 +0300
@@ -194,7 +194,7 @@
{ "LOG_REWRITE", STR_TYPE_VAR, 0, 0, NULL, NULL, 0, 0 },
{ "MAIL", INT_TYPE_VAR, DEFAULT_MAIL, 0, NULL, set_mail, 0, 0 },
{ "MAIL_INTERVAL", INT_TYPE_VAR, DEFAULT_MAIL_INTERVAL, 0, NULL, set_mail_interval, 0, 0 },
- / { "MAIL_TYPE", STR_TYPE_VAR, 0, 0, NULL, set_mail_type, 0, 0 }, /
+ { "MAIL_TYPE", STR_TYPE_VAR, 0, 0, NULL, set_mail_type, 0, 0 },
{ "MANGLE_INBOUND", STR_TYPE_VAR, 0, 0, NULL, set_mangle_inbound, 0, 0 },
{ "MANGLE_LOGFILES", STR_TYPE_VAR, 0, 0, NULL, set_mangle_logfiles, 0, 0 },
{ "MANGLE_OUTBOUND", STR_TYPE_VAR, 0, 0, NULL, set_mangle_outbound, 0, 0 },
@@ -350,7 +350,7 @@
set_string_var(HIGHLIGHT_CHAR_VAR, DEFAULT_HIGHLIGHT_CHAR);
set_string_var(LASTLOG_LEVEL_VAR, DEFAULT_LASTLOG_LEVEL);
set_string_var(LOG_REWRITE_VAR, NULL);
- / set_string_var(MAIL_TYPE_VAR, DEFAULT_MAIL_TYPE); /
+ set_string_var(MAIL_TYPE_VAR, DEFAULT_MAIL_TYPE);
set_string_var(MANGLE_INBOUND_VAR, NULL);
set_string_var(MANGLE_LOGFILES_VAR, NULL);
set_string_var(MANGLE_OUTBOUND_VAR, NULL);