X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/a3d3e7ef81a649d2bbd6599fc561cf22c6875e70..44b6e099b76f403a55e77650821f8a69e9d2682e:/src/src/expand.c diff --git a/src/src/expand.c b/src/src/expand.c index ff0b4d600..7bb2e4274 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -5,6 +5,7 @@ /* Copyright (c) The Exim Maintainers 2020 - 2022 */ /* Copyright (c) University of Cambridge 1995 - 2018 */ /* See the file NOTICE for conditions of use and distribution. */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* Functions for handling string expansion. */ @@ -12,6 +13,10 @@ #include "exim.h" +#ifdef MACRO_PREDEF +# include "macro_predef.h" +#endif + typedef unsigned esi_flags; #define ESI_NOFLAGS 0 #define ESI_BRACE_ENDS BIT(0) /* expansion should stop at } */ @@ -710,6 +715,7 @@ static var_entry var_table[] = { { "sender_fullhost", vtype_stringptr, &sender_fullhost }, { "sender_helo_dnssec", vtype_bool, &sender_helo_dnssec }, { "sender_helo_name", vtype_stringptr, &sender_helo_name }, + { "sender_helo_verified",vtype_string_func, (void *) &sender_helo_verified_boolstr }, { "sender_host_address", vtype_stringptr, &sender_host_address }, { "sender_host_authenticated",vtype_stringptr, &sender_host_authenticated }, { "sender_host_dnssec", vtype_bool, &sender_host_dnssec }, @@ -830,6 +836,76 @@ static var_entry var_table[] = { }; static int var_table_size = nelem(var_table); + +#ifdef MACRO_PREDEF + +/* dummies */ +uschar * fn_arc_domains(void) {return NULL;} +uschar * fn_hdrs_added(void) {return NULL;} +uschar * fn_queue_size(void) {return NULL;} +uschar * fn_recipients(void) {return NULL;} +uschar * sender_helo_verified_boolstr(void) {return NULL;} +uschar * smtp_cmd_hist(void) {return NULL;} + + + +static void +expansion_items(void) +{ +uschar buf[64]; +for (int i = 0; i < nelem(item_table); i++) + { + spf(buf, sizeof(buf), CUS"_EXP_ITEM_%T", item_table[i]); + builtin_macro_create(buf); + } +} +static void +expansion_operators(void) +{ +uschar buf[64]; +for (int i = 0; i < nelem(op_table_underscore); i++) + { + spf(buf, sizeof(buf), CUS"_EXP_OP_%T", op_table_underscore[i]); + builtin_macro_create(buf); + } +for (int i = 0; i < nelem(op_table_main); i++) + { + spf(buf, sizeof(buf), CUS"_EXP_OP_%T", op_table_main[i]); + builtin_macro_create(buf); + } +} +static void +expansion_conditions(void) +{ +uschar buf[64]; +for (int i = 0; i < nelem(cond_table); i++) + { + spf(buf, sizeof(buf), CUS"_EXP_COND_%T", cond_table[i]); + builtin_macro_create(buf); + } +} +static void +expansion_variables(void) +{ +uschar buf[64]; +for (int i = 0; i < nelem(var_table); i++) + { + spf(buf, sizeof(buf), CUS"_EXP_VAR_%T", var_table[i].name); + builtin_macro_create(buf); + } +} + +void +expansions(void) +{ +expansion_items(); +expansion_operators(); +expansion_conditions(); +expansion_variables(); +} + +#else /*!MACRO_PREDEF*/ + static uschar var_buffer[256]; static BOOL malformed_header; @@ -5538,7 +5614,7 @@ while (*s) const uschar * arg, ** argv; BOOL late_expand = TRUE; - if ((expand_forbid & RDO_RUN) != 0) + if (expand_forbid & RDO_RUN) { expand_string_message = US"running a command is not permitted"; goto EXPAND_FAILED; @@ -5569,13 +5645,20 @@ while (*s) s++; if (late_expand) /* this is the default case */ - { /*{*/ - int n = Ustrcspn(s, "}"); + { + int n; + const uschar * t; + /* Locate the end of the args */ + (void) expand_string_internal(s, + ESI_BRACE_ENDS | ESI_HONOR_DOLLAR | ESI_SKIPPING, &t, NULL, NULL); + n = t - s; arg = flags & ESI_SKIPPING ? NULL : string_copyn(s, n); s += n; } else { + DEBUG(D_expand) + debug_printf_indent("args string for ${run} expand before split\n"); if (!(arg = expand_string_internal(s, ESI_BRACE_ENDS | ESI_HONOR_DOLLAR | flags, &s, &resetok, NULL))) goto EXPAND_FAILED; @@ -8860,8 +8943,9 @@ search_tidyup(); return 0; } -#endif +#endif /*STAND_ALONE*/ +#endif /*!MACRO_PREDEF*/ /* vi: aw ai sw=2 */ /* End of expand.c */