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

API to create and manipulate internal format configurations. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/time.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/token.h>
#include <freeradius-devel/util/log.h>
+ Include dependency graph for cf_util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define cf_canonicalize_error(_ci, _slen, _msg, _str)   _cf_canonicalize_error(CF_TO_ITEM(_ci), _slen, _msg, _str)
 
#define cf_data_add(_cf, _data, _name, _free)   _cf_data_add(CF_TO_ITEM(_cf), (void const *) _data, _name, _free, __FILE__, __LINE__)
 
#define cf_data_add_static(_cf, _data, _type, _name)   _cf_data_add_static(CF_TO_ITEM(_cf), _data, #_type, _name, __FILE__, __LINE__)
 
#define cf_data_find(_cf, _type, _name)   _cf_data_find(CF_TO_ITEM(_cf), #_type, _name)
 
#define cf_data_find_in_parent(_cf, _type, _name)   _cf_data_find_in_parent(CF_TO_ITEM(_cf), #_type, _name)
 
#define cf_data_find_next(_cf, _prev, _type, _name)   _cf_data_find_next(CF_TO_ITEM(_cf), CF_TO_ITEM(_prev), #_type, _name)
 
#define cf_data_remove(_cf, _type, _name)   _cf_data_remove(CF_TO_ITEM(_cf), cf_data_find(_cf, _type, _name))
 Remove an item from a parent by type and name. More...
 
#define cf_data_remove_by_data(_cf, _cd)   _cf_data_remove(CF_TO_ITEM(_cf), _cd)
 Remove an item from a parent. More...
 
#define cf_data_walk(_cf, _type, _cb, _ctx)   _cf_data_walk(CF_TO_ITEM(_cf), #_type, _cb, _ctx)
 
#define cf_debug(_cf)   _cf_debug(CF_TO_ITEM(_cf))
 
#define cf_filename(_cf)   _cf_filename(CF_TO_ITEM(_cf))
 
#define cf_filename_set(_ci, _filename)   _cf_filename_set(CF_TO_ITEM(_ci), _filename)
 
#define CF_IDENT_ANY   ((void *) (-1))
 
#define cf_item_add(_parent, _child)   _cf_item_add(CF_TO_ITEM(_parent), CF_TO_ITEM(_child))
 
#define cf_item_insert_after(_parent, _prev, _child)   _cf_item_insert_after(CF_TO_ITEM(_parent), CF_TO_ITEM(_prev), CF_TO_ITEM(_child))
 
#define cf_item_next(_ci, _prev)   _cf_item_next(CF_TO_ITEM(_ci), _prev)
 
#define cf_item_remove(_parent, _child)   _cf_item_remove(CF_TO_ITEM(_parent), CF_TO_ITEM(_child))
 
#define cf_lineno(_cf)   _cf_lineno(CF_TO_ITEM(_cf))
 
#define cf_lineno_set(_ci, _lineno)   _cf_lineno_set(CF_TO_ITEM(_ci), _lineno)
 
#define cf_log_debug(_cf, _fmt, ...)   _cf_log(L_DBG, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 
#define cf_log_debug_by_child(_parent, _child, _fmt, ...)   _cf_log_by_child(L_DBG, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 Log a debug message against a specified child. More...
 
#define cf_log_debug_prefix(_cf, _fmt, ...)   _cf_log_with_filename(L_DBG, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 
#define cf_log_err(_cf, _fmt, ...)   _cf_log(L_ERR, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 
#define cf_log_err_by_child(_parent, _child, _fmt, ...)   _cf_log_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 Log an error message against a specified child. More...
 
#define cf_log_info(_cf, _fmt, ...)   _cf_log(L_INFO, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 
#define cf_log_info_by_child(_parent, _child, _fmt, ...)   _cf_log_by_child(L_INFO, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 Log an info message against a specified child. More...
 
#define cf_log_perr(_cf, _fmt, ...)   _cf_log_perr(L_ERR, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
 
#define cf_log_perr_by_child(_parent, _child, _f_rules, _fmt, ...)   _cf_log_perr_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _f_rules, _fmt, ## __VA_ARGS__)
 Log an error message against a specified child, draining the thread local error stack. More...
 
#define cf_log_pwarn(_cf, _fmt, ...)   _cf_log_perr(L_WARN, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
 
#define cf_log_warn(_cf, _fmt, ...)   _cf_log(L_WARN, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 
#define cf_log_warn_by_child(_parent, _child, _fmt, ...)   _cf_log_by_child(L_WARN, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 Log a warning message against a specified child. More...
 
#define cf_parent(_cf)   _cf_parent(CF_TO_ITEM(_cf))
 
#define cf_root(_cf)   _cf_root(CF_TO_ITEM(_cf))
 
#define cf_section_alloc(_ctx, _parent, _name1, _name2)    _cf_section_alloc(_ctx, _parent, _name1, _name2, __FILE__, __LINE__)
 
#define cf_section_free_children(_x)   cf_item_free_children(cf_section_to_item(_x))
 
#define CF_TO_ITEM(_cf)
 Auto cast from the input type to CONF_ITEM (which is the base type) More...
 
#define FR_TIMESPEC_TO_MS(_x)   (((_x)->tv_usec / 1000000) + ((_x)->tv_sec * (uint64_t)1000))
 
#define FR_TIMEVAL_TO_MS(_x)   (((_x)->tv_usec / 1000) + ((_x)->tv_sec * (uint64_t)1000))
 

Typedefs

typedef int(* cf_walker_t) (void *data, void *ctx)
 
typedef struct cf_data CONF_DATA
 CONF_ITEM used to associate arbitrary data with a CONF_PAIR or CONF_SECTION. More...
 
typedef struct cf_item CONF_ITEM
 Generic configuration element, extended to become a CONF_PAIR, a CONF_SECTION or CONF_DATA. More...
 
typedef struct cf_pair CONF_PAIR
 CONF_ITEM with an attribute, an operator and a value. More...
 
typedef struct cf_section CONF_SECTION
 CONF_ITEM used to group multiple CONF_PAIR and CONF_SECTION, together. More...
 

Functions

void _cf_canonicalize_error (CONF_ITEM *ci, ssize_t slen, char const *msg, char const *str)
 
CONF_DATA const * _cf_data_add (CONF_ITEM *ci, void const *data, char const *name, bool free, char const *filename, int lineno)
 Add talloced user data to a config section. More...
 
CONF_DATA const * _cf_data_add_static (CONF_ITEM *ci, void const *data, char const *type, char const *name, char const *filename, int lineno)
 Add non-talloced user data to a config section. More...
 
CONF_DATA const * _cf_data_find (CONF_ITEM const *ci, char const *type, char const *name)
 Find user data in a config section. More...
 
CONF_DATA_cf_data_find_in_parent (CONF_ITEM const *ci, char const *type, char const *name)
 Find matching data in the specified section or one of its parents. More...
 
CONF_DATA const * _cf_data_find_next (CONF_ITEM const *ci, CONF_ITEM const *prev, char const *type, char const *name)
 Return the next item of user data. More...
 
void * _cf_data_remove (CONF_ITEM *ci, CONF_DATA const *_cd)
 Remove data from a configuration section. More...
 
int _cf_data_walk (CONF_ITEM *ci, char const *type, cf_walker_t cb, void *ctx)
 Walk over a specific type of CONF_DATA. More...
 
void _cf_debug (CONF_ITEM const *ci)
 Print out debugging information about a CONFIG_ITEM. More...
 
char const * _cf_filename (CONF_ITEM const *ci)
 Return the filename the CONF_ITEM was parsed in. More...
 
void _cf_filename_set (CONF_ITEM *cs, char const *filename)
 Set the filename of a CONF_ITEM. More...
 
void _cf_item_add (CONF_ITEM *parent, CONF_ITEM *child)
 Add a child. More...
 
void _cf_item_insert_after (CONF_ITEM *parent, CONF_ITEM *prev, CONF_ITEM *child)
 Insert a child after a given one. More...
 
CONF_ITEM_cf_item_next (CONF_ITEM const *ci, CONF_ITEM const *prev)
 Return the next child of cs. More...
 
CONF_ITEM_cf_item_remove (CONF_ITEM *parent, CONF_ITEM *child)
 Remove item from parent and fixup trees. More...
 
int _cf_lineno (CONF_ITEM const *ci)
 Return the lineno the CONF_ITEM was parsed at. More...
 
void _cf_lineno_set (CONF_ITEM *cs, int lineno)
 Set the line number of a CONF_ITEM. More...
 
void _cf_log (fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt,...))
 Log an error message relating to a CONF_ITEM. More...
 
void _cf_log_by_child (fr_log_type_t type, CONF_SECTION const *parent, char const *child, char const *file, int line, char const *fmt,...))
 Log an error message in the context of a child pair of the specified parent. More...
 
void _cf_log_perr (fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, fr_log_perror_format_t const *f_rules, char const *fmt,...))
 Log an error message relating to a CONF_ITEM. More...
 
void _cf_log_perr_by_child (fr_log_type_t type, CONF_SECTION const *parent, char const *child, char const *file, int line, fr_log_perror_format_t const *f_rules, char const *fmt,...))
 Log an error message in the context of a child pair of the specified parent. More...
 
void _cf_log_with_filename (fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt,...))
 Log a debug message relating to a CONF_ITEM. More...
 
CONF_ITEM_cf_parent (CONF_ITEM const *ci)
 Return the parent of a CONF_ITEM. More...
 
CONF_SECTION_cf_root (CONF_ITEM const *ci)
 Return the top level CONF_SECTION holding all other CONF_ITEM. More...
 
CONF_SECTION_cf_section_alloc (TALLOC_CTX *ctx, CONF_SECTION *parent, char const *name1, char const *name2, char const *filename, int lineno)
 Allocate a CONF_SECTION. More...
 
void _cf_vlog (fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, char const *fmt, va_list ap))
 Log an error message relating to a CONF_ITEM. More...
 
void _cf_vlog_perr (fr_log_type_t type, CONF_ITEM const *ci, char const *file, int line, fr_log_perror_format_t const *f_rules, char const *fmt, va_list ap))
 Log an error message relating to a CONF_ITEM. More...
 
CONF_ITEMcf_data_to_item (CONF_DATA const *cs)
 Cast CONF_DATA to a CONF_ITEM. More...
 
void * cf_data_value (CONF_DATA const *cd)
 Return the user assigned value of CONF_DATA. More...
 
void cf_item_free_children (CONF_ITEM *ci)
 
bool cf_item_is_data (CONF_ITEM const *ci)
 Determine if CONF_ITEM is CONF_DATA. More...
 
bool cf_item_is_pair (CONF_ITEM const *ci)
 Determine if CONF_ITEM is a CONF_PAIR. More...
 
bool cf_item_is_section (CONF_ITEM const *ci)
 Determine if CONF_ITEM is a CONF_SECTION. More...
 
CONF_DATAcf_item_to_data (CONF_ITEM const *ci)
 Cast CONF_ITEM to CONF_DATA performing a type check. More...
 
CONF_PAIRcf_item_to_pair (CONF_ITEM const *ci)
 Cast a CONF_ITEM to a CONF_PAIR. More...
 
CONF_SECTIONcf_item_to_section (CONF_ITEM const *ci)
 Cast a CONF_ITEM to a CONF_SECTION. More...
 
CONF_PAIRcf_pair_alloc (CONF_SECTION *parent, char const *attr, char const *value, fr_token_t op, fr_token_t lhs_type, fr_token_t rhs_type)
 Allocate a CONF_PAIR. More...
 
char const * cf_pair_attr (CONF_PAIR const *pair)
 Return the attr of a CONF_PAIR. More...
 
fr_token_t cf_pair_attr_quote (CONF_PAIR const *pair)
 Return the value (lhs) quoting of a pair. More...
 
unsigned int cf_pair_count (CONF_SECTION const *cs, char const *attr)
 Count the number of times an attribute occurs in a parent section. More...
 
unsigned int cf_pair_count_descendents (CONF_SECTION const *cs)
 Count the number of conf pairs beneath a section. More...
 
CONF_PAIRcf_pair_dup (CONF_SECTION *parent, CONF_PAIR *cp)
 Duplicate a CONF_PAIR. More...
 
CONF_PAIRcf_pair_find (CONF_SECTION const *cs, char const *name)
 Search for a CONF_PAIR with a specific name. More...
 
CONF_PAIRcf_pair_find_in_parent (CONF_SECTION const *cs, char const *attr)
 Find a pair with a name matching attr in the specified section or one of its parents. More...
 
CONF_PAIRcf_pair_find_next (CONF_SECTION const *cs, CONF_PAIR const *prev, char const *name)
 Find a pair with a name matching attr, after specified pair. More...
 
int cf_pair_in_table (int32_t *out, fr_table_num_sorted_t const *table, size_t table_len, CONF_PAIR *cp)
 Check to see if the CONF_PAIR value is present in the specified table. More...
 
bool cf_pair_is_parsed (CONF_PAIR *cp)
 Return whether a pair has already been parsed. More...
 
void cf_pair_mark_parsed (CONF_PAIR *cp)
 Mark a pair as parsed. More...
 
CONF_PAIRcf_pair_next (CONF_SECTION const *cs, CONF_PAIR const *prev)
 Return the next child that's a CONF_PAIR. More...
 
fr_token_t cf_pair_operator (CONF_PAIR const *pair)
 Return the operator of a pair. More...
 
int cf_pair_replace (CONF_SECTION *cs, CONF_PAIR *cp, char const *value)
 Replace pair in a given section with a new pair, of the given value. More...
 
CONF_ITEMcf_pair_to_item (CONF_PAIR const *cp)
 Cast a CONF_PAIR to a CONF_ITEM. More...
 
char const * cf_pair_value (CONF_PAIR const *pair)
 Return the value of a CONF_PAIR. More...
 
fr_token_t cf_pair_value_quote (CONF_PAIR const *pair)
 Return the value (rhs) quoting of a pair. More...
 
fr_slen_t cf_pair_values_concat (fr_sbuff_t *sbuff, CONF_SECTION const *cs, char const *attr, char const *sep)
 Concatenate the values of any pairs with name attr. More...
 
void cf_section_add_name2_quote (CONF_SECTION *cs, fr_token_t token)
 Set the quoting of the name2 identifier. More...
 
char const * cf_section_argv (CONF_SECTION const *cs, int argc)
 Return variadic argument at the specified index. More...
 
fr_token_t cf_section_argv_quote (CONF_SECTION const *cs, int argc)
 Return the quoting for one of the variadic arguments. More...
 
CONF_SECTIONcf_section_dup (TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION const *cs, char const *name1, char const *name2, bool copy_meta)
 Duplicate a configuration section. More...
 
CONF_SECTIONcf_section_find (CONF_SECTION const *cs, char const *name1, char const *name2)
 Find a CONF_SECTION with name1 and optionally name2. More...
 
CONF_SECTIONcf_section_find_in_parent (CONF_SECTION const *cs, char const *name1, char const *name2)
 Find a section in the lineage of a CONF_SECTION which matches a specific name1 and optionally name2. More...
 
CONF_SECTIONcf_section_find_next (CONF_SECTION const *cs, CONF_SECTION const *subcs, char const *name1, char const *name2)
 Return the next matching section. More...
 
CONF_SECTIONcf_section_find_parent (CONF_SECTION const *cs, char const *name1, char const *name2)
 Find a parent CONF_SECTION with name1 and optionally name2. More...
 
char const * cf_section_name (CONF_SECTION const *cs)
 Return name2 if set, else name1. More...
 
char const * cf_section_name1 (CONF_SECTION const *cs)
 Return the second identifier of a CONF_SECTION. More...
 
char const * cf_section_name2 (CONF_SECTION const *cs)
 Return the second identifier of a CONF_SECTION. More...
 
fr_token_t cf_section_name2_quote (CONF_SECTION const *cs)
 Return the quoting of the name2 identifier. More...
 
int8_t cf_section_name_cmp (CONF_SECTION const *cs, char const *name1, char const *name2)
 Check if a given section matches the specified name1/name2 identifiers. More...
 
CONF_SECTIONcf_section_next (CONF_SECTION const *cs, CONF_SECTION const *prev)
 Return the next child that's a CONF_SECTION. More...
 
CONF_ITEMcf_section_to_item (CONF_SECTION const *cs)
 Cast a CONF_SECTION to a CONF_ITEM. More...
 
char const * cf_section_value_find (CONF_SECTION const *, char const *attr)
 Find a pair in a CONF_SECTION. More...
 

Detailed Description

API to create and manipulate internal format configurations.

Id
6a31fb06dc2140d299017d2591d00b54f967d18d

Definition in file cf_util.h.

Macro Definition Documentation

◆ cf_canonicalize_error

#define cf_canonicalize_error (   _ci,
  _slen,
  _msg,
  _str 
)    _cf_canonicalize_error(CF_TO_ITEM(_ci), _slen, _msg, _str)

Definition at line 340 of file cf_util.h.

◆ cf_data_add

#define cf_data_add (   _cf,
  _data,
  _name,
  _free 
)    _cf_data_add(CF_TO_ITEM(_cf), (void const *) _data, _name, _free, __FILE__, __LINE__)

Definition at line 231 of file cf_util.h.

◆ cf_data_add_static

#define cf_data_add_static (   _cf,
  _data,
  _type,
  _name 
)    _cf_data_add_static(CF_TO_ITEM(_cf), _data, #_type, _name, __FILE__, __LINE__)

Definition at line 234 of file cf_util.h.

◆ cf_data_find

#define cf_data_find (   _cf,
  _type,
  _name 
)    _cf_data_find(CF_TO_ITEM(_cf), #_type, _name)

Definition at line 220 of file cf_util.h.

◆ cf_data_find_in_parent

#define cf_data_find_in_parent (   _cf,
  _type,
  _name 
)    _cf_data_find_in_parent(CF_TO_ITEM(_cf), #_type, _name)

Definition at line 226 of file cf_util.h.

◆ cf_data_find_next

#define cf_data_find_next (   _cf,
  _prev,
  _type,
  _name 
)    _cf_data_find_next(CF_TO_ITEM(_cf), CF_TO_ITEM(_prev), #_type, _name)

Definition at line 223 of file cf_util.h.

◆ cf_data_remove

#define cf_data_remove (   _cf,
  _type,
  _name 
)    _cf_data_remove(CF_TO_ITEM(_cf), cf_data_find(_cf, _type, _name))

Remove an item from a parent by type and name.

Parameters
[in]_cfconf section or pair to remove data from.
[in]_typeof data to remove.
[in]_nameof data to remove.

Definition at line 243 of file cf_util.h.

◆ cf_data_remove_by_data

#define cf_data_remove_by_data (   _cf,
  _cd 
)    _cf_data_remove(CF_TO_ITEM(_cf), _cd)

Remove an item from a parent.

Parameters
[in]_cfconf section or pair to remove data from.
[in]_cdconf data to remove.

Definition at line 250 of file cf_util.h.

◆ cf_data_walk

#define cf_data_walk (   _cf,
  _type,
  _cb,
  _ctx 
)    _cf_data_walk(CF_TO_ITEM(_cf), #_type, _cb, _ctx)

Definition at line 253 of file cf_util.h.

◆ cf_debug

#define cf_debug (   _cf)    _cf_debug(CF_TO_ITEM(_cf))

Definition at line 337 of file cf_util.h.

◆ cf_filename

#define cf_filename (   _cf)    _cf_filename(CF_TO_ITEM(_cf))

Definition at line 104 of file cf_util.h.

◆ cf_filename_set

#define cf_filename_set (   _ci,
  _filename 
)    _cf_filename_set(CF_TO_ITEM(_ci), _filename)

Definition at line 125 of file cf_util.h.

◆ CF_IDENT_ANY

#define CF_IDENT_ANY   ((void *) (-1))

Definition at line 78 of file cf_util.h.

◆ cf_item_add

#define cf_item_add (   _parent,
  _child 
)    _cf_item_add(CF_TO_ITEM(_parent), CF_TO_ITEM(_child))

Definition at line 83 of file cf_util.h.

◆ cf_item_insert_after

#define cf_item_insert_after (   _parent,
  _prev,
  _child 
)    _cf_item_insert_after(CF_TO_ITEM(_parent), CF_TO_ITEM(_prev), CF_TO_ITEM(_child))

Definition at line 86 of file cf_util.h.

◆ cf_item_next

#define cf_item_next (   _ci,
  _prev 
)    _cf_item_next(CF_TO_ITEM(_ci), _prev)

Definition at line 92 of file cf_util.h.

◆ cf_item_remove

#define cf_item_remove (   _parent,
  _child 
)    _cf_item_remove(CF_TO_ITEM(_parent), CF_TO_ITEM(_child))

Definition at line 89 of file cf_util.h.

◆ cf_lineno

#define cf_lineno (   _cf)    _cf_lineno(CF_TO_ITEM(_cf))

Definition at line 101 of file cf_util.h.

◆ cf_lineno_set

#define cf_lineno_set (   _ci,
  _lineno 
)    _cf_lineno_set(CF_TO_ITEM(_ci), _lineno)

Definition at line 128 of file cf_util.h.

◆ cf_log_debug

#define cf_log_debug (   _cf,
  _fmt,
  ... 
)    _cf_log(L_DBG, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Definition at line 268 of file cf_util.h.

◆ cf_log_debug_by_child

#define cf_log_debug_by_child (   _parent,
  _child,
  _fmt,
  ... 
)    _cf_log_by_child(L_DBG, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Log a debug message against a specified child.

Parameters
[in]_parentCONF_SECTION.
[in]_childstring identifier.
[in]_fmtof message.
[in]...arguments.

Definition at line 329 of file cf_util.h.

◆ cf_log_debug_prefix

#define cf_log_debug_prefix (   _cf,
  _fmt,
  ... 
)    _cf_log_with_filename(L_DBG, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Definition at line 282 of file cf_util.h.

◆ cf_log_err

#define cf_log_err (   _cf,
  _fmt,
  ... 
)    _cf_log(L_ERR, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Definition at line 265 of file cf_util.h.

◆ cf_log_err_by_child

#define cf_log_err_by_child (   _parent,
  _child,
  _fmt,
  ... 
)    _cf_log_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Log an error message against a specified child.

Parameters
[in]_parentCONF_SECTION.
[in]_childstring identifier.
[in]_fmtof message.
[in]...arguments.

Definition at line 292 of file cf_util.h.

◆ cf_log_info

#define cf_log_info (   _cf,
  _fmt,
  ... 
)    _cf_log(L_INFO, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Definition at line 267 of file cf_util.h.

◆ cf_log_info_by_child

#define cf_log_info_by_child (   _parent,
  _child,
  _fmt,
  ... 
)    _cf_log_by_child(L_INFO, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Log an info message against a specified child.

Parameters
[in]_parentCONF_SECTION.
[in]_childstring identifier.
[in]_fmtof message.
[in]...arguments.

Definition at line 320 of file cf_util.h.

◆ cf_log_perr

#define cf_log_perr (   _cf,
  _fmt,
  ... 
)    _cf_log_perr(L_ERR, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)

Definition at line 272 of file cf_util.h.

◆ cf_log_perr_by_child

#define cf_log_perr_by_child (   _parent,
  _child,
  _f_rules,
  _fmt,
  ... 
)    _cf_log_perr_by_child(L_ERR, _parent, _child, __FILE__, __LINE__, _f_rules, _fmt, ## __VA_ARGS__)

Log an error message against a specified child, draining the thread local error stack.

Parameters
[in]_parentCONF_SECTION.
[in]_childstring identifier.
[in]_f_rulesLine prefixes.
[in]_fmtof message.
[in]...arguments.

Definition at line 302 of file cf_util.h.

◆ cf_log_pwarn

#define cf_log_pwarn (   _cf,
  _fmt,
  ... 
)    _cf_log_perr(L_WARN, CF_TO_ITEM(_cf), __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)

Definition at line 273 of file cf_util.h.

◆ cf_log_warn

#define cf_log_warn (   _cf,
  _fmt,
  ... 
)    _cf_log(L_WARN, CF_TO_ITEM(_cf), __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Definition at line 266 of file cf_util.h.

◆ cf_log_warn_by_child

#define cf_log_warn_by_child (   _parent,
  _child,
  _fmt,
  ... 
)    _cf_log_by_child(L_WARN, _parent, _child, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Log a warning message against a specified child.

Parameters
[in]_parentCONF_SECTION.
[in]_childstring identifier.
[in]_fmtof message.
[in]...arguments.

Definition at line 311 of file cf_util.h.

◆ cf_parent

#define cf_parent (   _cf)    _cf_parent(CF_TO_ITEM(_cf))

Definition at line 98 of file cf_util.h.

◆ cf_root

#define cf_root (   _cf)    _cf_root(CF_TO_ITEM(_cf))

Definition at line 95 of file cf_util.h.

◆ cf_section_alloc

#define cf_section_alloc (   _ctx,
  _parent,
  _name1,
  _name2 
)     _cf_section_alloc(_ctx, _parent, _name1, _name2, __FILE__, __LINE__)

Definition at line 137 of file cf_util.h.

◆ cf_section_free_children

#define cf_section_free_children (   _x)    cf_item_free_children(cf_section_to_item(_x))

Definition at line 176 of file cf_util.h.

◆ CF_TO_ITEM

#define CF_TO_ITEM (   _cf)
Value:
_Generic((_cf), \
CONF_SECTION const * : cf_section_to_item((CONF_SECTION const *)_cf), \
CONF_PAIR * : cf_pair_to_item((CONF_PAIR const *)_cf), \
CONF_PAIR const * : cf_pair_to_item((CONF_PAIR const *)_cf), \
CONF_DATA * : cf_data_to_item((CONF_DATA const *)_cf), \
CONF_DATA const * : cf_data_to_item((CONF_DATA const *)_cf), \
default: _cf \
)
Internal data that is associated with a configuration section.
Definition: cf_priv.h:113
Configuration AVP similar to a fr_pair_t.
Definition: cf_priv.h:70
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
CONF_ITEM * cf_section_to_item(CONF_SECTION const *cs)
Cast a CONF_SECTION to a CONF_ITEM.
Definition: cf_util.c:703
CONF_ITEM * cf_pair_to_item(CONF_PAIR const *cp)
Cast a CONF_PAIR to a CONF_ITEM.
Definition: cf_util.c:687
CONF_ITEM * cf_data_to_item(CONF_DATA const *cs)
Cast CONF_DATA to a CONF_ITEM.
Definition: cf_util.c:719

Auto cast from the input type to CONF_ITEM (which is the base type)

Automatically casts:

To a CONF_ITEM, whilst performing talloc type checks.

Definition at line 65 of file cf_util.h.

◆ FR_TIMESPEC_TO_MS

#define FR_TIMESPEC_TO_MS (   _x)    (((_x)->tv_usec / 1000000) + ((_x)->tv_sec * (uint64_t)1000))

Definition at line 54 of file cf_util.h.

◆ FR_TIMEVAL_TO_MS

#define FR_TIMEVAL_TO_MS (   _x)    (((_x)->tv_usec / 1000) + ((_x)->tv_sec * (uint64_t)1000))

Definition at line 53 of file cf_util.h.

Typedef Documentation

◆ cf_walker_t

typedef int(* cf_walker_t) (void *data, void *ctx)

Definition at line 76 of file cf_util.h.

◆ CONF_DATA

typedef struct cf_data CONF_DATA

CONF_ITEM used to associate arbitrary data with a CONF_PAIR or CONF_SECTION.

Definition at line 1 of file cf_util.h.

◆ CONF_ITEM

typedef struct cf_item CONF_ITEM

Generic configuration element, extended to become a CONF_PAIR, a CONF_SECTION or CONF_DATA.

Definition at line 1 of file cf_util.h.

◆ CONF_PAIR

typedef struct cf_pair CONF_PAIR

CONF_ITEM with an attribute, an operator and a value.

Definition at line 1 of file cf_util.h.

◆ CONF_SECTION

typedef struct cf_section CONF_SECTION

CONF_ITEM used to group multiple CONF_PAIR and CONF_SECTION, together.

Definition at line 1 of file cf_util.h.

Function Documentation

◆ _cf_canonicalize_error()

void _cf_canonicalize_error ( CONF_ITEM ci,
ssize_t  slen,
char const *  msg,
char const *  str 
)

Definition at line 2335 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_data_add()

CONF_DATA const* _cf_data_add ( CONF_ITEM ci,
void const *  data,
char const *  name,
bool  do_free,
char const *  filename,
int  lineno 
)

Add talloced user data to a config section.

Parameters
[in]cito add data to.
[in]datato add.
[in]nameString identifier of the user data.
[in]do_freeFunction to free user data when the CONF_SECTION is freed.
[in]filenameSource file the CONF_DATA was added in.
[in]linenothe CONF_DATA was added at.
Returns
  • CONF_DATA - opaque handle to the stored data - on success.
  • NULL error.

Definition at line 1703 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_data_add_static()

CONF_DATA const* _cf_data_add_static ( CONF_ITEM ci,
void const *  data,
char const *  type,
char const *  name,
char const *  filename,
int  lineno 
)

Add non-talloced user data to a config section.

Parameters
[in]cito add data to.
[in]datato add.
[in]typeidentifier of the user data.
[in]nameString identifier of the user data.
[in]filenameSource file the CONF_DATA was added in.
[in]linenothe CONF_DATA was added at.
  • CONF_DATA - opaque handle to the stored data - on success.
  • NULL error.

Definition at line 1745 of file cf_util.c.

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

◆ _cf_data_find()

CONF_DATA const* _cf_data_find ( CONF_ITEM const *  ci,
char const *  type,
char const *  name 
)

Find user data in a config section.

Parameters
[in]ciThe section to search for data in.
[in]typeof user data. Used for name spacing and walking over a specific type of user data.
[in]nameString identifier of the user data. Special value CF_IDENT_ANY may be used to match on type only.
Returns
  • The user data.
  • NULL if no user data exists.

Definition at line 1627 of file cf_util.c.

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

◆ _cf_data_find_in_parent()

CONF_DATA* _cf_data_find_in_parent ( CONF_ITEM const *  ci,
char const *  type,
char const *  name 
)

Find matching data in the specified section or one of its parents.

Parameters
[in]ciThe section to search for data in.
[in]typeof user data. Used for name spacing and walking over a specific type of user data.
[in]nameString identifier of the user data. Special value CF_IDENT_ANY may be used to match on type only.
Returns

Definition at line 1661 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_data_find_next()

CONF_DATA const* _cf_data_find_next ( CONF_ITEM const *  ci,
CONF_ITEM const *  prev,
char const *  type,
char const *  name 
)

Return the next item of user data.

Parameters
[in]ciThe section to search for data in.
[in]prevsection we found. May be NULL in which case we just return the next section after prev.
[in]typeof user data. Used for name spacing and walking over a specific type of user data.
[in]nameString identifier of the user data. Special value CF_IDENT_ANY can be used to match any name2 value.
Returns

Definition at line 1645 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_data_remove()

void* _cf_data_remove ( CONF_ITEM parent,
CONF_DATA const *  cd 
)

Remove data from a configuration section.

Note
If cd was not found it will not be freed, and it is the caller's responsibility to free it explicitly, or free the section it belongs to.
Parameters
[in]parentto remove data from.
[in]cdopaque handle of the stored data.
Returns
  • The value stored within the data (if cd is valid and was found and removed).
  • NULL if not found.

Definition at line 1789 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_data_walk()

int _cf_data_walk ( CONF_ITEM ci,
char const *  type,
cf_walker_t  cb,
void *  ctx 
)

Walk over a specific type of CONF_DATA.

Parameters
[in]cicontaining the CONF_DATA to walk over.
[in]typeof CONF_DATA to walk over.
[in]cbto call when we find CONF_DATA of the specified type.
[in]ctxto pass to cb.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1817 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_debug()

void _cf_debug ( CONF_ITEM const *  ci)

Print out debugging information about a CONFIG_ITEM.

Parameters
[in]cibeing debugged.

Definition at line 2194 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_filename()

char const* _cf_filename ( CONF_ITEM const *  ci)

Return the filename the CONF_ITEM was parsed in.

Parameters
[in]cito return the location of.
Returns
  • NULL if the CONF_ITEM was created programmatically.
  • The path of the config file the CONF_ITEM was located in.

Definition at line 569 of file cf_util.c.

◆ _cf_filename_set()

void _cf_filename_set ( CONF_ITEM ci,
char const *  filename 
)

Set the filename of a CONF_ITEM.

Parameters
[in]cito set filename on.
[in]filenameto set.

Definition at line 861 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_item_add()

void _cf_item_add ( CONF_ITEM parent,
CONF_ITEM child 
)

Add a child.

Parameters
[in]parentto add child to.
[in]childto add.

Definition at line 363 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_item_insert_after()

void _cf_item_insert_after ( CONF_ITEM parent,
CONF_ITEM prev,
CONF_ITEM child 
)

Insert a child after a given one.

Parameters
[in]parentto add child to.
[in]prevprevious
[in]childto add.

Definition at line 390 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_item_next()

CONF_ITEM* _cf_item_next ( CONF_ITEM const *  ci,
CONF_ITEM const *  prev 
)

Return the next child of cs.

Parameters
[in]cito return children from.
[in]prevchild to start searching from.
Returns

Definition at line 490 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_item_remove()

CONF_ITEM* _cf_item_remove ( CONF_ITEM parent,
CONF_ITEM child 
)

Remove item from parent and fixup trees.

Parameters
[in]parentto remove child from.
[in]childto remove.
Returns
  • The item removed.
  • NULL if the item wasn't set.

Definition at line 428 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_lineno()

int _cf_lineno ( CONF_ITEM const *  ci)

Return the lineno the CONF_ITEM was parsed at.

Parameters
[in]cito return the location of.
Returns
  • -1 if the CONF_ITEM was created programmatically.
  • >= 0 where in the config file the line was parsed from.

Definition at line 555 of file cf_util.c.

◆ _cf_lineno_set()

void _cf_lineno_set ( CONF_ITEM ci,
int  lineno 
)

Set the line number of a CONF_ITEM.

Parameters
[in]cito set the lineno for.
[in]linenoto set.

Definition at line 873 of file cf_util.c.

◆ _cf_log()

void _cf_log ( fr_log_type_t  type,
CONF_ITEM const *  ci,
char const *  file,
int  line,
char const *  fmt,
  ... 
)

Log an error message relating to a CONF_ITEM.

Parameters
[in]typeof log message.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]ciCONF_ITEM to print file/lineno for.
[in]fmtof the message.
[in]...Message args.

Definition at line 1965 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_log_by_child()

void _cf_log_by_child ( fr_log_type_t  type,
CONF_SECTION const *  parent,
char const *  child,
char const *  file,
int  line,
char const *  fmt,
  ... 
)

Log an error message in the context of a child pair of the specified parent.

Parameters
[in]parentcontaining the pair.
[in]childname to use as a logging context.
[in]typeof log message.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]fmtof the message.
[in]...Message args.

Definition at line 2139 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_log_perr()

void _cf_log_perr ( fr_log_type_t  type,
CONF_ITEM const *  ci,
char const *  file,
int  line,
fr_log_perror_format_t const *  f_rules,
char const *  fmt,
  ... 
)

Log an error message relating to a CONF_ITEM.

Drains the fr_strerror() stack emitting one or more error messages.

Parameters
[in]typeof log message.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]ciCONF_ITEM to print file/lineno for.
[in]f_rulesAdditional optional formatting controls.
[in]fmtof the message.
[in]...Message args.

Definition at line 2077 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_log_perr_by_child()

void _cf_log_perr_by_child ( fr_log_type_t  type,
CONF_SECTION const *  parent,
char const *  child,
char const *  file,
int  line,
fr_log_perror_format_t const *  f_rules,
char const *  fmt,
  ... 
)

Log an error message in the context of a child pair of the specified parent.

Parameters
[in]parentcontaining the pair.
[in]childname to use as a logging context.
[in]typeof log message.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]f_rulesLine prefixes.
[in]fmtof the message.
[in]...Message args.

Definition at line 2170 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_log_with_filename()

void _cf_log_with_filename ( fr_log_type_t  type,
CONF_ITEM const *  ci,
char const *  file,
int  line,
char const *  fmt,
  ... 
)

Log a debug message relating to a CONF_ITEM.

Always emits a filename/lineno prefix if available

Parameters
[in]typeof log message.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]ciCONF_ITEM to print file/lineno for.
[in]fmtof the message.
[in]...Message args.

Definition at line 2100 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_parent()

CONF_ITEM* _cf_parent ( CONF_ITEM const *  ci)

Return the parent of a CONF_ITEM.

Parameters
[in]cito return the parent of.
Returns
  • NULL if ci was NULL or it has no parents.
  • The parent of ci.

Definition at line 541 of file cf_util.c.

◆ _cf_root()

CONF_SECTION* _cf_root ( CONF_ITEM const *  ci)

Return the top level CONF_SECTION holding all other CONF_ITEM.

Parameters
[in]cito traverse up from.
Returns

Definition at line 523 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_section_alloc()

CONF_SECTION* _cf_section_alloc ( TALLOC_CTX *  ctx,
CONF_SECTION parent,
char const *  name1,
char const *  name2,
char const *  filename,
int  lineno 
)

Allocate a CONF_SECTION.

Parameters
[in]ctxto allocate
[in]parentCONF_SECTION to hang this CONF_SECTION off of. If parent is not NULL, the new section will be added as a child.
[in]name1Primary name.
[in]name2Secondary name.
[in]filenameCaller file name for debugging. May be overridden later.
[in]linenoCaller line number for debugging. May be overridden later.
Returns

Definition at line 752 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_vlog()

void _cf_vlog ( fr_log_type_t  type,
CONF_ITEM const *  ci,
char const *  file,
int  line,
char const *  fmt,
va_list  ap 
)

Log an error message relating to a CONF_ITEM.

Parameters
[in]typeof log message.
[in]ciCONF_ITEM to print file/lineno for.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]fmtof the message.
[in]apMessage args.

Definition at line 1926 of file cf_util.c.

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

◆ _cf_vlog_perr()

void _cf_vlog_perr ( fr_log_type_t  type,
CONF_ITEM const *  ci,
char const *  file,
int  line,
fr_log_perror_format_t const *  f_rules,
char const *  fmt,
va_list  ap 
)

Log an error message relating to a CONF_ITEM.

Drains the fr_strerror() stack emitting one or more error messages.

Parameters
[in]typeof log message.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]ciCONF_ITEM to print file/lineno for.
[in]f_rulesAdditional optional formatting controls.
[in]fmtof the message.
[in]apMessage args.

Definition at line 1988 of file cf_util.c.

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

◆ cf_data_to_item()

CONF_ITEM* cf_data_to_item ( CONF_DATA const *  cd)

Cast CONF_DATA to a CONF_ITEM.

Parameters
[in]cdto cast.
Returns
  • The common CONF_ITEM header.
  • NULL if cd was NULL.

Definition at line 719 of file cf_util.c.

◆ cf_data_value()

void* cf_data_value ( CONF_DATA const *  cd)

Return the user assigned value of CONF_DATA.

Parameters
[in]cdto return value of.
Returns
the user data stored within the CONF_DATA.

Definition at line 1680 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_item_free_children()

void cf_item_free_children ( CONF_ITEM ci)

Definition at line 2322 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_item_is_data()

bool cf_item_is_data ( CONF_ITEM const *  ci)

Determine if CONF_ITEM is CONF_DATA.

Parameters
[in]cito check.
Returns
  • true if ci is CONF_DATA.
  • false if ci is another specialisation.

Definition at line 611 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_item_is_pair()

bool cf_item_is_pair ( CONF_ITEM const *  ci)

Determine if CONF_ITEM is a CONF_PAIR.

Parameters
[in]cito check.
Returns
  • true if ci is a CONF_PAIR.
  • false if ci is another specialisation.

Definition at line 597 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_item_is_section()

bool cf_item_is_section ( CONF_ITEM const *  ci)

Determine if CONF_ITEM is a CONF_SECTION.

Parameters
[in]cito check.
Returns
  • true if ci is a CONF_SECTION.
  • false if ci is another specialisation.

Definition at line 583 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_item_to_data()

CONF_DATA* cf_item_to_data ( CONF_ITEM const *  ci)

Cast CONF_ITEM to CONF_DATA performing a type check.

Note
Will assert if ci does not contain CONF_DATA.
Parameters
[in]cito cast.
Returns

Definition at line 669 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_item_to_pair()

CONF_PAIR* cf_item_to_pair ( CONF_ITEM const *  ci)

Cast a CONF_ITEM to a CONF_PAIR.

Note
Will assert if ci does not contain CONF_PAIR.
Parameters
[in]cito cast.
Returns

Definition at line 629 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_item_to_section()

CONF_SECTION* cf_item_to_section ( CONF_ITEM const *  ci)

Cast a CONF_ITEM to a CONF_SECTION.

Note
Will assert if ci does not contain CONF_SECTION.
Parameters
[in]cito cast.
Returns

Definition at line 649 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_pair_alloc()

CONF_PAIR* cf_pair_alloc ( CONF_SECTION parent,
char const *  attr,
char const *  value,
fr_token_t  op,
fr_token_t  lhs_quote,
fr_token_t  rhs_quote 
)

Allocate a CONF_PAIR.

Parameters
[in]parentCONF_SECTION to hang this CONF_PAIR off of.
[in]attrname.
[in]valueof CONF_PAIR.
[in]opT_OP_EQ, T_OP_SET etc.
[in]lhs_quoteT_BARE_WORD, T_DOUBLE_QUOTED_STRING, T_BACK_QUOTED_STRING.
[in]rhs_quoteT_BARE_WORD, T_DOUBLE_QUOTED_STRING, T_BACK_QUOTED_STRING.
Returns

Definition at line 1220 of file cf_util.c.

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

◆ cf_pair_attr()

char const* cf_pair_attr ( CONF_PAIR const *  pair)

Return the attr of a CONF_PAIR.

Return the LHS value of a pair (the attribute).

Parameters
[in]pairto return the attribute for.
Returns
  • NULL if the pair was NULL.
  • The attribute name of the pair.

Definition at line 1495 of file cf_util.c.

◆ cf_pair_attr_quote()

fr_token_t cf_pair_attr_quote ( CONF_PAIR const *  pair)

Return the value (lhs) quoting of a pair.

Parameters
pairto extract value type from.
Returns

Definition at line 1540 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_pair_count()

unsigned int cf_pair_count ( CONF_SECTION const *  cs,
char const *  attr 
)

Count the number of times an attribute occurs in a parent section.

Parameters
[in]csto search for items in.
[in]attrto search for.
Returns
The number of pairs of that attribute type.

Definition at line 1437 of file cf_util.c.

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

◆ cf_pair_count_descendents()

unsigned int cf_pair_count_descendents ( CONF_SECTION const *  cs)

Count the number of conf pairs beneath a section.

Parameters
[in]csto search for items in.
Returns
The number of pairs nested within section.

Definition at line 1422 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_pair_dup()

CONF_PAIR* cf_pair_dup ( CONF_SECTION parent,
CONF_PAIR cp 
)

Duplicate a CONF_PAIR.

Parameters
parentto allocate new pair in.
cpto duplicate.
Returns
  • NULL on error.
  • A duplicate of the input pair.

Definition at line 1261 of file cf_util.c.

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

◆ cf_pair_find()

CONF_PAIR* cf_pair_find ( CONF_SECTION const *  cs,
char const *  attr 
)

Search for a CONF_PAIR with a specific name.

Parameters
[in]csto search in.
[in]attrto find.
Returns
  • The next matching CONF_PAIR.
  • NULL if none matched.

Definition at line 1356 of file cf_util.c.

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

◆ cf_pair_find_in_parent()

CONF_PAIR* cf_pair_find_in_parent ( CONF_SECTION const *  cs,
char const *  attr 
)

Find a pair with a name matching attr in the specified section or one of its parents.

Parameters
[in]csto search in. Will start in the current section and work upwards.
[in]attrto find.
Returns
  • A matching CONF_PAIR.
  • NULL if none matched.

Definition at line 1384 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_pair_find_next()

CONF_PAIR* cf_pair_find_next ( CONF_SECTION const *  cs,
CONF_PAIR const *  prev,
char const *  attr 
)

Find a pair with a name matching attr, after specified pair.

Parameters
[in]csto search in.
[in]prevPair to search from (may be NULL).
[in]attrto find (may be NULL in which case any attribute matches).
Returns
  • The next matching CONF_PAIR
  • NULL if none matched.

Definition at line 1370 of file cf_util.c.

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

◆ cf_pair_in_table()

int cf_pair_in_table ( int32_t *  out,
fr_table_num_sorted_t const *  table,
size_t  table_len,
CONF_PAIR cp 
)

Check to see if the CONF_PAIR value is present in the specified table.

If it's not present, return an error and produce a helpful log message

Parameters
[out]outThe result of parsing the pair value.
[in]tableto look for string values in.
[in]table_lenLength of the table.
[in]cpto parse.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1886 of file cf_util.c.

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

◆ cf_pair_is_parsed()

bool cf_pair_is_parsed ( CONF_PAIR cp)

Return whether a pair has already been parsed.

Parameters
[in]cpto check.
Returns
  • true if pair has been parsed.
  • false if the pair hasn't been parsed.

Definition at line 1330 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_pair_mark_parsed()

void cf_pair_mark_parsed ( CONF_PAIR cp)

Mark a pair as parsed.

Parameters
[in]cpto mark as parsed.

Definition at line 1318 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_pair_next()

CONF_PAIR* cf_pair_next ( CONF_SECTION const *  cs,
CONF_PAIR const *  prev 
)

Return the next child that's a CONF_PAIR.

Parameters
[in]csto return children from.
[in]prevchild to start searching from.
Returns
  • The next CONF_ITEM that's a child of cs and a CONF_PAIR.
  • NULL if no CONF_ITEM matches that criteria.

Definition at line 1343 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_pair_operator()

fr_token_t cf_pair_operator ( CONF_PAIR const *  pair)

Return the operator of a pair.

Parameters
[in]pairto return the operator of.
Returns
  • T_INVALID if pair was NULL.
  • T_OP_* (one of the operator constants).

Definition at line 1525 of file cf_util.c.

◆ cf_pair_replace()

int cf_pair_replace ( CONF_SECTION cs,
CONF_PAIR cp,
char const *  value 
)

Replace pair in a given section with a new pair, of the given value.

Note
A new pair with the same metadata as the CONF_PAIR will be added even if the CONF_PAIR can't be found inside the CONF_SECTION.
Parameters
[in]csto replace pair in.
[in]cpto replace.
[in]valueNew value to assign to cp.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1290 of file cf_util.c.

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

◆ cf_pair_to_item()

CONF_ITEM* cf_pair_to_item ( CONF_PAIR const *  cp)

Cast a CONF_PAIR to a CONF_ITEM.

Parameters
[in]cpto cast.
Returns
  • The common CONF_ITEM header.
  • NULL if cp was NULL.

Definition at line 687 of file cf_util.c.

◆ cf_pair_value()

char const* cf_pair_value ( CONF_PAIR const *  pair)

Return the value of a CONF_PAIR.

Return the RHS value of a pair (the value).

Parameters
[in]pairto return the value of.
Returns
  • NULL if pair was NULL or the pair has no value.
  • The string value of the pair.

Definition at line 1511 of file cf_util.c.

◆ cf_pair_value_quote()

fr_token_t cf_pair_value_quote ( CONF_PAIR const *  pair)

Return the value (rhs) quoting of a pair.

Parameters
pairto extract value type from.
Returns

Definition at line 1555 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_pair_values_concat()

fr_slen_t cf_pair_values_concat ( fr_sbuff_t out,
CONF_SECTION const *  cs,
char const *  attr,
char const *  sep 
)

Concatenate the values of any pairs with name attr.

Parameters
[out]outwhere to write the concatenated values.
[in]csto search in.
[in]attrto search for.
[in]septo use to separate values
Returns
  • Length of the data written to out on success.
  • < 0 on failure. Number of additional bytes required in buffer.

Definition at line 1457 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_section_add_name2_quote()

void cf_section_add_name2_quote ( CONF_SECTION cs,
fr_token_t  token 
)

Set the quoting of the name2 identifier.

Parameters
[in]cscontaining name2.
[in]tokenthe quote token

Definition at line 1183 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_section_argv()

char const* cf_section_argv ( CONF_SECTION const *  cs,
int  argc 
)

Return variadic argument at the specified index.

Parameters
[in]cscontaining the arguments.
[in]argcArgument index. Note name1 and name2 are not counted in this index.
Returns
the argument value or NULL.

Definition at line 1154 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_section_argv_quote()

fr_token_t cf_section_argv_quote ( CONF_SECTION const *  cs,
int  argc 
)

Return the quoting for one of the variadic arguments.

Parameters
[in]cscontaining the arguments.
[in]argcArgument index. Note name1 and name2 are not counted in this index.
Returns

Definition at line 1201 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_section_dup()

CONF_SECTION* cf_section_dup ( TALLOC_CTX *  ctx,
CONF_SECTION parent,
CONF_SECTION const *  cs,
char const *  name1,
char const *  name2,
bool  copy_meta 
)

Duplicate a configuration section.

Note
recursively duplicates any child sections.
does not duplicate any data associated with a section, or its child sections.
Parameters
[in]ctxto allocate memory in.
[in]parentsection (may be NULL).
[in]csto duplicate.
[in]name1of new section.
[in]name2of new section.
[in]copy_metaCopy additional meta data for a section (like template, base, depth and variables).
Returns
  • A duplicate of the existing section.
  • NULL on error.

Definition at line 894 of file cf_util.c.

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

◆ cf_section_find()

CONF_SECTION* cf_section_find ( CONF_SECTION const *  cs,
char const *  name1,
char const *  name2 
)

Find a CONF_SECTION with name1 and optionally name2.

Parameters
[in]csThe section we're searching in.
[in]name1of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value.
[in]name2of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value.
Returns
  • The first matching subsection.
  • NULL if no subsections match.

Definition at line 970 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_section_find_in_parent()

CONF_SECTION* cf_section_find_in_parent ( CONF_SECTION const *  cs,
char const *  name1,
char const *  name2 
)

Find a section in the lineage of a CONF_SECTION which matches a specific name1 and optionally name2.

Will walk up the configuration tree, searching in each parent until a matching section is found or we hit the root.

Parameters
[in]csThe section we're searching in.
[in]name1of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value.
[in]name2of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value.
Returns
  • The first matching subsection.
  • NULL if no subsections match.

Definition at line 1012 of file cf_util.c.

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

◆ cf_section_find_next()

CONF_SECTION* cf_section_find_next ( CONF_SECTION const *  cs,
CONF_SECTION const *  prev,
char const *  name1,
char const *  name2 
)

Return the next matching section.

Parameters
[in]csThe section we're searching in.
[in]prevsection we found. May be NULL in which case we just return the next section after prev.
[in]name1of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value.
[in]name2of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value.
Returns
  • The next CONF_SECTION.
  • NULL if there are no more CONF_SECTIONs

Definition at line 991 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_section_find_parent()

CONF_SECTION* cf_section_find_parent ( CONF_SECTION const *  cs,
char const *  name1,
char const *  name2 
)

Find a parent CONF_SECTION with name1 and optionally name2.

Parameters
[in]csThe section we're searching in.
[in]name1of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value.
[in]name2of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value.
Returns
  • The first matching subsection.
  • NULL if no subsections match.

Definition at line 1039 of file cf_util.c.

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

◆ cf_section_name()

char const* cf_section_name ( CONF_SECTION const *  cs)

Return name2 if set, else name1.

Parameters
[in]csto return identifiers for.
Returns
name1 or name2 identifier.

Definition at line 1138 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_section_name1()

char const* cf_section_name1 ( CONF_SECTION const *  cs)

Return the second identifier of a CONF_SECTION.

Parameters
[in]csto return identifiers for.
Returns
  • The first identifier.
  • NULL if cs was NULL or no name1 set.

Definition at line 1112 of file cf_util.c.

◆ cf_section_name2()

char const* cf_section_name2 ( CONF_SECTION const *  cs)

Return the second identifier of a CONF_SECTION.

Parameters
[in]csto return identifiers for.
Returns
  • The second identifier.
  • NULL if cs was NULL or no name2 set.

Definition at line 1126 of file cf_util.c.

◆ cf_section_name2_quote()

fr_token_t cf_section_name2_quote ( CONF_SECTION const *  cs)

Return the quoting of the name2 identifier.

Parameters
[in]cscontaining name2.
Returns

Definition at line 1171 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_section_name_cmp()

int8_t cf_section_name_cmp ( CONF_SECTION const *  cs,
char const *  name1,
char const *  name2 
)

Check if a given section matches the specified name1/name2 identifiers.

Parameters
[in]csto check.
[in]name1identifier. May be CF_IDENT_ANY for wildcard matches.
[in]name2identifier. May be CF_IDENT_ANY for wildcard matches.
Returns
  • >1 if cs is greater than the identifiers.
  • 0 if cs matches the identifiers.
  • <0 if cs is less than the identifiers.

Definition at line 1080 of file cf_util.c.

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

◆ cf_section_next()

CONF_SECTION* cf_section_next ( CONF_SECTION const *  cs,
CONF_SECTION const *  prev 
)

Return the next child that's a CONF_SECTION.

Parameters
[in]csto return children from.
[in]prevchild to start searching from.
Returns
  • The next CONF_ITEM that's a child of cs and a CONF_SECTION.
  • NULL if no CONF_ITEM matches that criteria.

Definition at line 952 of file cf_util.c.

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

◆ cf_section_to_item()

CONF_ITEM* cf_section_to_item ( CONF_SECTION const *  cs)

Cast a CONF_SECTION to a CONF_ITEM.

Parameters
[in]csto cast.
Returns
  • The common CONF_ITEM header.
  • NULL if cs was NULL.

Definition at line 703 of file cf_util.c.

◆ cf_section_value_find()

char const* cf_section_value_find ( CONF_SECTION const *  cs,
char const *  attr 
)

Find a pair in a CONF_SECTION.

Parameters
[in]csthe CONF_SECTION to search in.
[in]attrto search for.
Returns
  • NULL if no pair can be found.
  • The value of the pair found.

Definition at line 1061 of file cf_util.c.

+ Here is the call graph for this function: