if (!(xlat = xlat_func_register(NULL, "op_" STRINGIFY(_name), xlat_func_op_ ## _name, FR_TYPE_VOID))) return -1; \
xlat_func_args_set(xlat, binary_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
- xlat_print_set(xlat, xlat_expr_print_binary); \
+ xlat_func_print_set(xlat, xlat_expr_print_binary); \
xlat_func_async_instantiate_set(xlat, xlat_function_args_to_tmpl, NULL, NULL, NULL); \
xlat->token = _op; \
} while (0)
if (!(xlat = xlat_func_register(NULL, "cmp_" STRINGIFY(_name), xlat_func_cmp_ ## _name, FR_TYPE_VOID))) return -1; \
xlat_func_args_set(xlat, binary_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
- xlat_print_set(xlat, xlat_expr_print_binary); \
- xlat_resolve_set(xlat, xlat_expr_resolve_binary); \
+ xlat_func_print_set(xlat, xlat_expr_print_binary); \
+ xlat_func_resolve_set(xlat, xlat_expr_resolve_binary); \
xlat->token = _op; \
} while (0)
if (!(xlat = xlat_func_register(NULL, STRINGIFY(_name), xlat_func_ ## _func_name, FR_TYPE_VOID))) return -1; \
xlat_func_async_instantiate_set(xlat, xlat_instantiate_ ## _func_name, xlat_ ## _func_name ## _inst_t, NULL, NULL); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
- xlat_print_set(xlat, xlat_expr_print_ ## _func_name); \
- xlat_purify_set(xlat, xlat_expr_logical_purify); \
+ xlat_func_print_set(xlat, xlat_expr_print_ ## _func_name); \
+ xlat_purify_func_set(xlat, xlat_expr_logical_purify); \
xlat->token = _op; \
} while (0)
xlat_func_args_set(xlat, regex_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
xlat_func_async_instantiate_set(xlat, xlat_instantiate_regex, xlat_regex_inst_t, NULL, NULL); \
- xlat_print_set(xlat, xlat_expr_print_regex); \
+ xlat_func_print_set(xlat, xlat_expr_print_regex); \
xlat->token = _op; \
} while (0)
if (!(xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_VOID))) return -1; \
xlat_func_args_set(xlat, unary_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
- xlat_print_set(xlat, xlat_expr_print_unary); \
+ xlat_func_print_set(xlat, xlat_expr_print_unary); \
xlat->token = _op; \
} while (0)
XLAT_REGISTER_MONO("rcode", xlat_func_rcode, xlat_func_rcode_arg);
XLAT_REGISTER_MONO("exists", xlat_func_exists, xlat_func_exists_arg);
xlat_func_async_instantiate_set(xlat, xlat_instantiate_exists, xlat_exists_inst_t, NULL, NULL);
- xlat_print_set(xlat, xlat_expr_print_exists);
+ xlat_func_print_set(xlat, xlat_expr_print_exists);
/*
* -EXPR
x->internal = flags & XLAT_FUNC_FLAG_INTERNAL;
}
+/** Set a print routine for an xlat function.
+ *
+ * @param[in] xlat to set
+ * @param[in] func for printing
+ */
+void xlat_func_print_set(xlat_t *xlat, xlat_print_t func)
+{
+ xlat->print = func;
+}
+
+/** Set a resolve routine for an xlat function.
+ *
+ * @param[in] xlat to set
+ * @param[in] func to resolve xlat.
+ */
+void xlat_func_resolve_set(xlat_t *xlat, xlat_resolve_t func)
+{
+ xlat->resolve = func;
+}
+
+/** Set a resolve routine for an xlat function.
+ *
+ * @param[in] xlat to set
+ * @param[in] func to purify xlat
+ */
+void xlat_purify_func_set(xlat_t *xlat, xlat_purify_t func)
+{
+ xlat->purify = func;
+}
+
/** Set global instantiation/detach callbacks
*
* @param[in] xlat to set instantiation callbacks for.
} xlat_func_flags_t;
DIAG_ON(attributes)
+/** Custom function to print xlat debug
+ */
+typedef 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 perform resolution of arguments
+ */
+typedef int (*xlat_resolve_t)(xlat_exp_t *xlat, void *inst, xlat_res_rules_t const *xr_rules);
+
+/** Custom function purify the result of an xlat function
+ */
+typedef int (*xlat_purify_t)(xlat_exp_t *xlat, void *inst, request_t *request);
+
xlat_t *xlat_func_register_module(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx,
char const *name, xlat_func_t func, fr_type_t return_type);
xlat_t *xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func, fr_type_t return_type) CC_HINT(nonnull(2));
void xlat_func_flags_set(xlat_t *x, xlat_func_flags_t flags) CC_HINT(nonnull);
+void xlat_func_print_set(xlat_t *xlat, xlat_print_t func);
+
+void xlat_func_resolve_set(xlat_t *xlat, xlat_resolve_t func);
+
+void xlat_purify_func_set(xlat_t *xlat, xlat_purify_t func);
+
/** Set a callback for global instantiation of xlat functions
*
* @param[in] _xlat function to set the callback for (as returned by xlat_register).
#include <freeradius-devel/unlang/xlat_ctx.h>
#include <freeradius-devel/unlang/xlat.h>
+#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/io/pair.h>
#include <freeradius-devel/util/talloc.h>
#include <freeradius-devel/build.h>
# define _CONST
#endif
-typedef 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);
-typedef int (*xlat_resolve_t)(xlat_exp_t *self, void *inst, xlat_res_rules_t const *xr_rules);
-typedef int (*xlat_purify_t)(xlat_exp_t *self, void *inst, request_t *request);
-
typedef struct xlat_s {
fr_rb_node_t node; //!< Entry in the xlat function tree.
char const *name; //!< Name of xlat function.
return fr_dlist_next(&head->dlist, node);
}
-/** Set a print routine for an xlat function.
- *
- * @param[in] xlat to set
- * @param[in] func for printing
- */
-static inline void xlat_print_set(xlat_t *xlat, xlat_print_t func)
-{
- xlat->print = func;
-}
-
-
-/** Set a resolve routine for an xlat function.
- *
- * @param[in] xlat to set
- * @param[in] func to resolve xlat.
- */
-static inline void xlat_resolve_set(xlat_t *xlat, xlat_resolve_t func)
-{
- xlat->resolve = func;
-}
-
-
-/** Set a resolve routine for an xlat function.
- *
- * @param[in] xlat to set
- * @param[in] func to purify xlat
- */
-static inline void xlat_purify_set(xlat_t *xlat, xlat_purify_t func)
-{
- xlat->purify = func;
-}
-
/*
* xlat_purify.c
*/