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