The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
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: 24a3273be7a26b71975f1a3073647eb777cb042c $
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 private; //!< If true, can only be created by the parser,
69 ///< and is invisible to %func() in the input.
70 bool deprecated; //!< this function was deprecated
71 char const *replaced_with; //!< this function was replaced with something else
72 fr_token_t token; //!< for expressions
73
74 module_inst_ctx_t *mctx; //!< Original module instantiation ctx if this
75 ///< xlat was registered by a module.
76
77 xlat_instantiate_t instantiate; //!< Instantiation function.
78 xlat_detach_t detach; //!< Destructor for when xlat instances are freed.
79 char const *inst_type; //!< C type of instance structure.
80 size_t inst_size; //!< Size of instance data to pre-allocate.
81 void *uctx; //!< uctx to pass to instantiation functions.
82
83 xlat_thread_instantiate_t thread_instantiate; //!< Thread instantiation function.
84 xlat_thread_detach_t thread_detach; //!< Destructor for when xlat thread instance data
85 ///< is freed.
86 char const *thread_inst_type; //!< C type of thread instance structure.
87 size_t thread_inst_size; //!< Size of the thread instance data to pre-allocate.
88 void *thread_uctx; //!< uctx to pass to instantiation functions.
89
90 xlat_print_t print; //!< function to call when printing
91 xlat_resolve_t resolve; //!< function to call when resolving
92 xlat_purify_t purify; //!< function to call when purifying the node.
93
94 xlat_flags_t flags; //!< various flags
95
96 xlat_arg_parser_t const *args; //!< Definition of args consumed.
97
98 call_env_method_t const *call_env_method; //!< Optional tmpl expansions performed before calling the
99 ///< xlat. Typically used for xlats which refer to tmpls
100 ///< in their module config.
101
102 fr_value_box_safe_for_t return_safe_for; //!< Escaped value to set in output boxes.
103 fr_type_t return_type; //!< Function is guaranteed to return one or more boxes
104 ///< of this type. If the return type is FR_TYPE_VOID
105 ///< then the xlat function can return any type of output.
107
108typedef enum {
109 XLAT_INVALID = 0x0000, //!< Bad expansion
110 XLAT_BOX = 0x0001, //!< #fr_value_box_t
111 XLAT_ONE_LETTER = 0x0002, //!< Special "one-letter" expansion
112 XLAT_FUNC = 0x0004, //!< xlat module
113 XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2.
114 XLAT_TMPL = 0x0010, //!< xlat attribute
115#ifdef HAVE_REGEX
116 XLAT_REGEX = 0x0020, //!< regex reference %{1}, etc.
117#endif
118 XLAT_GROUP = 0x0100 //!< encapsulated string of xlats
120
121/** An xlat function call
122 *
123 */
124typedef struct {
125 uint64_t id; //!< Identifier unique to each permanent xlat node.
126 ///< This is used by the instantiation code to order
127 ///< nodes by the time they were created.
128
129 xlat_t const *func; //!< The xlat expansion to expand format with.
130 xlat_exp_head_t *args; //!< arguments to the function call
131
132 fr_dict_t const *dict; //!< Records the namespace this xlat call was created in.
133 ///< Used by the purify code to run fake requests in
134 ///< the correct namespace, and accessible to instantiation
135 ///< functions in case the xlat needs to perform runtime
136 ///< resolution of attributes (as with %eval()).
137
138 xlat_inst_t *inst; //!< Instance data for the #xlat_t.
139 xlat_thread_inst_t *thread_inst; //!< Thread specific instance.
140 ///< ONLY USED FOR EPHEMERAL XLATS.
141
142 bool ephemeral; //!< Instance data is ephemeral (not inserted)
143 ///< into the instance tree.
145
146/** An xlat expansion node
147 *
148 * These nodes form a tree which represents one or more nested expansions.
149 */
152
153 char const * _CONST fmt; //!< The original format string (a talloced buffer).
154 fr_token_t quote; //!< Type of quoting around XLAT_GROUP types.
155
156 xlat_flags_t flags; //!< Flags that control resolution and evaluation.
157 xlat_type_t _CONST type; //!< type of this expansion.
158
159#ifndef NDEBUG
160 char const * _CONST file; //!< File where the xlat was allocated.
161 int line; //!< Line where the xlat was allocated.
162#endif
163
164 union {
165 struct {
166 xlat_exp_head_t *group; //!< children of a group
167 unsigned int hoist : 1; //!< it's a group, but we need to hoist the results
168 };
169
170 /** An tmpl_t reference
171 *
172 * May be an attribute to expand, or an exec reference, or a value-box, ...
173 */
174 tmpl_t *vpt;
175
176 /** A capture group, i.e. for %{1} and friends
177 */
178 int regex_index;
179
180 /** An xlat function call
181 */
182 xlat_call_t call;
183
184 /** A value box
185 */
187 };
188};
189
192 xlat_flags_t flags; //!< Flags that control resolution and evaluation.
193 unsigned int instantiated : 1; //!< temporary flag until we fix more things
194 unsigned int is_argv : 1; //!< this thing holds function arguments
195 unsigned int cursor : 1; //!< otherwise it's too hard to pass xlat_arg_parser_t to the evaluation function.
196 unsigned int is_attr : 1; //!< the argument is an attribute reference
197
198#ifndef NDEBUG
199 char const * _CONST file; //!< File where the xlat was allocated.
200 int line; //!< Line where the xlat was allocated.
201#endif
202};
203
204typedef struct {
205 char const *out; //!< Output data.
206 size_t len; //!< Length of the output string.
207} xlat_out_t;
208/*
209 * Helper functions
210 */
211
213{
214 if (!head) return NULL;
215
216 return fr_dlist_head(&head->dlist);
217}
218
219/** Iterate over the contents of a list, only one level
220 *
221 * @param[in] _list_head to iterate over.
222 * @param[in] _iter Name of iteration variable.
223 * Will be declared in the scope of the loop.
224 */
225#define xlat_exp_foreach(_list_head, _iter) fr_dlist_foreach(&((_list_head)->dlist), xlat_exp_t, _iter)
226
227/** Merge flags from child to parent
228 *
229 * For pass2, if either the parent or child is marked up for pass2, then the parent
230 * is marked up for pass2.
231 */
232static inline CC_HINT(nonnull) void xlat_flags_merge(xlat_flags_t *parent, xlat_flags_t const *child)
233{
234 parent->needs_resolving |= child->needs_resolving;
235 parent->pure &= child->pure; /* purity can only be removed, never added */
236 parent->can_purify |= child->can_purify; /* there is SOME node under us which can be purified */
237 parent->constant &= child->constant;
238 parent->impure_func |= child->impure_func;
239}
240
241static inline CC_HINT(nonnull) int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
242{
243 XLAT_VERIFY(node);
244
245 xlat_flags_merge(&head->flags, &node->flags);
246 return fr_dlist_insert_tail(&head->dlist, node);
247}
248
249static inline xlat_exp_t *xlat_exp_next(xlat_exp_head_t const *head, xlat_exp_t const *node)
250{
251 if (!head) return NULL;
252
253 return fr_dlist_next(&head->dlist, node);
254}
255
256/*
257 * xlat_purify.c
258 */
260
261/** Walker callback for xlat_walk()
262 *
263 * @param[in] exp being evaluated.
264 * @param[in] uctx passed to xlat_walk.
265 * @return
266 * - 1 for "prune walk here".
267 * - 0 on success.
268 * - <0 if node evaluation failed. Causes xlat_walk to return the negative integer.
269 */
270typedef int (*xlat_walker_t)(xlat_exp_t *exp, void *uctx);
271
272/*
273 * xlat_alloc.c
274 */
276#define xlat_exp_head_alloc(_ctx) _xlat_exp_head_alloc(NDEBUG_LOCATION_EXP _ctx)
277
279#define xlat_exp_set_type(_node, _type) _xlat_exp_set_type(NDEBUG_LOCATION_EXP _node, _type)
280
282#define xlat_exp_alloc_null(_ctx) _xlat_exp_alloc_null(NDEBUG_LOCATION_EXP _ctx)
283
284xlat_exp_t *_xlat_exp_alloc(NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_type_t type, char const *in, size_t inlen);
285#define xlat_exp_alloc(_ctx, _type, _in, _inlen) _xlat_exp_alloc(NDEBUG_LOCATION_EXP _ctx, _type, _in, _inlen)
286
287void xlat_exp_set_name(xlat_exp_t *node, char const *fmt, size_t len) CC_HINT(nonnull);
288void xlat_exp_set_name_shallow(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
289void xlat_exp_set_name_buffer(xlat_exp_t *node, char const *fmt) CC_HINT(nonnull);
290
291void xlat_exp_set_vpt(xlat_exp_t *node, tmpl_t *vpt) CC_HINT(nonnull);
292void xlat_exp_set_func(xlat_exp_t *node, xlat_t const *func, fr_dict_t const *dict) CC_HINT(nonnull(1,2));
293void xlat_exp_finalize_func(xlat_exp_t *node) CC_HINT(nonnull);
294
295/*
296 * xlat_func.c
297 */
298xlat_t *xlat_func_find(char const *name, ssize_t namelen);
299
300/*
301 * xlat_eval.c
302 */
305extern fr_dict_attr_t const *attr_cast_base;
306
307fr_dict_attr_t const *xlat_time_res_attr(char const *res);
308
309/*
310 * xlat_tokenize.c
311 */
312extern bool const xlat_func_chars[SBUFF_CHAR_CLASS];
313
315
316void xlat_signal(xlat_func_signal_t signal, xlat_exp_t const *exp,
317 request_t *request, void *rctx, fr_signal_t action);
318
320 xlat_exp_head_t const **child,
321 request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
322 fr_value_box_list_t *result, xlat_func_t resume, void *rctx);
323
325 xlat_exp_head_t const **child,
326 request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in,
327 void *env_data, fr_value_box_list_t *result) CC_HINT(nonnull(1,2,3,4));
328
329xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_t const **child,
330 request_t *request, xlat_exp_head_t const *head, xlat_exp_t const **in);
331
333
334int xlat_eval_init(void);
335
336void xlat_eval_free(void);
337
338void unlang_xlat_init(void);
339
340int unlang_xlat_push_node(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_list_t *out,
341 request_t *request, xlat_exp_t *node);
342
343int xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out,
344 request_t *request, void *decode_ctx, fr_pair_decode_t decode,
345 fr_value_box_list_t *in);
346/*
347 * xlat_builtin.c
348 */
350
351bool xlat_file_allowed(request_t *request, fr_value_box_t const *vb, int oflag) CC_HINT(nonnull);
352
353/* for xlat_data_type */
355 UNUSED xlat_ctx_t const *xctx,
356 request_t *request, fr_value_box_list_t *args);
357
358/*
359 * xlat_expr.c
360 */
362
363/*
364 * xlat_profiling.c
365 */
366int xlat_profiling_init(void);
367
368/*
369 * xlat_tokenize.c
370 */
372 fr_sbuff_escape_rules_t const *e_rules, char c);
373
375 fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules) CC_HINT(nonnull);
376
377#ifdef __cplusplus
378}
379#endif
va_list args
Definition acutest.h:770
static int const char * fmt
Definition acutest.h:573
#define NDEBUG_LOCATION_ARGS
Pass caller information to the function.
Definition build.h:330
#define UNUSED
Definition build.h:384
static fr_slen_t in
Definition dict.h:904
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:468
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:360
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:537
Head of a doubly linked list.
Definition dlist.h:51
Entry in a doubly linked list.
Definition dlist.h:41
xlat_action_t xlat_func_cast(TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
Cast one or more output value-boxes to the given type.
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
#define SBUFF_CHAR_CLASS
fr_type_t
long int ssize_t
ssize_t fr_slen_t
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:1198
static char const * name
static fr_slen_t vpt
Definition tmpl.h:1290
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:343
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:281
int(* xlat_detach_t)(xlat_inst_ctx_t const *xctx)
xlat detach callback
Definition xlat.h:266
unsigned int pure
has no external side effects, true for BOX, LITERAL, and some functions
Definition xlat.h:110
unsigned int impure_func
xlat contains an impure function
Definition xlat.h:111
static fr_slen_t head
Definition xlat.h:410
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:233
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:222
#define XLAT_VERIFY(_node)
Definition xlat.h:455
int(* xlat_thread_instantiate_t)(xlat_thread_inst_ctx_t const *xctx)
Allocate new thread instance data for an xlat instance.
Definition xlat.h:252
xlat_action_t
Definition xlat.h:37
unsigned int can_purify
if the xlat has a pure function with pure arguments.
Definition xlat.h:112
unsigned int constant
xlat is just tmpl_attr_tail_data, or XLAT_BOX
Definition xlat.h:114
unsigned int needs_resolving
Needs pass2 resolution.
Definition xlat.h:109
int(* xlat_instantiate_t)(xlat_inst_ctx_t const *xctx)
Allocate new instance data for an xlat instance.
Definition xlat.h:243
Definition for a single argument consumed by an xlat function.
Definition xlat.h:135
Flags that control resolution and evaluation.
Definition xlat.h:108
Instance data for an xlat expansion node.
Definition xlat.h:71
Thread specific instance data for xlat expansion node.
Definition xlat.h:85
static fr_slen_t parent
Definition pair.h:860
static fr_slen_t data
Definition value.h:1367
static fr_sbuff_err_t char ** out
Definition value.h:1062
static fr_sbuff_err_t char size_t * len
Definition value.h:1062
uintptr_t fr_value_box_safe_for_t
Escaping that's been applied to a value box.
Definition value.h:162
int nonnull(2, 5))
An xlat calling ctx.
Definition xlat_ctx.h:49
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:55
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:51
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:47
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:86
int xlat_profiling_init(void)
Register the control functions for every profiler that the build compiled in.
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:156
fr_type_t return_type
Function is guaranteed to return one or more boxes of this type.
Definition xlat_priv.h:103
module_inst_ctx_t * mctx
Original module instantiation ctx if this xlat was registered by a module.
Definition xlat_priv.h:74
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:249
void xlat_exp_finalize_func(xlat_exp_t *node)
Definition xlat_alloc.c:310
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:278
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:1079
fr_dict_t const * dict
Records the namespace this xlat call was created in.
Definition xlat_priv.h:132
fr_dict_attr_t const * xlat_time_res_attr(char const *res)
Definition xlat_eval.c:127
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:142
xlat_func_t func
async xlat function (async unsafe).
Definition xlat_priv.h:65
xlat_instantiate_t instantiate
Instantiation function.
Definition xlat_priv.h:77
size_t thread_inst_size
Size of the thread instance data to pre-allocate.
Definition xlat_priv.h:87
int xlat_eval_init(void)
Definition xlat_eval.c:2045
xlat_detach_t detach
Destructor for when xlat instances are freed.
Definition xlat_priv.h:78
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:1113
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:224
unsigned int cursor
otherwise it's too hard to pass xlat_arg_parser_t to the evaluation function.
Definition xlat_priv.h:195
xlat_flags_t flags
Flags that control resolution and evaluation.
Definition xlat_priv.h:192
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:199
int line
Line where the xlat was allocated.
Definition xlat_priv.h:161
int xlat_register_expressions(void)
Definition xlat_expr.c:1882
void * thread_uctx
uctx to pass to instantiation functions.
Definition xlat_priv.h:88
call_env_method_t const * call_env_method
Optional tmpl expansions performed before calling the xlat.
Definition xlat_priv.h:98
size_t inst_size
Size of instance data to pre-allocate.
Definition xlat_priv.h:80
int(* xlat_walker_t)(xlat_exp_t *exp, void *uctx)
Walker callback for xlat_walk()
Definition xlat_priv.h:270
fr_token_t quote
Type of quoting around XLAT_GROUP types.
Definition xlat_priv.h:154
xlat_type_t
Definition xlat_priv.h:108
@ XLAT_ONE_LETTER
Special "one-letter" expansion.
Definition xlat_priv.h:111
@ XLAT_BOX
fr_value_box_t
Definition xlat_priv.h:110
@ XLAT_TMPL
xlat attribute
Definition xlat_priv.h:114
@ XLAT_FUNC
xlat module
Definition xlat_priv.h:112
@ XLAT_GROUP
encapsulated string of xlats
Definition xlat_priv.h:118
@ XLAT_FUNC_UNRESOLVED
func needs resolution during pass2.
Definition xlat_priv.h:113
@ XLAT_INVALID
Bad expansion.
Definition xlat_priv.h:109
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:334
fr_dict_attr_t const * attr_expr_bool_enum
Definition xlat_eval.c:42
int unlang_xlat_push_node(TALLOC_CTX *ctx, unlang_result_t *p_result, 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:289
xlat_arg_parser_t const * args
Definition of args consumed.
Definition xlat_priv.h:96
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:300
size_t len
Length of the output string.
Definition xlat_priv.h:206
unsigned int is_argv
this thing holds function arguments
Definition xlat_priv.h:194
bool deprecated
this function was deprecated
Definition xlat_priv.h:70
xlat_resolve_t resolve
function to call when resolving
Definition xlat_priv.h:91
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:232
char const * out
Output data.
Definition xlat_priv.h:205
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:347
bool const xlat_func_chars[SBUFF_CHAR_CLASS]
xlat_thread_instantiate_t thread_instantiate
Thread instantiation function.
Definition xlat_priv.h:83
char const * replaced_with
this function was replaced with something else
Definition xlat_priv.h:71
fr_dlist_t entry
Definition xlat_priv.h:151
xlat_thread_inst_t * thread_inst
Thread specific instance.
Definition xlat_priv.h:139
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:211
#define _CONST
Definition xlat_priv.h:54
fr_dict_attr_t const * attr_cast_base
Definition xlat_eval.c:43
xlat_inst_t * inst
Instance data for the xlat_t.
Definition xlat_priv.h:138
fr_token_t token
for expressions
Definition xlat_priv.h:72
char const * inst_type
C type of instance structure.
Definition xlat_priv.h:79
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:129
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:1398
char const *_CONST fmt
The original format string (a talloced buffer).
Definition xlat_priv.h:153
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:125
int xlat_purify_list(xlat_exp_head_t *head, request_t *request)
Definition xlat_purify.c:65
xlat_type_t _CONST type
type of this expansion.
Definition xlat_priv.h:157
fr_value_box_safe_for_t return_safe_for
Escaped value to set in output boxes.
Definition xlat_priv.h:102
char const *_CONST file
File where the xlat was allocated.
Definition xlat_priv.h:160
xlat_thread_detach_t thread_detach
Destructor for when xlat thread instance data is freed.
Definition xlat_priv.h:84
void xlat_eval_free(void)
Definition xlat_eval.c:2067
xlat_purify_t purify
function to call when purifying the node.
Definition xlat_priv.h:92
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:1981
xlat_flags_t flags
various flags
Definition xlat_priv.h:94
xlat_print_t print
function to call when printing
Definition xlat_priv.h:90
fr_dict_attr_t const * attr_module_return_code
int line
Line where the xlat was allocated.
Definition xlat_priv.h:200
static int xlat_exp_insert_tail(xlat_exp_head_t *head, xlat_exp_t *node)
Definition xlat_priv.h:241
unsigned int is_attr
the argument is an attribute reference
Definition xlat_priv.h:196
xlat_exp_head_t * args
arguments to the function call
Definition xlat_priv.h:130
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:364
bool xlat_file_allowed(request_t *request, fr_value_box_t const *vb, int oflag)
void * uctx
uctx to pass to instantiation functions.
Definition xlat_priv.h:81
fr_dlist_t mi_entry
Entry in the list of functions registered to a module instance.
Definition xlat_priv.h:61
unsigned int instantiated
temporary flag until we fix more things
Definition xlat_priv.h:193
xlat_arg_parser_t const xlat_func_file_name_args[]
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:1187
void unlang_xlat_init(void)
Register xlat operation with the interpreter.
Definition xlat.c:805
static xlat_exp_t * xlat_exp_head(xlat_exp_head_t const *head)
Definition xlat_priv.h:212
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:191
An xlat function call.
Definition xlat_priv.h:124
An xlat expansion node.
Definition xlat_priv.h:150