The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Functions | Variables
xlat_func.c File Reference

Registration API for xlat functions. More...

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

Go to the source code of this file.

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, fr_value_box_safe_for_t safe_for)
 Set the escaped values for output boxes. More...
 
static int _xlat_func_talloc_free (xlat_t *xlat)
 Remove an xlat function from the function tree. 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...
 
static void _xlat_func_tree_free (void *xlat)
 Callback for the rbtree to clear out any xlats still registered. More...
 
static int xlat_arg_parser_validate (xlat_t *x, xlat_arg_parser_t const *arg, bool last)
 Verify xlat arg specifications are valid. More...
 
static int8_t xlat_cmp (void const *one, void const *two)
 
int xlat_func_args_set (xlat_t *x, 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_method)
 Register call environment of an xlat. More...
 
xlat_txlat_func_find (char const *in, ssize_t inlen)
 
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)
 
int xlat_func_mono_set (xlat_t *x, xlat_arg_parser_t const args[])
 Register the argument of an xlat. More...
 
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...
 
xlat_txlat_func_register_module (TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, char const *name, xlat_func_t func, fr_type_t return_type)
 Register an xlat function for a module. 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 (dl_module_inst_t const *inst)
 
void xlat_purify_func_set (xlat_t *xlat, xlat_purify_t func)
 Set a resolve routine for an xlat function. More...
 

Variables

static fr_rb_tree_txlat_root = NULL
 

Detailed Description

Registration API for xlat functions.

Id
2ef35b08dee54fc50b562f3d6928a107818b3c1b

Definition in file xlat_func.c.

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 473 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 456 of file xlat_func.c.

◆ _xlat_func_talloc_free()

static int _xlat_func_talloc_free ( xlat_t xlat)
static

Remove an xlat function from the function tree.

Parameters
[in]xlatto free.
Returns
0

Definition at line 77 of file xlat_func.c.

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

◆ _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 501 of file xlat_func.c.

+ Here is the call graph for this function:

◆ _xlat_func_tree_free()

static void _xlat_func_tree_free ( void *  xlat)
static

Callback for the rbtree to clear out any xlats still registered.

Definition at line 91 of file xlat_func.c.

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

◆ xlat_arg_parser_validate()

static int xlat_arg_parser_validate ( xlat_t x,
xlat_arg_parser_t const *  arg,
bool  last 
)
inlinestatic

Verify xlat arg specifications are valid.

Parameters
[in]xwe're setting arguments for.
[in]argspecification to validate.
[in]lastIs this the last argument in the list.

Definition at line 310 of file xlat_func.c.

+ Here is the caller graph for this function:

◆ xlat_cmp()

static int8_t xlat_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 37 of file xlat_func.c.

+ Here is the caller 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 360 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 405 of file xlat_func.c.

+ Here is the caller graph for this function:

◆ xlat_func_find()

xlat_t* xlat_func_find ( char const *  in,
ssize_t  inlen 
)

Definition at line 56 of file xlat_func.c.

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

◆ xlat_func_find_module()

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

Definition at line 159 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 415 of file xlat_func.c.

+ Here is the caller graph for this function:

◆ xlat_func_free()

void xlat_func_free ( void  )

Definition at line 578 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 562 of file xlat_func.c.

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

◆ xlat_func_mono_set()

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

Register the argument of an xlat.

For xlats that take all their input as a single argument

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

Definition at line 392 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 426 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 195 of file xlat_func.c.

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

◆ xlat_func_register_module()

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 
)

Register an xlat function for a module.

Parameters
[in]ctxUsed to automate deregistration of the xlat function.
[in]mctxInstantiation context from the module. Will be duplicated and passed to future xlat calls.
[in]nameof the xlat. Must be NULL, for "self-named" xlats. e.g. cache, sql, delay, etc.
[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 274 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 436 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 531 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 ( dl_module_inst_t const *  inst)

Definition at line 545 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 446 of file xlat_func.c.

Variable Documentation

◆ xlat_root

fr_rb_tree_t* xlat_root = NULL
static

Definition at line 32 of file xlat_func.c.