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

Registration API for xlat functions. More...

#include <freeradius-devel/server/module_rlm.h>
#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...
 
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...
 
int8_t xlat_func_cmp (void const *one, void const *two)
 Compare two xlat_t by the underlying function. 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)
 
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...
 
static int8_t xlat_name_cmp (void const *one, void const *two)
 Compare two xlat_t by the registered name. More...
 
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
4ce620fd72d54fafe0e94993d07a86eb0e9683ab

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 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_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 100 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 489 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 114 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 315 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 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()

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

Definition at line 79 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 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_name_cmp()

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

Compare two xlat_t by the registered name.

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

+ 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.

Variable Documentation

◆ xlat_root

fr_rb_tree_t* xlat_root = NULL
static

Definition at line 33 of file xlat_func.c.