The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
xlat_priv.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 982b93e73e5559f2564a0f0d7c1d0b2227650f06 $
20 *
21 * @file src/lib/unlang/xlat_priv.h
22 * @brief String expansion ("translation"). Implements %Attribute -> value
23 *
24 * Private structures for the xlat tokenizer and xlat eval code.
25 *
26 * @copyright 2000,2006 The FreeRADIUS server project
27 * @copyright 2000 Alan DeKok (aland@freeradius.org)
28 */
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <freeradius-devel/unlang/xlat_ctx.h>
34#include <freeradius-devel/unlang/xlat.h>
35#include <freeradius-devel/unlang/xlat_func.h>
36#include <freeradius-devel/server/module_ctx.h>
37#include <freeradius-devel/io/pair.h>
38#include <freeradius-devel/util/talloc.h>
39#include <freeradius-devel/build.h>
40
41#ifdef DEBUG_XLAT
42# define XLAT_DEBUG RDEBUG3
43#else
44# define XLAT_DEBUG(...)
45#endif
46
47/*
48 * Allow public and private versions of the same structures
49 */
50#ifdef _CONST
51# error _CONST can only be defined in the local header
52#endif
53#ifndef _XLAT_PRIVATE
54# define _CONST const
55#else
56# define _CONST
57#endif
58
59typedef struct xlat_s {
60 fr_rb_node_t func_node; //!< Entry in the xlat function tree.
61 fr_dlist_t mi_entry; //!< Entry in the list of functions
62 ///< registered to a module instance.
63
64 char const *name; //!< Name of xlat function.
65 xlat_func_t func; //!< async xlat function (async unsafe).
66
67 bool internal; //!< If true, cannot be redefined.
68 bool deprecated; //!< this function was deprecated
69 char const *replaced_with; //!< this function was replaced with something else
70 fr_token_t token; //!< for expressions
71
72 module_inst_ctx_t *mctx; //!< Original module instantiation ctx if this
73 ///< xlat was registered by a module.
74
75 xlat_instantiate_t instantiate; //!< Instantiation function.
76 xlat_detach_t detach; //!< Destructor for when xlat instances are freed.
77 char const *inst_type; //!< C type of instance structure.
78 size_t inst_size; //!< Size of instance data to pre-allocate.
79 void *uctx; //!< uctx to pass to instantiation functions.
80
81 xlat_thread_instantiate_t thread_instantiate; //!< Thread instantiation function.
82 xlat_thread_detach_t thread_detach; //!< Destructor for when xlat thread instance data
83 ///< is freed.
84 char const *thread_inst_type; //!< C type of thread instance structure.
85 size_t thread_inst_size; //!< Size of the thread instance data to pre-allocate.
86 void *thread_uctx; //!< uctx to pass to instantiation functions.
87
88 xlat_print_t print; //!< function to call when printing
89 xlat_resolve_t resolve; //!< function to call when resolving
90 xlat_purify_t purify; //!< function to call when purifying the node.
91
92 xlat_flags_t flags; //!< various flags
93
94 xlat_arg_parser_t const *args; //!< Definition of args consumed.
95
96 call_env_method_t const *call_env_method; //!< Optional tmpl expansions performed before calling the
97 ///< xlat. Typically used for xlats which refer to tmpls
98 ///< in their module config.
99
100 fr_value_box_safe_for_t return_safe_for; //!< Escaped value to set in output boxes.
101 fr_type_t return_type; //!< Function is guaranteed to return one or more boxes
102 ///< of this type. If the return type is FR_TYPE_VOID
103 ///< then the xlat function can return any type of output.
105
106typedef enum {
107 XLAT_INVALID = 0x0000, //!< Bad expansion
108 XLAT_BOX = 0x0001, //!< #fr_value_box_t
109 XLAT_ONE_LETTER = 0x0002, //!< Special "one-letter" expansion
110 XLAT_FUNC = 0x0004, //!< xlat module
111 XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2.
112 XLAT_TMPL = 0x0010, //!< xlat attribute
113#ifdef HAVE_REGEX
114 XLAT_REGEX = 0x0020, //!< regex reference %{1}, etc.
115#endif
116 XLAT_GROUP = 0x0100 //!< encapsulated string of xlats
118
119/** An xlat function call
120 *
121 */
122typedef struct {
123 uint64_t id; //!< Identifier unique to each permanent xlat node.
124 ///< This is used by the instantiation code to order
125 ///< nodes by the time they were created.
126
127 xlat_t const *func; //!< The xlat expansion to expand format with.
128 xlat_exp_head_t *args; //!< arguments to the function call
129
130 fr_dict_t const *dict; //!< Records the namespace this xlat call was created in.
131 ///< Used by the purify code to run fake requests in
132 ///< the correct namespace, and accessible to instantiation
133 ///< functions in case the xlat needs to perform runtime
134 ///< resolution of attributes (as with %eval()).
135
136 xlat_inst_t *inst; //!< Instance data for the #xlat_t.
137 xlat_thread_inst_t *thread_inst; //!< Thread specific instance.
138 ///< ONLY USED FOR EPHEMERAL XLATS.
139
140 bool ephemeral; //!< Instance data is ephemeral (not inserted)
141 ///< into the instance tree.
143
144/** An xlat expansion node
145 *
146 * These nodes form a tree which represents one or more nested expansions.
147 */
150
151 char const * _CONST fmt; //!< The original format string (a talloced buffer).
152 fr_token_t quote; //!< Type of quoting around XLAT_GROUP types.
153
154 xlat_flags_t flags; //!< Flags that control resolution and evaluation.
155 xlat_type_t _CONST type; //!< type of this expansion.
156
157#ifndef NDEBUG
158 char const * _CONST file; //!< File where the xlat was allocated.
159 int line; //!< Line where the xlat was allocated.
160#endif
161
162 union {
163 struct {
164 xlat_exp_head_t *group; //!< children of a group
165 uint8_t hoist : 1; //!< it's a group, but we need to hoist the results
166 };
167
168 /** An tmpl_t reference
169 *
170 * May be an attribute to expand, or an exec reference, or a value-box, ...
171 */
172 tmpl_t *vpt;
173
174 /** A capture group, i.e. for %{1} and friends
175 */
176 int regex_index;
177
178 /** An xlat function call
179 */
180 xlat_call_t call;
181
182 /** A value box
183 */
185 };
186};
187
190 xlat_flags_t flags; //!< Flags that control resolution and evaluation.
191 uint8_t instantiated : 1; //!< temporary flag until we fix more things
192 uint8_t is_argv : 1; //!< this thing holds function arguments
193
194#ifndef NDEBUG
195 char const * _CONST file; //!< File where the xlat was allocated.
196 int line; //!< Line where the xlat was allocated.
197#endif
198};
199
200typedef struct {
201 char const *out; //!< Output data.
202 size_t len; //!< Length of the output string.
203} xlat_out_t;
204/*
205 * Helper functions
206 */
207
209{
210 if (!head) return NULL;
211
212 return fr_dlist_head(&head->dlist);
213}
214
215/** Iterate over the contents of a list, only one level
216 *
217 * @param[in] _list_head to iterate over.
218 * @param[in] _iter Name of iteration variable.
219 * Will be declared in the scope of the loop.
220 */
221#define xlat_exp_foreach(_list_head, _iter) fr_dlist_foreach(&((_list_head)->dlist), xlat_exp_t, _iter)
222
223/** Merge flags from child to parent
224 *
225 * For pass2, if either the parent or child is marked up for pass2, then the parent
226 * is marked up for pass2.
227 */
228static inline CC_HINT(nonnull) void xlat_flags_merge(xlat_flags_t *parent, xlat_flags_t const *child)
229{
230 parent->needs_resolving |= child->needs_resolving;
231 parent->pure &= child->pure; /* purity can only be removed, never added */
232 parent->can_purify |= child->can_purify; /* there is SOME node under us which can be purified */
233 parent->constant &= child->constant;
234 parent->impure_func |= child->impure_func;
235}
236
237static inline CC_HINT(nonnull) int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
238{
239 XLAT_VERIFY(node);
240
241 xlat_flags_merge(&head->flags, &node->flags);
242 return fr_dlist_insert_tail(&head->dlist, node);
243}
244
245static inline xlat_exp_t *xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
246{
247 if (!head) return NULL;
248
249 return fr_dlist_next(&head->dlist, node);
250}
251
252/*
253 * xlat_purify.c
254 */
256
257/** Walker callback for xlat_walk()
258 *
259 * @param[in] exp being evaluated.
260 * @param[in] uctx passed to xlat_walk.
261 * @return
262 * - 1 for "prune walk here".
263 * - 0 on success.
264 * - <0 if node evaluation failed. Causes xlat_walk to return the negative integer.
265 */
266typedef int (*xlat_walker_t)(xlat_exp_t *exp, void *uctx);
267
268/*
269 * xlat_alloc.c
270 */
272#define xlat_exp_head_alloc(_ctx) _xlat_exp_head_alloc(NDEBUG_LOCATION_EXP _ctx)
273
275#define xlat_exp_set_type(_node, _type) _xlat_exp_set_type(NDEBUG_LOCATION_EXP _node, _type)
276
278#define xlat_exp_alloc_null(_ctx) _xlat_exp_alloc_null(NDEBUG_LOCATION_EXP _ctx)
279
280xlat_exp_t *_xlat_exp_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_type_t type, char const *in, size_t inlen);
281#define xlat_exp_alloc(_ctx, _type, _in, _inlen) _xlat_exp_alloc(NDEBUG_LOCATION_EXP _ctx, _type, _in, _inlen)
282
283void xlat_exp_set_name(xlat_exp_t *node, char const *fmt, size_t len) CC_HINT(nonnull);
284void xlat_exp_set_name_shallow(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
285void xlat_exp_set_name_buffer(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
286
287void xlat_exp_set_vpt(xlat_exp_t *node, tmpl_t *vpt) CC_HINT(nonnull);
288void xlat_exp_set_func(xlat_exp_t *node, xlat_t const *func, fr_dict_t const *dict) CC_HINT(nonnull(1,2));
289void xlat_exp_finalize_func(xlat_exp_t *node) CC_HINT(nonnull);
290
291/*
292 * xlat_func.c
293 */
294xlat_t *xlat_func_find(char const *name, ssize_t namelen);
295
296/*
297 * xlat_eval.c
298 */
301extern fr_dict_attr_t const *attr_cast_base;
302
303fr_dict_attr_t const *xlat_time_res_attr(char const *res);
304
305/*
306 * xlat_tokenize.c
307 */
308extern bool const xlat_func_chars[UINT8_MAX + 1];
309
311
312void xlat_signal(xlat_func_signal_t signal, xlat_exp_t const *exp,
313 request_t *request, void *rctx, fr_signal_t action);
314
316 xlat_exp_head_t const **child,
317 request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
318 fr_value_box_list_t *result, xlat_func_t resume, void *rctx);
319
321 xlat_exp_head_t const **child,
322 request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
323 void *env_data, fr_value_box_list_t *result) CC_HINT(nonnull(1,2,3,4));
324
325xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_t const **child,
326 request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in);
327
329
330int xlat_eval_init(void);
331
332void xlat_eval_free(void);
333
334void unlang_xlat_init(void);
335
336int unlang_xlat_push_node(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
337 request_t *request, xlat_exp_t *node);
338
339int xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out,
340 request_t *request, void *decode_ctx, fr_pair_decode_t decode,
341 fr_value_box_list_t *in);
342/*
343 * xlat_expr.c
344 */
346
347/*
348 * xlat_tokenize.c
349 */
351 fr_sbuff_escape_rules_t const *e_rules, char c);
352
354 fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules) CC_HINT(nonnull);
355
356#ifdef __cplusplus
357}
358#endif
static int const char * fmt
Definition acutest.h:573
#define NDEBUG_LOCATION_ARGS
Pass caller information to the function.
Definition build.h:263
static fr_slen_t in
Definition dict.h:833
static void * fr_dlist_head(fr_dlist_head_t const *list_head)
Return the HEAD item of a list or NULL if the list is empty.
Definition dlist.h:486
static int fr_dlist_insert_tail(fr_dlist_head_t *list_head, void *ptr)
Insert an item into the tail of a list.
Definition dlist.h:378
static void * fr_dlist_next(fr_dlist_head_t const *list_head, void const *ptr)
Get the next item in a list.
Definition dlist.h:555
Head of a doubly linked list.
Definition dlist.h:51
Entry in a doubly linked list.
Definition dlist.h:41
ssize_t(* fr_pair_decode_t)(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
A generic interface for decoding fr_pair_ts.
Definition pair.h:129
fr_type_t
long int ssize_t
unsigned char uint8_t
ssize_t fr_slen_t
#define UINT8_MAX
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
static fr_radius_decode_fail_t decode(TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *response_code, bio_handle_t *h, request_t *request, bio_request_t *u, uint8_t const request_authenticator[static RADIUS_AUTH_VECTOR_LENGTH], uint8_t *data, size_t data_len)
Decode response packet data, extracting relevant information and validating the packet.
Definition bio.c:1073
static char const * name
static fr_slen_t vpt
Definition tmpl.h:1269
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:332
fr_signal_t
Signals that can be generated/processed by request signal handlers.
Definition signal.h:38
fr_aka_sim_id_type_t type
enum fr_token fr_token_t
int(* xlat_thread_detach_t)(xlat_thread_inst_ctx_t const *xctx)
xlat thread detach callback
Definition xlat.h:287
int(* xlat_detach_t)(xlat_inst_ctx_t const *xctx)
xlat detach callback
Definition xlat.h:272
static fr_slen_t head
Definition xlat.h:416
void(* xlat_func_signal_t)(xlat_ctx_t const *xctx, request_t *request, fr_signal_t action)
A callback when the request gets a fr_signal_t.
Definition xlat.h:239
xlat_action_t(* xlat_func_t)(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
xlat callback function
Definition xlat.h:228
uint8_t needs_resolving
Needs pass2 resolution.
Definition xlat.h:108
#define XLAT_VERIFY(_node)
Definition xlat.h:462
uint8_t can_purify
if the xlat has a pure function with pure arguments.
Definition xlat.h:111
uint8_t pure
has no external side effects, true for BOX, LITERAL, and some functions
Definition xlat.h:109
int(* xlat_thread_instantiate_t)(xlat_thread_inst_ctx_t const *xctx)
Allocate new thread instance data for an xlat instance.
Definition xlat.h:258
uint8_t impure_func
xlat contains an impure function
Definition xlat.h:110
xlat_action_t
Definition xlat.h:37
uint8_t constant
xlat is just tmpl_attr_tail_data, or XLAT_BOX
Definition xlat.h:113
int(* xlat_instantiate_t)(xlat_inst_ctx_t const *xctx)
Allocate new instance data for an xlat instance.
Definition xlat.h:249
Definition for a single argument consumend by an xlat function.
Definition xlat.h:144
Flags that control resolution and evaluation.
Definition xlat.h:107
Instance data for an xlat expansion node.
Definition xlat.h:70
Thread specific instance data for xlat expansion node.
Definition xlat.h:84
static fr_slen_t parent
Definition pair.h:845
static fr_slen_t data
Definition value.h:1274
static size_t char fr_sbuff_t size_t inlen
Definition value.h:1012
uintptr_t fr_value_box_safe_for_t
Escaping that's been applied to a value box.
Definition value.h:155
int nonnull(2, 5))
static size_t char ** out
Definition value.h:1012
int(* xlat_purify_t)(xlat_exp_t *xlat, void *inst, request_t *request)
Custom function purify the result of an xlat function.
Definition xlat_func.h:53
int(* xlat_resolve_t)(xlat_exp_t *xlat, void *inst, xlat_res_rules_t const *xr_rules)
Custom function to perform resolution of arguments.
Definition xlat_func.h:49
fr_slen_t(* xlat_print_t)(fr_sbuff_t *in, xlat_exp_t const *self, void *inst, fr_sbuff_escape_rules_t const *e_rules)
Custom function to print xlat debug.
Definition xlat_func.h:45
char const * name
Name of xlat function.
Definition xlat_priv.h:64
char const * thread_inst_type
C type of thread instance structure.
Definition xlat_priv.h:84
xlat_exp_head_t * _xlat_exp_head_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx)
Definition xlat_alloc.c:32
xlat_flags_t flags
Flags that control resolution and evaluation.
Definition xlat_priv.h:154
fr_type_t return_type
Function is guaranteed to return one or more boxes of this type.
Definition xlat_priv.h:101
module_inst_ctx_t * mctx
Original module instantiation ctx if this xlat was registered by a module.
Definition xlat_priv.h:72
bool const xlat_func_chars[UINT8_MAX+1]
int xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, void *decode_ctx, fr_pair_decode_t decode, fr_value_box_list_t *in)
Decode all of the value boxes into the output cursor.
Definition xlat_pair.c:90
fr_rb_node_t func_node
Entry in the xlat function tree.
Definition xlat_priv.h:60
static xlat_exp_t * xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
Definition xlat_priv.h:245
void xlat_exp_finalize_func(xlat_exp_t *node)
Definition xlat_alloc.c:284
void xlat_exp_set_vpt(xlat_exp_t *node, tmpl_t *vpt)
Set the tmpl for a node, along with flags and the name.
Definition xlat_alloc.c:252
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.
Definition xlat_eval.c:927
fr_dict_t const * dict
Records the namespace this xlat call was created in.
Definition xlat_priv.h:130
fr_dict_attr_t const * xlat_time_res_attr(char const *res)
Definition xlat_eval.c:126
bool internal
If true, cannot be redefined.
Definition xlat_priv.h:67
bool ephemeral
Instance data is ephemeral (not inserted) into the instance tree.
Definition xlat_priv.h:140
xlat_func_t func
async xlat function (async unsafe).
Definition xlat_priv.h:65
xlat_instantiate_t instantiate
Instantiation function.
Definition xlat_priv.h:75
size_t thread_inst_size
Size of the thread instance data to pre-allocate.
Definition xlat_priv.h:85
int xlat_eval_init(void)
Definition xlat_eval.c:1845
xlat_detach_t detach
Destructor for when xlat instances are freed.
Definition xlat_priv.h:76
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.
Definition xlat_eval.c:961
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.
Definition xlat_alloc.c:198
xlat_flags_t flags
Flags that control resolution and evaluation.
Definition xlat_priv.h:190
fr_slen_t xlat_tokenize_word(TALLOC_CTX *ctx, xlat_exp_t **out, fr_sbuff_t *in, fr_token_t quote, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules)
int xlat_tokenize_regex(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in, fr_sbuff_marker_t *m_s)
char const *_CONST file
File where the xlat was allocated.
Definition xlat_priv.h:195
int line
Line where the xlat was allocated.
Definition xlat_priv.h:159
int xlat_register_expressions(void)
Definition xlat_expr.c:1762
void * thread_uctx
uctx to pass to instantiation functions.
Definition xlat_priv.h:86
call_env_method_t const * call_env_method
Optional tmpl expansions performed before calling the xlat.
Definition xlat_priv.h:96
size_t inst_size
Size of instance data to pre-allocate.
Definition xlat_priv.h:78
int(* xlat_walker_t)(xlat_exp_t *exp, void *uctx)
Walker callback for xlat_walk()
Definition xlat_priv.h:266
fr_token_t quote
Type of quoting around XLAT_GROUP types.
Definition xlat_priv.h:152
xlat_type_t
Definition xlat_priv.h:106
@ XLAT_ONE_LETTER
Special "one-letter" expansion.
Definition xlat_priv.h:109
@ XLAT_BOX
fr_value_box_t
Definition xlat_priv.h:108
@ XLAT_TMPL
xlat attribute
Definition xlat_priv.h:112
@ XLAT_FUNC
xlat module
Definition xlat_priv.h:110
@ XLAT_GROUP
encapsulated string of xlats
Definition xlat_priv.h:116
@ XLAT_FUNC_UNRESOLVED
func needs resolution during pass2.
Definition xlat_priv.h:111
@ XLAT_INVALID
Bad expansion.
Definition xlat_priv.h:107
void xlat_exp_set_name(xlat_exp_t *node, char const *fmt, size_t len)
Set the format string for an xlat node.
Definition xlat_alloc.c:308
fr_dict_attr_t const * attr_expr_bool_enum
Definition xlat_eval.c:41
xlat_arg_parser_t const * args
Definition of args consumed.
Definition xlat_priv.h:94
void xlat_exp_set_func(xlat_exp_t *node, xlat_t const *func, fr_dict_t const *dict))
Set the function for a node.
Definition xlat_alloc.c:274
size_t len
Length of the output string.
Definition xlat_priv.h:202
bool deprecated
this function was deprecated
Definition xlat_priv.h:68
xlat_resolve_t resolve
function to call when resolving
Definition xlat_priv.h:89
struct xlat_s xlat_t
static void xlat_flags_merge(xlat_flags_t *parent, xlat_flags_t const *child)
Merge flags from child to parent.
Definition xlat_priv.h:228
char const * out
Output data.
Definition xlat_priv.h:201
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.
Definition xlat_alloc.c:321
xlat_thread_instantiate_t thread_instantiate
Thread instantiation function.
Definition xlat_priv.h:81
char const * replaced_with
this function was replaced with something else
Definition xlat_priv.h:69
fr_dlist_t entry
Definition xlat_priv.h:149
xlat_thread_inst_t * thread_inst
Thread specific instance.
Definition xlat_priv.h:137
xlat_exp_t * _xlat_exp_alloc_null(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx)
Allocate an xlat node with no name, and no type set.
Definition xlat_alloc.c:185
#define _CONST
Definition xlat_priv.h:54
fr_dict_attr_t const * attr_cast_base
Definition xlat_eval.c:42
xlat_inst_t * inst
Instance data for the xlat_t.
Definition xlat_priv.h:136
uint8_t instantiated
temporary flag until we fix more things
Definition xlat_priv.h:191
fr_token_t token
for expressions
Definition xlat_priv.h:70
char const * inst_type
C type of instance structure.
Definition xlat_priv.h:77
xlat_t * xlat_func_find(char const *name, ssize_t namelen)
Definition xlat_func.c:77
xlat_t const * func
The xlat expansion to expand format with.
Definition xlat_priv.h:127
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.
Definition xlat_eval.c:1240
char const *_CONST fmt
The original format string (a talloced buffer).
Definition xlat_priv.h:151
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)
uint64_t id
Identifier unique to each permanent xlat node.
Definition xlat_priv.h:123
int unlang_xlat_push_node(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out, request_t *request, xlat_exp_t *node)
Push a pre-compiled xlat onto the stack for evaluation.
Definition xlat.c:302
int xlat_purify_list(xlat_exp_head_t *head, request_t *request)
Definition xlat_purify.c:60
xlat_type_t _CONST type
type of this expansion.
Definition xlat_priv.h:155
fr_value_box_safe_for_t return_safe_for
Escaped value to set in output boxes.
Definition xlat_priv.h:100
char const *_CONST file
File where the xlat was allocated.
Definition xlat_priv.h:158
xlat_thread_detach_t thread_detach
Destructor for when xlat thread instance data is freed.
Definition xlat_priv.h:82
void xlat_eval_free(void)
Definition xlat_eval.c:1870
xlat_purify_t purify
function to call when purifying the node.
Definition xlat_priv.h:90
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.
Definition xlat_eval.c:1781
xlat_flags_t flags
various flags
Definition xlat_priv.h:92
xlat_print_t print
function to call when printing
Definition xlat_priv.h:88
fr_dict_attr_t const * attr_module_return_code
int line
Line where the xlat was allocated.
Definition xlat_priv.h:196
static int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
Definition xlat_priv.h:237
xlat_exp_head_t * args
arguments to the function call
Definition xlat_priv.h:128
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.
Definition xlat_alloc.c:338
void * uctx
uctx to pass to instantiation functions.
Definition xlat_priv.h:79
fr_dlist_t mi_entry
Entry in the list of functions registered to a module instance.
Definition xlat_priv.h:61
uint8_t is_argv
this thing holds function arguments
Definition xlat_priv.h:192
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.
Definition xlat_eval.c:1035
void unlang_xlat_init(void)
Register xlat operation with the interpreter.
Definition xlat.c:823
static xlat_exp_t * xlat_exp_head(xlat_exp_head_t const *head)
Definition xlat_priv.h:208
void _xlat_exp_set_type(NDEBUG_LOCATION_ARGS xlat_exp_t *node, xlat_type_t type)
Set the type of an xlat node.
Definition xlat_alloc.c:55
fr_dlist_head_t dlist
Definition xlat_priv.h:189
An xlat function call.
Definition xlat_priv.h:122
An xlat expansion node.
Definition xlat_priv.h:148