![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
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 <freeradius-devel/util/sbuff.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 fr_cmp_ret_t | _cf_ident1_cmp (void const *one, void const *two) |
| Compare the first identifier of a child. | |
| static fr_cmp_ret_t | _cf_ident2_cmp (void const *a, void const *b) |
| Compare the first and second identifiers of a child. | |
| int | _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. | |
| 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_COMMENT * | cf_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_ITEM * | cf_comment_to_item (CONF_COMMENT const *c) |
| Cast a CONF_COMMENT back to a CONF_ITEM. | |
| static CONF_DATA * | cf_data_alloc (CONF_ITEM *parent, void const *data, char const *type, char const *name, bool do_free) |
| Allocate a new user data container. | |
| CONF_ITEM * | cf_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_ITEM * | cf_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_ITEM * | cf_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 fr_cmp_ret_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_COMMENT * | cf_item_to_comment (CONF_ITEM const *ci) |
| Cast a CONF_ITEM to a CONF_COMMENT (asserts on type mismatch). | |
| CONF_DATA * | cf_item_to_data (CONF_ITEM const *ci) |
| Cast CONF_ITEM to CONF_DATA performing a type check. | |
| CONF_PAIR * | cf_item_to_pair (CONF_ITEM const *ci) |
| Cast a CONF_ITEM to a CONF_PAIR. | |
| CONF_SECTION * | cf_item_to_section (CONF_ITEM const *ci) |
| Cast a CONF_ITEM to a CONF_SECTION. | |
| static CONF_ITEM * | cf_next (CONF_ITEM const *parent, CONF_ITEM const *current, CONF_ITEM_TYPE type) |
| Return the next child that's of the specified type. | |
| 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. | |
| 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_PAIR * | cf_pair_dup (CONF_SECTION *parent, CONF_PAIR *cp, bool copy_meta) |
| Duplicate a CONF_PAIR. | |
| CONF_PAIR * | cf_pair_find (CONF_SECTION const *cs, char const *attr) |
| Search for a CONF_PAIR with a specific name. | |
| 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. | |
| 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. | |
| CONF_PAIR * | cf_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_PAIR * | cf_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_PAIR * | cf_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 const *ref, char const *value) |
| CONF_ITEM * | cf_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. | |
| void | cf_preserve_comments_set (bool preserve) |
Control whether the CF parser preserves # ... comments. | |
| static CONF_ITEM * | cf_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_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. | |
| CONF_SECTION * | cf_section_find (CONF_SECTION const *cs, char const *name1, char const *name2) |
| Find a CONF_SECTION with name1 and optionally name2. | |
| 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. | |
| CONF_SECTION * | cf_section_first (CONF_SECTION const *cs) |
| Return the first child in a CONF_SECTION. | |
| static unsigned int | cf_section_item_count (CONF_SECTION const *cs, unsigned int *total) |
| Count the items in a section, giving up once the count reaches a limit. | |
| 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. | |
| fr_cmp_ret_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_SECTION * | cf_section_next (CONF_SECTION const *cs, CONF_SECTION const *curr) |
| Return the next child that's a CONF_SECTION. | |
| CONF_SECTION * | cf_section_prev (CONF_SECTION const *cs, CONF_SECTION const *curr) |
| Return the previous child that's a CONF_SECTION. | |
| CONF_ITEM * | cf_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 |
| static fr_sbuff_term_t const | ref_char = FR_SBUFF_TERMS(L("."), L("[")) |
| static fr_sbuff_term_t const | ref_char_end = FR_SBUFF_TERMS(L("]")) |
Functions for building and managing the structure of internal format config items.
Definition in file cf_util.c.
| #define FILENAME_TRUNCATE 60 |
| #define IS_WILDCARD | ( | _ident | ) | (_ident == CF_IDENT_ANY) |
|
static |
| 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.
| [in] | ci | to add data to. |
| [in] | data | to add. |
| [in] | name | String identifier of the user data. |
| [in] | do_free | Function to free user data when the CONF_SECTION is freed. |
| [in] | filename | Source file the CONF_DATA was added in. |
| [in] | lineno | the CONF_DATA was added at. |
Definition at line 1945 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | ci | to add data to. |
| [in] | data | to add. |
| [in] | type | identifier of the user data. |
| [in] | name | String identifier of the user data. |
| [in] | filename | Source file the CONF_DATA was added in. |
| [in] | lineno | the CONF_DATA was added at.
|
Definition at line 1987 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:Find user data in a config section.
| [in] | ci | The section to search for data in. |
| [in] | type | of user data. Used for name spacing and walking over a specific type of user data. |
| [in] | name | String identifier of the user data. Special value CF_IDENT_ANY may be used to match on type only. |
Definition at line 1869 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:Find matching data in the specified section or one of its parents.
| [in] | ci | The section to search for data in. |
| [in] | type | of user data. Used for name spacing and walking over a specific type of user data. |
| [in] | name | String identifier of the user data. Special value CF_IDENT_ANY may be used to match on type only. |
Definition at line 1903 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | ci | The section to search for data in. |
| [in] | prev | section we found. May be NULL in which case we just return the next section after prev. |
| [in] | type | of user data. Used for name spacing and walking over a specific type of user data. |
| [in] | name | String identifier of the user data. Special value CF_IDENT_ANY can be used to match any name2 value. |
Definition at line 1887 of file cf_util.c.
Here is the call graph for this function:Remove data from a configuration section.
| [in] | parent | to remove data from. |
| [in] | cd | opaque handle of the stored data. |
Definition at line 2031 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int _cf_data_walk | ( | CONF_ITEM * | ci, |
| char const * | type, | ||
| cf_walker_t | cb, | ||
| void * | ctx | ||
| ) |
Walk over a specific type of CONF_DATA.
| [in] | ci | containing the CONF_DATA to walk over. |
| [in] | type | of CONF_DATA to walk over. |
| [in] | cb | to call when we find CONF_DATA of the specified type. |
| [in] | ctx | to pass to cb. |
Definition at line 2056 of file cf_util.c.
Here is the call graph for this function:| bool _cf_expand_variables | ( | void | ) |
| char const * _cf_filename | ( | CONF_ITEM const * | ci | ) |
| void _cf_filename_set | ( | CONF_ITEM * | ci, |
| char const * | filename | ||
| ) |
|
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'.
| [in] | one | First CONF_ITEM to compare. |
| [in] | two | Second CONF_ITEM to compare. |
Definition at line 272 of file cf_util.c.
Here is the caller graph for this function:
|
static |
Compare the first and second identifiers of a child.
For CONF_ITEM_SECTION this is 'name2'. For CONF_ITEM_DATA this is 'name'.
| [in] | a | First CONF_ITEM to compare. |
| [in] | b | Second CONF_ITEM to compare. |
Definition at line 379 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void _cf_item_debug | ( | CONF_ITEM const * | ci | ) |
| void _cf_item_mark_parsed | ( | CONF_ITEM * | ci | ) |
Remove item from parent and fixup trees.
| [in] | parent | to remove child from. |
| [in] | child | to remove. |
Definition at line 434 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int _cf_lineno | ( | CONF_ITEM const * | ci | ) |
| void _cf_lineno_set | ( | CONF_ITEM * | ci, |
| int | lineno | ||
| ) |
| 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.
| [in] | type | of log message. |
| [in] | file | src file the log message was generated in. |
| [in] | line | number the log message was generated on. |
| [in] | ci | CONF_ITEM to print file/lineno for. |
| [in] | fmt | of the message. |
| [in] | ... | Message args. |
Definition at line 2208 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | parent | containing the pair. |
| [in] | child | name to use as a logging context. |
| [in] | type | of log message. |
| [in] | file | src file the log message was generated in. |
| [in] | line | number the log message was generated on. |
| [in] | fmt | of the message. |
| [in] | ... | Message args. |
Definition at line 2382 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | type | of log message. |
| [in] | file | src file the log message was generated in. |
| [in] | line | number the log message was generated on. |
| [in] | ci | CONF_ITEM to print file/lineno for. |
| [in] | f_rules | Additional optional formatting controls. |
| [in] | fmt | of the message. |
| [in] | ... | Message args. |
Definition at line 2320 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | parent | containing the pair. |
| [in] | child | name to use as a logging context. |
| [in] | type | of log message. |
| [in] | file | src file the log message was generated in. |
| [in] | line | number the log message was generated on. |
| [in] | f_rules | Line prefixes. |
| [in] | fmt | of the message. |
| [in] | ... | Message args. |
Definition at line 2413 of file cf_util.c.
Here is the call graph for this function:| 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
| [in] | type | of log message. |
| [in] | file | src file the log message was generated in. |
| [in] | line | number the log message was generated on. |
| [in] | ci | CONF_ITEM to print file/lineno for. |
| [in] | fmt | of the message. |
| [in] | ... | Message args. |
Definition at line 2343 of file cf_util.c.
Here is the call graph for this function:| bool _cf_preserve_comments | ( | void | ) |
| CONF_SECTION * _cf_root | ( | CONF_ITEM const * | ci | ) |
Return the top level CONF_SECTION holding all other CONF_ITEM.
| [in] | ci | to traverse up from. |
Definition at line 545 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | ctx | to allocate |
| [in] | parent | CONF_SECTION to hang this CONF_SECTION off of. If parent is not NULL, the new section will be added as a child. |
| [in] | name1 | Primary name. |
| [in] | name2 | Secondary name. |
| [in] | filename | Caller file name for debugging. May be overridden later. |
| [in] | lineno | Caller line number for debugging. May be overridden later. |
Definition at line 870 of file cf_util.c.
Here is the call graph for this function:| 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.
Will walk up the configuration tree, searching in each parent until a matching section is found or we hit the root.
| [in] | ci | The conf item we're searching back from. |
| [in] | name1 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value. |
| [in] | name2 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value. |
Definition at line 1291 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | ci | The section we're searching in. |
| [in] | name1 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value. |
| [in] | name2 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value. |
Definition at line 1315 of file cf_util.c.
Here is the call graph for this function:
|
static |
| 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.
| [in] | type | of log message. |
| [in] | ci | CONF_ITEM to print file/lineno for. |
| [in] | file | src file the log message was generated in. |
| [in] | line | number the log message was generated on. |
| [in] | fmt | of the message. |
| [in] | ap | Message args. |
Definition at line 2169 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| [in] | type | of log message. |
| [in] | file | src file the log message was generated in. |
| [in] | line | number the log message was generated on. |
| [in] | ci | CONF_ITEM to print file/lineno for. |
| [in] | f_rules | Additional optional formatting controls. |
| [in] | fmt | of the message. |
| [in] | ap | Message args. |
Definition at line 2231 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
| 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 821 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| char const * cf_comment_text | ( | CONF_COMMENT const * | c | ) |
| CONF_ITEM * cf_comment_to_item | ( | CONF_COMMENT const * | c | ) |
Cast a CONF_COMMENT back to a CONF_ITEM.
Definition at line 767 of file cf_util.c.
Here is the caller graph for this function:
|
static |
Allocate a new user data container.
| [in] | parent | CONF_PAIR, or CONF_SECTION to hang CONF_DATA off of. |
| [in] | data | being added. |
| [in] | type | of data being added. |
| [in] | name | String identifier of the user data. |
| [in] | do_free | function, called when the parent CONF_SECTION is being freed. |
Definition at line 1828 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void * cf_data_value | ( | CONF_DATA const * | cd | ) |
| 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 811 of file cf_util.c.
Here is the caller graph for this function:
|
static |
Return the next child that's of the specified type with the specified identifiers.
| [in] | parent | The section we're searching in. |
| [in] | type | of CONF_ITEM we're searching for. |
| [in] | ident1 | The first identifier. |
| [in] | ident2 | The second identifier. Special value CF_IDENT_ANY can be used to match any ident2 value. |
Definition at line 89 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Return the next child that's of the specified type with the specified identifiers.
| [in] | parent | The section we're searching in. |
| [in] | prev | item we found, or NULL to start from the beginning. |
| [in] | type | of CONF_ITEM we're searching for. |
| [in] | ident1 | The first identifier. |
| [in] | ident2 | The second identifier. Special value CF_IDENT_ANY can be used to match any ident2 value. |
Definition at line 186 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Compare only the second identifier of a child.
For CONF_ITEM_SECTION this is 'name2'. For CONF_ITEM_DATA this is 'name'.
| [in] | one | First CONF_ITEM to compare. |
| [in] | two | Second CONF_ITEM to compare. |
Definition at line 329 of file cf_util.c.
Here is the caller graph for this function:| void cf_item_free_children | ( | CONF_ITEM * | ci | ) |
|
static |
Initialize a CONF_ITEM, so we don't have repeated code.
| [in] | ci | the CONF_ITEM to initialize |
| [in] | type | the type to set |
| [in] | parent | the parent node hosting this one |
| [in] | filename | which caused this node to be created |
| [in] | lineno | where in the filename |
Definition at line 527 of file cf_util.c.
Here is the caller graph for this function:Determine if CONF_ITEM is a CONF_COMMENT.
Definition at line 750 of file cf_util.c.
Here is the caller graph for this function:Determine if CONF_ITEM is a CONF_SECTION.
| [in] | ci | to check. |
Definition at line 605 of file cf_util.c.
Here is the caller graph for this function:| 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 758 of file cf_util.c.
Here is the caller graph for this function:| CONF_SECTION * cf_item_to_section | ( | CONF_ITEM const * | ci | ) |
Cast a CONF_ITEM to a CONF_SECTION.
| [in] | ci | to cast. |
|
static |
| 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.
| [in] | parent | CONF_SECTION to hang this CONF_PAIR off of. |
| [in] | attr | name. |
| [in] | value | of CONF_PAIR. |
| [in] | op | T_OP_EQ, T_OP_SET etc. |
| [in] | lhs_quote | T_BARE_WORD, T_DOUBLE_QUOTED_STRING, T_BACK_QUOTED_STRING. |
| [in] | rhs_quote | T_BARE_WORD, T_DOUBLE_QUOTED_STRING, T_BACK_QUOTED_STRING. |
Definition at line 1487 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| char const * cf_pair_attr | ( | CONF_PAIR const * | pair | ) |
| fr_token_t cf_pair_attr_quote | ( | CONF_PAIR const * | pair | ) |
Return the value (lhs) quoting of a pair.
| pair | to extract value type from. |
Definition at line 1787 of file cf_util.c.
Here is the caller graph for this function:| unsigned int cf_pair_count | ( | CONF_SECTION const * | cs, |
| char const * | attr | ||
| ) |
Count the number of times an attribute occurs in a parent section.
| [in] | cs | to search for items in. |
| [in] | attr | to search for. |
Definition at line 1721 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| unsigned int cf_pair_count_descendents | ( | CONF_SECTION const * | cs | ) |
| void cf_pair_debug | ( | CONF_PAIR * | cp | ) |
| CONF_PAIR * cf_pair_dup | ( | CONF_SECTION * | parent, |
| CONF_PAIR * | cp, | ||
| bool | copy_meta | ||
| ) |
Duplicate a CONF_PAIR.
| parent | to allocate new pair in. |
| cp | to duplicate. |
| copy_meta | Copy additional meta data for a pair |
Definition at line 1529 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CONF_PAIR * cf_pair_find | ( | CONF_SECTION const * | cs, |
| char const * | attr | ||
| ) |
| 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.
| [in] | cs | to search in. Will start in the current section and work upwards. |
| [in] | attr | to find. |
Definition at line 1668 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | cs | to search in. |
| [in] | prev | Pair to search from (may be NULL). |
| [in] | attr | to find (may be NULL in which case any attribute matches). |
Definition at line 1654 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CONF_PAIR * cf_pair_first | ( | CONF_SECTION const * | cs | ) |
| 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
| [out] | out | The result of parsing the pair value. |
| [in] | table | to look for string values in. |
| [in] | table_len | Length of the table. |
| [in] | cp | to parse. |
Definition at line 2129 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CONF_PAIR * cf_pair_next | ( | CONF_SECTION const * | cs, |
| CONF_PAIR const * | curr | ||
| ) |
| fr_token_t cf_pair_operator | ( | CONF_PAIR const * | pair | ) |
| CONF_PAIR * cf_pair_prev | ( | CONF_SECTION const * | cs, |
| CONF_PAIR const * | curr | ||
| ) |
| int cf_pair_replace | ( | CONF_SECTION * | cs, |
| CONF_PAIR * | cp, | ||
| char const * | value | ||
| ) |
Replace pair value in a given section with the given value.
| [in] | cs | to replace pair in. |
| [in] | cp | to replace. |
| [in] | value | New value to assign to cp. |
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:| int cf_pair_replace_or_add | ( | CONF_SECTION * | cs, |
| char const * | ref, | ||
| char const * | value | ||
| ) |
| char const * cf_pair_value | ( | CONF_PAIR const * | pair | ) |
| fr_token_t cf_pair_value_quote | ( | CONF_PAIR const * | pair | ) |
Return the value (rhs) quoting of a pair.
| pair | to extract value type from. |
Definition at line 1802 of file cf_util.c.
Here is the caller graph for this function:| 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 786 of file cf_util.c.
Here is the caller graph for this function:
|
inlinestatic |
| char const * cf_section_argv | ( | CONF_SECTION const * | cs, |
| int | argc | ||
| ) |
| fr_token_t cf_section_argv_quote | ( | CONF_SECTION const * | cs, |
| int | argc | ||
| ) |
Return the quoting for one of the variadic arguments.
| [in] | cs | containing the arguments. |
| [in] | argc | Argument index. Note name1 and name2 are not counted in this index. |
Definition at line 1468 of file cf_util.c.
Here is the caller graph for this function:| void cf_section_debug | ( | CONF_SECTION * | cs | ) |
| 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.
| [in] | ctx | to allocate memory in. |
| [in] | parent | section (may be NULL). |
| [in] | cs | to duplicate. |
| [in] | name1 | of new section. |
| [in] | name2 | of new section. |
| [in] | copy_meta | Copy additional meta data for a section (like template, base, depth, parsed state, and variables). |
Definition at line 1052 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CONF_SECTION * cf_section_find | ( | CONF_SECTION const * | cs, |
| char const * | name1, | ||
| char const * | name2 | ||
| ) |
Find a CONF_SECTION with name1 and optionally name2.
| [in] | cs | The section we're searching in. |
| [in] | name1 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value. |
| [in] | name2 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value. |
Definition at line 1247 of file cf_util.c.
Here is the call graph for this function:| 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.
| [in] | cs | The section we're searching in. |
| [in] | prev | section we found. May be NULL in which case we just return the next section after prev. |
| [in] | name1 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name1 value. |
| [in] | name2 | of the section we're searching for. Special value CF_IDENT_ANY can be used to match any name2 value. |
Definition at line 1268 of file cf_util.c.
Here is the call graph for this function:| CONF_SECTION * cf_section_first | ( | CONF_SECTION const * | cs | ) |
|
static |
Count the items in a section, giving up once the count reaches a limit.
total is the running count, shared by every level of the walk. Each level adds its own children to it, so the caller reads the whole subtree from one variable rather than from a return value which each level would have to add up by hand.
Stopping early is what keeps this cheap. The answer only has to be good enough to compare against the limit, so the walk never costs more than the limit itself, however large the section is.
| [in] | cs | to count, including everything nested inside it. NULL counts as nothing, because cf_section_dup() is called with a NULL parent. |
| [in,out] | total | the running count, which the caller sets to 0. |
*total, so that a caller which wants only the answer can take it from here. 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:| char const * cf_section_name | ( | CONF_SECTION const * | cs | ) |
| char const * cf_section_name1 | ( | CONF_SECTION const * | cs | ) |
Return the first identifier of a CONF_SECTION.
| [in] | cs | to return identifiers for. |
| char const * cf_section_name2 | ( | CONF_SECTION const * | cs | ) |
Return the second identifier of a CONF_SECTION.
| [in] | cs | to return identifiers for. |
| fr_token_t cf_section_name2_quote | ( | CONF_SECTION const * | cs | ) |
Return the quoting of the name2 identifier.
| [in] | cs | containing name2. |
Definition at line 1450 of file cf_util.c.
Here is the caller graph for this function:| fr_cmp_ret_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.
| [in] | cs | to check. |
| [in] | name1 | identifier. May be CF_IDENT_ANY for wildcard matches. |
| [in] | name2 | identifier. May be CF_IDENT_ANY for wildcard matches. |
Definition at line 1358 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CONF_SECTION * cf_section_next | ( | CONF_SECTION const * | cs, |
| CONF_SECTION const * | curr | ||
| ) |
Return the next child that's a CONF_SECTION.
| [in] | cs | to return children from. |
| [in] | curr | child to start searching from. |
Definition at line 1216 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CONF_SECTION * cf_section_prev | ( | CONF_SECTION const * | cs, |
| CONF_SECTION const * | curr | ||
| ) |
Return the previous child that's a CONF_SECTION.
| [in] | cs | to return children from. |
| [in] | curr | child to start searching from. |
Definition at line 1229 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:| CONF_ITEM * cf_section_to_item | ( | CONF_SECTION const * | cs | ) |
Cast a CONF_SECTION to a CONF_ITEM.
| [in] | cs | to cast. |
| char const * cf_section_value_find | ( | CONF_SECTION const * | cs, |
| char const * | attr | ||
| ) |
Find a pair in a CONF_SECTION.
| [in] | cs | the CONF_SECTION to search in. |
| [in] | attr | to search for. |
Definition at line 1339 of file cf_util.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
|
static |
|
static |
1.9.8