summaryrefslogtreecommitdiffstats
path: root/src/routers/rf_expand_data.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:47:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:47:26 +0000
commit96b619cc129afed52411b9fad3407037a1cb7207 (patch)
treee453a74cc9ae39fbfcb3ac55a347e880413e4a06 /src/routers/rf_expand_data.c
parentInitial commit. (diff)
downloadexim4-96b619cc129afed52411b9fad3407037a1cb7207.tar.xz
exim4-96b619cc129afed52411b9fad3407037a1cb7207.zip
Adding upstream version 4.92.upstream/4.92upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/routers/rf_expand_data.c')
-rw-r--r--src/routers/rf_expand_data.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/routers/rf_expand_data.c b/src/routers/rf_expand_data.c
new file mode 100644
index 0000000..6a8ad17
--- /dev/null
+++ b/src/routers/rf_expand_data.c
@@ -0,0 +1,48 @@
+/*************************************************
+* Exim - an Internet mail transport agent *
+*************************************************/
+
+/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* See the file NOTICE for conditions of use and distribution. */
+
+
+#include "../exim.h"
+#include "rf_functions.h"
+
+
+/*************************************************
+* Expand data string and handle errors *
+*************************************************/
+
+/* This little function is used by a couple of routers for expanding things. It
+just saves repeating this code too many times. It does an expansion, and
+chooses a suitable return code on error.
+
+Arguments:
+ addr the address that's being routed
+ s the string to be expanded
+ prc pointer to where to put the return code on failure
+
+Returns: the expanded string, or NULL (with prc set) on failure
+*/
+
+uschar *
+rf_expand_data(address_item *addr, uschar *s, int *prc)
+{
+uschar *yield = expand_string(s);
+if (yield != NULL) return yield;
+if (f.expand_string_forcedfail)
+ {
+ DEBUG(D_route) debug_printf("forced failure for expansion of \"%s\"\n", s);
+ *prc = DECLINE;
+ }
+else
+ {
+ addr->message = string_sprintf("failed to expand \"%s\": %s", s,
+ expand_string_message);
+ *prc = DEFER;
+ }
+return NULL;
+}
+
+/* End of routers/rf_expand_data.c */