25RCSID(
"$Id: bccda50f6ba70de66f8134cb3e50dce15be0d34a $")
27#include "condition_priv.h"
31 fr_value_box_list_t
out;
49 RDEBUG2(
"... failed to evaluate condition ...");
58 }
else if (fr_value_box_list_next(&state->
out, box) != NULL) {
107 fr_value_box_list_init(&state->
out);
154 .allow_unresolved =
false,
155 .allow_unknown =
false,
156 .allow_wildcard =
true,
158 .literals_safe_for =
unlang_ctx->rules->literals_safe_for,
161 fr_sbuff_parse_rules_t p_rules = { };
237 gext->
has_else = (strcmp(
name,
"else") == 0) || (strcmp(
name,
"elsif") == 0);
258 cf_log_err(cs,
"'else' cannot have a condition");
277 .unlang_name =
"unlang_cond_t",
282 .frame_state_type =
"unlang_frame_state_cond_t",
294 .unlang_name =
"unlang_group_t"
306 .unlang_name =
"unlang_cond_t",
311 .frame_state_type =
"unlang_frame_state_cond_t",
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_PUSHED_CHILD
unlang_t pushed a new child onto the stack, execute it instead of continuing.
@ UNLANG_ACTION_EXECUTE_NEXT
Execute the next unlang_t.
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
#define L(_str)
Helper for initialising arrays of string literals.
Common header for all CONF_* types.
A section grouping multiple CONF_PAIR.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
CONF_ITEM * cf_section_to_item(CONF_SECTION const *cs)
Cast a CONF_SECTION to a CONF_ITEM.
char const * cf_section_name1(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
bool cf_item_is_data(CONF_ITEM const *ci)
Determine if CONF_ITEM is CONF_DATA.
bool cf_item_is_section(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_SECTION.
#define cf_log_err(_cf, _fmt,...)
#define cf_log_debug_prefix(_cf, _fmt,...)
#define cf_section_free_children(_x)
#define cf_canonicalize_error(_ci, _slen, _msg, _str)
#define cf_item_next(_parent, _curr)
unlang_t * unlang_compile_section(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type)
unlang_t * unlang_compile_empty(unlang_t *parent, UNUSED unlang_compile_ctx_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type)
static unlang_t * unlang_compile_if(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx, CONF_ITEM const *ci)
unlang_result_t result
Store the result of unlang expressions.
static unlang_t * unlang_compile_elsif(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx, CONF_ITEM const *ci)
static unlang_t * unlang_compile_else(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx, CONF_ITEM const *ci)
void unlang_condition_init(void)
static const fr_sbuff_term_t if_terminals
static unlang_action_t unlang_if(unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
fr_value_box_list_t out
Head of the result of a nested expansion.
static unlang_action_t unlang_if_resume(unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
static unlang_t * compile_if_subsection(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx, CONF_SECTION *cs, unlang_type_t type)
static unlang_cond_t * unlang_group_to_cond(unlang_group_t *g)
Cast a group structure to the cond keyword extension.
unlang_action_t unlang_group(UNUSED unlang_result_t *p_result, request_t *request, UNUSED unlang_stack_frame_t *frame)
Declarations for the "group" keyword.
rlm_rcode_t rcode
The current rcode, from executing the instruction or merging the result from a frame.
unlang_op_t unlang_ops[UNLANG_TYPE_MAX]
Different operations the interpreter can execute.
static TALLOC_CTX * unlang_ctx
void unlang_register(unlang_op_t *op)
Register an operation with the interpreter.
#define RETURN_UNLANG_FAIL
@ RLM_MODULE_FAIL
Module failed, don't reply.
fr_dict_attr_t const * request_attr_request
#define FR_SBUFF_IN(_start, _len_or_end)
#define FR_SBUFF_TERMS(...)
Initialise a terminal structure with a list of sorted strings.
Set of terminal elements.
tmpl_rules_t const * parent
for parent / child relationships
fr_dict_t const * dict_def
Alternative default dictionary to use if vpt->rules->dict_def is NULL.
#define TMPL_POOL_DEF_HEADERS
Define manipulation functions for the attribute reference list.
#define TMPL_POOL_DEF_LEN
How many additional bytes to allocate in a pool for a tmpl_t.
tmpl_attr_rules_t attr
Rules/data for parsing attribute references.
struct tmpl_res_rules_s tmpl_res_rules_t
struct tmpl_rules_s tmpl_rules_t
Optional arguments passed to vp_tmpl functions.
fr_aka_sim_id_type_t type
fr_dict_t const * dict_def
Default dictionary to use with unqualified attribute references.
int unlang_xlat_push(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out, request_t *request, xlat_exp_head_t const *xlat, bool top_frame)
Push a pre-compiled xlat onto the stack for evaluation.
bool xlat_needs_resolving(xlat_exp_head_t const *head)
Check to see if the expansion needs resolving.
tmpl_res_rules_t const * tr_rules
tmpl resolution rules.
fr_slen_t xlat_tokenize_condition(TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules))
static fr_slen_t e_rules bool xlat_is_truthy(xlat_exp_head_t const *head, bool *out)
Allow callers to see if an xlat is truthy.
int xlat_resolve(xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules)
Walk over an xlat tree recursively, resolving any unresolved functions or references.
unlang_t * next
Next node (executed on UNLANG_ACTION_EXECUTE_NEXT et al).
void * state
Stack frame specialisations.
static unlang_group_t * unlang_generic_to_group(unlang_t const *p)
unlang_type_t
Types of unlang_t nodes.
@ UNLANG_TYPE_ELSIF
!Condition && Condition.
@ UNLANG_TYPE_ELSE
!Condition.
@ UNLANG_TYPE_IF
Condition.
static void frame_repeat(unlang_stack_frame_t *frame, unlang_process_t process)
Mark the current stack frame up for repeat, and set a new process function.
unlang_t const * instruction
The unlang node we're evaluating.
unlang_t const * next
The next unlang node we will evaluate.
@ UNLANG_OP_FLAG_DEBUG_BRACES
Print debug braces.
unlang_type_t type
The specialisation of this node.
Generic representation of a grouping.
A node in a graph of unlang_op_t (s) that we execute.
Our interpreter stack, as distinct from the C stack.
char const * fr_strerror(void)
Get the last library error.
bool fr_value_box_is_truthy(fr_value_box_t const *in)
Check truthiness of values.
static bool is_truthy(xlat_exp_t *node, bool *out)