24RCSID(
"$Id: c08ae80128a212f2f942f8e78b058aef654da43f $")
26#include <freeradius-devel/server/base.h>
30#include <freeradius-devel/unlang/xlat_priv.h>
60 if (node->type ==
type)
return;
65 if (node->type != 0)
switch (node->type) {
67 TALLOC_FREE(node->group);
75 TALLOC_FREE(node->call.args);
79 if (node->vpt && (node->fmt == node->vpt->name)) (void) talloc_steal(node, node->fmt);
107 TALLOC_FREE(node->vpt);
120 node->flags = node->group->flags;
129 node->flags.needs_resolving =
true;
149 if (node->fmt[0] !=
'%') {
201 unsigned int extra_hdrs;
226 (
in != NULL) + extra_hdrs,
232 if (!
in)
return node;
276 node->call.func = func;
277 node->call.dict = dict;
286 if (!node->call.args)
return;
288 node->call.args->is_argv =
true;
325 (void) talloc_steal(node,
fmt);
376 node->
quote = p->quote;
377 node->
flags = p->flags;
405 node->call.func = p->call.func;
406 node->call.dict = p->call.dict;
407 node->call.ephemeral = p->call.ephemeral;
409 node, node->call.args, p->call.args) < 0))
goto error;
418 node->regex_index = p->regex_index;
424 node, node->group, p->group) < 0))
goto error;
447#ifdef WITH_VERIFY_PTR
452 switch (node->
type) {
454 xlat_exp_head_verify(node->group);
471 xlat_exp_head_verify(node->call.args);
static int const char * fmt
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
#define NDEBUG_LOCATION_VALS
#define NDEBUG_LOCATION_ARGS
Pass caller information to the function.
#define fr_dlist_init(_head, _type, _field)
Initialise the head structure of a doubly linked list.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
#define tmpl_contains_xlat(vpt)
#define tmpl_is_xlat(vpt)
#define tmpl_value(_tmpl)
#define tmpl_is_attr(vpt)
#define tmpl_is_exec(vpt)
#define tmpl_is_exec_unresolved(vpt)
#define tmpl_rules_cast(_tmpl)
#define tmpl_contains_attr(vpt)
tmpl_t * tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in)
Copy a tmpl.
#define tmpl_is_data(vpt)
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
#define tmpl_needs_resolving(vpt)
fr_aka_sim_id_type_t type
char * talloc_typed_strdup_buffer(TALLOC_CTX *ctx, char const *p)
Call talloc_strndup, setting the type on the new chunk correctly.
char * talloc_bstrndup(TALLOC_CTX *ctx, char const *in, size_t inlen)
Binary safe strndup function.
#define talloc_get_type_abort_const
#define talloc_zero_pooled_object(_ctx, _type, _num_subobjects, _total_subobjects_size)
static int talloc_const_free(void const *ptr)
Free const'd memory.
@ T_SOLIDUS_QUOTED_STRING
#define XLAT_HEAD_VERIFY(_head)
uint8_t needs_resolving
Needs pass2 resolution.
uint8_t can_purify
if the xlat has a pure function with pure arguments.
uint8_t pure
has no external side effects, true for BOX, LITERAL, and some functions
uint8_t impure_func
xlat contains an impure function
uint8_t constant
xlat is just tmpl_attr_tail_data, or XLAT_BOX
Flags that control resolution and evaluation.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
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.
void fr_value_box_strdup_shallow(fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, bool tainted)
Assign a buffer containing a nul terminated string to a box, but don't copy it.
int fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t *src)
Copy value data verbatim moving any buffers to the specified context.
#define fr_value_box_init_null(_vb)
Initialise an empty/null box that will be filled later.
static size_t char fr_sbuff_t size_t inlen
static size_t char ** out
xlat_exp_head_t * _xlat_exp_head_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx)
void xlat_exp_finalize_func(xlat_exp_t *node)
void xlat_exp_set_vpt(xlat_exp_t *node, tmpl_t *vpt)
Set the tmpl for a node, along with flags and the name.
xlat_exp_t * _xlat_exp_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_type_t type, char const *in, size_t inlen)
Allocate an xlat node.
void xlat_exp_set_name(xlat_exp_t *node, char const *fmt, size_t len)
Set the format string for an xlat node.
void xlat_exp_set_name_buffer(xlat_exp_t *node, char const *fmt)
Set the format string for an xlat node, copying from a talloc'd buffer.
xlat_exp_t * _xlat_exp_alloc_null(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx)
Allocate an xlat node with no name, and no type set.
int _xlat_copy(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_exp_head_t *out, xlat_exp_head_t const *in)
void xlat_exp_set_func(xlat_exp_t *node, xlat_t const *func, fr_dict_t const *dict)
Set the function for a node.
static xlat_exp_t * xlat_exp_alloc_pool(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, unsigned int extra_hdrs, size_t extra)
void xlat_exp_set_name_shallow(xlat_exp_t *node, char const *fmt)
Set the format string for an xlat node from a pre-existing buffer.
static int _xlat_copy_internal(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_exp_head_t *out, xlat_exp_head_t const *in)
Copy all nodes in the input list to the output list.
void _xlat_exp_set_type(NDEBUG_LOCATION_ARGS xlat_exp_t *node, xlat_type_t type)
Set the type of an xlat node.
struct xlat_exp_head_s xlat_exp_head_t
xlat_flags_t flags
Flags that control resolution and evaluation.
int line
Line where the xlat was allocated.
fr_token_t quote
Type of quoting around XLAT_GROUP types.
@ XLAT_ONE_LETTER
Special "one-letter" expansion.
@ XLAT_TMPL
xlat attribute
@ XLAT_GROUP
encapsulated string of xlats
@ XLAT_FUNC_UNRESOLVED
func needs resolution during pass2.
@ XLAT_INVALID
Bad expansion.
static void xlat_flags_merge(xlat_flags_t *parent, xlat_flags_t const *child)
Merge flags from child to parent.
char const *_CONST fmt
The original format string (a talloced buffer).
xlat_type_t _CONST type
type of this expansion.
char const *_CONST file
File where the xlat was allocated.
#define xlat_exp_alloc(_ctx, _type, _in, _inlen)
xlat_flags_t flags
various flags
#define xlat_exp_foreach(_list_head, _iter)
Iterate over the contents of a list, only one level.
static int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)