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: 390c7121c2bae2fbf0f9d27bb987ed8274abf951 $
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: 390c7121c2bae2fbf0f9d27bb987ed8274abf951 $")
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 xlat_exp_t const *ex; //!< Tokenized expression
56};
57
58/** An xlat instantiation ctx
59 *
60 * This provides optional arguments to xlat functions.
61 */
63 void *inst; //!< xlat instance data to populate.
64 xlat_exp_t *ex; //!< Tokenized expression to use in expansion.
65 module_inst_ctx_t const *mctx; //!< Synthesised module calling ctx.
66 void *uctx; //!< Passed to the registration function.
67};
68
69/** An xlat thread instantiation ctx
70 *
71 * This provides optional arguments to xlat functions.
72 */
74 void const *inst; //!< xlat instance data.
75 void *thread; //!< xlat thread instance data to populate.
76 xlat_exp_t const *ex; //!< Tokenized expression to use in expansion.
77 module_ctx_t const *mctx; //!< Synthesised module calling ctx.
78 fr_event_list_t *el; //!< To register any I/O handlers or timers against.
79 void *uctx; //!< Passed to the registration function.
80};
81
82/** Wrapper to create a xlat_ctx_t as a compound literal
83 *
84 * This is used so that the compiler will flag any uses of (xlat_ctx_t)
85 * which don't set the required fields. Additional arguments should be added
86 * to this macro whenever the xlat_ctx_t fields are altered.
87 *
88 * @param[in] _inst Instance data of the module being called.
89 * @param[in] _thread Instance data of the thread being called.
90 * @param[in] _ex xlat expression
91 * @param[in] _mctx Module ctx.
92 * @param[in] _env_data Expanded call env.
93 * @param[in] _rctx resume ctx data.
94 */
95#define XLAT_CTX(_inst, _thread, _ex, _mctx, _env_data, _rctx) &(xlat_ctx_t){ .inst = _inst, .thread = _thread, .ex = _ex, \
96 .mctx = _mctx, .env_data = _env_data, .rctx = _rctx }
97
98/** Wrapper to create a xlat_inst_ctx_t as a compound literal
99 *
100 * This is used so that the compiler will flag any uses of (xlat_inst_ctx_t)
101 * which don't set the required fields. Additional arguments should be added
102 * to this macro whenever the xlat_inst_ctx_t fields are altered.
103 *
104 * @param[in] _inst Instance data of the module being called.
105 * @param[in] _ex xlat expression to be evaluated by the instantiation function.
106 * @param[in] _mctx The module_inst_ctx_t from the parent module (if any).
107 * @param[in] _uctx passed when the instantiation function was registered.
108 */
109#define XLAT_INST_CTX(_inst, _ex, _mctx, _uctx) &(xlat_inst_ctx_t){ .inst = _inst, .ex = _ex, .mctx = _mctx, .uctx = _uctx }
110
111/** Wrapper to create a xlat_thread_inst_ctx_t as a compound literal
112 *
113 * This is used so that the compiler will flag any uses of (xlat_thread_inst_ctx_t)
114 * which don't set the required fields. Additional arguments should be added
115 * to this macro whenever the xlat_thread_inst_ctx_t fields are altered.
116 *
117 * @param[in] _inst Instance data of the module being called.
118 * @param[in] _thread Instance data of the thread being called.
119 * @param[in] _ex xlat expression
120 * @param[in] _mctx The module_inst_ctx_t from the parent module (if any).
121 * @param[in] _el To register any I/O handlers or timers against.
122 * @param[in] _uctx passed when the instantiation function was registered.
123 */
124#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 }
125
126#ifdef __cplusplus
127}
128#endif
#define RCSIDH(h, id)
Definition build.h:486
Stores all information relating to an event list.
Definition event.c:377
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:79
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:78
void const * inst
xlat instance data.
Definition xlat_ctx.h:74
void * env_data
Expanded call env data.
Definition xlat_ctx.h:53
xlat_exp_t const * ex
Tokenized expression.
Definition xlat_ctx.h:55
xlat_exp_t * ex
Tokenized expression to use in expansion.
Definition xlat_ctx.h:64
xlat_exp_t const * ex
Tokenized expression to use in expansion.
Definition xlat_ctx.h:76
void const * inst
xlat instance data.
Definition xlat_ctx.h:50
void * uctx
Passed to the registration function.
Definition xlat_ctx.h:66
module_inst_ctx_t const * mctx
Synthesised module calling ctx.
Definition xlat_ctx.h:65
void * thread
xlat thread instance data to populate.
Definition xlat_ctx.h:75
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:77
void * inst
xlat instance data to populate.
Definition xlat_ctx.h:63
An xlat calling ctx.
Definition xlat_ctx.h:49
An xlat instantiation ctx.
Definition xlat_ctx.h:62
An xlat thread instantiation ctx.
Definition xlat_ctx.h:73
An xlat expansion node.
Definition xlat_priv.h:148