diff options
author | Philip Hazel <ph10@hermes.cam.ac.uk> | 2006-10-24 12:56:06 +0000 |
---|---|---|
committer | Philip Hazel <ph10@hermes.cam.ac.uk> | 2006-10-24 12:56:06 +0000 |
commit | 328895cc07b8caf8c18003569431a02129989289 (patch) | |
tree | d63fd2d73d25cefa6e803846040023253c80d1a7 /src | |
parent | 0ef732d996b5f37b28410c5efe132fbbe5c686ef (diff) |
Added -bem option.
Diffstat (limited to 'src')
-rw-r--r-- | src/src/exim.c | 50 | ||||
-rw-r--r-- | src/src/filtertest.c | 11 | ||||
-rw-r--r-- | src/src/functions.h | 3 |
3 files changed, 54 insertions, 10 deletions
diff --git a/src/src/exim.c b/src/src/exim.c index 0a1f2b8c1..9cef9226b 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.c,v 1.45 2006/10/23 13:24:21 ph10 Exp $ */ +/* $Cambridge: exim/src/src/exim.c,v 1.46 2006/10/24 12:56:06 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1177,7 +1177,7 @@ int size = 0; int ptr = 0; uschar *yield = NULL; -if (fn_readline == NULL) printf("> "); +if (fn_readline == NULL) { printf("> "); fflush(stdout); } for (i = 0;; i++) { @@ -1300,6 +1300,7 @@ uschar *alias_arg = NULL; uschar *called_as = US""; uschar *start_queue_run_id = NULL; uschar *stop_queue_run_id = NULL; +uschar *expansion_test_message = NULL; uschar *ftest_domain = NULL; uschar *ftest_localpart = NULL; uschar *ftest_prefix = NULL; @@ -1680,10 +1681,21 @@ for (i = 1; i < argc; i++) else if (*argrest != 0) { badarg = TRUE; break; } } - /* -be: Run in expansion test mode */ + /* -be: Run in expansion test mode + -bem: Ditto, but read a message from a file first + */ else if (*argrest == 'e') + { expansion_test = checking = TRUE; + if (argrest[1] == 'm') + { + if (++i >= argc) { badarg = TRUE; break; } + expansion_test_message = argv[i]; + argrest++; + } + if (argrest[1] != 0) { badarg = TRUE; break; } + } /* -bF: Run system filter test */ @@ -2924,6 +2936,10 @@ if (( ) || ( deliver_selectstring != NULL && queue_interval < 0 + ) || + ( + msg_action == MSG_LOAD && + (!expansion_test || expansion_test_message != NULL) ) ) { @@ -4181,7 +4197,8 @@ if (verify_address_mode || address_test_mode) /* Handle expansion checking. Either expand items on the command line, or read from stdin if there aren't any. If -Mset was specified, load the message so -that its variables can be used, but restrict this facility to admin users. */ +that its variables can be used, but restrict this facility to admin users. +Otherwise, if -bem was used, read a message from stdin. */ if (expansion_test) { @@ -4201,6 +4218,31 @@ if (expansion_test) printf ("Failed to load message %s\n", message_id); } + /* Read a test message from a file. We fudge it up to be on stdin, saving + stdin itself for later reading of expansion strings. */ + + else if (expansion_test_message != NULL) + { + int save_stdin = dup(0); + int fd = Uopen(expansion_test_message, O_RDONLY, 0); + if (fd < 0) + { + fprintf(stderr, "exim: failed to open %s: %s\n", expansion_test_message, + strerror(errno)); + return EXIT_FAILURE; + } + (void) dup2(fd, 0); + filter_test = FTEST_USER; /* Fudge to make it look like filter test */ + message_ended = END_NOTENDED; + read_message_body(receive_msg(extract_recipients)); + (void)dup2(save_stdin, 0); + (void)close(save_stdin); + } + + /* Allow $recipients for this testing */ + + enable_dollar_recipients = TRUE; + /* Expand command line items */ if (recipients_arg < argc) diff --git a/src/src/filtertest.c b/src/src/filtertest.c index 3275cd0d4..10af6b596 100644 --- a/src/src/filtertest.c +++ b/src/src/filtertest.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/filtertest.c,v 1.8 2006/02/07 11:19:00 ph10 Exp $ */ +/* $Cambridge: exim/src/src/filtertest.c,v 1.9 2006/10/24 12:56:06 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -22,9 +22,10 @@ we can set up the message_body variables at the same time (in normal use, the message_body variables are not set up unless needed). The reading code is written out here rather than having options in read_message_data, in order to -keep that function as efficient as possible. Handling message_body_end is -somewhat more tedious. Pile it all into a circular buffer and sort out at the -end. +keep that function as efficient as possible. (Later: this function is now +global because it is also used by the -bem testing option.) Handling +message_body_end is somewhat more tedious. Pile it all into a circular buffer +and sort out at the end. Arguments: dot_ended TRUE if message already terminated by '.' @@ -32,7 +33,7 @@ Arguments: Returns: nothing */ -static void +void read_message_body(BOOL dot_ended) { register int ch; diff --git a/src/src/functions.h b/src/src/functions.h index 170a84411..b91ca274d 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/functions.h,v 1.29 2006/10/16 15:44:36 ph10 Exp $ */ +/* $Cambridge: exim/src/src/functions.h,v 1.30 2006/10/24 12:56:06 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -206,6 +206,7 @@ extern uschar *readconf_readname(uschar *, int, uschar *); extern int readconf_readtime(uschar *, int, BOOL); extern void readconf_rest(BOOL); extern uschar *readconf_retry_error(uschar *, uschar *, int *, int *); +extern void read_message_body(BOOL); extern void receive_bomb_out(uschar *); extern BOOL receive_check_fs(int); extern BOOL receive_check_set_sender(uschar *); |