25 RCSID(
"$Id: 07657d98ee7ae7d73f7337513ee5819d7d71c4b6 $")
27 #include <freeradius-devel/server/request_data.h>
28 #include <freeradius-devel/unlang/xlat_func.h>
43 "Foreach-Variable-9"};
66 #define FOREACH_REQUEST_DATA (void *)unlang_foreach_xlat
91 switch (
vp->vp_type) {
102 *p_result = frame->
result;
110 RDEBUG2(
"# looping with: Foreach-Variable-%d = %pV", state->
depth, &
vp->data);
143 if (
stack->depth > 0)
for (i = (
stack->depth - 1); i >= 0; i--) {
145 our_instruction =
stack->frame[i].instruction;
151 REDEBUG(
"foreach Nesting too deep!");
180 switch (
vp->vp_type) {
202 state->
indent = request->log.indent.unlang;
226 *p_result = frame->
result;
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
static void fr_dcursor_free_list(fr_dcursor_t *cursor)
Free the current item and all items after it.
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
static void * fr_dcursor_current(fr_dcursor_t *cursor)
Return the item the cursor current points to.
static char const *const xlat_foreach_names[]
static int xlat_foreach_inst[]
fr_dcursor_t cursor
Used to track our place in the list we're iterating over.
void unlang_foreach_init(TALLOC_CTX *ctx)
int depth
Level of nesting of this foreach loop.
static unlang_action_t unlang_foreach(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
#define FOREACH_REQUEST_DATA
static unlang_action_t unlang_break(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
int indent
for catching indentation issues
request_t * request
The current request.
static unlang_action_t unlang_foreach_next(rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
fr_pair_list_t vps
List containing the attribute(s) we're iterating over.
static int _free_unlang_frame_state_foreach(unlang_frame_state_foreach_t *state)
Ensure request data is pulled out of the request if the frame is popped.
static unlang_foreach_t * unlang_group_to_foreach(unlang_group_t *g)
Cast a group structure to the foreach keyword extension.
static xlat_action_t unlang_foreach_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
Implements the Foreach-Variable-X.
unlang_action_t unlang_interpret_push_children(rlm_rcode_t *p_result, request_t *request, rlm_rcode_t default_rcode, bool do_next_sibling)
Push the children of the current frame onto a new frame onto the stack.
void unlang_register(int type, unlang_op_t *op)
Register an operation with the interpreter.
unlang_op_t unlang_ops[UNLANG_TYPE_MAX]
Different operations the interpreter can execute.
static char * stack[MAX_STACK]
static uint8_t depth(fr_minmax_heap_index_t i)
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
void * request_data_get(request_t *request, void const *unique_ptr, int unique_int)
Get opaque data from a request.
void * request_data_reference(request_t *request, void const *unique_ptr, int unique_int)
Get opaque data from a request without removing it.
#define request_data_add(_request, _unique_ptr, _unique_int, _opaque, _free_on_replace, _free_on_parent, _persist)
Add opaque data to a request_t.
Declarations for the "return" keyword, used to implement other keywords.
int tmpl_copy_pairs(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, tmpl_t const *vpt))
Copy pairs matching a tmpl_t in the current request_t.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
Stores an attribute, a value and various bits of other data.
@ XLAT_ACTION_FAIL
An xlat function failed.
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
#define UNLANG_NEXT_SIBLING
void * state
Stack frame specialisations.
static unlang_group_t * unlang_generic_to_group(unlang_t const *p)
@ UNLANG_TYPE_BREAK
Break statement (within a UNLANG_TYPE_FOREACH).
@ UNLANG_TYPE_FOREACH
Foreach section.
unlang_t const * instruction
The unlang node we're evaluating.
static void break_point_set(unlang_stack_frame_t *frame)
rlm_rcode_t result
The result from executing the instruction.
char const * name
Name of the operation.
static bool is_stack_unwinding_to_break(unlang_stack_t *stack)
static void repeatable_set(unlang_stack_frame_t *frame)
static unlang_action_t unwind_to_break(unlang_stack_t *stack)
unlang_process_t process
function to call for interpreting this stack frame
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.
An unlang stack associated with a request.
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
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.
#define fr_value_box_alloc_null(_ctx)
Allocate a value box for later use with a value assignment function.
static size_t char ** out
void const * inst
xlat instance data.
void xlat_func_flags_set(xlat_t *x, xlat_func_flags_t flags)
Specify flags that alter the xlat's behaviour.
xlat_t * xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func, fr_type_t return_type)
Register an xlat function.
@ XLAT_FUNC_FLAG_INTERNAL
String expansion ("translation").
void * uctx
uctx to pass to instantiation functions.