The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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: bdf7ab068ec85e73d93f5828e9eaec0a6a36260b $
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
30 extern "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/io/pair.h>
37 #include <freeradius-devel/util/talloc.h>
38 #include <freeradius-devel/build.h>
39 
40 #ifdef DEBUG_XLAT
41 # define XLAT_DEBUG RDEBUG3
42 #else
43 # define XLAT_DEBUG(...)
44 #endif
45 
46 /*
47  * Allow public and private versions of the same structures
48  */
49 #ifdef _CONST
50 # error _CONST can only be defined in the local header
51 #endif
52 #ifndef _XLAT_PRIVATE
53 # define _CONST const
54 #else
55 # define _CONST
56 #endif
57 
58 typedef struct xlat_s {
59  fr_rb_node_t node; //!< Entry in the xlat function tree.
60  char const *name; //!< Name of xlat function.
61  xlat_func_t func; //!< async xlat function (async unsafe).
62 
63  bool internal; //!< If true, cannot be redefined.
64  fr_token_t token; //!< for expressions
65 
66  module_inst_ctx_t const *mctx; //!< Original module instantiation ctx if this
67  ///< xlat was registered by a module.
68 
69  xlat_instantiate_t instantiate; //!< Instantiation function.
70  xlat_detach_t detach; //!< Destructor for when xlat instances are freed.
71  char const *inst_type; //!< C type of instance structure.
72  size_t inst_size; //!< Size of instance data to pre-allocate.
73  void *uctx; //!< uctx to pass to instantiation functions.
74 
75  xlat_thread_instantiate_t thread_instantiate; //!< Thread instantiation function.
76  xlat_thread_detach_t thread_detach; //!< Destructor for when xlat thread instance data
77  ///< is freed.
78  char const *thread_inst_type; //!< C type of thread instance structure.
79  size_t thread_inst_size; //!< Size of the thread instance data to pre-allocate.
80  void *thread_uctx; //!< uctx to pass to instantiation functions.
81 
82  xlat_print_t print; //!< function to call when printing
83  xlat_resolve_t resolve; //!< function to call when resolving
84  xlat_purify_t purify; //!< function to call when purifying the node.
85 
86  xlat_flags_t flags; //!< various flags
87 
88  xlat_input_type_t input_type; //!< Type of input used.
89  xlat_arg_parser_t const *args; //!< Definition of args consumed.
90 
91  call_env_method_t const *call_env_method; //!< Optional tmpl expansions performed before calling the
92  ///< xlat. Typically used for xlats which refer to tmpls
93  ///< in their module config.
94 
95  fr_value_box_safe_for_t return_safe_for; //!< Escaped value to set in output boxes.
96  fr_type_t return_type; //!< Function is guaranteed to return one or more boxes
97  ///< of this type. If the return type is FR_TYPE_VOID
98  ///< then the xlat function can return any type of output.
100 
101 typedef enum {
102  XLAT_INVALID = 0x0000, //!< Bad expansion
103  XLAT_BOX = 0x0001, //!< #fr_value_box_t
104  XLAT_ONE_LETTER = 0x0002, //!< Special "one-letter" expansion
105  XLAT_FUNC = 0x0004, //!< xlat module
106  XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2.
107  XLAT_VIRTUAL = 0x0010, //!< virtual attribute
108  XLAT_VIRTUAL_UNRESOLVED = 0x0020, //!< virtual attribute needs resolution during pass2.
109  XLAT_TMPL = 0x0040, //!< xlat attribute
110 #ifdef HAVE_REGEX
111  XLAT_REGEX = 0x0080, //!< regex reference %{1}, etc.
112 #endif
113  XLAT_GROUP = 0x0200 //!< encapsulated string of xlats
115 
116 /** An xlat function call
117  *
118  */
119 typedef struct {
120  uint64_t id; //!< Identifier unique to each permanent xlat node.
121  ///< This is used by the instantiation code to order
122  ///< nodes by the time they were created.
123 
124  xlat_t const *func; //!< The xlat expansion to expand format with.
125  xlat_exp_head_t *args; //!< arguments to the function call
126 
127  fr_dict_t const *dict; //!< Records the namespace this xlat call was created in.
128  ///< Used by the purify code to run fake requests in
129  ///< the correct namespace, and accessible to instantiation
130  ///< functions in case the xlat needs to perform runtime
131  ///< resolution of attributes (as with %eval()).
132 
133  xlat_inst_t *inst; //!< Instance data for the #xlat_t.
134  xlat_thread_inst_t *thread_inst; //!< Thread specific instance.
135  ///< ONLY USED FOR EPHEMERAL XLATS.
136 
137  bool ephemeral; //!< Instance data is ephemeral (not inserted)
138  ///< into the instance tree.
139  xlat_input_type_t input_type; //!< The input type used inferred from the
140  ///< bracketing style.
141 } xlat_call_t;
142 
143 /** An xlat expansion node
144  *
145  * These nodes form a tree which represents one or more nested expansions.
146  */
147 struct xlat_exp_s {
149 
150  char const * _CONST fmt; //!< The original format string (a talloced buffer).
151  fr_token_t quote; //!< Type of quoting around XLAT_GROUP types.
152 
153  xlat_flags_t flags; //!< Flags that control resolution and evaluation.
154  xlat_type_t _CONST type; //!< type of this expansion.
155 
156 #ifndef NDEBUG
157  char const * _CONST file; //!< File where the xlat was allocated.
158  int line; //!< Line where the xlat was allocated.
159 #endif
160 
161  union {
162  xlat_exp_head_t *group; //!< children of a group
163 
164  /** An tmpl_t reference
165  *
166  * May be an attribute to expand, or an exec reference, or a value-box, ...
167  */
168  tmpl_t *vpt;
169 
170  /** A capture group, i.e. for %{1} and friends
171  */
172  int regex_index;
173 
174  /** An xlat function call
175  */
176  xlat_call_t call;
177 
178  /** A value box
179  */
181  };
182 };
183 
186  xlat_flags_t flags; //!< Flags that control resolution and evaluation.
187  bool instantiated; //!< temporary flag until we fix more things
188 
189 #ifndef NDEBUG
190  char const * _CONST file; //!< File where the xlat was allocated.
191  int line; //!< Line where the xlat was allocated.
192 #endif
193 };
194 
195 typedef struct {
196  char const *out; //!< Output data.
197  size_t len; //!< Length of the output string.
198 } xlat_out_t;
199 /*
200  * Helper functions
201  */
202 
204 {
205  if (!head) return NULL;
206 
207  return fr_dlist_head(&head->dlist);
208 }
209 
210 /** Iterate over the contents of a list, only one level
211  *
212  * @param[in] _list_head to iterate over.
213  * @param[in] _iter Name of iteration variable.
214  * Will be declared in the scope of the loop.
215  */
216 #define xlat_exp_foreach(_list_head, _iter) fr_dlist_foreach(&((_list_head)->dlist), xlat_exp_t, _iter)
217 
218 /** Merge flags from child to parent
219  *
220  * For pass2, if either the parent or child is marked up for pass2, then the parent
221  * is marked up for pass2.
222  */
223 static inline CC_HINT(nonnull) void xlat_flags_merge(xlat_flags_t *parent, xlat_flags_t const *child)
224 {
225  parent->needs_resolving |= child->needs_resolving;
226  parent->pure &= child->pure; /* purity can only be removed, never added */
227  parent->can_purify |= child->can_purify;
228  parent->constant &= child->constant;
229 }
230 
231 static inline CC_HINT(nonnull) int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
232 {
233  XLAT_VERIFY(node);
234 
235  xlat_flags_merge(&head->flags, &node->flags);
236  return fr_dlist_insert_tail(&head->dlist, node);
237 }
238 
239 static inline xlat_exp_t *xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
240 {
241  if (!head) return NULL;
242 
243  return fr_dlist_next(&head->dlist, node);
244 }
245 
246 /*
247  * xlat_purify.c
248  */
250 
251 /** Walker callback for xlat_walk()
252  *
253  * @param[in] exp being evaluated.
254  * @param[in] uctx passed to xlat_walk.
255  * @return
256  * - 1 for "prune walk here".
257  * - 0 on success.
258  * - <0 if node evaluation failed. Causes xlat_walk to return the negative integer.
259  */
260 typedef int (*xlat_walker_t)(xlat_exp_t *exp, void *uctx);
261 
262 /*
263  * xlat_alloc.c
264  */
266 #define xlat_exp_head_alloc(_ctx) _xlat_exp_head_alloc(NDEBUG_LOCATION_EXP _ctx)
267 
269 #define xlat_exp_set_type(_node, _type) _xlat_exp_set_type(NDEBUG_LOCATION_EXP _node, _type)
270 
272 #define xlat_exp_alloc_null(_ctx) _xlat_exp_alloc_null(NDEBUG_LOCATION_EXP _ctx)
273 
274 xlat_exp_t *_xlat_exp_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_type_t type, char const *in, size_t inlen);
275 #define xlat_exp_alloc(_ctx, _type, _in, _inlen) _xlat_exp_alloc(NDEBUG_LOCATION_EXP _ctx, _type, _in, _inlen)
276 
277 void xlat_exp_set_name(xlat_exp_t *node, char const *fmt, size_t len) CC_HINT(nonnull);
278 void xlat_exp_set_name_buffer_shallow(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
279 void xlat_exp_set_name_buffer(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
280 
281 /*
282  * xlat_func.c
283  */
284 xlat_t *xlat_func_find(char const *name, ssize_t namelen);
285 
286 /*
287  * xlat_eval.c
288  */
289 extern fr_dict_attr_t const *attr_expr_bool_enum;
291 extern fr_dict_attr_t const *attr_cast_base;
292 
293 /*
294  * xlat_tokenize.c
295  */
296 extern bool const xlat_func_chars[UINT8_MAX + 1];
297 
298 void xlat_signal(xlat_func_signal_t signal, xlat_exp_t const *exp,
299  request_t *request, void *rctx, fr_signal_t action);
300 
302  xlat_exp_head_t const **child,
303  request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
304  fr_value_box_list_t *result, xlat_func_t resume, void *rctx);
305 
307  xlat_exp_head_t const **child,
308  request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
309  void *env_data, fr_value_box_list_t *result) CC_HINT(nonnull(1,2,3,4));
310 
311 xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_t const **child,
312  request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in);
313 
315 
316 int xlat_eval_init(void);
317 
318 void xlat_eval_free(void);
319 
320 void unlang_xlat_init(void);
321 
322 int unlang_xlat_push_node(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
323  request_t *request, xlat_exp_t *node);
324 
325 int xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out,
326  request_t *request, void *decode_ctx, fr_pair_decode_t decode,
327  fr_value_box_list_t *in);
328 /*
329  * xlat_expr.c
330  */
331 int xlat_register_expressions(void);
332 
333 /*
334  * xlat_tokenize.c
335  */
337  tmpl_rules_t const *t_rules);
338 
340  fr_sbuff_escape_rules_t const *e_rules, char c);
341 
342 #ifdef __cplusplus
343 }
344 #endif
static int const char * fmt
Definition: acutest.h:573
#define NDEBUG_LOCATION_ARGS
Pass caller information to the function.
Definition: build.h:261
static fr_slen_t in
Definition: dict.h:645
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
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
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:130
fr_type_t
Definition: merged_model.c:80
long int ssize_t
Definition: merged_model.c:24
#define UINT8_MAX
Definition: merged_model.c:32
Temporary structure to hold arguments for instantiation calls.
Definition: module_ctx.h:51
static decode_fail_t decode(TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *response_code, udp_handle_t *h, request_t *request, udp_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.
static char const * name
static fr_slen_t vpt
Definition: tmpl.h:1260
Optional arguments passed to vp_tmpl functions.
Definition: tmpl.h:341
fr_signal_t
Definition: signal.h:48
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:273
int(* xlat_detach_t)(xlat_inst_ctx_t const *xctx)
xlat detach callback
Definition: xlat.h:258
static fr_slen_t head
Definition: xlat.h:408
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:225
bool can_purify
if the xlat has a pure function with pure arguments.
Definition: xlat.h:114
xlat_input_type_t
Definition: xlat.h:45
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:214
#define XLAT_VERIFY(_node)
Definition: xlat.h:453
bool pure
has no external side effects, true for BOX, LITERAL, and some functions
Definition: xlat.h:113
bool needs_resolving
Needs pass2 resolution.
Definition: xlat.h:112
int(* xlat_thread_instantiate_t)(xlat_thread_inst_ctx_t const *xctx)
Allocate new thread instance data for an xlat instance.
Definition: xlat.h:244
xlat_action_t
Definition: xlat.h:35
bool constant
xlat is just tmpl_attr_tail_data, or XLAT_BOX
Definition: xlat.h:116
int(* xlat_instantiate_t)(xlat_inst_ctx_t const *xctx)
Allocate new instance data for an xlat instance.
Definition: xlat.h:235
Definition for a single argument consumend by an xlat function.
Definition: xlat.h:145
Flags that control resolution and evaluation.
Definition: xlat.h:111
Instance data for an xlat expansion node.
Definition: xlat.h:74
Thread specific instance data for xlat expansion node.
Definition: xlat.h:88
static fr_slen_t parent
Definition: pair.h:844
static fr_slen_t data
Definition: value.h:1259
static size_t char fr_sbuff_t size_t inlen
Definition: value.h:984
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:984
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
xlat_input_type_t input_type
The input type used inferred from the bracketing style.
Definition: xlat_priv.h:139
char const * name
Name of xlat function.
Definition: xlat_priv.h:60
char const * thread_inst_type
C type of thread instance structure.
Definition: xlat_priv.h:78
static xlat_exp_t * xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
Definition: xlat_priv.h:239
xlat_flags_t flags
Flags that control resolution and evaluation.
Definition: xlat_priv.h:153
fr_type_t return_type
Function is guaranteed to return one or more boxes of this type.
Definition: xlat_priv.h:96
bool const xlat_func_chars[UINT8_MAX+1]
int xlat_tokenize_expansion(xlat_exp_head_t *head, fr_sbuff_t *in, tmpl_rules_t const *t_rules)
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
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:125
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:761
fr_dict_t const * dict
Records the namespace this xlat call was created in.
Definition: xlat_priv.h:127
bool ephemeral
Instance data is ephemeral (not inserted) into the instance tree.
Definition: xlat_priv.h:137
xlat_func_t func
async xlat function (async unsafe).
Definition: xlat_priv.h:61
xlat_instantiate_t instantiate
Instantiation function.
Definition: xlat_priv.h:69
size_t thread_inst_size
Size of the thread instance data to pre-allocate.
Definition: xlat_priv.h:79
int xlat_eval_init(void)
Definition: xlat_eval.c:1639
xlat_detach_t detach
Destructor for when xlat instances are freed.
Definition: xlat_priv.h:70
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:795
xlat_flags_t flags
Flags that control resolution and evaluation.
Definition: xlat_priv.h:186
char const *_CONST file
File where the xlat was allocated.
Definition: xlat_priv.h:190
int line
Line where the xlat was allocated.
Definition: xlat_priv.h:158
int xlat_register_expressions(void)
Definition: xlat_expr.c:1807
void * thread_uctx
uctx to pass to instantiation functions.
Definition: xlat_priv.h:80
call_env_method_t const * call_env_method
Optional tmpl expansions performed before calling the xlat.
Definition: xlat_priv.h:91
size_t inst_size
Size of instance data to pre-allocate.
Definition: xlat_priv.h:72
int(* xlat_walker_t)(xlat_exp_t *exp, void *uctx)
Walker callback for xlat_walk()
Definition: xlat_priv.h:260
fr_token_t quote
Type of quoting around XLAT_GROUP types.
Definition: xlat_priv.h:151
xlat_type_t
Definition: xlat_priv.h:101
@ XLAT_ONE_LETTER
Special "one-letter" expansion.
Definition: xlat_priv.h:104
@ XLAT_BOX
fr_value_box_t
Definition: xlat_priv.h:103
@ XLAT_TMPL
xlat attribute
Definition: xlat_priv.h:109
@ XLAT_VIRTUAL_UNRESOLVED
virtual attribute needs resolution during pass2.
Definition: xlat_priv.h:108
@ XLAT_FUNC
xlat module
Definition: xlat_priv.h:105
@ XLAT_VIRTUAL
virtual attribute
Definition: xlat_priv.h:107
@ XLAT_GROUP
encapsulated string of xlats
Definition: xlat_priv.h:113
@ XLAT_FUNC_UNRESOLVED
func needs resolution during pass2.
Definition: xlat_priv.h:106
@ XLAT_INVALID
Bad expansion.
Definition: xlat_priv.h:102
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:191
fr_dict_attr_t const * attr_expr_bool_enum
Definition: xlat_eval.c:51
xlat_arg_parser_t const * args
Definition of args consumed.
Definition: xlat_priv.h:89
size_t len
Length of the output string.
Definition: xlat_priv.h:197
xlat_resolve_t resolve
function to call when resolving
Definition: xlat_priv.h:83
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:138
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:223
char const * out
Output data.
Definition: xlat_priv.h:196
xlat_exp_head_t * _xlat_exp_head_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx)
Definition: xlat_alloc.c:35
fr_rb_node_t node
Entry in the xlat function tree.
Definition: xlat_priv.h:59
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:202
module_inst_ctx_t const * mctx
Original module instantiation ctx if this xlat was registered by a module.
Definition: xlat_priv.h:66
xlat_thread_instantiate_t thread_instantiate
Thread instantiation function.
Definition: xlat_priv.h:75
fr_dlist_t entry
Definition: xlat_priv.h:148
xlat_thread_inst_t * thread_inst
Thread specific instance.
Definition: xlat_priv.h:134
#define _CONST
Definition: xlat_priv.h:53
fr_dict_attr_t const * attr_cast_base
Definition: xlat_eval.c:52
xlat_inst_t * inst
Instance data for the xlat_t.
Definition: xlat_priv.h:133
fr_token_t token
for expressions
Definition: xlat_priv.h:64
char const * inst_type
C type of instance structure.
Definition: xlat_priv.h:71
static xlat_exp_t * xlat_exp_head(xlat_exp_head_t const *head)
Definition: xlat_priv.h:203
xlat_t const * func
The xlat expansion to expand format with.
Definition: xlat_priv.h:124
xlat_input_type_t input_type
Type of input used.
Definition: xlat_priv.h:88
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:1035
char const *_CONST fmt
The original format string (a talloced buffer).
Definition: xlat_priv.h:150
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:120
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:294
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:154
fr_value_box_safe_for_t return_safe_for
Escaped value to set in output boxes.
Definition: xlat_priv.h:95
char const *_CONST file
File where the xlat was allocated.
Definition: xlat_priv.h:157
xlat_thread_detach_t thread_detach
Destructor for when xlat thread instance data is freed.
Definition: xlat_priv.h:76
void xlat_eval_free(void)
Definition: xlat_eval.c:1664
xlat_purify_t purify
function to call when purifying the node.
Definition: xlat_priv.h:84
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:1575
xlat_flags_t flags
various flags
Definition: xlat_priv.h:86
xlat_print_t print
function to call when printing
Definition: xlat_priv.h:82
fr_dict_attr_t const * attr_module_return_code
int line
Line where the xlat was allocated.
Definition: xlat_priv.h:191
static int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
Definition: xlat_priv.h:231
void xlat_exp_set_name_buffer_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:213
xlat_exp_head_t * args
arguments to the function call
Definition: xlat_priv.h:125
void * uctx
uctx to pass to instantiation functions.
Definition: xlat_priv.h:73
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:869
xlat_t * xlat_func_find(char const *name, ssize_t namelen)
Definition: xlat_func.c:56
void unlang_xlat_init(void)
Register xlat operation with the interpreter.
Definition: xlat.c:586
bool instantiated
temporary flag until we fix more things
Definition: xlat_priv.h:187
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:58
fr_dlist_head_t dlist
Definition: xlat_priv.h:185
An xlat function call.
Definition: xlat_priv.h:119
An xlat expansion node.
Definition: xlat_priv.h:147