The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Macros | Functions | Variables
cf_util.c File Reference

Functions for building and managing the structure of internal format config items. More...

#include <string.h>
#include <freeradius-devel/server/cf_file.h>
#include <freeradius-devel/server/cf_priv.h>
#include <freeradius-devel/server/log.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/atexit.h>
+ Include dependency graph for cf_util.c:

Go to the source code of this file.

Macros

#define FILENAME_TRUNCATE   60
 
#define IS_WILDCARD(_ident)   (_ident == CF_IDENT_ANY)
 

Functions

static int _cd_free (CONF_DATA *cd)
 Free user data associated with CONF_DATA.
 
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 do_free, char const *filename, int lineno)
 Add talloced user data to a config section.
 
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.
 
CONF_DATA const * _cf_data_find (CONF_ITEM const *ci, char const *type, char const *name)
 Find user data in a config section.
 
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.
 
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.
 
void * _cf_data_remove (CONF_ITEM *parent, CONF_DATA const *cd)
 Remove data from a configuration section.
 
int _cf_data_walk (CONF_ITEM *ci, char const *type, cf_walker_t cb, void *ctx)
 Walk over a specific type of CONF_DATA.
 
bool _cf_expand_variables (void)
 
char const * _cf_filename (CONF_ITEM const *ci)
 Return the filename the CONF_ITEM was parsed in.
 
void _cf_filename_set (CONF_ITEM *ci, char const *filename)
 Set the filename of a CONF_ITEM.
 
static int8_t _cf_ident1_cmp (void const *one, void const *two)
 Compare the first identifier of a child.
 
static int8_t _cf_ident2_cmp (void const *a, void const *b)
 Compare the first and second identifiers of a child.
 
void _cf_item_add (CONF_ITEM *parent, CONF_ITEM *child)
 Add a child.
 
void _cf_item_debug (CONF_ITEM const *ci)
 Print out debugging information about a CONFIG_ITEM.
 
void _cf_item_insert_after (CONF_ITEM *parent, CONF_ITEM *prev, CONF_ITEM *child)
 Insert a child after a given one.
 
bool _cf_item_is_parsed (CONF_ITEM *ci)
 Return whether an item has already been parsed.
 
void _cf_item_mark_parsed (CONF_ITEM *ci)
 Mark an item as parsed.
 
CONF_ITEM_cf_item_next (CONF_ITEM const *parent, CONF_ITEM const *curr)
 Return the next child of the CONF_ITEM.
 
CONF_ITEM_cf_item_prev (CONF_ITEM const *ci, CONF_ITEM const *curr)
 Return the next child of cs.
 
CONF_ITEM_cf_item_remove (CONF_ITEM *parent, CONF_ITEM *child)
 Remove item from parent and fixup trees.
 
int _cf_lineno (CONF_ITEM const *ci)
 Return the lineno the CONF_ITEM was parsed at.
 
void _cf_lineno_set (CONF_ITEM *ci, int lineno)
 Set the line number of a CONF_ITEM.
 
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.
 
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.
 
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.
 
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.
 
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.
 
CONF_ITEM_cf_parent (CONF_ITEM const *ci)
 Return the parent of a CONF_ITEM.
 
bool _cf_preserve_comments (void)
 
CONF_SECTION_cf_root (CONF_ITEM const *ci)
 Return the top level CONF_SECTION holding all other CONF_ITEM.
 
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.
 
CONF_SECTION_cf_section_find_in_parent (CONF_ITEM const *ci, char const *name1, char const *name2)
 Find an ancestor of the passed CONF_ITEM which has a child matching a specific name1 and optionally name2.
 
CONF_SECTION_cf_section_find_parent (CONF_ITEM const *ci, char const *name1, char const *name2)
 Find a parent CONF_SECTION with name1 and optionally name2.
 
static int _cf_section_free (CONF_SECTION *cs)
 Free a section and associated trees.
 
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.
 
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.
 
static void _pair_count (int *count, CONF_SECTION const *cs)
 Callback to determine the number of pairs in a section.
 
CONF_COMMENTcf_comment_alloc (CONF_SECTION *parent, char const *text)
 Allocate a new comment item attached to parent.
 
char const * cf_comment_text (CONF_COMMENT const *c)
 
CONF_ITEMcf_comment_to_item (CONF_COMMENT const *c)
 Cast a CONF_COMMENT back to a CONF_ITEM.
 
static CONF_DATAcf_data_alloc (CONF_ITEM *parent, void const *data, char const *type, char const *name, bool do_free)
 Allocate a new user data container.
 
CONF_ITEMcf_data_to_item (CONF_DATA const *cd)
 Cast CONF_DATA to a CONF_ITEM.
 
void * cf_data_value (CONF_DATA const *cd)
 Return the user assigned value of CONF_DATA.
 
void cf_expand_variables_set (bool expand)
 Opt out of ${var} expansion when reading config (default: enabled).
 
static CONF_ITEMcf_find (CONF_ITEM const *parent, CONF_ITEM_TYPE type, char const *ident1, char const *ident2)
 Return the next child that's of the specified type with the specified identifiers.
 
static CONF_ITEMcf_find_next (CONF_ITEM const *parent, CONF_ITEM const *prev, CONF_ITEM_TYPE type, char const *ident1, char const *ident2)
 Return the next child that's of the specified type with the specified identifiers.
 
static int8_t cf_ident2_cmp (void const *one, void const *two)
 Compare only the second identifier of a child.
 
void cf_item_free_children (CONF_ITEM *ci)
 
static void cf_item_init (CONF_ITEM *ci, CONF_ITEM_TYPE type, CONF_ITEM *parent, char const *filename, int lineno)
 Initialize a CONF_ITEM, so we don't have repeated code.
 
bool cf_item_is_comment (CONF_ITEM const *ci)
 Determine if CONF_ITEM is a CONF_COMMENT.
 
bool cf_item_is_data (CONF_ITEM const *ci)
 Determine if CONF_ITEM is CONF_DATA.
 
bool cf_item_is_pair (CONF_ITEM const *ci)
 Determine if CONF_ITEM is a CONF_PAIR.
 
bool cf_item_is_section (CONF_ITEM const *ci)
 Determine if CONF_ITEM is a CONF_SECTION.
 
CONF_COMMENTcf_item_to_comment (CONF_ITEM const *ci)
 Cast a CONF_ITEM to a CONF_COMMENT (asserts on type mismatch).
 
CONF_DATAcf_item_to_data (CONF_ITEM const *ci)
 Cast CONF_ITEM to CONF_DATA performing a type check.
 
CONF_PAIRcf_item_to_pair (CONF_ITEM const *ci)
 Cast a CONF_ITEM to a CONF_PAIR.
 
CONF_SECTIONcf_item_to_section (CONF_ITEM const *ci)
 Cast a CONF_ITEM to a CONF_SECTION.
 
static CONF_ITEMcf_next (CONF_ITEM const *parent, CONF_ITEM const *current, CONF_ITEM_TYPE type)
 Return the next child that's of the specified type.
 
CONF_PAIRcf_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.
 
char const * cf_pair_attr (CONF_PAIR const *pair)
 Return the attr of a CONF_PAIR.
 
fr_token_t cf_pair_attr_quote (CONF_PAIR const *pair)
 Return the value (lhs) quoting of a pair.
 
unsigned int cf_pair_count (CONF_SECTION const *cs, char const *attr)
 Count the number of times an attribute occurs in a parent section.
 
unsigned int cf_pair_count_descendents (CONF_SECTION const *cs)
 Count the number of conf pairs beneath a section.
 
void cf_pair_debug (CONF_PAIR *cp)
 Ease of use from debugger.
 
CONF_PAIRcf_pair_dup (CONF_SECTION *parent, CONF_PAIR *cp, bool copy_meta)
 Duplicate a CONF_PAIR.
 
CONF_PAIRcf_pair_find (CONF_SECTION const *cs, char const *attr)
 Search for a CONF_PAIR with a specific name.
 
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.
 
CONF_PAIRcf_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.
 
CONF_PAIRcf_pair_first (CONF_SECTION const *cs)
 Return the first child that's a CONF_PAIR.
 
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.
 
CONF_PAIRcf_pair_next (CONF_SECTION const *cs, CONF_PAIR const *curr)
 Return the next child that's a CONF_PAIR.
 
fr_token_t cf_pair_operator (CONF_PAIR const *pair)
 Return the operator of a pair.
 
CONF_PAIRcf_pair_prev (CONF_SECTION const *cs, CONF_PAIR const *curr)
 Return the previous child that's a CONF_PAIR.
 
int cf_pair_replace (CONF_SECTION *cs, CONF_PAIR *cp, char const *value)
 Replace pair value in a given section with the given value.
 
int cf_pair_replace_or_add (CONF_SECTION *cs, char *ref, char const *value)
 
CONF_ITEMcf_pair_to_item (CONF_PAIR const *cp)
 Cast a CONF_PAIR to a CONF_ITEM.
 
char const * cf_pair_value (CONF_PAIR const *pair)
 Return the value of a CONF_PAIR.
 
fr_token_t cf_pair_value_quote (CONF_PAIR const *pair)
 Return the value (rhs) quoting of a pair.
 
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.
 
void cf_preserve_comments_set (bool preserve)
 Control whether the CF parser preserves # ... comments.
 
static CONF_ITEMcf_prev (CONF_ITEM const *parent, CONF_ITEM const *current, CONF_ITEM_TYPE type)
 Return the previous child that's of the specified type.
 
char const * cf_section_argv (CONF_SECTION const *cs, int argc)
 Return variadic argument at the specified index.
 
fr_token_t cf_section_argv_quote (CONF_SECTION const *cs, int argc)
 Return the quoting for one of the variadic arguments.
 
void cf_section_debug (CONF_SECTION *cs)
 Ease of use from debugger.
 
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.
 
CONF_SECTIONcf_section_find (CONF_SECTION const *cs, char const *name1, char const *name2)
 Find a CONF_SECTION with name1 and optionally name2.
 
CONF_SECTIONcf_section_find_next (CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
 Return the next matching section.
 
CONF_SECTIONcf_section_first (CONF_SECTION const *cs)
 Return the first child in a CONF_SECTION.
 
char const * cf_section_name (CONF_SECTION const *cs)
 Return name2 if set, else name1.
 
char const * cf_section_name1 (CONF_SECTION const *cs)
 Return the first identifier of a CONF_SECTION.
 
char const * cf_section_name2 (CONF_SECTION const *cs)
 Return the second identifier of a CONF_SECTION.
 
fr_token_t cf_section_name2_quote (CONF_SECTION const *cs)
 Return the quoting of the name2 identifier.
 
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.
 
CONF_SECTIONcf_section_next (CONF_SECTION const *cs, CONF_SECTION const *curr)
 Return the next child that's a CONF_SECTION.
 
CONF_SECTIONcf_section_prev (CONF_SECTION const *cs, CONF_SECTION const *curr)
 Return the previous child that's a CONF_SECTION.
 
CONF_ITEMcf_section_to_item (CONF_SECTION const *cs)
 Cast a CONF_SECTION to a CONF_ITEM.
 
char const * cf_section_value_find (CONF_SECTION const *cs, char const *attr)
 Find a pair in a CONF_SECTION.
 
static void truncate_filename (char const **e, char const **p, int *len, char const *filename)
 

Variables

static bool cf_expand_vars = true
 
static bool cf_preserve_comments = false
 

Detailed Description

Functions for building and managing the structure of internal format config items.

Id
a62aa99000f96a195c40ecb197101e6249034858

Definition in file cf_util.c.

Macro Definition Documentation

◆ FILENAME_TRUNCATE

#define FILENAME_TRUNCATE   60

◆ IS_WILDCARD

#define IS_WILDCARD (   _ident)    (_ident == CF_IDENT_ANY)

Definition at line 75 of file cf_util.c.

Function Documentation

◆ _cd_free()

static int _cd_free ( CONF_DATA cd)
static

Free user data associated with CONF_DATA.

Parameters
[in]cdbeing freed.
Returns
0

Definition at line 1800 of file cf_util.c.

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

◆ _cf_canonicalize_error()

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

Definition at line 2571 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 1929 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 1971 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 1853 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 1887 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 1871 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 2015 of file cf_util.c.

+ Here is the call graph for this function:
+ Here is the caller 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 2040 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_expand_variables()

bool _cf_expand_variables ( void  )

Definition at line 837 of file cf_util.c.

+ Here is the caller 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 612 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 998 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_ident1_cmp()

static int8_t _cf_ident1_cmp ( void const *  one,
void const *  two 
)
inlinestatic

Compare the first identifier of a child.

For CONF_ITEM_PAIR this is 'attr'. For CONF_ITEM_SECTION this is 'name1'. For CONF_ITEM_DATA this is 'type'.

Parameters
[in]oneFirst CONF_ITEM to compare.
[in]twoSecond CONF_ITEM to compare.
Returns
CMP(one, two)

Definition at line 268 of file cf_util.c.

+ Here is the caller graph for this function:

◆ _cf_ident2_cmp()

static int8_t _cf_ident2_cmp ( void const *  a,
void const *  b 
)
static

Compare the first and second identifiers of a child.

For CONF_ITEM_SECTION this is 'name2'. For CONF_ITEM_DATA this is 'name'.

Parameters
[in]aFirst CONF_ITEM to compare.
[in]bSecond CONF_ITEM to compare.
Returns
CMP(a, b)

Definition at line 375 of file cf_util.c.

+ Here is the call graph for this function:
+ Here is the caller 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 390 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_item_debug()

void _cf_item_debug ( CONF_ITEM const *  ci)

Print out debugging information about a CONFIG_ITEM.

Parameters
[in]cibeing debugged.

Definition at line 2421 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 417 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_item_is_parsed()

bool _cf_item_is_parsed ( CONF_ITEM ci)

Return whether an item has already been parsed.

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

Definition at line 1536 of file cf_util.c.

◆ _cf_item_mark_parsed()

void _cf_item_mark_parsed ( CONF_ITEM ci)

Mark an item as parsed.

Parameters
[in]cito mark as parsed.

Definition at line 1524 of file cf_util.c.

◆ _cf_item_next()

CONF_ITEM * _cf_item_next ( CONF_ITEM const *  parent,
CONF_ITEM const *  curr 
)

Return the next child of the CONF_ITEM.

Parameters
[in]parentto return children from.
[in]currchild to start searching from.
Returns

Definition at line 518 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_item_prev()

CONF_ITEM * _cf_item_prev ( CONF_ITEM const *  ci,
CONF_ITEM const *  curr 
)

Return the next child of cs.

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

Definition at line 533 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 previous item (makes iteration easier)
  • NULL if the item wasn't set.

Definition at line 455 of file cf_util.c.

+ Here is the call graph for this function:
+ Here is the caller 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 598 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 1010 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 2192 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 2366 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 2304 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 2397 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 2327 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 584 of file cf_util.c.

◆ _cf_preserve_comments()

bool _cf_preserve_comments ( void  )

Definition at line 817 of file cf_util.c.

+ Here is the caller graph for this function:

◆ _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 566 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 891 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_ITEM const *  ci,
char const *  name1,
char const *  name2 
)

Find an ancestor of the passed CONF_ITEM which has a child matching a specific name1 and optionally name2.

Note
Despite the name, this function also searches in ci for a matching item.

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

Parameters
[in]ciThe conf item we're searching back from.
[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 1238 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_section_find_parent()

CONF_SECTION * _cf_section_find_parent ( CONF_ITEM const *  ci,
char const *  name1,
char const *  name2 
)

Find a parent CONF_SECTION with name1 and optionally name2.

Parameters
[in]ciThe 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 1262 of file cf_util.c.

+ Here is the call graph for this function:

◆ _cf_section_free()

static int _cf_section_free ( CONF_SECTION cs)
static

Free a section and associated trees.

Parameters
[in]csto free.
Returns
0

Definition at line 870 of file cf_util.c.

+ Here is the caller 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 2153 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 2215 of file cf_util.c.

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

◆ _pair_count()

static void _pair_count ( int *  count,
CONF_SECTION const *  cs 
)
static

Callback to determine the number of pairs in a section.

Parameters
[out]countWhere we store the number of pairs found.
[in]cswe're currently searching in.

Definition at line 1634 of file cf_util.c.

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

◆ cf_comment_alloc()

CONF_COMMENT * cf_comment_alloc ( CONF_SECTION parent,
char const *  text 
)

Allocate a new comment item attached to parent.

Inserted into the parent's ordered children list so it appears between the surrounding pairs/sections at output time. Not indexed by name - comment lookup isn't meaningful.

text is talloc_strduped onto the new node so the caller can free their copy. Returns NULL if allocation fails.

Definition at line 842 of file cf_util.c.

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

◆ cf_comment_text()

char const * cf_comment_text ( CONF_COMMENT const *  c)

Definition at line 794 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_comment_to_item()

CONF_ITEM * cf_comment_to_item ( CONF_COMMENT const *  c)

Cast a CONF_COMMENT back to a CONF_ITEM.

Definition at line 788 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_data_alloc()

static CONF_DATA * cf_data_alloc ( CONF_ITEM parent,
void const *  data,
char const *  type,
char const *  name,
bool  do_free 
)
static

Allocate a new user data container.

Parameters
[in]parentCONF_PAIR, or CONF_SECTION to hang CONF_DATA off of.
[in]databeing added.
[in]typeof data being added.
[in]nameString identifier of the user data.
[in]do_freefunction, called when the parent CONF_SECTION is being freed.
Returns
  • CONF_DATA on success.
  • NULL on error.

Definition at line 1816 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 762 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 1906 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_expand_variables_set()

void cf_expand_variables_set ( bool  expand)

Opt out of ${var} expansion when reading config (default: enabled).

Utilities that round-trip the source - e.g. radjson2conf rebuilding a fragment from JSON - call this with false so values containing ${...} survive verbatim instead of being resolved against an incomplete tree. $INCLUDE handling is a separate parser path and is unaffected.

Definition at line 832 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_find()

static CONF_ITEM * cf_find ( CONF_ITEM const *  parent,
CONF_ITEM_TYPE  type,
char const *  ident1,
char const *  ident2 
)
static

Return the next child that's of the specified type with the specified identifiers.

Parameters
[in]parentThe section we're searching in.
[in]typeof CONF_ITEM we're searching for.
[in]ident1The first identifier.
[in]ident2The second identifier. Special value CF_IDENT_ANY can be used to match any ident2 value.
Returns
  • The first matching item.
  • NULL if no items matched.

Definition at line 88 of file cf_util.c.

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

◆ cf_find_next()

static CONF_ITEM * cf_find_next ( CONF_ITEM const *  parent,
CONF_ITEM const *  prev,
CONF_ITEM_TYPE  type,
char const *  ident1,
char const *  ident2 
)
static

Return the next child that's of the specified type with the specified identifiers.

Parameters
[in]parentThe section we're searching in.
[in]previtem we found, or NULL to start from the beginning.
[in]typeof CONF_ITEM we're searching for.
[in]ident1The first identifier.
[in]ident2The second identifier. Special value CF_IDENT_ANY can be used to match any ident2 value.
Returns
  • The first matching item.
  • NULL if no items matched.

Definition at line 182 of file cf_util.c.

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

◆ cf_ident2_cmp()

static int8_t cf_ident2_cmp ( void const *  one,
void const *  two 
)
inlinestatic

Compare only the second identifier of a child.

For CONF_ITEM_SECTION this is 'name2'. For CONF_ITEM_DATA this is 'name'.

Parameters
[in]oneFirst CONF_ITEM to compare.
[in]twoSecond CONF_ITEM to compare.
Returns
CMP(one,two)

Definition at line 325 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 2562 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_item_init()

static void cf_item_init ( CONF_ITEM ci,
CONF_ITEM_TYPE  type,
CONF_ITEM parent,
char const *  filename,
int  lineno 
)
static

Initialize a CONF_ITEM, so we don't have repeated code.

Parameters
[in]cithe CONF_ITEM to initialize
[in]typethe type to set
[in]parentthe parent node hosting this one
[in]filenamewhich caused this node to be created
[in]linenowhere in the filename

Definition at line 548 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_item_is_comment()

bool cf_item_is_comment ( CONF_ITEM const *  ci)

Determine if CONF_ITEM is a CONF_COMMENT.

Definition at line 771 of file cf_util.c.

+ Here is the caller 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 654 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 640 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 626 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_item_to_comment()

CONF_COMMENT * cf_item_to_comment ( CONF_ITEM const *  ci)

Cast a CONF_ITEM to a CONF_COMMENT (asserts on type mismatch).

Definition at line 779 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 712 of file cf_util.c.

◆ 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 672 of file cf_util.c.

◆ 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 692 of file cf_util.c.

◆ cf_next()

static CONF_ITEM * cf_next ( CONF_ITEM const *  parent,
CONF_ITEM const *  current,
CONF_ITEM_TYPE  type 
)
static

Return the next child that's of the specified type.

Parameters
[in]parentto return children from.
[in]currentchild to start searching from.
[in]typeto search for.
Returns
  • The next CONF_ITEM that's a child of ci matching type.
  • NULL if no CONF_ITEM matches that criteria.

Definition at line 47 of file cf_util.c.

+ Here is the caller 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 1434 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 1730 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 1775 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 1668 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 1653 of file cf_util.c.

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

◆ cf_pair_debug()

void cf_pair_debug ( CONF_PAIR cp)

Ease of use from debugger.

Definition at line 2545 of file cf_util.c.

◆ cf_pair_dup()

CONF_PAIR * cf_pair_dup ( CONF_SECTION parent,
CONF_PAIR cp,
bool  copy_meta 
)

Duplicate a CONF_PAIR.

Parameters
parentto allocate new pair in.
cpto duplicate.
copy_metaCopy additional meta data for a pair
Returns
  • NULL on error.
  • A duplicate of the input pair.

Definition at line 1476 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 1587 of file cf_util.c.

+ Here is the call 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 1615 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 1601 of file cf_util.c.

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

◆ cf_pair_first()

CONF_PAIR * cf_pair_first ( CONF_SECTION const *  cs)

Return the first child that's a CONF_PAIR.

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

Definition at line 1548 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 2113 of file cf_util.c.

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

◆ cf_pair_next()

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

Return the next child that's a CONF_PAIR.

Parameters
[in]csto return children from.
[in]currchild 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 1561 of file cf_util.c.

+ Here is the call graph for this function:
+ Here is the caller 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 1760 of file cf_util.c.

◆ cf_pair_prev()

CONF_PAIR * cf_pair_prev ( CONF_SECTION const *  cs,
CONF_PAIR const *  curr 
)

Return the previous child that's a CONF_PAIR.

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

Definition at line 1574 of file cf_util.c.

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

◆ cf_pair_replace()

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

Replace pair value in a given section with 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 1508 of file cf_util.c.

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

◆ cf_pair_replace_or_add()

int cf_pair_replace_or_add ( CONF_SECTION cs,
char *  ref,
char const *  value 
)

Definition at line 2592 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 730 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 1746 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 1790 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 1688 of file cf_util.c.

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

◆ cf_preserve_comments_set()

void cf_preserve_comments_set ( bool  preserve)

Control whether the CF parser preserves # ... comments.

Defaults to off (historical behaviour: comments are dropped at parse time). Utilities that want comments to round-trip through the CF tree should call the setter before cf_file_read(). The runtime server parser never opts in.

Definition at line 807 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_prev()

static CONF_ITEM * cf_prev ( CONF_ITEM const *  parent,
CONF_ITEM const *  current,
CONF_ITEM_TYPE  type 
)
inlinestatic

Return the previous child that's of the specified type.

Parameters
[in]parentto return children from.
[in]currentchild to start searching from.
[in]typeto search for.
Returns
  • The next CONF_ITEM that's a child of ci matching type.
  • NULL if no CONF_ITEM matches that criteria.

Definition at line 66 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 1380 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 1415 of file cf_util.c.

+ Here is the caller graph for this function:

◆ cf_section_debug()

void cf_section_debug ( CONF_SECTION cs)

Ease of use from debugger.

Definition at line 2552 of file cf_util.c.

◆ 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, parsed state, and variables).
Returns
  • A duplicate of the existing section.
  • NULL on error.

Definition at line 1032 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 1194 of file cf_util.c.

+ Here is the call 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 1215 of file cf_util.c.

+ Here is the call graph for this function:

◆ cf_section_first()

CONF_SECTION * cf_section_first ( CONF_SECTION const *  cs)

Return the first child in a CONF_SECTION.

Parameters
[in]csto return children 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 1150 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 1364 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 first 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 1338 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 1352 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 1397 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 1305 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 *  curr 
)

Return the next child that's a CONF_SECTION.

Parameters
[in]csto return children from.
[in]currchild 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 1163 of file cf_util.c.

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

◆ cf_section_prev()

CONF_SECTION * cf_section_prev ( CONF_SECTION const *  cs,
CONF_SECTION const *  curr 
)

Return the previous child that's a CONF_SECTION.

Parameters
[in]csto return children from.
[in]currchild 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 1176 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 746 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 1286 of file cf_util.c.

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

◆ truncate_filename()

static void truncate_filename ( char const **  e,
char const **  p,
int *  len,
char const *  filename 
)
inlinestatic

Definition at line 2072 of file cf_util.c.

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

Variable Documentation

◆ cf_expand_vars

bool cf_expand_vars = true
static

Definition at line 830 of file cf_util.c.

◆ cf_preserve_comments

bool cf_preserve_comments = false
static

Definition at line 805 of file cf_util.c.