-/* $Cambridge: exim/src/src/sieve.c,v 1.2 2004/11/25 13:54:31 ph10 Exp $ */
+/* $Cambridge: exim/src/src/sieve.c,v 1.7 2005/02/17 11:58:26 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
/* The code is currently broken. */
#undef SUBADDRESS
-/* Define this for development of the vacation Sieve extension. */
-/* The code is not yet finished. */
+/* Define this for the vacation Sieve extension. */
#define VACATION
/* Must be >= 1 */
}
else
{
- filter->errmsg=CUS "missing closing brace";
+ filter->errmsg=CUS "expecting command or closing brace";
return -1;
}
}
int m;
unsigned long days;
- struct String *addresses=(struct String*)0;
+ struct String *addresses;
struct String subject;
int reason_is_mime;
string_item *aliases;
filter->vacation_ran=1;
}
days=VACATION_MIN_DAYS>7 ? VACATION_MIN_DAYS : 7;
+ addresses=(struct String*)0;
subject.character=(uschar*)0;
subject.length=-1;
aliases=NULL;
uschar *buffer;
int buffer_capacity;
struct String key;
+ struct String *a;
md5 base;
uschar digest[16];
uschar hexdigest[33];
if (subject.length!=-1) key.character=string_cat(key.character,&capacity,&key.length,subject.character,subject.length);
key.character=string_cat(key.character,&capacity,&key.length,reason_is_mime?US"1":US"0",1);
key.character=string_cat(key.character,&capacity,&key.length,reason.character,reason.length);
+ if (addresses!=(struct String*)0) for (a=addresses; a->length!=-1; ++a)
+ {
+ key.character=string_cat(key.character,&capacity,&key.length,US":",1);
+ key.character=string_cat(key.character,&capacity,&key.length,a->character,a->length);
+ }
md5_start(&base);
md5_end(&base, key.character, key.length, digest);
for (i = 0; i < 16; i++) sprintf(CS (hexdigest+2*i), "%02X", digest[i]);
start=capacity;
once=string_cat(filter->vacation_directory,&capacity,&start,US"/",1);
once=string_cat(once,&capacity,&start,hexdigest,33);
+ once[start] = '\0';
/* process subject */
addr->reply = store_get(sizeof(reply_item));
memset(addr->reply,0,sizeof(reply_item)); /* XXX */
addr->reply->to = string_copy(sender_address);
+ addr->reply->from = expand_string(US"$local_part@$domain");
/* Allocation is larger than neccessary, but enough even for split MIME words */
buffer_capacity=16+4*subject.length;
buffer=store_get(buffer_capacity);
capacity = 0;
start = 0;
addr->reply->headers = string_cat(NULL,&capacity,&start,reason.character,mime_body-reason.character);
+ addr->reply->headers[start] = '\0';
capacity = 0;
start = 0;
- if (mime_body<reason_end) mime_body+=sizeof(nlnl)-1;
+ if (mime_body+(sizeof(nlnl)-1)<reason_end) mime_body+=sizeof(nlnl)-1;
+ else mime_body=reason_end-1;
addr->reply->text = string_cat(NULL,&capacity,&start,mime_body,reason_end-mime_body);
+ addr->reply->text[start] = '\0';
}
else
{