25RCSID(
"$Id: aa1be92f8d61909a1a4d7c7280b0dd1a976d15d6 $")
27#include "unlang_priv.h"
42 if (gext->
catch[rcode]) {
51 RDEBUG3(
"No catch section for %s",
87 cf_log_err(cs,
"'try' sections cannot be empty");
94 cf_log_err(cs,
"Unexpected argument to 'try' section");
103 cf_log_err(cs,
"'try' sections must be followed by a 'catch'");
121 for (default_catch = NULL;
132 cf_log_err(default_catch,
"Invalid 'catch' - cannot have another 'catch' after a default 'catch { ... }'");
142 default_catch = next;
148 cf_log_err(cs,
"Invalid argument to 'catch' - unknown rcode '%s'.",
name);
149 goto print_catch_url;
152 if (catcher[rcode]) {
154 cf_log_err(catcher[rcode],
"First instance is here");
155 goto print_catch_url;
157 catcher[rcode] = next;
162 cf_log_err(cs,
"Invalid argument to 'catch' - unknown rcode '%s'.",
name);
163 goto print_catch_url;
166 if (catcher[rcode]) {
168 cf_log_err(catcher[rcode],
"First instance is here");
169 goto print_catch_url;
172 catcher[rcode] = next;
192 cf_log_err(default_catch,
"Invalide 'catch { ... }' - all rcodes had previously been used");
193 goto print_catch_url;
220 if (!catcher[i])
continue;
265 .unlang_name =
"unlang_try_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_STOP_PROCESSING
Break out of processing the current request (unwind).
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
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_SECTION * cf_section_next(CONF_SECTION const *cs, CONF_SECTION const *curr)
Return the next child that's a CONF_SECTION.
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.
char const * cf_section_argv(CONF_SECTION const *cs, int argc)
Return variadic argument at the specified index.
#define cf_log_err(_cf, _fmt,...)
#define cf_item_next(_parent, _curr)
unlang_t * unlang_compile_children(unlang_group_t *g, unlang_compile_ctx_t *unlang_ctx_in)
unlang_group_t * unlang_group_allocate(unlang_t *parent, CONF_SECTION *cs, unlang_type_t type)
fr_table_num_sorted_t const mod_rcode_table[]
int unlang_interpret_push(unlang_result_t *p_result, request_t *request, unlang_t const *instruction, unlang_frame_conf_t const *conf, bool do_next_sibling)
Push a new frame onto the stack.
rlm_rcode_t unlang_interpret_rcode(request_t *request)
Get the last instruction result OR the last frame that was popped.
unlang_action_t unlang_interpret_push_children(unlang_result_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.
#define FRAME_CONF(_default_rcode, _top_frame)
static TALLOC_CTX * unlang_ctx
void unlang_register(unlang_op_t *op)
Register an operation with the interpreter.
@ MOD_ACTION_NOT_SET
default "not set by anything"
@ MOD_ACTION_RETURN
stop processing the section, and return the rcode with unset priority
unlang_mod_action_t actions[RLM_MODULE_NUMCODES]
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_INVALID
The module considers the request invalid.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_DISALLOW
Reject the request (user is locked out).
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_TIMEOUT
Module (or section) timed out.
@ RLM_MODULE_NOT_SET
Error resolving rcode (should not be returned by modules).
@ RLM_MODULE_NUMCODES
How many valid return codes there are.
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
static unlang_action_t unlang_try(UNUSED unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
static unlang_action_t skip_to_catch(UNUSED unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
static unlang_t * unlang_compile_try(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx, CONF_ITEM const *ci)
void unlang_try_init(void)
Declaration for unlang try.
static unlang_try_t const * unlang_generic_to_try(unlang_t const *g)
Cast a generic structure to the try keyword extension.
unlang_t * catch[RLM_MODULE_NUMCODES]
#define UNLANG_NEXT_SIBLING
char const * debug_name
Printed in log messages when the node is executed.
unlang_mod_actions_t actions
unlang_mod_actions_t actions
Priorities, etc. for the various return codes.
static void unlang_compile_ctx_copy(unlang_compile_ctx_t *dst, unlang_compile_ctx_t const *src)
static unlang_t * unlang_group_to_generic(unlang_group_t const *p)
char const * name
Unknown...
@ UNLANG_TYPE_TRY
try / catch blocks
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_OP_FLAG_DEBUG_BRACES
Print debug braces.
@ UNLANG_OP_FLAG_RCODE_SET
Set request->rcode to the result of this operation.
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.
#define DOC_KEYWORD_REF(_x)