dovecot-sieve-1.1: Upgraded to Cyrus Sieve v2.3 and changed code...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Jul 20 10:33:13 EEST 2007
details: http://hg.dovecot.org/dovecot-sieve-1.1/rev/09f894d3cc84
changeset: 24:09f894d3cc84
user: Timo Sirainen <tss at iki.fi>
date: Fri Jul 20 10:33:08 2007 +0300
description:
Upgraded to Cyrus Sieve v2.3 and changed code to compile against Dovecot v1.1.
Sieve body extension works now, but include doesn't yet.
diffstat:
26 files changed, 1831 insertions(+), 488 deletions(-)
src/cmusieve-plugin.c | 7
src/cmusieve-plugin.h | 3
src/libsieve/Makefile.am | 3
src/libsieve/bc_dump.c | 52 +++++-
src/libsieve/bc_emit.c | 124 ++++++++++++++-
src/libsieve/bc_eval.c | 307 ++++++++++++++++++++++++++++++++-----
src/libsieve/bc_generate.c | 118 +++++++++++++-
src/libsieve/bytecode.h | 120 +++++++++-----
src/libsieve/comparator.c | 274 ++++++++++++++++++---------------
src/libsieve/comparator.h | 2
src/libsieve/interp.c | 83 ++++++++--
src/libsieve/interp.h | 21 ++
src/libsieve/message.c | 46 ++++-
src/libsieve/message.h | 19 +-
src/libsieve/script.c | 324 ++++++++++++++++++++++++----------------
src/libsieve/script.h | 21 ++
src/libsieve/sieve-lex.l | 19 +-
src/libsieve/sieve.y | 238 +++++++++++++++++++++++++++--
src/libsieve/sieve_err.c | 17 --
src/libsieve/sieve_err.h | 3
src/libsieve/sieve_interface.h | 34 +++-
src/libsieve/sievec.c | 15 +
src/libsieve/sieved.c | 144 +++++++++++------
src/libsieve/tree.c | 16 +
src/libsieve/tree.h | 25 +++
src/sieve-cmu.c | 284 +++++++++++++++++++++++++++++++++--
diffs (truncated from 4003 to 300 lines):
diff -r 0ddc99d4b747 -r 09f894d3cc84 src/cmusieve-plugin.c
--- a/src/cmusieve-plugin.c Fri Jul 13 01:55:12 2007 +0300
+++ b/src/cmusieve-plugin.c Fri Jul 20 10:33:08 2007 +0300
@@ -57,7 +57,9 @@ static const char *get_sieve_path(void)
}
static int
-cmusieve_deliver_mail(struct mail_storage *storage, struct mail *mail,
+cmusieve_deliver_mail(struct mail_namespace *namespaces,
+ struct mail_storage **storage_r,
+ struct mail *mail,
const char *username, const char *mailbox)
{
const char *script_path;
@@ -69,7 +71,8 @@ cmusieve_deliver_mail(struct mail_storag
if (getenv("DEBUG") != NULL)
i_info("cmusieve: Using sieve path: %s", script_path);
- return cmu_sieve_run(storage, mail, script_path, username, mailbox);
+ return cmu_sieve_run(namespaces, storage_r, mail, script_path,
+ username, mailbox);
}
void cmusieve_plugin_init(void)
diff -r 0ddc99d4b747 -r 09f894d3cc84 src/cmusieve-plugin.h
--- a/src/cmusieve-plugin.h Fri Jul 13 01:55:12 2007 +0300
+++ b/src/cmusieve-plugin.h Fri Jul 20 10:33:08 2007 +0300
@@ -1,7 +1,8 @@
#ifndef __CMUSIEVE_PLUGIN_H
#define __CMUSIEVE_PLUGIN_H
-int cmu_sieve_run(struct mail_storage *storage, struct mail *mail,
+int cmu_sieve_run(struct mail_namespace *namespaces,
+ struct mail_storage **storage_r, struct mail *mail,
const char *script_path, const char *username,
const char *mailbox);
diff -r 0ddc99d4b747 -r 09f894d3cc84 src/libsieve/Makefile.am
--- a/src/libsieve/Makefile.am Fri Jul 13 01:55:12 2007 +0300
+++ b/src/libsieve/Makefile.am Fri Jul 20 10:33:08 2007 +0300
@@ -55,7 +55,8 @@ sievec_SOURCES = \
sieved_SOURCES = \
sieved.c \
- ../map.c
+ ../map.c \
+ ../imparse.c
sievec_LDADD = \
libsieve.la \
diff -r 0ddc99d4b747 -r 09f894d3cc84 src/libsieve/bc_dump.c
--- a/src/libsieve/bc_dump.c Fri Jul 13 01:55:12 2007 +0300
+++ b/src/libsieve/bc_dump.c Fri Jul 20 10:33:08 2007 +0300
@@ -162,6 +162,26 @@ static int dump_test(bytecode_info_t *d,
d->data[ip].value,d->data[ip+1].value,d->data[ip+3].value);
}
ip+=4;
+ ip = dump_sl(d,ip,level); ip++;
+ print_spaces(level*4);
+ printf(" DATA:\n");
+ ip = dump_sl(d,ip,level);
+ break;
+
+ case BC_BODY:
+ printf("%d: BODY (\n",ip++);
+ print_spaces(level*4);
+ if (d->data[ip].value == B_COUNT || d->data[ip].value == B_VALUE)
+ {
+ printf(" MATCH:%d RELATION: %d COMP: %d TRANSFORM: %d OFFSET: %d CONTENT-TYPES:\n",
+ d->data[ip].value,d->data[ip+1].value,d->data[ip+2].value,
+ d->data[ip+3].value,d->data[ip+4].value);
+ } else {
+ printf(" MATCH:%d COMP:%d TRANSFORM:%d OFFSET: %d CONTENT-TYPES:\n",
+ d->data[ip].value,d->data[ip+1].value,d->data[ip+3].value,
+ d->data[ip+4].value);
+ }
+ ip+=5;
ip = dump_sl(d,ip,level); ip++;
print_spaces(level*4);
printf(" DATA:\n");
@@ -228,15 +248,15 @@ void dump(bytecode_info_t *d, int level)
break;
case B_FILEINTO:
- printf("%d: FILEINTO {%d}%s\n",i,
- d->data[i+1].len,d->data[i+2].str);
- i+=2;
+ printf("%d: FILEINTO COPY(%d) FOLDER({%d}%s)\n",i,
+ d->data[i+1].value,d->data[i+2].len,d->data[i+3].str);
+ i+=3;
break;
case B_REDIRECT:
- printf("%d: REDIRECT {%d}%s\n",i,
- d->data[i+1].len,d->data[i+2].str);
- i+=2;
+ printf("%d: REDIRECT COPY(%d) ADDRESS({%d}%s)\n",i,
+ d->data[i+1].value,d->data[i+2].len,d->data[i+3].str);
+ i+=3;
break;
case B_SETFLAG:
@@ -280,11 +300,14 @@ void dump(bytecode_info_t *d, int level)
printf("%d:VACATION\n",i);
i++;
i=dump_sl(d,i,level);
- printf("SUBJ({%d}%s) MESG({%d}%s)\n DAYS(%d) MIME(%d)\n",
+ printf("SUBJ({%d}%s) MESG({%d}%s)\n DAYS(%d) MIME(%d)\n"
+ " FROM({%d}%s) HANDLE({%d}%s)\n",
d->data[i+1].len, (d->data[i+1].len == -1 ? "[nil]" : d->data[i+2].str),
d->data[i+3].len, (d->data[i+3].len == -1 ? "[nil]" : d->data[i+4].str),
- d->data[i+5].value, d->data[i+6].value);
- i+=6;
+ d->data[i+5].value, d->data[i+6].value,
+ d->data[i+7].len, (d->data[i+7].len == -1 ? "[nil]" : d->data[i+8].str),
+ d->data[i+9].len, (d->data[i+9].len == -1 ? "[nil]" : d->data[i+10].str));
+ i+=10;
break;
case B_JUMP:
@@ -293,6 +316,17 @@ void dump(bytecode_info_t *d, int level)
case B_NULL:
printf("%d: NULL\n",i);
break;
+
+ case B_INCLUDE:
+ printf("%d: INCLUDE LOCATION:%d {%d}%s\n",i,
+ d->data[i+1].value,d->data[i+2].len,d->data[i+3].str);
+ i+=3;
+ break;
+
+ case B_RETURN:
+ printf("%d: RETURN\n",i);
+ break;
+
default:
printf("%d: %d\n",i,d->data[i].op);
break;
diff -r 0ddc99d4b747 -r 09f894d3cc84 src/libsieve/bc_emit.c
--- a/src/libsieve/bc_emit.c Fri Jul 13 01:55:12 2007 +0300
+++ b/src/libsieve/bc_emit.c Fri Jul 20 10:33:08 2007 +0300
@@ -288,6 +288,45 @@ static int bc_test_emit(int fd, int *cod
wrote += sizeof(int);
(*codep)++;
/* Now drop headers */
+ ret = bc_stringlist_emit(fd, codep, bc);
+ if(ret < 0) return -1;
+ wrote+=ret;
+ /* Now drop data */
+ ret = bc_stringlist_emit(fd, codep, bc);
+ if(ret < 0) return -1;
+ wrote+=ret;
+ break;
+ }
+
+ case BC_BODY:
+ {
+ int ret;
+ /* Drop match type */
+ if(write_int(fd, bc->data[(*codep)].value) == -1)
+ return -1;
+ wrote += sizeof(int);
+ (*codep)++;
+ /*drop comparator */
+ if(write_int(fd, bc->data[(*codep)].value) == -1)
+ return -1;
+ wrote += sizeof(int);
+ (*codep)++;
+ /*now drop relation*/
+ if(write_int(fd, bc->data[(*codep)].value) == -1)
+ return -1;
+ wrote += sizeof(int);
+ (*codep)++;
+ /*now drop transform*/
+ if(write_int(fd, bc->data[(*codep)].value) == -1)
+ return -1;
+ wrote += sizeof(int);
+ (*codep)++;
+ /*now drop offset*/
+ if(write_int(fd, bc->data[(*codep)].value) == -1)
+ return -1;
+ wrote += sizeof(int);
+ (*codep)++;
+ /*now drop content-types*/
ret = bc_stringlist_emit(fd, codep, bc);
if(ret < 0) return -1;
wrote+=ret;
@@ -452,9 +491,33 @@ static int bc_action_emit(int fd, int co
break;
}
- case B_REJECT:
case B_FILEINTO:
case B_REDIRECT:
+ /* Copy (word), Folder/Address String */
+
+ if(write_int(fd,bc->data[codep++].value) == -1)
+ return -1;
+
+ filelen += sizeof(int);
+
+ len = bc->data[codep++].len;
+ if(write_int(fd,len) == -1)
+ return -1;
+
+ filelen+=sizeof(int);
+
+ if(write(fd,bc->data[codep++].str,len) == -1)
+ return -1;
+
+ ret = align_string(fd, len);
+ if(ret == -1)
+ return -1;
+
+ filelen += len + ret;
+
+ break;
+
+ case B_REJECT:
/*just a string*/
len = bc->data[codep++].len;
if(write_int(fd,len) == -1)
@@ -585,7 +648,7 @@ static int bc_action_emit(int fd, int co
break;
case B_VACATION:
/* Address list, Subject String, Message String,
- Days (word), Mime (word) */
+ Days (word), Mime (word), From String, Handle String */
/*new code-this might be broken*/
ret = bc_stringlist_emit(fd, &codep, bc);
@@ -630,8 +693,60 @@ static int bc_action_emit(int fd, int co
if(write_int(fd,bc->data[codep].value) == -1)
return -1;
codep++;
- filelen += sizeof(int);
-
+
+ for(i=0; i<2; i++) {/*writing strings*/
+
+ /*write length of string*/
+ len = bc->data[codep++].len;
+ if(write_int(fd,len) == -1)
+ return -1;
+ filelen += sizeof(int);
+
+ if(len == -1)
+ {
+ /* this is a nil string */
+ /* skip the null pointer and make up for it
+ * by adjusting the offset */
+ codep++;
+ }
+ else
+ {
+ /*write string*/
+ if(write(fd,bc->data[codep++].str,len) == -1)
+ return -1;
+
+ ret = align_string(fd, len);
+ if(ret == -1) return -1;
+
+ filelen += len + ret;
+ }
+
+ }
+ filelen += sizeof(int);
+
+ break;
+ case B_INCLUDE:
+ /* Location (word), Filename String */
+
+ /* Location */
+ if(write_int(fd, bc->data[codep].value) == -1)
+ return -1;
+ filelen += sizeof(int);
+ codep++;
+ /* Filename */
+ len = bc->data[codep++].len;
+ if(write_int(fd,len) == -1)
+ return -1;
+
+ filelen += sizeof(int);
+
+ if(write(fd,bc->data[codep++].str,len) == -1)
+ return -1;
+
+ ret = align_string(fd, len);
+ if(ret == -1) return -1;
+
+ filelen += len + ret;
break;
case B_NULL:
case B_STOP:
@@ -639,6 +754,7 @@ static int bc_action_emit(int fd, int co
case B_KEEP:
case B_MARK:
case B_UNMARK:
+ case B_RETURN:
/* No Parameters! */
More information about the dovecot-cvs
mailing list