Import Debian changes 4.92-8+deb10u3
[hcoop/debian/exim4.git] / src / routers / rf_expand_data.c
CommitLineData
420a0d19
CE
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
18just saves repeating this code too many times. It does an expansion, and
19chooses a suitable return code on error.
20
21Arguments:
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
26Returns: the expanded string, or NULL (with prc set) on failure
27*/
28
29uschar *
30rf_expand_data(address_item *addr, uschar *s, int *prc)
31{
32uschar *yield = expand_string(s);
33if (yield != NULL) return yield;
2ea97746 34if (f.expand_string_forcedfail)
420a0d19
CE
35 {
36 DEBUG(D_route) debug_printf("forced failure for expansion of \"%s\"\n", s);
37 *prc = DECLINE;
38 }
39else
40 {
41 addr->message = string_sprintf("failed to expand \"%s\": %s", s,
42 expand_string_message);
43 *prc = DEFER;
44 }
45return NULL;
46}
47
48/* End of routers/rf_expand_data.c */