diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2012-02-25 16:00:22 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2012-02-25 16:00:22 +0100 |
commit | 6eaad612f5fdaa0746249d182a33ad23cfe0b298 (patch) | |
tree | 319fcc970cbffe3fe6b7007b82820625f331e86e | |
parent | 8b08a3eeefe733a1367f27afcbfc40733486334a (diff) | |
download | maildirlearn-6eaad612f5fdaa0746249d182a33ad23cfe0b298.tar.gz maildirlearn-6eaad612f5fdaa0746249d182a33ad23cfe0b298.tar.bz2 maildirlearn-6eaad612f5fdaa0746249d182a33ad23cfe0b298.zip |
Easy setup (with #define’s)
-rw-r--r-- | maildirlearn.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/maildirlearn.c b/maildirlearn.c index 91b66c8..d608bde 100644 --- a/maildirlearn.c +++ b/maildirlearn.c @@ -21,6 +21,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* === BEGIN SETUP === */ + +/* your maildir; must include trailing '/' */ +#define WATCHDIR "mail/" + +/* paths you use for spam */ +#define SPAMDIRRE "mail/\\.Junk/" + +/* paths you want to exclude (temporary files, deleted mail, unsure) */ +#define EXCLUDERE "mail/(\\.Unsure/|[^/]+/(tmp|.*:2,[A-S]*T[U-Z]*$)|.*dovecot)" + +/* bogofilter executable name or path (if not in PATH) */ +#define BOGOPATH "bogofilter" + +/* increase if you have a lot of directories */ +#define HASHTBL_SIZE 128 + +/* === END SETUP === */ + /* strdup */ #define _BSD_SOURCE @@ -471,21 +490,20 @@ static bool runBogofilter (const char *bogopath, const regex_t spamdirre, int main (int argc, char **argv) { regex_t spamdirre, excludere; - const char bogopath[] = "bogofilter"; - /* with '/' postfix */ - const char watchdir[] = "mail/"; int running = 1; notify_t n; /* setup */ - notifyInit (&n, 128, watchdir); + notifyInit (&n, HASHTBL_SIZE, WATCHDIR); - if (regcomp (&spamdirre, "mail/\\.Junk/", REG_EXTENDED) != 0) { + if (regcomp (&spamdirre, SPAMDIRRE, REG_EXTENDED) != 0) { printf ("invalid spamdir re\n"); + return EXIT_FAILURE; } - if (regcomp (&excludere, "mail/(\\.Unsure/|[^/]+/(tmp|.*:2,[A-S]*T[U-Z]*$)|.*dovecot)", REG_EXTENDED) != 0) { + if (regcomp (&excludere, EXCLUDERE, REG_EXTENDED) != 0) { printf ("invalid exclude re\n"); + return EXIT_FAILURE; } while (running) { @@ -522,7 +540,7 @@ int main (int argc, char **argv) { strncat (fullpath, "/", sizeof (fullpath)-strlen (fullpath)-1); notifyAdd (&n, relpath); } else { - runBogofilter (bogopath, spamdirre, fullpath); + runBogofilter (BOGOPATH, spamdirre, fullpath); } } else { printf ("notifyRead failed\n"); @@ -531,4 +549,6 @@ int main (int argc, char **argv) { regfree (&spamdirre); regfree (&excludere); + + return EXIT_SUCCESS; } |