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: 08132bb64125bcc47c92ba02a93388f4b996c69d $
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/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 
59 typedef 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  fr_token_t token; //!< for expressions
69 
70  module_inst_ctx_t *mctx; //!< Original module instantiation ctx if this
71  ///< xlat was registered by a module.
72 
73  xlat_instantiate_t instantiate; //!< Instantiation function.
74  xlat_detach_t detach; //!< Destructor for when xlat instances are freed.
75  char const *inst_type; //!< C type of instance structure.
76  size_t inst_size; //!< Size of instance data to pre-allocate.
77  void *uctx; //!< uctx to pass to instantiation functions.
78 
79  xlat_thread_instantiate_t thread_instantiate; //!< Thread instantiation function.
80  xlat_thread_detach_t thread_detach; //!< Destructor for when xlat thread instance data
81  ///< is freed.
82  char const *thread_inst_type; //!< C type of thread instance structure.
83  size_t thread_inst_size; //!< Size of the thread instance data to pre-allocate.
84  void *thread_uctx; //!< uctx to pass to instantiation functions.
85 
86  xlat_print_t print; //!< function to call when printing
87  xlat_resolve_t resolve; //!< function to call when resolving
88  xlat_purify_t purify; //!< function to call when purifying the node.
89 
90  xlat_flags_t flags; //!< various flags
91 
92  xlat_input_type_t input_type; //!< Type of input used.
93  xlat_arg_parser_t const *args; //!< Definition of args consumed.
94 
95  call_env_method_t const *call_env_method; //!< Optional tmpl expansions performed before calling the
96  ///< xlat. Typically used for xlats which refer to tmpls
97  ///< in their module config.
98 
99  fr_value_box_safe_for_t return_safe_for; //!< Escaped value to set in output boxes.
100  fr_type_t return_type; //!< Function is guaranteed to return one or more boxes
101  ///< of this type. If the return type is FR_TYPE_VOID
102  ///< then the xlat function can return any type of output.
104 
105 typedef enum {
106  XLAT_INVALID = 0x0000, //!< Bad expansion
107  XLAT_BOX = 0x0001, //!< #fr_value_box_t
108  XLAT_ONE_LETTER = 0x0002, //!< Special "one-letter" expansion
109  XLAT_FUNC = 0x0004, //!< xlat module
110  XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2.
111  XLAT_VIRTUAL = 0x0010, //!< virtual attribute
112  XLAT_VIRTUAL_UNRESOLVED = 0x0020, //!< virtual attribute needs resolution during pass2.
113  XLAT_TMPL = 0x0040, //!< xlat attribute
114 #ifdef HAVE_REGEX
115  XLAT_REGEX = 0x0080, //!< regex reference %{1}, etc.
116 #endif
117  XLAT_GROUP = 0x0200 //!< encapsulated string of xlats
119 
120 /** An xlat function call
121  *
122  */
123 typedef struct {
124  uint64_t id; //!< Identifier unique to each permanent xlat node.
125  ///< This is used by the instantiation code to order
126  ///< nodes by the time they were created.
127 
128  xlat_t const *func; //!< The xlat expansion to expand format with.
129  xlat_exp_head_t *args; //!< arguments to the function call
130 
131  fr_dict_t const *dict; //!< Records the namespace this xlat call was created in.
132  ///< Used by the purify code to run fake requests in
133  ///< the correct namespace, and accessible to instantiation
134  ///< functions in case the xlat needs to perform runtime
135  ///< resolution of attributes (as with %eval()).
136 
137  xlat_inst_t *inst; //!< Instance data for the #xlat_t.
138  xlat_thread_inst_t *thread_inst; //!< Thread specific instance.
139  ///< ONLY USED FOR EPHEMERAL XLATS.
140 
141  bool ephemeral; //!< Instance data is ephemeral (not inserted)
142  ///< into the instance tree.
143  xlat_input_type_t input_type; //!< The input type used inferred from the
144  ///< bracketing style.
145 } xlat_call_t;
146 
147 /** An xlat expansion node
148  *
149  * These nodes form a tree which represents one or more nested expansions.
150  */
151 struct xlat_exp_s {
153 
154  char const * _CONST fmt; //!< The original format string (a talloced buffer).
155  fr_token_t quote; //!< Type of quoting around XLAT_GROUP types.
156 
157  xlat_flags_t flags; //!< Flags that control resolution and evaluation.
158  xlat_type_t _CONST type; //!< type of this expansion.
159 
160 #ifndef NDEBUG
161  char const * _CONST file; //!< File where the xlat was allocated.
162  int line; //!< Line where the xlat was allocated.
163 #endif
164 
165  union {
166  xlat_exp_head_t *group; //!< children of a group
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  bool instantiated; //!< temporary flag until we fix more things
192 
193 #ifndef NDEBUG
194  char const * _CONST file; //!< File where the xlat was allocated.
195  int line; //!< Line where the xlat was allocated.
196 #endif
197 };
198 
199 typedef struct {
200  char const *out; //!< Output data.
201  size_t len; //!< Length of the output string.
202 } xlat_out_t;
203 /*
204  * Helper functions
205  */
206 
208 {
209  if (!head) return NULL;
210 
211  return fr_dlist_head(&head->dlist);
212 }
213 
214 /** Iterate over the contents of a list, only one level
215  *
216  * @param[in] _list_head to iterate over.
217  * @param[in] _iter Name of iteration variable.
218  * Will be declared in the scope of the loop.
219  */
220 #define xlat_exp_foreach(_list_head, _iter) fr_dlist_foreach(&((_list_head)->dlist), xlat_exp_t, _iter)
221 
222 /** Merge flags from child to parent
223  *
224  * For pass2, if either the parent or child is marked up for pass2, then the parent
225  * is marked up for pass2.
226  */
227 static inline CC_HINT(nonnull) void xlat_flags_merge(xlat_flags_t *parent, xlat_flags_t const *child)
228 {
229  parent->needs_resolving |= child->needs_resolving;
230  parent->pure &= child->pure; /* purity can only be removed, never added */
231  parent->can_purify |= child->can_purify;
232  parent->constant &= child->constant;
233  parent->impure_func |= child->impure_func;
234 }
235 
236 static inline CC_HINT(nonnull) int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
237 {
238  XLAT_VERIFY(node);
239 
240  xlat_flags_merge(&head->flags, &node->flags);
241  return fr_dlist_insert_tail(&head->dlist, node);
242 }
243 
244 static inline xlat_exp_t *xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
245 {
246  if (!head) return NULL;
247 
248  return fr_dlist_next(&head->dlist, node);
249 }
250 
251 /*
252  * xlat_purify.c
253  */
255 
256 /** Walker callback for xlat_walk()
257  *
258  * @param[in] exp being evaluated.
259  * @param[in] uctx passed to xlat_walk.
260  * @return
261  * - 1 for "prune walk here".
262  * - 0 on success.
263  * - <0 if node evaluation failed. Causes xlat_walk to return the negative integer.
264  */
265 typedef int (*xlat_walker_t)(xlat_exp_t *exp, void *uctx);
266 
267 /*
268  * xlat_alloc.c
269  */
271 #define xlat_exp_head_alloc(_ctx) _xlat_exp_head_alloc(NDEBUG_LOCATION_EXP _ctx)
272 
274 #define xlat_exp_set_type(_node, _type) _xlat_exp_set_type(NDEBUG_LOCATION_EXP _node, _type)
275 
277 #define xlat_exp_alloc_null(_ctx) _xlat_exp_alloc_null(NDEBUG_LOCATION_EXP _ctx)
278 
279 xlat_exp_t *_xlat_exp_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_type_t type, char const *in, size_t inlen);
280 #define xlat_exp_alloc(_ctx, _type, _in, _inlen) _xlat_exp_alloc(NDEBUG_LOCATION_EXP _ctx, _type, _in, _inlen)
281 
282 void xlat_exp_set_name(xlat_exp_t *node, char const *fmt, size_t len) CC_HINT(nonnull);
283 void xlat_exp_set_name_buffer_shallow(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
284 void xlat_exp_set_name_buffer(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
285 
286 /*
287  * xlat_func.c
288  */
289 xlat_t *xlat_func_find(char const *name, ssize_t namelen);
290 
291 /*
292  * xlat_eval.c
293  */
294 extern fr_dict_attr_t const *attr_expr_bool_enum;
296 extern fr_dict_attr_t const *attr_cast_base;
297 
298 fr_dict_attr_t const *xlat_time_res_attr(char const *res);
299 
300 /*
301  * xlat_tokenize.c
302  */
303 extern bool const xlat_func_chars[UINT8_MAX + 1];
304 
305 void xlat_signal(xlat_func_signal_t signal, xlat_exp_t const *exp,
306  request_t *request, void *rctx, fr_signal_t action);
307 
309  xlat_exp_head_t const **child,
310  request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
311  fr_value_box_list_t *result, xlat_func_t resume, void *rctx);
312 
314  xlat_exp_head_t const **child,
315  request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
316  void *env_data, fr_value_box_list_t *result) CC_HINT(nonnull(1,2,3,4));
317 
318 xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_t const **child,
319  request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in);
320 
322 
323 int xlat_eval_init(void);
324 
325 void xlat_eval_free(void);
326 
327 void unlang_xlat_init(void);
328 
329 int unlang_xlat_push_node(TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out,
330  request_t *request, xlat_exp_t *node);
331 
332 int xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out,
333  request_t *request, void *decode_ctx, fr_pair_decode_t decode,
334  fr_value_box_list_t *in);
335 /*
336  * xlat_expr.c
337  */
338 int xlat_register_expressions(void);
339 
340 /*
341  * xlat_tokenize.c
342  */
344  tmpl_rules_t const *t_rules);
345 
347  fr_sbuff_escape_rules_t const *e_rules, char c);
348 
349 #ifdef __cplusplus
350 }
351 #endif
static int const char * fmt
Definition: acutest.h:573
#define NDEBUG_LOCATION_ARGS
Pass caller information to the function.
Definition: build.h:261
fr_dcursor_eval_t void const * uctx
Definition: dcursor.h:546
static fr_slen_t in
Definition: dict.h:821
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:129
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:50
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:1272
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:406
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:451
bool pure
has no external side effects, true for BOX, LITERAL, and some functions
Definition: xlat.h:112
bool needs_resolving
Needs pass2 resolution.
Definition: xlat.h:111
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
bool impure_func
xlat contains an impure function
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:235
Definition for a single argument consumend by an xlat function.
Definition: xlat.h:145
Flags that control resolution and evaluation.
Definition: xlat.h:110
Instance data for an xlat expansion node.
Definition: xlat.h:73
Thread specific instance data for xlat expansion node.
Definition: xlat.h:87
static fr_slen_t parent
Definition: pair.h:851
static fr_slen_t data
Definition: value.h:1265
static size_t char fr_sbuff_t size_t inlen
Definition: value.h:997
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:997
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:143
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:82
static xlat_exp_t * xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
Definition: xlat_priv.h:244
xlat_flags_t flags
Flags that control resolution and evaluation.
Definition: xlat_priv.h:157
fr_type_t return_type
Function is guaranteed to return one or more boxes of this type.
Definition: xlat_priv.h:100
module_inst_ctx_t * mctx
Original module instantiation ctx if this xlat was registered by a module.
Definition: xlat_priv.h:70
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
fr_rb_node_t func_node
Entry in the xlat function tree.
Definition: xlat_priv.h:60
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:836
fr_dict_t const * dict
Records the namespace this xlat call was created in.
Definition: xlat_priv.h:131
bool ephemeral
Instance data is ephemeral (not inserted) into the instance tree.
Definition: xlat_priv.h:141
xlat_func_t func
async xlat function (async unsafe).
Definition: xlat_priv.h:65
xlat_instantiate_t instantiate
Instantiation function.
Definition: xlat_priv.h:73
size_t thread_inst_size
Size of the thread instance data to pre-allocate.
Definition: xlat_priv.h:83
int xlat_eval_init(void)
Definition: xlat_eval.c:1714
xlat_detach_t detach
Destructor for when xlat instances are freed.
Definition: xlat_priv.h:74
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:870
xlat_flags_t flags
Flags that control resolution and evaluation.
Definition: xlat_priv.h:190
char const *_CONST file
File where the xlat was allocated.
Definition: xlat_priv.h:194
int line
Line where the xlat was allocated.
Definition: xlat_priv.h:162
int xlat_register_expressions(void)
Definition: xlat_expr.c:1877
void * thread_uctx
uctx to pass to instantiation functions.
Definition: xlat_priv.h:84
call_env_method_t const * call_env_method
Optional tmpl expansions performed before calling the xlat.
Definition: xlat_priv.h:95
size_t inst_size
Size of instance data to pre-allocate.
Definition: xlat_priv.h:76
int(* xlat_walker_t)(xlat_exp_t *exp, void *uctx)
Walker callback for xlat_walk()
Definition: xlat_priv.h:265
fr_token_t quote
Type of quoting around XLAT_GROUP types.
Definition: xlat_priv.h:155
xlat_type_t
Definition: xlat_priv.h:105
@ XLAT_ONE_LETTER
Special "one-letter" expansion.
Definition: xlat_priv.h:108
@ XLAT_BOX
fr_value_box_t
Definition: xlat_priv.h:107
@ XLAT_TMPL
xlat attribute
Definition: xlat_priv.h:113
@ XLAT_VIRTUAL_UNRESOLVED
virtual attribute needs resolution during pass2.
Definition: xlat_priv.h:112
@ XLAT_FUNC
xlat module
Definition: xlat_priv.h:109
@ XLAT_VIRTUAL
virtual attribute
Definition: xlat_priv.h:111
@ XLAT_GROUP
encapsulated string of xlats
Definition: xlat_priv.h:117
@ XLAT_FUNC_UNRESOLVED
func needs resolution during pass2.
Definition: xlat_priv.h:110
@ XLAT_INVALID
Bad expansion.
Definition: xlat_priv.h:106
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:49
xlat_arg_parser_t const * args
Definition of args consumed.
Definition: xlat_priv.h:93
size_t len
Length of the output string.
Definition: xlat_priv.h:201
xlat_resolve_t resolve
function to call when resolving
Definition: xlat_priv.h:87
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:227
char const * out
Output data.
Definition: xlat_priv.h:200
xlat_exp_head_t * _xlat_exp_head_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx)
Definition: xlat_alloc.c:35
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
xlat_thread_instantiate_t thread_instantiate
Thread instantiation function.
Definition: xlat_priv.h:79
fr_dlist_t entry
Definition: xlat_priv.h:152
xlat_thread_inst_t * thread_inst
Thread specific instance.
Definition: xlat_priv.h:138
#define _CONST
Definition: xlat_priv.h:54
fr_dict_attr_t const * attr_cast_base
Definition: xlat_eval.c:50
xlat_inst_t * inst
Instance data for the xlat_t.
Definition: xlat_priv.h:137
fr_token_t token
for expressions
Definition: xlat_priv.h:68
char const * inst_type
C type of instance structure.
Definition: xlat_priv.h:75
static xlat_exp_t * xlat_exp_head(xlat_exp_head_t const *head)
Definition: xlat_priv.h:207
xlat_t const * func
The xlat expansion to expand format with.
Definition: xlat_priv.h:128
xlat_input_type_t input_type
Type of input used.
Definition: xlat_priv.h:92
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:1110
char const *_CONST fmt
The original format string (a talloced buffer).
Definition: xlat_priv.h:154
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:124
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:158
fr_value_box_safe_for_t return_safe_for
Escaped value to set in output boxes.
Definition: xlat_priv.h:99
char const *_CONST file
File where the xlat was allocated.
Definition: xlat_priv.h:161
xlat_thread_detach_t thread_detach
Destructor for when xlat thread instance data is freed.
Definition: xlat_priv.h:80
void xlat_eval_free(void)
Definition: xlat_eval.c:1739
xlat_purify_t purify
function to call when purifying the node.
Definition: xlat_priv.h:88
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:1650
xlat_flags_t flags
various flags
Definition: xlat_priv.h:90
xlat_print_t print
function to call when printing
Definition: xlat_priv.h:86
fr_dict_attr_t const * attr_module_return_code
int line
Line where the xlat was allocated.
Definition: xlat_priv.h:195
static int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
Definition: xlat_priv.h:236
fr_dict_attr_t const * xlat_time_res_attr(char const *res)
Definition: xlat_eval.c:134
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:129
void * uctx
uctx to pass to instantiation functions.
Definition: xlat_priv.h:77
fr_dlist_t mi_entry
Entry in the list of functions registered to a module instance.
Definition: xlat_priv.h:61
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:944
xlat_t * xlat_func_find(char const *name, ssize_t namelen)
Definition: xlat_func.c:79
void unlang_xlat_init(void)
Register xlat operation with the interpreter.
Definition: xlat.c:680
bool instantiated
temporary flag until we fix more things
Definition: xlat_priv.h:191
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:189
An xlat function call.
Definition: xlat_priv.h:123
An xlat expansion node.
Definition: xlat_priv.h:151