tpop3d-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tpop3d-discuss]PATCH: maildir-ignore-folders: regexp


From: Arkadiusz Miskiewicz
Subject: [tpop3d-discuss]PATCH: maildir-ignore-folders: regexp
Date: Wed, 13 Sep 2006 14:06:15 +0200
User-agent: KMail/1.9.4

Hello,

This patch adds support for regexps in maildir-ignore-folders - they
have to start with ^ char.

diff -ur tpop3d-1.5.3.org/maildir.c tpop3d-1.5.3/maildir.c
--- tpop3d-1.5.3.org/maildir.c  2006-09-13 13:50:55.000000000 +0200
+++ tpop3d-1.5.3/maildir.c      2006-09-13 13:50:26.000000000 +0200
@@ -26,6 +26,7 @@
 #include <unistd.h>
 #include <utime.h>
 #include <time.h>
+#include <regex.h>
 
 #include <sys/fcntl.h>
 #include <sys/stat.h>
@@ -253,7 +254,18 @@
         foldersl = strlen(folder);
 
         for (i = 0; i < ignorefolders->num; i++) {
-            if(0 == strcmp(folder, ignorefolders->toks[i])) {
+           if (*ignorefolders->toks[i] == '^') {
+                   /* We have a regexp */
+                   regex_t re;
+                   if (regcomp(&re, ignorefolders->toks[i], 
REG_EXTENDED|REG_NOSUB) == 0) {
+                           if (regexec(&re, folder, (size_t) 0, NULL, 0) == 0) 
{
+                                   ignore = 1;
+                                   regfree(&re);
+                                   break;
+                           }
+                           regfree(&re);
+                   }
+           } else if (0 == strcmp(folder, ignorefolders->toks[i])) {
                 ignore = 1;
                 break;
             }


-- 
Arkadiusz Miƛkiewicz        PLD/Linux Team
arekm / maven.pl            http://ftp.pld-linux.org/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]