[tpop3d-discuss]PATCH: maildir-ignore-folders: regexp
Arkadiusz Miskiewicz
arekm at pld-linux.org
Wed, 13 Sep 2006 14:06:15 +0200
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
=2D-- 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>
=20
#include <sys/fcntl.h>
#include <sys/stat.h>
@@ -253,7 +254,18 @@
foldersl =3D strlen(folder);
=20
for (i =3D 0; i < ignorefolders->num; i++) {
=2D if(0 =3D=3D strcmp(folder, ignorefolders->toks[i])) {
+ if (*ignorefolders->toks[i] =3D=3D '^') {
+ /* We have a regexp */
+ regex_t re;
+ if (regcomp(&re, ignorefolders->toks[i], REG_EXTENDED|REG_NOSUB) =3D=
=3D 0) {
+ if (regexec(&re, folder, (size_t) 0, NULL, 0) =3D=3D 0) {
+ ignore =3D 1;
+ regfree(&re);
+ break;
+ }
+ regfree(&re);
+ }
+ } else if (0 =3D=3D strcmp(folder, ignorefolders->toks[i])) {
ignore =3D 1;
break;
}
=2D-=20
Arkadiusz Mi=B6kiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/