27RCSID(
"$Id: 486f2eb58a0ccd2e53ed6f2b3520dd2e82fc841a $")
29#include <freeradius-devel/server/base.h>
30#include <freeradius-devel/unlang/xlat_priv.h>
31#include <freeradius-devel/util/calc.h>
32#include <freeradius-devel/util/dict.h>
39 while ((box = fr_value_box_list_pop_head(list)) != NULL) {
64 fr_value_box_list_t list;
67 if (!
head->flags.can_purify)
return 0;
72 if (
head->flags.needs_resolving)
return -1;
74 our_flags =
head->flags;
75 our_flags.
pure =
true;
78 if (!node->flags.can_purify)
continue;
86 if (rcode < 0)
return rcode;
88 node->flags = child->
flags;
99 if (rcode < 0)
return rcode;
101 node->flags = node->group->flags;
109 if (!node->flags.pure) {
110 if (node->call.func->purify) {
123 request->dict = node->call.dict;
124 if (node->call.func->purify(node, node->call.inst->data, request) < 0)
return -1;
125 request->dict = dict;
135 node->flags = node->call.func->flags;
148 fr_value_box_list_init(&list);
168 node->flags = node->group->flags;
172 node->flags.can_purify =
false;
183 head->flags = our_flags;
199 if (!
head->flags.can_purify)
return 0;
202 if (!request)
return -1;
214#ifdef STATIC_ANALYZER
215 if (!node)
return NULL;
405 if (!lhs_box)
return 0;
408 if (!rhs_box)
return 0;
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
int fr_value_calc_binary_op(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t hint, fr_value_box_t const *a, fr_token_t op, fr_value_box_t const *b)
Calculate DST = A OP B.
fr_dict_t const * fr_dict_internal(void)
void unlang_interpret_set(request_t *request, unlang_interpret_t *intp)
Set a specific interpreter for a request.
rlm_rcode_t unlang_interpret_synchronous(fr_event_list_t *el, request_t *request)
Execute an unlang section synchronously.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_BOOL
A truth value.
#define request_alloc_internal(_ctx, _args)
Allocate a new internal request.
Optional arguments for initialising requests.
#define tmpl_is_xlat(vpt)
#define tmpl_value(_tmpl)
#define tmpl_is_attr(vpt)
#define tmpl_rules_cast(_tmpl)
int tmpl_cast_in_place(tmpl_t *vpt, fr_type_t type, fr_dict_attr_t const *enumv))
Convert tmpl_t of type TMPL_TYPE_DATA_UNRESOLVED or TMPL_TYPE_DATA to TMPL_TYPE_DATA of type specifie...
#define tmpl_is_data(vpt)
#define tmpl_is_data_unresolved(vpt)
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
int unlang_xlat_push_node(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out, request_t *request, xlat_exp_t *node)
Push a pre-compiled xlat onto the stack for evaluation.
bool can_purify
if the xlat has a pure function with pure arguments.
bool pure
has no external side effects, true for BOX, LITERAL, and some functions
bool needs_resolving
Needs pass2 resolution.
int xlat_instance_unregister_func(xlat_exp_t *node)
Remove a node from the list of xlat instance data.
Flags that control resolution and evaluation.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_type_is_null(_x)
int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src)
Copy value data verbatim duplicating any buffers.
bool fr_value_box_is_truthy(fr_value_box_t const *in)
Check truthiness of values.
static fr_slen_t fr_value_box_aprint(TALLOC_CTX *ctx, char **out, fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules) 1(fr_value_box_print
static size_t char ** out
void xlat_exp_set_name_buffer_shallow(xlat_exp_t *node, char const *fmt)
Set the format string for an xlat node from a pre-existing buffer.
fr_dict_attr_t const * attr_expr_bool_enum
xlat_flags_t flags
Flags that control resolution and evaluation.
xlat_flags_t flags
Flags that control resolution and evaluation.
fr_token_t quote
Type of quoting around XLAT_GROUP types.
@ XLAT_TMPL
xlat attribute
@ XLAT_GROUP
encapsulated string of xlats
static void xlat_flags_merge(xlat_flags_t *parent, xlat_flags_t const *child)
Merge flags from child to parent.
#define xlat_exp_set_type(_node, _type)
xlat_type_t _CONST type
type of this expansion.
#define xlat_exp_alloc(_ctx, _type, _in, _inlen)
#define xlat_exp_foreach(_list_head, _iter)
Iterate over the contents of a list, only one level.
static int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
static xlat_exp_t * peephole_optimize_lor(xlat_exp_t *lhs, xlat_exp_t *rhs)
static int binary_peephole_optimize(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t *lhs, fr_token_t op, xlat_exp_t *rhs)
static fr_value_box_t * xlat_value_box(xlat_exp_t *node)
static bool is_truthy(xlat_exp_t *node, bool *out)
int xlat_purify_op(TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t *lhs, fr_token_t op, xlat_exp_t *rhs)
int xlat_purify(xlat_exp_head_t *head, unlang_interpret_t *intp)
Purify an xlat.
int xlat_purify_list(xlat_exp_head_t *head, request_t *request)
static xlat_exp_t * peephole_optimize_land(xlat_exp_t *lhs, xlat_exp_t *rhs)
static void xlat_value_list_to_xlat(xlat_exp_head_t *head, fr_value_box_list_t *list)