The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
String expansion ("translation"). More...
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/server/regex.h>
#include <freeradius-devel/unlang/xlat_priv.h>
Go to the source code of this file.
Macros | |
#define | INFO_INDENT(_fmt, ...) INFO("%*s"_fmt, depth * 2, " ", ## __VA_ARGS__) |
#define | XLAT_DEBUG(...) |
#define | XLAT_HEXDUMP(...) |
Functions | |
static void | _xlat_debug_head (xlat_exp_head_t const *head, int depth) |
static void | _xlat_debug_node (xlat_exp_t const *node, int depth) |
void | xlat_debug (xlat_exp_t const *node) |
void | xlat_debug_head (xlat_exp_head_t const *head) |
int | xlat_from_tmpl_attr (TALLOC_CTX *ctx, xlat_exp_head_t **out, tmpl_t **vpt_p) |
Convert attr tmpl to an xlat for &attr[*]. | |
bool | xlat_impure_func (xlat_exp_head_t const *head) |
bool | xlat_is_literal (xlat_exp_head_t const *head) |
Check to see if the expansion consists entirely of value-box elements. | |
bool | xlat_needs_resolving (xlat_exp_head_t const *head) |
Check to see if the expansion needs resolving. | |
ssize_t | xlat_print (fr_sbuff_t *out, xlat_exp_head_t const *head, fr_sbuff_escape_rules_t const *e_rules) |
Reconstitute an xlat expression from its constituent nodes. | |
ssize_t | xlat_print_node (fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t const *node, fr_sbuff_escape_rules_t const *e_rules, char c) |
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. | |
static int | xlat_resolve_virtual_attribute (xlat_exp_t *node, tmpl_t *vpt) |
bool | xlat_to_string (TALLOC_CTX *ctx, char **str, xlat_exp_head_t **head) |
Convert an xlat node to an unescaped literal string and free the original node. | |
tmpl_t * | xlat_to_tmpl_attr (TALLOC_CTX *ctx, xlat_exp_head_t *head) |
Try to convert an xlat to a tmpl for efficiency. | |
fr_slen_t | xlat_tokenize (TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, fr_value_box_safe_for_t literals_safe_for) |
Tokenize an xlat expansion. | |
fr_slen_t | xlat_tokenize_argv (TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in, xlat_t const *xlat, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, bool comma, bool allow_attr) |
Tokenize an xlat expansion into a series of XLAT_TYPE_CHILD arguments. | |
static int | xlat_tokenize_attribute (xlat_exp_head_t *head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, tmpl_attr_prefix_t attr_prefix) |
Parse an attribute ref or a virtual attribute. | |
int | xlat_tokenize_expansion (xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rules_t const *t_rules) |
static int | xlat_tokenize_function_args (xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rules_t const *t_rules) |
Parse an xlat function and its child argument. | |
static int | xlat_tokenize_input (xlat_exp_head_t *head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, fr_value_box_safe_for_t safe_for) |
Parse an xlat string i.e. | |
static fr_slen_t | xlat_validate_function_arg (xlat_arg_parser_t const *arg_p, xlat_exp_t *arg) |
fr_slen_t | xlat_validate_function_args (xlat_exp_t *node) |
Variables | |
static bool const | tmpl_attr_allowed_chars [UINT8_MAX+1] |
static fr_sbuff_escape_rules_t const | xlat_escape |
These rules apply to literal values and function arguments inside of an expansion. | |
bool const | xlat_func_chars [UINT8_MAX+1] |
static fr_sbuff_parse_rules_t const | xlat_function_arg_rules |
Parse rules for literal values inside of an expansion. | |
static fr_table_num_sorted_t const | xlat_quote_table [] |
static size_t | xlat_quote_table_len = NUM_ELEMENTS(xlat_quote_table) |
static fr_sbuff_unescape_rules_t const | xlat_unescape |
These rules apply to literal values and function arguments inside of an expansion. | |
String expansion ("translation").
Tokenizes xlat expansion strings.
Definition in file xlat_tokenize.c.
Definition at line 919 of file xlat_tokenize.c.
#define XLAT_DEBUG | ( | ... | ) |
Definition at line 44 of file xlat_tokenize.c.
#define XLAT_HEXDUMP | ( | ... | ) |
Definition at line 45 of file xlat_tokenize.c.
|
static |
Definition at line 1032 of file xlat_tokenize.c.
|
static |
Definition at line 922 of file xlat_tokenize.c.
void xlat_debug | ( | xlat_exp_t const * | node | ) |
void xlat_debug_head | ( | xlat_exp_head_t const * | head | ) |
Definition at line 1055 of file xlat_tokenize.c.
int xlat_from_tmpl_attr | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t ** | out, | ||
tmpl_t ** | vpt_p | ||
) |
Convert attr tmpl to an xlat for &attr[*].
[in] | ctx | to allocate new expansion in. |
[out] | out | Where to write new xlat node. |
[in,out] | vpt_p | to convert to xlat expansion. Will be set to NULL on completion |
Definition at line 1829 of file xlat_tokenize.c.
bool xlat_impure_func | ( | xlat_exp_head_t const * | head | ) |
bool xlat_is_literal | ( | xlat_exp_head_t const * | head | ) |
Check to see if the expansion consists entirely of value-box elements.
[in] | head | to check. |
Definition at line 1547 of file xlat_tokenize.c.
bool xlat_needs_resolving | ( | xlat_exp_head_t const * | head | ) |
Check to see if the expansion needs resolving.
[in] | head | to check. |
Definition at line 1563 of file xlat_tokenize.c.
ssize_t xlat_print | ( | fr_sbuff_t * | out, |
xlat_exp_head_t const * | head, | ||
fr_sbuff_escape_rules_t const * | e_rules | ||
) |
Reconstitute an xlat expression from its constituent nodes.
[in] | out | Where to write the output string. |
[in] | head | First node to print. |
[in] | e_rules | Specifying how to escape literal values. |
Definition at line 1239 of file xlat_tokenize.c.
ssize_t xlat_print_node | ( | fr_sbuff_t * | out, |
xlat_exp_head_t const * | head, | ||
xlat_exp_t const * | node, | ||
fr_sbuff_escape_rules_t const * | e_rules, | ||
char | c | ||
) |
Definition at line 1060 of file xlat_tokenize.c.
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.
[in,out] | head | of xlat tree to resolve. |
[in] | xr_rules | Specifies rules to use for resolution passes after initial tokenization. |
Definition at line 1618 of file xlat_tokenize.c.
|
static |
Definition at line 435 of file xlat_tokenize.c.
bool xlat_to_string | ( | TALLOC_CTX * | ctx, |
char ** | str, | ||
xlat_exp_head_t ** | head | ||
) |
Convert an xlat node to an unescaped literal string and free the original node.
This is really "unparse the xlat nodes, and convert back to their original string".
[in] | ctx | to allocate the new string in. |
[out] | str | a duplicate of the node's fmt string. |
[in,out] | head | to convert. |
Definition at line 1579 of file xlat_tokenize.c.
tmpl_t * xlat_to_tmpl_attr | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t * | head | ||
) |
Try to convert an xlat to a tmpl for efficiency.
ctx | to allocate new tmpl_t in. |
head | to convert. |
Definition at line 1796 of file xlat_tokenize.c.
fr_slen_t xlat_tokenize | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t ** | out, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_parse_rules_t const * | p_rules, | ||
tmpl_rules_t const * | t_rules, | ||
fr_value_box_safe_for_t | literals_safe_for | ||
) |
Tokenize an xlat expansion.
[in] | ctx | to allocate dynamic buffers in. |
[out] | out | the head of the xlat list / tree structure. |
[in] | in | the format string to expand. |
[in] | p_rules | controlling how the string containing the xlat expansions should be parsed. |
[in] | t_rules | controlling how attribute references are parsed. Do NOT alter this function to take tmpl_rules_t as this provides another value for literals_safe_for and this gets very confusing. |
[in] | literals_safe_for | the safe_for value to assign to any literals occurring at the top level of the expansion. |
Definition at line 1509 of file xlat_tokenize.c.
fr_slen_t xlat_tokenize_argv | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t ** | out, | ||
fr_sbuff_t * | in, | ||
xlat_t const * | xlat, | ||
fr_sbuff_parse_rules_t const * | p_rules, | ||
tmpl_rules_t const * | t_rules, | ||
bool | comma, | ||
bool | allow_attr | ||
) |
Tokenize an xlat expansion into a series of XLAT_TYPE_CHILD arguments.
[in] | ctx | to allocate nodes in. Note: All nodes will be allocated in the same ctx. This is to allow manipulation by xlat instantiation functions later. |
[out] | out | the head of the xlat list / tree structure. |
[in] | in | the format string to expand. |
[in] | xlat | we're tokenizing arguments for. |
[in] | p_rules | controlling how to parse the string outside of any expansions. |
[in] | t_rules | controlling how attribute references are parsed. |
[in] | comma | whether the arguments are delimited by commas |
[in] | allow_attr | allow attribute references as arguments |
Definition at line 1274 of file xlat_tokenize.c.
|
static |
Parse an attribute ref or a virtual attribute.
Definition at line 460 of file xlat_tokenize.c.
int xlat_tokenize_expansion | ( | xlat_exp_head_t * | head, |
fr_sbuff_t * | in, | ||
tmpl_rules_t const * | t_rules | ||
) |
Definition at line 571 of file xlat_tokenize.c.
|
static |
Parse an xlat function and its child argument.
Parses a function call string in the format
%<func>(<argument>)
Definition at line 277 of file xlat_tokenize.c.
|
static |
Parse an xlat string i.e.
a non-expansion or non-function
When this function is being used outside of an xlat expansion, i.e. on a string which contains one or more xlat expansions, it uses the terminal grammar and escaping rules of that string type.
Which this function is being used inside of an xlat expansion, it uses xlat specific terminal grammar and escaping rules.
This allows us to be smart about processing quotes within the expansions themselves.
[out] | head | to allocate nodes in, and where to write the first child, and where the flags are stored. |
[in] | in | sbuff to parse. |
[in] | p_rules | that control parsing. |
[in] | t_rules | that control attribute reference and xlat function parsing. |
[in] | safe_for | mark up literal values as being pre-escaped. May be merged with t_rules in future. |
Definition at line 781 of file xlat_tokenize.c.
|
static |
Definition at line 174 of file xlat_tokenize.c.
fr_slen_t xlat_validate_function_args | ( | xlat_exp_t * | node | ) |
Definition at line 230 of file xlat_tokenize.c.
Definition at line 564 of file xlat_tokenize.c.
|
static |
These rules apply to literal values and function arguments inside of an expansion.
Definition at line 73 of file xlat_tokenize.c.
Definition at line 168 of file xlat_tokenize.c.
|
static |
Parse rules for literal values inside of an expansion.
These rules are used to parse literals as arguments to functions and on the RHS of alternations.
The caller sets the literal parse rules for outside of expansions when they call xlat_tokenize.
Definition at line 103 of file xlat_tokenize.c.
|
static |
Definition at line 912 of file xlat_tokenize.c.
|
static |
Definition at line 917 of file xlat_tokenize.c.
|
static |
These rules apply to literal values and function arguments inside of an expansion.
Definition at line 51 of file xlat_tokenize.c.