The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
String expansion ("translation"). More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/unlang/xlat.h>
#include <freeradius-devel/unlang/xlat_priv.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/types.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/unlang/unlang_priv.h>
Go to the source code of this file.
Data Structures | |
struct | xlat_exec_rctx_t |
Macros | |
#define | ESCAPE(_arg, _vb, _arg_num) |
Functions | |
static ssize_t | _xlat_eval (TALLOC_CTX *ctx, char **out, size_t outlen, request_t *request, char const *fmt, xlat_escape_legacy_t escape, void const *escape_ctx) |
Replace whatever in a string. More... | |
static ssize_t | _xlat_eval_compiled (TALLOC_CTX *ctx, char **out, size_t outlen, request_t *request, xlat_exp_head_t const *head, xlat_escape_legacy_t escape, void const *escape_ctx) |
Replace whatever in a string. More... | |
ssize_t | xlat_aeval (TALLOC_CTX *ctx, char **out, request_t *request, char const *fmt, xlat_escape_legacy_t escape, void const *escape_ctx) |
ssize_t | xlat_aeval_compiled (TALLOC_CTX *ctx, char **out, request_t *request, xlat_exp_head_t const *xlat, xlat_escape_legacy_t escape, void const *escape_ctx) |
int | xlat_aeval_compiled_argv (TALLOC_CTX *ctx, char ***argv, request_t *request, xlat_exp_head_t const *head, xlat_escape_legacy_t escape, void const *escape_ctx) |
Synchronous compile xlat_tokenize_argv() into argv[] array. More... | |
static void | xlat_debug_log_expansion (request_t *request, xlat_exp_t const *node, fr_value_box_list_t const *args, UNUSED int line) |
Output what we're currently expanding. More... | |
static void | xlat_debug_log_list_result (request_t *request, xlat_exp_t const *node, fr_value_box_list_t const *result) |
Output the list result of an expansion. More... | |
static void | xlat_debug_log_result (request_t *request, xlat_exp_t const *node, fr_value_box_t const *result) |
Output the result of an expansion. More... | |
ssize_t | xlat_eval (char *out, size_t outlen, request_t *request, char const *fmt, xlat_escape_legacy_t escape, void const *escape_ctx) |
ssize_t | xlat_eval_compiled (char *out, size_t outlen, request_t *request, xlat_exp_head_t const *xlat, xlat_escape_legacy_t escape, void const *escape_ctx) |
void | xlat_eval_free (void) |
int | xlat_eval_init (void) |
static xlat_action_t | xlat_eval_one_letter (TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *request, char letter) |
One letter expansions. More... | |
static ssize_t | xlat_eval_sync (TALLOC_CTX *ctx, char **out, request_t *request, xlat_exp_head_t const *const head, xlat_escape_legacy_t escape, void const *escape_ctx) |
int | xlat_eval_walk (xlat_exp_head_t *head, xlat_walker_t walker, xlat_type_t type, void *uctx) |
Walk over all xlat nodes (depth first) in a xlat expansion, calling a callback. More... | |
static xlat_action_t | xlat_exec_resume (UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, UNUSED fr_value_box_list_t *in) |
int | xlat_flatten_compiled_argv (TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head) |
Turn xlat_tokenize_argv() into an argv[] array, and nuke the input list. More... | |
static fr_slen_t | xlat_fmt_print (fr_sbuff_t *out, xlat_exp_t const *node) |
Reconstruct the original expansion string from an xlat tree. More... | |
xlat_action_t | xlat_frame_eval (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_t const **child, request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in) |
Converts xlat nodes to value boxes. More... | |
xlat_action_t | xlat_frame_eval_repeat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_t const **child, request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in, void *env_data, fr_value_box_list_t *result) |
Process the result of a previous nested expansion. More... | |
xlat_action_t | xlat_frame_eval_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_t const **child, request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in, fr_value_box_list_t *result, xlat_func_t resume, void *rctx) |
Call an xlat's resumption method. More... | |
static xlat_action_t | xlat_null_resume (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request, UNUSED fr_value_box_list_t *in) |
static xlat_action_t | xlat_process_arg_list (TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, char const *name, xlat_arg_parser_t const *arg, unsigned int arg_num) |
Process an individual xlat argument value box group. More... | |
static xlat_action_t | xlat_process_args (TALLOC_CTX *ctx, fr_value_box_list_t *list, request_t *request, xlat_t const *func) |
Process list of boxed values provided as input to an xlat. More... | |
static bool | xlat_process_return (request_t *request, xlat_t const *func, fr_value_box_list_t const *returned, fr_value_box_t *pos) |
Validate that the return values from an xlat function match what it registered. More... | |
void | xlat_signal (xlat_func_signal_t signal, xlat_exp_t const *exp, request_t *request, void *rctx, fr_signal_t action) |
Signal an xlat function. More... | |
fr_dict_attr_t const * | xlat_time_res_attr (char const *res) |
String expansion ("translation").
Evaluation of pre-parsed xlat expansions.
Definition in file xlat_eval.c.
struct xlat_exec_rctx_t |
Definition at line 805 of file xlat_eval.c.
Data Fields | ||
---|---|---|
fr_value_box_list_t | list | |
int | status |
#define ESCAPE | ( | _arg, | |
_vb, | |||
_arg_num | |||
) |
|
static |
Replace whatever in a string.
See 'doc/unlang/xlat.adoc' for more information.
[in] | ctx | to allocate expansion buffers in. |
[out] | out | Where to write pointer to output buffer. |
[in] | outlen | Size of out. |
[in] | request | current request. |
[in] | fmt | string to expand. |
[in] | escape | function to escape final value e.g. SQL quoting. |
[in] | escape_ctx | pointer to pass to escape function. |
Definition at line 1480 of file xlat_eval.c.
|
static |
Replace whatever in a string.
See 'doc/unlang/xlat.adoc' for more information.
[in] | ctx | to allocate expansion buffers in. |
[out] | out | Where to write pointer to output buffer. |
[in] | outlen | Size of out. |
[in] | request | current request. |
[in] | head | the xlat structure to expand |
[in] | escape | function to escape final value e.g. SQL quoting. |
[in] | escape_ctx | pointer to pass to escape function. |
Definition at line 1427 of file xlat_eval.c.
ssize_t xlat_aeval | ( | TALLOC_CTX * | ctx, |
char ** | out, | ||
request_t * | request, | ||
char const * | fmt, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Definition at line 1545 of file xlat_eval.c.
ssize_t xlat_aeval_compiled | ( | TALLOC_CTX * | ctx, |
char ** | out, | ||
request_t * | request, | ||
xlat_exp_head_t const * | xlat, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Definition at line 1554 of file xlat_eval.c.
int xlat_aeval_compiled_argv | ( | TALLOC_CTX * | ctx, |
char *** | argv, | ||
request_t * | request, | ||
xlat_exp_head_t const * | head, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Synchronous compile xlat_tokenize_argv() into argv[] array.
This is mostly for synchronous evaluation.
ctx | The talloc_ctx | |
[out] | argv | the argv array of resulting strings, size is argc + 1 |
request | the request | |
head | from xlat_tokenize_argv() | |
escape | escape function | |
escape_ctx | context for escape function |
Definition at line 1578 of file xlat_eval.c.
|
inlinestatic |
Output what we're currently expanding.
[in] | request | The current request. |
[in] | node | Being processed. |
[in] | args | from previous expansion. |
[in] | line | Unused |
Definition at line 224 of file xlat_eval.c.
|
inlinestatic |
Output the list result of an expansion.
[in] | request | The current request. |
[in] | node | which was expanded. |
[in] | result | of the expansion. |
Definition at line 257 of file xlat_eval.c.
|
inlinestatic |
Output the result of an expansion.
[in] | request | The current request. |
[in] | node | which was expanded. |
[in] | result | of the expansion. |
Definition at line 272 of file xlat_eval.c.
ssize_t xlat_eval | ( | char * | out, |
size_t | outlen, | ||
request_t * | request, | ||
char const * | fmt, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
ssize_t xlat_eval_compiled | ( | char * | out, |
size_t | outlen, | ||
request_t * | request, | ||
xlat_exp_head_t const * | xlat, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Definition at line 1537 of file xlat_eval.c.
void xlat_eval_free | ( | void | ) |
Definition at line 1739 of file xlat_eval.c.
int xlat_eval_init | ( | void | ) |
Definition at line 1714 of file xlat_eval.c.
|
inlinestatic |
One letter expansions.
[in] | ctx | to allocate boxed value, and buffers in. |
[out] | out | Where to write the boxed value. |
[in] | request | The current request. |
[in] | letter | to expand. |
Definition at line 619 of file xlat_eval.c.
|
static |
Definition at line 1328 of file xlat_eval.c.
int xlat_eval_walk | ( | xlat_exp_head_t * | head, |
xlat_walker_t | walker, | ||
xlat_type_t | type, | ||
void * | uctx | ||
) |
Walk over all xlat nodes (depth first) in a xlat expansion, calling a callback.
[in] | head | to evaluate. |
[in] | walker | callback to pass nodes to. |
[in] | type | if > 0 a mask of types to call walker for. |
[in] | uctx | to pass to walker. |
Definition at line 1650 of file xlat_eval.c.
|
static |
int xlat_flatten_compiled_argv | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t *** | argv, | ||
xlat_exp_head_t * | head | ||
) |
Turn xlat_tokenize_argv() into an argv[] array, and nuke the input list.
This is mostly for async use.
Definition at line 1613 of file xlat_eval.c.
|
static |
Reconstruct the original expansion string from an xlat tree.
[in] | out | sbuff to print result in. |
[in] | node | in the tree to start printing. |
Definition at line 155 of file xlat_eval.c.
xlat_action_t xlat_frame_eval | ( | TALLOC_CTX * | ctx, |
fr_dcursor_t * | out, | ||
xlat_exp_head_t const ** | child, | ||
request_t * | request, | ||
xlat_exp_head_t const * | head, | ||
xlat_exp_t const ** | in | ||
) |
Converts xlat nodes to value boxes.
Evaluates a single level of expansions.
[in] | ctx | to allocate value boxes in. |
[out] | out | a list of fr_value_box_t to append to. |
[out] | child | to evaluate. If a child needs to be evaluated by the caller, we return XLAT_ACTION_PUSH_CHILD and place the child to be evaluated here. Once evaluation is complete, the caller should call us with the same xlat_exp_t and the result of the nested evaluation in result. |
[in] | request | the current request. |
[in] | head | of the list to evaluate |
[in,out] | in | xlat node to evaluate. Advanced as we process additional xlat_exp_t. |
Definition at line 1110 of file xlat_eval.c.
xlat_action_t xlat_frame_eval_repeat | ( | TALLOC_CTX * | ctx, |
fr_dcursor_t * | out, | ||
xlat_exp_head_t const ** | child, | ||
request_t * | request, | ||
xlat_exp_head_t const * | head, | ||
xlat_exp_t const ** | in, | ||
void * | env_data, | ||
fr_value_box_list_t * | result | ||
) |
Process the result of a previous nested expansion.
[in] | ctx | to allocate value boxes in. |
[out] | out | a list of fr_value_box_t to append to. |
[out] | child | to evaluate. If a child needs to be evaluated by the caller, we return XLAT_ACTION_PUSH_CHILD and place the child to be evaluated here. Once evaluation is complete, the caller should call us with the same xlat_exp_t and the result of the nested evaluation in result. |
[in] | request | the current request. |
[in] | head | of the list to evaluate |
[in,out] | in | xlat node to evaluate. Advanced as we process additional xlat_exp_t. |
[in] | env_data | Expanded call env. |
[in] | result | of a previous nested evaluation. |
Definition at line 944 of file xlat_eval.c.
xlat_action_t xlat_frame_eval_resume | ( | TALLOC_CTX * | ctx, |
fr_dcursor_t * | out, | ||
xlat_exp_head_t const ** | child, | ||
request_t * | request, | ||
xlat_exp_head_t const * | head, | ||
xlat_exp_t const ** | in, | ||
fr_value_box_list_t * | result, | ||
xlat_func_t | resume, | ||
void * | rctx | ||
) |
Call an xlat's resumption method.
[in] | ctx | to allocate value boxes in. |
[out] | out | a list of fr_value_box_t to append to. |
[out] | child | to evaluate. If a child needs to be evaluated by the caller, we return XLAT_ACTION_PUSH_CHILD and place the child to be evaluated here. Once evaluation is complete, the caller should call us with the same xlat_exp_t and the result of the nested evaluation in result. |
[in] | request | the current request. |
[in] | head | of the list to evaluate |
[in,out] | in | xlat node to evaluate. Advanced as we process additional xlat_exp_t. |
[in] | result | Previously expanded arguments to this xlat function. |
[in] | resume | function to call. |
[in] | rctx | Opaque (to us), resume ctx provided by xlat function when it yielded. |
Definition at line 870 of file xlat_eval.c.
|
static |
|
static |
Process an individual xlat argument value box group.
[in] | ctx | to allocate any additional buffers in |
[in,out] | list | of value boxes representing one argument |
[in] | request | currently being processed |
[in] | name | of the function being called |
[in] | arg | specification of current argument |
[in] | arg_num | number of current argument in the argument specifications |
Definition at line 293 of file xlat_eval.c.
|
inlinestatic |
Process list of boxed values provided as input to an xlat.
Ensures that the value boxes passed to an xlat function match the requirements listed in its "args", and escapes any tainted boxes using the specified escaping routine.
[in] | ctx | in which to allocate any buffers. |
[in,out] | list | value boxes provided as input. List will be modified in accordance to rules provided in the args array. |
[in] | request | being processed. |
[in] | func | to call |
Definition at line 409 of file xlat_eval.c.
|
inlinestatic |
Validate that the return values from an xlat function match what it registered.
[in] | request | The current request. |
[in] | func | that was called. |
[in] | returned | the output list of the function. |
[in] | pos | current position in the output list. |
Definition at line 571 of file xlat_eval.c.
void xlat_signal | ( | xlat_func_signal_t | signal, |
xlat_exp_t const * | exp, | ||
request_t * | request, | ||
void * | rctx, | ||
fr_signal_t | action | ||
) |
Signal an xlat function.
[in] | signal | function to call. |
[in] | exp | Xlat node that previously yielded. |
[in] | request | The current request. |
[in] | rctx | Opaque (to us), resume ctx provided by the xlat function when it yielded. |
[in] | action | What the request should do (the type of signal). |
Definition at line 836 of file xlat_eval.c.
fr_dict_attr_t const* xlat_time_res_attr | ( | char const * | res | ) |
fr_dict_attr_t const* attr_cast_base |
Definition at line 50 of file xlat_eval.c.
|
static |
Definition at line 59 of file xlat_eval.c.
|
static |
Definition at line 55 of file xlat_eval.c.
|
static |
Definition at line 54 of file xlat_eval.c.
|
static |
Definition at line 53 of file xlat_eval.c.
|
static |
Definition at line 57 of file xlat_eval.c.
|
static |
Definition at line 60 of file xlat_eval.c.
|
static |
Definition at line 62 of file xlat_eval.c.
|
static |
Definition at line 52 of file xlat_eval.c.
|
static |
Definition at line 61 of file xlat_eval.c.
|
static |
Definition at line 56 of file xlat_eval.c.
|
static |
Definition at line 58 of file xlat_eval.c.
fr_dict_attr_t const* attr_expr_bool_enum |
Definition at line 49 of file xlat_eval.c.
|
static |
Definition at line 42 of file xlat_eval.c.
|
static |
Definition at line 40 of file xlat_eval.c.
fr_table_num_sorted_t const xlat_action_table[] |
Definition at line 83 of file xlat_eval.c.
size_t xlat_action_table_len = NUM_ELEMENTS(xlat_action_table) |
Definition at line 89 of file xlat_eval.c.
|
static |
Definition at line 44 of file xlat_eval.c.
|
static |
Definition at line 64 of file xlat_eval.c.
|
static |
Definition at line 94 of file xlat_eval.c.
|
static |
Definition at line 132 of file xlat_eval.c.