-/* $Cambridge: exim/src/src/filter.c,v 1.9 2006/02/07 11:19:00 ph10 Exp $ */
-
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2006 */
+/* Copyright (c) University of Cambridge 1995 - 2009 */
/* See the file NOTICE for conditions of use and distribution. */
one (it can have \n anywhere). Then the file names and once_repeat, which may
not contain \n. */
-static char *mailargs[] = { /* "to" must be first, and */
- "to", /* "cc" and "bcc" must follow */
+static const char *mailargs[] = { /* "to" must be first, and */
+ "to", /* "cc" and "bcc" must follow */
"cc",
"bcc",
"from",
cond_above, cond_below, cond_errormsg, cond_firsttime,
cond_manualthaw, cond_foranyaddress };
-static char *cond_names[] = {
+static const char *cond_names[] = {
"and", "or", "personal",
"begins", "BEGINS", "ends", "ENDS",
"is", "IS", "matches", "MATCHES", "contains",
"CONTAINS", "delivered", "above", "below", "error_message",
"first_delivery", "manually_thawed", "foranyaddress" };
-static char *cond_not_names[] = {
+static const char *cond_not_names[] = {
"", "", "not personal",
"does not begin", "does not BEGIN",
"does not end", "does not END",
/* Tables of binary condition words and their corresponding types. Not easy
to amalgamate with the above because of the different variants. */
-static char *cond_words[] = {
+static const char *cond_words[] = {
"BEGIN",
"BEGINS",
"CONTAIN",
mail_command, noerror_command, pipe_command, save_command, seen_command,
testprint_command, unseen_command, vacation_command };
-static char *command_list[] = {
+static const char *command_list[] = {
"add", "defer", "deliver", "elif", "else", "endif", "finish",
"fail", "freeze", "headers", "if", "logfile", "logwrite", "mail",
"noerror", "pipe", "save", "seen", "testprint", "unseen", "vacation"
static void
print_condition(condition_block *c, BOOL toplevel)
{
-char *name = (c->testfor)? cond_names[c->type] : cond_not_names[c->type];
+const char *name = (c->testfor)? cond_names[c->type] : cond_not_names[c->type];
switch(c->type)
{
case cond_personal:
case cond_ENDS:
case cond_above:
case cond_below:
- debug_printf("%s %s %s", c->left.u, (char *)name, c->right.u);
+ debug_printf("%s %s %s", c->left.u, name, c->right.u);
break;
case cond_and:
case elif_command:
case else_command:
case endif_command:
+ if (seen_force || noerror_force)
+ {
+ *error_pointer = string_sprintf("\"seen\", \"unseen\", or \"noerror\" "
+ "near line %d is not followed by a command", line_number);
+ yield = FALSE;
+ }
+
if (expect_endif > 0)
had_else_endif = (command == elif_command)? had_elif :
(command == else_command)? had_else : had_endif;
case seen_command:
case unseen_command:
+ if (*ptr == 0)
+ {
+ *error_pointer = string_sprintf("\"seen\" or \"unseen\" "
+ "near line %d is not followed by a command", line_number);
+ yield = FALSE;
+ }
if (seen_force)
{
*error_pointer = string_sprintf("\"seen\" or \"unseen\" repeated "
/* So does noerror */
case noerror_command:
+ if (*ptr == 0)
+ {
+ *error_pointer = string_sprintf("\"noerror\" "
+ "near line %d is not followed by a command", line_number);
+ yield = FALSE;
+ }
noerror_force = TRUE;
was_noerror = TRUE;
break;
static BOOL
test_condition(condition_block *c, BOOL toplevel)
{
-BOOL yield;
+BOOL yield = FALSE;
const pcre *re;
uschar *exp[2], *p, *pp;
const uschar *regcomp_error = NULL;
else
{
+ if (s[0] != '/' && (filter_options & RDO_PREPEND_HOME) != 0 &&
+ deliver_home != NULL && deliver_home[0] != 0)
+ s = string_sprintf("%s/%s", deliver_home, s);
DEBUG(D_filter) debug_printf("Filter: %ssave message to: %s%s\n",
(commands->seen)? "" : "unseen ", s,
commands->noerror? " (noerror)" : "");
- if (s[0] != '/' && deliver_home != NULL && deliver_home[0] != 0)
- s = string_sprintf("%s/%s", deliver_home, s);
/* Create the new address and add it to the chain, setting the
af_pfr and af_file flags, the af_ignore_error flag if necessary, and the
string_printing(s), command_list[commands->command]);
return FF_ERROR;
}
- pp++;
}
p = pp;
}