* @param[in] in the template to evaluate
* @param[in] async the asynchronously evaluated value box, for XLAT and EXEC
* @return
- * - <0 for failure
* - 0 for "no match"
* - 1 for "match".
*/
-static int cond_eval_tmpl(request_t *request, tmpl_t const *in, fr_value_box_t *async)
+static bool cond_eval_tmpl(request_t *request, tmpl_t const *in, fr_value_box_t *async)
{
- int rcode = -1;
+ int rcode = false;
fr_pair_t *vp = NULL;
fr_value_box_t *box, *box_free;
tmpl_t *vpt;
* particular type.
*/
if (tmpl_find_vp(&vp, request, vpt) < 0) {
- return -1;
+ return false;
}
MEM(box = fr_value_box_alloc_null(request));
* Realize and cast the tmpl.
*/
if (cond_realize_tmpl(request, &box, &box_free, vpt, NULL, async) < 0) {
- fr_strerror_const("Failed evaluating condition");
- return -1;
+ return false;
}
/*
*/
default:
fr_assert(0);
- return -1;
+ return false;
}
}
break;
if (!async) {
box = NULL;
ret = tmpl_aexpand(request, &box, request, in, escape, NULL);
- if (ret < 0) return ret;
+ if (ret < 0) {
+ if (cast_type != FR_TYPE_STRING) return -1;
+
+ box = fr_value_box_alloc(request, FR_TYPE_STRING, NULL, false);
+ if (!box) return -1;
+ }
fr_assert(box != NULL);
*out = *to_free = box;
if (request) RPEDEBUG("Failed casting %pV to type %s", &vp->data,
fr_table_str_by_value(fr_value_box_type_table,
vpt->cast, "??"));
- return -1;
+ return false;
}
*realized = box;
*/
bool cond_eval(request_t *request, rlm_rcode_t modreturn, fr_cond_t const *c)
{
- int rcode = -1;
+ int rcode = false;
#ifdef WITH_EVAL_DEBUG
char buffer[1024];