#define ESI_BRACE_ENDS BIT(0) /* expansion should stop at } */
#define ESI_HONOR_DOLLAR BIT(1) /* $ is meaningfull */
#define ESI_SKIPPING BIT(2) /* value will not be needed */
+#define ESI_EXISTS_ONLY BIT(3) /* actual value not needed */
#ifdef STAND_ALONE
# ifndef SUPPORT_CRYPTEQ
Arguments:
name the name of the variable being sought
- exists_only TRUE if this is a def: test; passed on to find_header()
- skipping TRUE => skip any processing evaluation; this is not the same as
+ flags
+ exists_only TRUE if this is a def: test; passed on to find_header()
+ skipping TRUE => skip any processing evaluation; this is not the same as
exists_only because def: may test for values that are first
evaluated here
newsize pointer to an int which is initially zero; if the answer is in
*/
static const uschar *
-find_variable(uschar *name, BOOL exists_only, BOOL skipping, int *newsize)
+find_variable(uschar * name, esi_flags flags, int * newsize)
{
var_entry * vp;
uschar *s, *domain;
/* Found an existing variable. If in skipping state, the value isn't needed,
and we want to avoid processing (such as looking up the host name). */
-if (skipping)
+if (flags & ESI_SKIPPING)
return US"";
val = vp->value;
return domain ? domain + 1 : US"";
case vtype_msgheaders:
- return find_header(NULL, newsize, exists_only ? FH_EXISTS_ONLY : 0, NULL);
+ return find_header(NULL, newsize,
+ flags & ESI_EXISTS_ONLY ? FH_EXISTS_ONLY : 0, NULL);
case vtype_msgheaders_raw:
return find_header(NULL, newsize,
- exists_only ? FH_EXISTS_ONLY|FH_WANT_RAW : FH_WANT_RAW, NULL);
+ flags & ESI_EXISTS_ONLY ? FH_EXISTS_ONLY|FH_WANT_RAW : FH_WANT_RAW,
+ NULL);
case vtype_msgbody: /* Pointer to msgbody string */
case vtype_msgbody_end: /* Ditto, the end of the msg */
case vtype_reply: /* Get reply address */
s = find_header(US"reply-to:", newsize,
- exists_only ? FH_EXISTS_ONLY|FH_WANT_RAW : FH_WANT_RAW,
- headers_charset);
+ flags & ESI_EXISTS_ONLY ? FH_EXISTS_ONLY|FH_WANT_RAW : FH_WANT_RAW,
+ headers_charset);
if (s) Uskip_whitespace(&s);
if (!s || !*s)
{
*newsize = 0; /* For the *s==0 case */
s = find_header(US"from:", newsize,
- exists_only ? FH_EXISTS_ONLY|FH_WANT_RAW : FH_WANT_RAW,
- headers_charset);
+ flags & ESI_EXISTS_ONLY ? FH_EXISTS_ONLY|FH_WANT_RAW : FH_WANT_RAW,
+ headers_charset);
}
if (s)
{
else
{
- if (!(t = find_variable(name, TRUE, yield == NULL, NULL)))
+ if (!(t = find_variable(name,
+ yield ? ESI_EXISTS_ONLY : ESI_EXISTS_ONLY | ESI_SKIPPING, NULL)))
{
expand_string_message = name[0]
? string_sprintf("unknown variable \"%s\" after \"def:\"", name)
/* Variable */
- else if (!(value = find_variable(name, FALSE, !!(flags & ESI_SKIPPING), &newsize)))
+ else if (!(value = find_variable(name, flags, &newsize)))
{
expand_string_message =
string_sprintf("unknown variable name \"%s\"", name);
reset_point = store_mark();
g = store_get(sizeof(gstring), GET_UNTAINTED); /* alloc _before_ calling find_variable() */
}
- if (!(value = find_variable(name, FALSE, !!(flags & ESI_SKIPPING), &newsize)))
+ if (!(value = find_variable(name, flags, &newsize)))
{
expand_string_message =
string_sprintf("unknown variable in \"${%s}\"", name);