3a28e43759c199539945e2fe68b7b1ab5f4f3ad2
[exim.git] / src / src / routers / rf_expand_data.c
1 /* $Cambridge: exim/src/src/routers/rf_expand_data.c,v 1.1 2004/10/07 13:10:02 ph10 Exp $ */
2
3 /*************************************************
4 * Exim - an Internet mail transport agent *
5 *************************************************/
6
7 /* Copyright (c) University of Cambridge 1995 - 2004 */
8 /* See the file NOTICE for conditions of use and distribution. */
9
10
11 #include "../exim.h"
12 #include "rf_functions.h"
13
14
15 /*************************************************
16 * Expand data string and handle errors *
17 *************************************************/
18
19 /* This little function is used by a couple of routers for expanding things. It
20 just saves repeating this code too many times. It does an expansion, and
21 chooses a suitable return code on error.
22
23 Arguments:
24 addr the address that's being routed
25 s the string to be expanded
26 prc pointer to where to put the return code on failure
27
28 Returns: the expanded string, or NULL (with prc set) on failure
29 */
30
31 uschar *
32 rf_expand_data(address_item *addr, uschar *s, int *prc)
33 {
34 uschar *yield = expand_string(s);
35 if (yield != NULL) return yield;
36 if (expand_string_forcedfail)
37 {
38 DEBUG(D_route) debug_printf("forced failure for expansion of \"%s\"\n", s);
39 *prc = DECLINE;
40 }
41 else
42 {
43 addr->message = string_sprintf("failed to expand \"%s\": %s", s,
44 expand_string_message);
45 *prc = DEFER;
46 }
47 return NULL;
48 }
49
50 /* End of routers/rf_expand_data.c */