The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Typedefs | Enumerations | Functions
xlat_func.h File Reference

Registration API for xlat functions. More...

#include <freeradius-devel/unlang/xlat.h>
+ Include dependency graph for xlat_func.h:

Go to the source code of this file.

Macros

#define xlat_func_instantiate_set(_xlat, _instantiate, _inst_struct, _detach, _uctx)    _xlat_func_instantiate_set(_xlat, _instantiate, #_inst_struct, sizeof(_inst_struct), _detach, _uctx)
 Set a callback for global instantiation of xlat functions. More...
 
#define xlat_func_safe_for_set(_xlat, _escaped)   _xlat_func_safe_for_set(_xlat, (uintptr_t) (_escaped))
 Set the escaped values for output boxes. More...
 
#define xlat_func_thread_instantiate_set(_xlat, _instantiate, _inst_struct, _detach, _uctx)    _xlat_func_thread_instantiate_set(_xlat, _instantiate, #_inst_struct, sizeof(_inst_struct), _detach, _uctx)
 Set a callback for thread-specific instantiation of xlat functions. More...
 

Typedefs

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 print xlat debug. More...
 
typedef int(* xlat_purify_t) (xlat_exp_t *xlat, void *inst, request_t *request)
 Custom function purify the result of an xlat function. More...
 
typedef int(* xlat_resolve_t) (xlat_exp_t *xlat, void *inst, xlat_res_rules_t const *xr_rules)
 Custom function to perform resolution of arguments. More...
 

Enumerations

enum  xlat_func_flags_t {
  XLAT_FUNC_FLAG_NONE = 0x00 ,
  XLAT_FUNC_FLAG_PURE = 0x01 ,
  XLAT_FUNC_FLAG_INTERNAL = 0x02
}
 

Functions

void _xlat_func_instantiate_set (xlat_t const *xlat, xlat_instantiate_t instantiate, char const *inst_type, size_t inst_size, xlat_detach_t detach, void *uctx)
 Set global instantiation/detach callbacks. More...
 
void _xlat_func_safe_for_set (xlat_t *xlat, uintptr_t escaped)
 Set the escaped values for output boxes. More...
 
void _xlat_func_thread_instantiate_set (xlat_t const *xlat, xlat_thread_instantiate_t thread_instantiate, char const *thread_inst_type, size_t thread_inst_size, xlat_thread_detach_t thread_detach, void *uctx)
 Register an async xlat. More...
 
int xlat_func_args_set (xlat_t *xlat, xlat_arg_parser_t const args[])
 Register the arguments of an xlat. More...
 
void xlat_func_call_env_set (xlat_t *x, call_env_method_t const *env)
 Register call environment of an xlat. More...
 
int8_t xlat_func_cmp (void const *one, void const *two)
 Compare two xlat_t by the underlying function. More...
 
xlat_txlat_func_find_module (module_inst_ctx_t const *mctx, char const *name)
 
void xlat_func_flags_set (xlat_t *x, xlat_func_flags_t flags)
 Specify flags that alter the xlat's behaviour. More...
 
void xlat_func_free (void)
 
int xlat_func_init (void)
 
void xlat_func_print_set (xlat_t *xlat, xlat_print_t func)
 Set a print routine for an xlat function. More...
 
xlat_txlat_func_register (TALLOC_CTX *ctx, char const *name, xlat_func_t func, fr_type_t return_type))
 Register an xlat function. More...
 
void xlat_func_resolve_set (xlat_t *xlat, xlat_resolve_t func)
 Set a resolve routine for an xlat function. More...
 
void xlat_func_unregister (char const *name)
 Unregister an xlat function. More...
 
void xlat_func_unregister_module (module_instance_t const *inst)
 
void xlat_mctx_set (xlat_t *x, module_inst_ctx_t const *mctx)
 Associate a module calling ctx with the xlat. More...
 
void xlat_purify_func_set (xlat_t *xlat, xlat_purify_t func)
 Set a resolve routine for an xlat function. More...
 

Detailed Description

Registration API for xlat functions.

Id
6d64d87b17c118971ad984eab390f5a557882302

Definition in file xlat_func.h.

Macro Definition Documentation

◆ xlat_func_instantiate_set

#define xlat_func_instantiate_set (   _xlat,
  _instantiate,
  _inst_struct,
  _detach,
  _uctx 
)     _xlat_func_instantiate_set(_xlat, _instantiate, #_inst_struct, sizeof(_inst_struct), _detach, _uctx)

Set a callback for global instantiation of xlat functions.

Parameters
[in]_xlatfunction to set the callback for (as returned by xlat_register).
[in]_instantiateA instantiation callback.
[in]_inst_structThe instance struct to pre-allocate.
[in]_detachA destructor callback.
[in]_uctxto pass to _instantiate and _detach callbacks.

Definition at line 93 of file xlat_func.h.

◆ xlat_func_safe_for_set

#define xlat_func_safe_for_set (   _xlat,
  _escaped 
)    _xlat_func_safe_for_set(_xlat, (uintptr_t) (_escaped))

Set the escaped values for output boxes.

Any boxes output by the xlat function will have their values marked as safe for something.

Parameters
[in]_xlatfunction to set the escaped value for (as returned by xlat_register).
[in]_escapedescaped value to write to output boxes.

Definition at line 82 of file xlat_func.h.

◆ xlat_func_thread_instantiate_set

#define xlat_func_thread_instantiate_set (   _xlat,
  _instantiate,
  _inst_struct,
  _detach,
  _uctx 
)     _xlat_func_thread_instantiate_set(_xlat, _instantiate, #_inst_struct, sizeof(_inst_struct), _detach, _uctx)

Set a callback for thread-specific instantiation of xlat functions.

Parameters
[in]_xlatfunction to set the callback for (as returned by xlat_register).
[in]_instantiateA instantiation callback.
[in]_inst_structThe instance struct to pre-allocate.
[in]_detachA destructor callback.
[in]_uctxto pass to _instantiate and _detach callbacks.

Definition at line 108 of file xlat_func.h.

Typedef Documentation

◆ xlat_print_t

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 print xlat debug.

Definition at line 45 of file xlat_func.h.

◆ xlat_purify_t

typedef int(* xlat_purify_t) (xlat_exp_t *xlat, void *inst, request_t *request)

Custom function purify the result of an xlat function.

Definition at line 53 of file xlat_func.h.

◆ xlat_resolve_t

typedef 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 at line 49 of file xlat_func.h.

Enumeration Type Documentation

◆ xlat_func_flags_t

Enumerator
XLAT_FUNC_FLAG_NONE 
XLAT_FUNC_FLAG_PURE 
XLAT_FUNC_FLAG_INTERNAL 

Definition at line 36 of file xlat_func.h.

Function Documentation

◆ _xlat_func_instantiate_set()

void _xlat_func_instantiate_set ( xlat_t const *  xlat,
xlat_instantiate_t  instantiate,
char const *  inst_type,
size_t  inst_size,
xlat_detach_t  detach,
void *  uctx 
)

Set global instantiation/detach callbacks.

Parameters
[in]xlatto set instantiation callbacks for.
[in]instantiateInstantiation function. Called whenever a xlat is compiled.
[in]inst_typeName of the instance structure.
[in]inst_sizeThe size of the instance struct. Pre-allocated for use by the instantiate function. If 0, no memory will be allocated.
[in]detachCalled when an xlat_exp_t is freed.
[in]uctxPassed to the instantiation function.

Definition at line 461 of file xlat_func.c.

+ Here is the call graph for this function:

◆ _xlat_func_safe_for_set()

void _xlat_func_safe_for_set ( xlat_t xlat,
fr_value_box_safe_for_t  safe_for 
)

Set the escaped values for output boxes.

Parameters
[in]xlatfunction to set the escaped value for (as returned by xlat_register).
[in]safe_forescaped value to write to output boxes.

Definition at line 444 of file xlat_func.c.

◆ _xlat_func_thread_instantiate_set()

void _xlat_func_thread_instantiate_set ( xlat_t const *  xlat,
xlat_thread_instantiate_t  thread_instantiate,
char const *  thread_inst_type,
size_t  thread_inst_size,
xlat_thread_detach_t  thread_detach,
void *  uctx 
)

Register an async xlat.

All functions registered must be !pure

Parameters
[in]xlatto set instantiation callbacks for.
[in]thread_instantiateInstantiation function. Called for every compiled xlat every time a thread is started.
[in]thread_inst_typeName of the thread instance structure.
[in]thread_inst_sizeThe size of the thread instance struct. Pre-allocated for use by the instantiate function. If 0, no memory will be allocated.
[in]thread_detachCalled when the thread is freed.
[in]uctxPassed to the thread instantiate function.

Definition at line 489 of file xlat_func.c.

+ Here is the call graph for this function:

◆ xlat_func_args_set()

int xlat_func_args_set ( xlat_t x,
xlat_arg_parser_t const  args[] 
)

Register the arguments of an xlat.

For xlats that take multiple arguments

Parameters
[in,out]xto have it's arguments registered
[in]argsto be registered
Returns
  • 0 on success.
  • < 0 on failure.

Definition at line 365 of file xlat_func.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_func_call_env_set()

void xlat_func_call_env_set ( xlat_t x,
call_env_method_t const *  env_method 
)

Register call environment of an xlat.

Parameters
[in,out]xto have it's module method env registered.
[in]env_methodto be registered.

Definition at line 392 of file xlat_func.c.

+ Here is the caller graph for this function:

◆ xlat_func_cmp()

int8_t xlat_func_cmp ( void const *  one,
void const *  two 
)

Compare two xlat_t by the underlying function.

Parameters
[in]oneFirst xlat_t to compare.
[in]twoSecond xlat_t to compare.
Returns
  • -1 if one < two
  • 0 if one == two
  • 1 if one > two

Definition at line 69 of file xlat_func.c.

◆ xlat_func_find_module()

xlat_t* xlat_func_find_module ( module_inst_ctx_t const *  mctx,
char const *  name 
)

Definition at line 182 of file xlat_func.c.

+ Here is the call graph for this function:

◆ xlat_func_flags_set()

void xlat_func_flags_set ( xlat_t x,
xlat_func_flags_t  flags 
)

Specify flags that alter the xlat's behaviour.

Parameters
[in]xxlat to set flags for.
[in]flagsto set.

Definition at line 402 of file xlat_func.c.

+ Here is the caller graph for this function:

◆ xlat_func_free()

void xlat_func_free ( void  )

Definition at line 566 of file xlat_func.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_func_init()

int xlat_func_init ( void  )

Definition at line 550 of file xlat_func.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_func_print_set()

void xlat_func_print_set ( xlat_t xlat,
xlat_print_t  func 
)

Set a print routine for an xlat function.

Parameters
[in]xlatto set
[in]funcfor printing

Definition at line 414 of file xlat_func.c.

+ Here is the caller graph for this function:

◆ xlat_func_register()

xlat_t* xlat_func_register ( TALLOC_CTX *  ctx,
char const *  name,
xlat_func_t  func,
fr_type_t  return_type 
)

Register an xlat function.

Parameters
[in]ctxUsed to automate deregistration of the xlat function.
[in]nameof the xlat.
[in]functo register.
[in]return_typewhat type of output the xlat function will produce.
Returns
  • A handle for the newly registered xlat function on success.
  • NULL on failure.

Definition at line 218 of file xlat_func.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_func_resolve_set()

void xlat_func_resolve_set ( xlat_t xlat,
xlat_resolve_t  func 
)

Set a resolve routine for an xlat function.

Parameters
[in]xlatto set
[in]functo resolve xlat.

Definition at line 424 of file xlat_func.c.

◆ xlat_func_unregister()

void xlat_func_unregister ( char const *  name)

Unregister an xlat function.

We can only have one function to call per name, so the passing of "func" here is extraneous.

Parameters
[in]namexlat to unregister.

Definition at line 519 of file xlat_func.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_func_unregister_module()

void xlat_func_unregister_module ( module_instance_t const *  inst)

Definition at line 533 of file xlat_func.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_mctx_set()

void xlat_mctx_set ( xlat_t x,
module_inst_ctx_t const *  mctx 
)

Associate a module calling ctx with the xlat.

Note
Intended to be called from the module_rlm
Parameters
[in]xto set the mctx for.
[in]mctxIs duplicated and about to the lifetime of the xlat.

Definition at line 299 of file xlat_func.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xlat_purify_func_set()

void xlat_purify_func_set ( xlat_t xlat,
xlat_purify_t  func 
)

Set a resolve routine for an xlat function.

Parameters
[in]xlatto set
[in]functo purify xlat

Definition at line 434 of file xlat_func.c.