The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
xlat_ctx.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: fe53a67be64a6c88b217f204ed9901250709466d $
20 *
21 * @file lib/unlang/xlat_ctx.h
22 * @brief xlat ephemeral argument passing structures
23 *
24 * @copyright 2021 Arran Cudbard-Bell <a.cudbardb@freeradius.org>
25 */
26RCSIDH(xlat_ctx_h, "$Id: fe53a67be64a6c88b217f204ed9901250709466d $")
27
28
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/* So we don't need to include xlat.h */
35typedef struct xlat_exp_s xlat_exp_t;
37
38/* Break dependency loop with module_ctx.h */
39typedef struct xlat_ctx_s xlat_ctx_t;
42
43#include <freeradius-devel/server/module_ctx.h>
44
45/** An xlat calling ctx
46 *
47 * This provides optional arguments to xlat functions.
48 */
49struct xlat_ctx_s {
50 void const *inst; //!< xlat instance data.
51 void *thread; //!< xlat threadinstance data.
52 module_ctx_t const *mctx; //!< Synthesised module calling ctx.
53 void *env_data; //!< Expanded call env data.
54 void *rctx; //!< Resume context.
55};
56
57/** An xlat instantiation ctx
58 *
59 * This provides optional arguments to xlat functions.
60 */
62 void *inst; //!< xlat instance data to populate.
63 xlat_exp_t *ex; //!< Tokenized expression to use in expansion.
64 module_inst_ctx_t const *mctx; //!< Synthesised module calling ctx.
65 void *uctx; //!< Passed to the registration function.
66};
67
68/** An xlat thread instantiation ctx
69 *
70 * This provides optional arguments to xlat functions.
71 */
73 void const *inst; //!< xlat instance data.
74 void *thread; //!< xlat thread instance data to populate.
75 xlat_exp_t const *ex; //!< Tokenized expression to use in expansion.
76 module_ctx_t const *mctx; //!< Synthesised module calling ctx.
77 fr_event_list_t *el; //!< To register any I/O handlers or timers against.
78 void *uctx; //!< Passed to the registration function.
79};
80
81/** Wrapper to create a xlat_ctx_t as a compound literal
82 *
83 * This is used so that the compiler will flag any uses of (xlat_ctx_t)
84 * which don't set the required fields. Additional arguments should be added
85 * to this macro whenever the xlat_ctx_t fields are altered.
86 *
87 * @param[in] _inst Instance data of the module being called.
88 * @param[in] _thread Instance data of the thread being called.
89 * @param[in] _mctx Module ctx.
90 * @param[in] _env_data Expanded call env.
91 * @param[in] _rctx resume ctx data.
92 */
93#define XLAT_CTX(_inst, _thread, _mctx, _env_data, _rctx) &(xlat_ctx_t){ .inst = _inst, .thread = _thread, \
94 .mctx = _mctx, .env_data = _env_data, .rctx = _rctx }
95
96/** Wrapper to create a xlat_inst_ctx_t as a compound literal
97 *
98 * This is used so that the compiler will flag any uses of (xlat_inst_ctx_t)
99 * which don't set the required fields. Additional arguments should be added
100 * to this macro whenever the xlat_inst_ctx_t fields are altered.
101 *
102 * @param[in] _inst Instance data of the module being called.
103 * @param[in] _ex xlat expression to be evaluated by the instantiation function.
104 * @param[in] _mctx The module_inst_ctx_t from the parent module (if any).
105 * @param[in] _uctx passed when the instantiation function was registered.
106 */
107#define XLAT_INST_CTX(_inst, _ex, _mctx, _uctx) &(xlat_inst_ctx_t){ .inst = _inst, .ex = _ex, .mctx = _mctx, .uctx = _uctx }
108
109/** Wrapper to create a xlat_thread_inst_ctx_t as a compound literal
110 *
111 * This is used so that the compiler will flag any uses of (xlat_thread_inst_ctx_t)
112 * which don't set the required fields. Additional arguments should be added
113 * to this macro whenever the xlat_thread_inst_ctx_t fields are altered.
114 *
115 * @param[in] _inst Instance data of the module being called.
116 * @param[in] _thread Instance data of the thread being called.
117 * @param[in] _ex xlat expression to be evaluated by the instantiation function.
118 * @param[in] _mctx The module_inst_ctx_t from the parent module (if any).
119 * @param[in] _el To register any I/O handlers or timers against.
120 * @param[in] _uctx passed when the instantiation function was registered.
121 */
122#define XLAT_THREAD_INST_CTX(_inst, _thread, _ex, _mctx, _el, _uctx) &(xlat_thread_inst_ctx_t){ .inst = _inst, .ex = _ex, .mctx = _mctx, .el = _el, .uctx = _uctx }
123
124#ifdef __cplusplus
125}
126#endif
#define RCSIDH(h, id)
Definition build.h:484
Stores all information relating to an event list.
Definition event.c:411
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
void * uctx
Passed to the registration function.
Definition xlat_ctx.h:78
void * thread
xlat threadinstance data.
Definition xlat_ctx.h:51
void * rctx
Resume context.
Definition xlat_ctx.h:54
fr_event_list_t * el
To register any I/O handlers or timers against.
Definition xlat_ctx.h:77
void const * inst
xlat instance data.
Definition xlat_ctx.h:73
void * env_data
Expanded call env data.
Definition xlat_ctx.h:53
xlat_exp_t * ex
Tokenized expression to use in expansion.
Definition xlat_ctx.h:63
xlat_exp_t const * ex
Tokenized expression to use in expansion.
Definition xlat_ctx.h:75
void const * inst
xlat instance data.
Definition xlat_ctx.h:50
void * uctx
Passed to the registration function.
Definition xlat_ctx.h:65
module_inst_ctx_t const * mctx
Synthesised module calling ctx.
Definition xlat_ctx.h:64
void * thread
xlat thread instance data to populate.
Definition xlat_ctx.h:74
module_ctx_t const * mctx
Synthesised module calling ctx.
Definition xlat_ctx.h:52
module_ctx_t const * mctx
Synthesised module calling ctx.
Definition xlat_ctx.h:76
void * inst
xlat instance data to populate.
Definition xlat_ctx.h:62
An xlat calling ctx.
Definition xlat_ctx.h:49
An xlat instantiation ctx.
Definition xlat_ctx.h:61
An xlat thread instantiation ctx.
Definition xlat_ctx.h:72
An xlat expansion node.
Definition xlat_priv.h:151