All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs
conffile.h File Reference

API to parse FreeRADIUS configuration file format, and convert string values to native C datatypes. More...

#include <stddef.h>
#include <freeradius-devel/token.h>
#include <sys/time.h>
+ Include dependency graph for conffile.h:

Go to the source code of this file.

Data Structures

struct  CONF_PARSER
 Defines a CONF_PAIR to C data type mapping. More...
 

Macros

#define FR_CONF_DEPRECATED(_n, _t, _p, _f)
 
#define FR_CONF_OFFSET(_n, _t, _s, _f)
 
#define FR_CONF_POINTER(_n, _t, _p)
 
#define FR_ITEM_POINTER(_t, _p)   .type = _t, .data = _p
 
#define PW_TYPE_SUBSECTION   102
 

Typedefs

typedef struct conf_data CONF_DATA
 CONF_ITEM used to associate arbitrary data with a CONF_PAIR or CONF_SECTION. More...
 
typedef struct conf_item CONF_ITEM
 Generic configuration element, extended to become a CONF_PAIR, a CONF_SECTION or CONF_DATA. More...
 
typedef struct conf_pair CONF_PAIR
 CONF_ITEM with an attribute, an operator and a value. More...
 
typedef struct conf_part CONF_SECTION
 CONF_ITEM used to group multiple CONF_PAIR and CONF_SECTION, together. More...
 
typedef void conf_type_invalid
 Dummy type used to indicate invalid PW_TYPE_*. More...
 
typedef void conf_type_mismatch
 Dummy type used to indicate PW_TYPE_*/C type mismatch. More...
 

#CONF_PARSER type flags

These flags should be or'd with another PW_TYPE_* value to create validation rules for the cf_pair_parse function.

Note
File PW_TYPE_FILE_* types have a base type of string, so they're validated correctly by the config parser.
#define PW_TYPE_DEPRECATED   (1 << 10)
 If a matching CONF_PAIR is found, error out with a deprecated message. More...
 
#define PW_TYPE_REQUIRED   (1 << 11)
 Error out if no matching CONF_PAIR is found, and no dflt value is set. More...
 
#define PW_TYPE_ATTRIBUTE   (1 << 12)
 Value must resolve to attribute in dict (deprecated, use PW_TYPE_TMPL). More...
 
#define PW_TYPE_SECRET   (1 << 13)
 Only print value if debug level >= 3. More...
 
#define PW_TYPE_FILE_INPUT   ((1 << 14) | PW_TYPE_STRING)
 File matching value must exist, and must be readable. More...
 
#define PW_TYPE_FILE_OUTPUT   ((1 << 15) | PW_TYPE_STRING)
 File matching value must exist, and must be writeable. More...
 
#define PW_TYPE_XLAT   (1 << 16)
 string will be dynamically expanded. More...
 
#define PW_TYPE_TMPL   (1 << 17)
 CONF_PAIR should be parsed as a template. More...
 
#define PW_TYPE_MULTI   (1 << 18)
 CONF_PAIR can have multiple copies. More...
 
#define PW_TYPE_NOT_EMPTY   (1 << 19)
 CONF_PAIR is required to have a non zero length value. More...
 
#define FR_INTEGER_COND_CHECK(_name, _var, _cond, _new)
 
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)   FR_INTEGER_COND_CHECK(_name, _var, (_var _op _bound), _bound)
 
#define FR_TIMEVAL_BOUND_CHECK(_name, _var, _op, _bound_sec, _bound_usec)
 
#define FR_TIMEVAL_TO_MS(_x)   (((_x)->tv_usec / 1000) + ((_x)->tv_sec * (uint64_t)1000))
 
#define FR_TIMESPEC_TO_MS(_x)   (((_x)->tv_usec / 1000000) + ((_x)->tv_sec * (uint64_t)1000))
 
#define CONF_PARSER_TERMINATOR   { NULL, -1, 0, NULL, NULL, T_INVALID }
 
#define CF_FILE_NONE   (0)
 
#define CF_FILE_ERROR   (1)
 
#define CF_FILE_CONFIG   (1 << 2)
 
#define CF_FILE_MODULE   (1 << 3)
 
typedef struct CONF_PARSER CONF_PARSER
 Defines a CONF_PAIR to C data type mapping. More...
 
bool check_config
 
CONF_PAIRcf_pair_alloc (CONF_SECTION *parent, char const *attr, char const *value, FR_TOKEN op, FR_TOKEN lhs_type, FR_TOKEN rhs_type)
 Allocate a CONF_PAIR. More...
 
CONF_PAIRcf_pair_dup (CONF_SECTION *parent, CONF_PAIR *cp)
 Duplicate a CONF_PAIR. More...
 
void cf_pair_add (CONF_SECTION *parent, CONF_PAIR *cp)
 Add a configuration pair to a section. More...
 
CONF_SECTIONcf_section_alloc (CONF_SECTION *parent, char const *name1, char const *name2)
 Allocate a CONF_SECTION. More...
 
CONF_SECTIONcf_section_dup (CONF_SECTION *parent, CONF_SECTION const *cs, char const *name1, char const *name2, bool copy_meta)
 Duplicate a configuration section. More...
 
void cf_section_add (CONF_SECTION *parent, CONF_SECTION *cs)
 
int cf_pair_replace (CONF_SECTION *cs, CONF_PAIR *cp, char const *value)
 Replace pair in a given section with a new pair, of the given value. More...
 
int cf_pair_parse (CONF_SECTION *cs, char const *name, unsigned int type, void *data, char const *dflt, FR_TOKEN dflt_quote)
 Parses a CONF_PAIR into a C data type, with a default value. More...
 
int cf_section_parse (CONF_SECTION *, void *base, CONF_PARSER const *variables)
 Parse a configuration section into user-supplied variables. More...
 
int cf_section_parse_pass2 (CONF_SECTION *, void *base, CONF_PARSER const *variables)
 
const CONF_PARSERcf_section_parse_table (CONF_SECTION *cs)
 
int cf_file_read (CONF_SECTION *cs, char const *file)
 
void cf_file_free (CONF_SECTION *cs)
 
CONF_PAIRcf_pair_find (CONF_SECTION const *, char const *name)
 
CONF_PAIRcf_pair_find_next (CONF_SECTION const *, CONF_PAIR const *, char const *name)
 Find a pair with a name matching attr, after specified pair. More...
 
CONF_SECTIONcf_section_find_name2 (CONF_SECTION const *section, char const *name1, char const *name2)
 
CONF_SECTIONcf_section_sub_find (CONF_SECTION const *, char const *name)
 Find a sub-section in a section. More...
 
CONF_SECTIONcf_section_sub_find_name2 (CONF_SECTION const *, char const *name1, char const *name2)
 Find a CONF_SECTION with both names. More...
 
char const * cf_section_value_find (CONF_SECTION const *, char const *attr)
 
CONF_SECTIONcf_top_section (CONF_SECTION *cs)
 
void * cf_data_find (CONF_SECTION const *, char const *)
 
int cf_data_add (CONF_SECTION *, char const *, void *, void(*)(void *))
 
void * cf_data_remove (CONF_SECTION *cs, char const *name)
 Remove named data from a configuration section. More...
 
char const * cf_pair_attr (CONF_PAIR const *pair)
 
char const * cf_pair_value (CONF_PAIR const *pair)
 
FR_TOKEN cf_pair_operator (CONF_PAIR const *pair)
 
FR_TOKEN cf_pair_attr_type (CONF_PAIR const *pair)
 Return the value (lhs) type. More...
 
FR_TOKEN cf_pair_value_type (CONF_PAIR const *pair)
 Return the value (rhs) type. More...
 
VALUE_PAIRcf_pairtovp (CONF_PAIR *pair)
 
char const * cf_section_name1 (CONF_SECTION const *cs)
 
char const * cf_section_name2 (CONF_SECTION const *cs)
 
char const * cf_section_name (CONF_SECTION const *cs)
 Return name2 if set, else name1. More...
 
char const * cf_section_argv (CONF_SECTION const *cs, int argc)
 
FR_TOKEN cf_section_name2_type (CONF_SECTION const *cs)
 
FR_TOKEN cf_section_argv_type (CONF_SECTION const *cs, int argc)
 
int dump_config (CONF_SECTION const *cs)
 
CONF_SECTIONcf_subsection_find_next (CONF_SECTION const *section, CONF_SECTION const *subsection, char const *name1)
 
CONF_SECTIONcf_section_find_next (CONF_SECTION const *section, CONF_SECTION const *subsection, char const *name1)
 
int cf_section_lineno (CONF_SECTION const *section)
 
int cf_pair_lineno (CONF_PAIR const *pair)
 
char const * cf_pair_filename (CONF_PAIR const *pair)
 
char const * cf_section_filename (CONF_SECTION const *section)
 
CONF_ITEMcf_item_find_next (CONF_SECTION const *section, CONF_ITEM const *item)
 Return the next item after a CONF_ITEM. More...
 
int cf_pair_count (CONF_SECTION const *cs)
 Count the number of conf pairs beneath a section. More...
 
CONF_SECTIONcf_item_parent (CONF_ITEM const *ci)
 
bool cf_item_is_section (CONF_ITEM const *item)
 
bool cf_item_is_pair (CONF_ITEM const *item)
 
CONF_PAIRcf_item_to_pair (CONF_ITEM const *item)
 Cast a CONF_ITEM to a CONF_PAIR. More...
 
CONF_SECTIONcf_item_to_section (CONF_ITEM const *item)
 Cast a CONF_ITEM to a CONF_SECTION. More...
 
CONF_ITEMcf_pair_to_item (CONF_PAIR const *cp)
 Cast a CONF_PAIR to a CONF_ITEM. More...
 
CONF_ITEMcf_section_to_item (CONF_SECTION const *cs)
 Cast a CONF_SECTION to a CONF_ITEM. More...
 
void cf_log_err (CONF_ITEM const *ci, char const *fmt,...) CC_HINT(format(printf
 
void void cf_log_err_cs (CONF_SECTION const *cs, char const *fmt,...) CC_HINT(format(printf
 
void void void cf_log_err_cp (CONF_PAIR const *cp, char const *fmt,...) CC_HINT(format(printf
 
void void void void cf_log_info (CONF_SECTION const *cs, char const *fmt,...) CC_HINT(format(printf
 
void void void void void cf_log_module (CONF_SECTION const *cs, char const *fmt,...) CC_HINT(format(printf
 
void void void void void void cf_item_add (CONF_SECTION *cs, CONF_ITEM *ci)
 
CONF_ITEMcf_reference_item (CONF_SECTION const *parentcs, CONF_SECTION *outercs, char const *ptr)
 
int cf_file_changed (CONF_SECTION *cs, rb_walker_t callback)
 

Detailed Description

API to parse FreeRADIUS configuration file format, and convert string values to native C datatypes.

Id:
1ca20fc179e138bbc8d9aef64301a3aa8f193ad8

Definition in file conffile.h.


Data Structure Documentation

struct CONF_PARSER

Defines a CONF_PAIR to C data type mapping.

Is typically used to define mappings between module sections, and module instance structs. May also be used to set global configuration options.

Offset/data values should be set using FR_CONF_OFFSET or FR_CONF_POINTER.

Example with FR_CONF_OFFSET :

{ FR_CONF_OFFSET("example", PW_TYPE_STRING | PW_TYPE_NOT_EMPTY, example_instance_t, example), .dflt = "default_value" },
}

Example with FR_CONF_POINTER :

static CONF_PARSER global_config[] = {
{ FR_CONF_POINTER("example", PW_TYPE_STRING | PW_TYPE_NOT_EMPTY, &my_global), .dflt = "default_value" },
}
See Also
FR_CONF_OFFSET
FR_CONF_POINTER
cf_section_parse
cf_pair_parse

Definition at line 267 of file conffile.h.

Data Fields
void * data Pointer to a static variable to write the parsed value to.
Note
Must be used exclusively to offset.
const void * dflt Default as it would appear in radiusd.conf.

When type is set to PW_TYPE_SUBSECTION, should be a pointer to the start of another array of CONF_PARSER structs, forming the subsection.

char const * name Name of the CONF_ITEM to parse.
size_t offset Relative offset of field or structure to write the parsed value to.

When type is set to PW_TYPE_SUBSECTION, may be used to specify a base offset to add to all offsets contained within the subsection.

Note
Must be used exclusively to data.
FR_TOKEN quote Quoting around the default value. Only used for templates.
int type A PW_TYPE value, may be or'd with one or more PW_TYPE_* flags.
See Also
cf_pair_parse.

Macro Definition Documentation

#define CF_FILE_CONFIG   (1 << 2)

Definition at line 371 of file conffile.h.

#define CF_FILE_ERROR   (1)

Definition at line 370 of file conffile.h.

#define CF_FILE_MODULE   (1 << 3)

Definition at line 372 of file conffile.h.

#define CF_FILE_NONE   (0)

Definition at line 369 of file conffile.h.

#define CONF_PARSER_TERMINATOR   { NULL, -1, 0, NULL, NULL, T_INVALID }

Definition at line 289 of file conffile.h.

#define FR_CONF_DEPRECATED (   _n,
  _t,
  _p,
  _f 
)
Value:
.name = _n, \
.type = (_t) | PW_TYPE_DEPRECATED
#define PW_TYPE_DEPRECATED
If a matching CONF_PAIR is found, error out with a deprecated message.
Definition: conffile.h:199

Definition at line 179 of file conffile.h.

#define FR_CONF_OFFSET (   _n,
  _t,
  _s,
  _f 
)
Value:
.name = _n, \
.type = _t, \
.offset = offsetof(_s, _f)

Definition at line 168 of file conffile.h.

#define FR_CONF_POINTER (   _n,
  _t,
  _p 
)
Value:
.name = _n, \
.type = _t, \
.data = _p

Definition at line 172 of file conffile.h.

#define FR_INTEGER_BOUND_CHECK (   _name,
  _var,
  _op,
  _bound 
)    FR_INTEGER_COND_CHECK(_name, _var, (_var _op _bound), _bound)

Definition at line 222 of file conffile.h.

#define FR_INTEGER_COND_CHECK (   _name,
  _var,
  _cond,
  _new 
)
Value:
do {\
if (!(_cond)) {\
WARN("WARNING: Ignoring \"" _name " = %i\", forcing to \"" _name " = %i\"", _var, _new);\
_var = _new;\
}\
} while (0)
#define WARN(fmt,...)
Definition: log.h:144

Definition at line 214 of file conffile.h.

#define FR_ITEM_POINTER (   _t,
  _p 
)    .type = _t, .data = _p

Definition at line 176 of file conffile.h.

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

Definition at line 236 of file conffile.h.

#define FR_TIMEVAL_BOUND_CHECK (   _name,
  _var,
  _op,
  _bound_sec,
  _bound_usec 
)
Value:
do {\
struct timeval _bound = {_bound_sec, _bound_usec};\
if (!timercmp(_var, &_bound, _op)) {\
WARN("WARNING: Ignoring \"" _name " = %d.%.06d\", forcing to \"" _name " = %d.%06d\"",\
(int)(_var)->tv_sec, (int)(_var)->tv_usec,\
(int)_bound.tv_sec, (int)_bound.tv_usec);\
*_var = _bound;\
}\
} while (0)
#define WARN(fmt,...)
Definition: log.h:144

Definition at line 224 of file conffile.h.

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

Definition at line 235 of file conffile.h.

#define PW_TYPE_ATTRIBUTE   (1 << 12)

Value must resolve to attribute in dict (deprecated, use PW_TYPE_TMPL).

Definition at line 201 of file conffile.h.

#define PW_TYPE_DEPRECATED   (1 << 10)

If a matching CONF_PAIR is found, error out with a deprecated message.

Definition at line 199 of file conffile.h.

#define PW_TYPE_FILE_INPUT   ((1 << 14) | PW_TYPE_STRING)

File matching value must exist, and must be readable.

Definition at line 204 of file conffile.h.

#define PW_TYPE_FILE_OUTPUT   ((1 << 15) | PW_TYPE_STRING)

File matching value must exist, and must be writeable.

Definition at line 205 of file conffile.h.

#define PW_TYPE_MULTI   (1 << 18)

CONF_PAIR can have multiple copies.

Definition at line 210 of file conffile.h.

#define PW_TYPE_NOT_EMPTY   (1 << 19)

CONF_PAIR is required to have a non zero length value.

Definition at line 211 of file conffile.h.

#define PW_TYPE_REQUIRED   (1 << 11)

Error out if no matching CONF_PAIR is found, and no dflt value is set.

Definition at line 200 of file conffile.h.

#define PW_TYPE_SECRET   (1 << 13)

Only print value if debug level >= 3.

Definition at line 202 of file conffile.h.

#define PW_TYPE_SUBSECTION   102

Definition at line 188 of file conffile.h.

#define PW_TYPE_TMPL   (1 << 17)

CONF_PAIR should be parsed as a template.

Definition at line 208 of file conffile.h.

#define PW_TYPE_XLAT   (1 << 16)

string will be dynamically expanded.

Definition at line 207 of file conffile.h.

Typedef Documentation

typedef struct conf_data CONF_DATA

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

Definition at line 44 of file conffile.h.

typedef struct conf_item CONF_ITEM

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

Definition at line 40 of file conffile.h.

typedef struct conf_pair CONF_PAIR

CONF_ITEM with an attribute, an operator and a value.

Definition at line 42 of file conffile.h.

typedef struct CONF_PARSER CONF_PARSER

Defines a CONF_PAIR to C data type mapping.

Is typically used to define mappings between module sections, and module instance structs. May also be used to set global configuration options.

Offset/data values should be set using FR_CONF_OFFSET or FR_CONF_POINTER.

Example with FR_CONF_OFFSET :

{ FR_CONF_OFFSET("example", PW_TYPE_STRING | PW_TYPE_NOT_EMPTY, example_instance_t, example), .dflt = "default_value" },
}

Example with FR_CONF_POINTER :

static CONF_PARSER global_config[] = {
{ FR_CONF_POINTER("example", PW_TYPE_STRING | PW_TYPE_NOT_EMPTY, &my_global), .dflt = "default_value" },
}
See Also
FR_CONF_OFFSET
FR_CONF_POINTER
cf_section_parse
cf_pair_parse
typedef struct conf_part CONF_SECTION

CONF_ITEM used to group multiple CONF_PAIR and CONF_SECTION, together.

Definition at line 43 of file conffile.h.

typedef void conf_type_invalid

Dummy type used to indicate invalid PW_TYPE_*.

Definition at line 49 of file conffile.h.

typedef void conf_type_mismatch

Dummy type used to indicate PW_TYPE_*/C type mismatch.

Definition at line 48 of file conffile.h.

Function Documentation

int cf_data_add ( CONF_SECTION ,
char const *  ,
void *  ,
void(*)(void *)   
)

Definition at line 4018 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* cf_data_find ( CONF_SECTION const *  ,
char const *   
)

Definition at line 3981 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* cf_data_remove ( CONF_SECTION cs,
char const *  name 
)

Remove named data from a configuration section.

Definition at line 4027 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int cf_file_changed ( CONF_SECTION cs,
rb_walker_t  callback 
)

Definition at line 486 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void cf_file_free ( CONF_SECTION cs)

Definition at line 3469 of file conffile.c.

+ Here is the caller graph for this function:

int cf_file_read ( CONF_SECTION cs,
char const *  file 
)

Definition at line 3421 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void void void void void void cf_item_add ( CONF_SECTION cs,
CONF_ITEM ci 
)

Definition at line 803 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CONF_ITEM* cf_item_find_next ( CONF_SECTION const *  section,
CONF_ITEM const *  item 
)

Return the next item after a CONF_ITEM.

Definition at line 3850 of file conffile.c.

+ Here is the caller graph for this function:

bool cf_item_is_pair ( CONF_ITEM const *  item)

Definition at line 3928 of file conffile.c.

+ Here is the caller graph for this function:

bool cf_item_is_section ( CONF_ITEM const *  item)

Definition at line 3923 of file conffile.c.

+ Here is the caller graph for this function:

CONF_SECTION* cf_item_parent ( CONF_ITEM const *  ci)

Definition at line 3896 of file conffile.c.

+ Here is the caller graph for this function:

CONF_PAIR* cf_item_to_pair ( CONF_ITEM const *  ci)

Cast a CONF_ITEM to a CONF_PAIR.

Definition at line 181 of file conffile.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.

Definition at line 196 of file conffile.c.

+ Here is the caller graph for this function:

void cf_log_err ( CONF_ITEM const *  ci,
char const *  fmt,
  ... 
)

+ Here is the caller graph for this function:

void void void cf_log_err_cp ( CONF_PAIR const *  cp,
char const *  fmt,
  ... 
)

+ Here is the caller graph for this function:

void void cf_log_err_cs ( CONF_SECTION const *  cs,
char const *  fmt,
  ... 
)

+ Here is the caller graph for this function:

void void void void cf_log_info ( CONF_SECTION const *  cs,
char const *  fmt,
  ... 
)

+ Here is the caller graph for this function:

void void void void void cf_log_module ( CONF_SECTION const *  cs,
char const *  fmt,
  ... 
)

+ Here is the caller graph for this function:

void cf_pair_add ( CONF_SECTION parent,
CONF_PAIR cp 
)

Add a configuration pair to a section.

Parameters
parentsection to add pair to.
cpto add.

Definition at line 612 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CONF_PAIR* cf_pair_alloc ( CONF_SECTION parent,
char const *  attr,
char const *  value,
FR_TOKEN  op,
FR_TOKEN  lhs_type,
FR_TOKEN  rhs_type 
)

Allocate a CONF_PAIR.

Parameters
parentCONF_SECTION to hang this CONF_PAIR off of.
attrname.
valueof CONF_PAIR.
opT_OP_EQ, T_OP_SET etc.
lhs_typeT_BARE_WORD, T_DOUBLE_QUOTED_STRING, T_BACK_QUOTED_STRING
rhs_typeT_BARE_WORD, T_DOUBLE_QUOTED_STRING, T_BACK_QUOTED_STRING
Returns

Definition at line 546 of file conffile.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)

Definition at line 3497 of file conffile.c.

+ Here is the caller graph for this function:

FR_TOKEN cf_pair_attr_type ( CONF_PAIR const *  pair)

Return the value (lhs) type.

Parameters
pairto extract value type from.
Returns

Definition at line 3526 of file conffile.c.

+ Here is the caller graph for this function:

int cf_pair_count ( CONF_SECTION const *  cs)

Count the number of conf pairs beneath a section.

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

Definition at line 3887 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CONF_PAIR* cf_pair_dup ( CONF_SECTION parent,
CONF_PAIR cp 
)

Duplicate a CONF_PAIR.

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

Definition at line 589 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const* cf_pair_filename ( CONF_PAIR const *  pair)

Definition at line 3908 of file conffile.c.

+ Here is the caller graph for this function:

CONF_PAIR* cf_pair_find ( CONF_SECTION const *  ,
char const *  name 
)

Definition at line 3478 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Parameters
csto search in.
pairto search from (may be NULL).
attrto find (may be NULL in which case any attribute matches).
Returns
the next matching CONF_PAIR or NULL if none matched.

Definition at line 3673 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int cf_pair_lineno ( CONF_PAIR const *  pair)

Definition at line 3918 of file conffile.c.

+ Here is the caller graph for this function:

FR_TOKEN cf_pair_operator ( CONF_PAIR const *  pair)

Definition at line 3511 of file conffile.c.

+ Here is the caller graph for this function:

int cf_pair_parse ( CONF_SECTION cs,
char const *  name,
unsigned int  type,
void *  data,
char const *  dflt,
FR_TOKEN  dflt_quote 
)

Parses a CONF_PAIR into a C data type, with a default value.

Takes fields from a CONF_PARSER struct and uses them to parse the string value of a CONF_PAIR into a C data type matching the type argument.

The format of the types are the same as value_data_t types.

Note
The dflt value will only be used if no matching CONF_PAIR is found. Empty strings will not result in the dflt value being used.

PW_TYPE to data type mappings

PW_TYPE Data type Dynamically allocated
PW_TYPE_TMPL vp_tmpl_t Yes
PW_TYPE_BOOLEAN bool No
PW_TYPE_INTEGER uint32_t No
PW_TYPE_SHORT uint16_t No
PW_TYPE_INTEGER64 uint64_t No
PW_TYPE_SIGNED int32_t No
PW_TYPE_STRING char const * Yes
PW_TYPE_IPV4_ADDR fr_ipaddr_t No
PW_TYPE_IPV4_PREFIX fr_ipaddr_t No
PW_TYPE_IPV6_ADDR fr_ipaddr_t No
PW_TYPE_IPV6_PREFIX fr_ipaddr_t No
PW_TYPE_COMBO_IP_ADDR fr_ipaddr_t No
PW_TYPE_COMBO_IP_PREFIX fr_ipaddr_t No
PW_TYPE_TIMEVAL struct timeval No
Parameters
csto search for matching CONF_PAIR in.
nameof CONF_PAIR to search for.
typeData type to parse CONF_PAIR value as. Should be one of the following data types, and one or more of the following flag types or'd together:
dataPointer to a global variable, or pointer to a field in the struct being populated with values.
dfltvalue to use, if no CONF_PAIR is found.
dflt_quotearound the dflt value.
Returns
  • 1 if default value was used, or if there was no CONF_PAIR or dflt.
  • 0 on success.
  • -1 on error.
  • -2 if deprecated.

Definition at line 1968 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Parameters
csto replace pair in.
cpto replace.
valueNew value to assign to cp.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 768 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CONF_ITEM* cf_pair_to_item ( CONF_PAIR const *  cp)

Cast a CONF_PAIR to a CONF_ITEM.

Definition at line 211 of file conffile.c.

+ Here is the caller graph for this function:

char const* cf_pair_value ( CONF_PAIR const *  pair)

Definition at line 3506 of file conffile.c.

+ Here is the caller graph for this function:

FR_TOKEN cf_pair_value_type ( CONF_PAIR const *  pair)

Return the value (rhs) type.

Parameters
pairto extract value type from.
Returns

Definition at line 3541 of file conffile.c.

+ Here is the caller graph for this function:

VALUE_PAIR* cf_pairtovp ( CONF_PAIR pair)

Definition at line 3550 of file conffile.c.

+ Here is the call graph for this function:

CONF_ITEM* cf_reference_item ( CONF_SECTION const *  parentcs,
CONF_SECTION outercs,
char const *  ptr 
)

Definition at line 906 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void cf_section_add ( CONF_SECTION parent,
CONF_SECTION cs 
)

Definition at line 754 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CONF_SECTION* cf_section_alloc ( CONF_SECTION parent,
char const *  name1,
char const *  name2 
)

Allocate a CONF_SECTION.

Parameters
parentCONF_SECTION to hang this CONF_SECTION off of.
name1Primary name.
name2Secondary name.
Returns

Definition at line 626 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3619 of file conffile.c.

+ Here is the caller graph for this function:

FR_TOKEN cf_section_argv_type ( CONF_SECTION const *  cs,
int  argc 
)

Definition at line 4155 of file conffile.c.

+ Here is the caller graph for this function:

CONF_SECTION* cf_section_dup ( 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
parentsection (may be NULL).
csto duplicate.
name1of new section.
name2of new section.
copy_metaCopy additional meta data for a section (like template, base, depth and variables).
Returns
  • A duplicate of the existing section.
  • NULL on error.

Definition at line 697 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const* cf_section_filename ( CONF_SECTION const *  section)

Definition at line 3913 of file conffile.c.

+ Here is the caller graph for this function:

CONF_SECTION* cf_section_find_name2 ( CONF_SECTION const *  section,
char const *  name1,
char const *  name2 
)

Definition at line 3639 of file conffile.c.

+ Here is the call graph for this function:

CONF_SECTION* cf_section_find_next ( CONF_SECTION const *  section,
CONF_SECTION const *  subsection,
char const *  name1 
)

Definition at line 3836 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int cf_section_lineno ( CONF_SECTION const *  section)

Definition at line 3903 of file conffile.c.

+ Here is the caller graph for this function:

char const* cf_section_name ( CONF_SECTION const *  cs)

Return name2 if set, else name1.

Definition at line 3609 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const* cf_section_name1 ( CONF_SECTION const *  cs)

Definition at line 3592 of file conffile.c.

+ Here is the caller graph for this function:

char const* cf_section_name2 ( CONF_SECTION const *  cs)

Definition at line 3601 of file conffile.c.

+ Here is the caller graph for this function:

FR_TOKEN cf_section_name2_type ( CONF_SECTION const *  cs)

Definition at line 4148 of file conffile.c.

+ Here is the caller graph for this function:

int cf_section_parse ( CONF_SECTION cs,
void *  base,
CONF_PARSER const *  variables 
)

Parse a configuration section into user-supplied variables.

Parameters
csto parse.
basepointer to a struct to fill with data. Any buffers will also be talloced using this parent as a pointer.
variablesmappings between struct fields and CONF_ITEM s.
Returns
  • 0 on success.
  • -1 on general error.
  • -2 if a deprecated CONF_ITEM was found.

Definition at line 2234 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int cf_section_parse_pass2 ( CONF_SECTION ,
void *  base,
CONF_PARSER const *  variables 
)

+ Here is the caller graph for this function:

const CONF_PARSER* cf_section_parse_table ( CONF_SECTION cs)

Definition at line 4138 of file conffile.c.

+ Here is the caller graph for this function:

CONF_SECTION* cf_section_sub_find ( CONF_SECTION const *  cs,
char const *  name 
)

Find a sub-section in a section.

This finds ANY section having the same first name. The second name is ignored.

Definition at line 3708 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CONF_SECTION* cf_section_sub_find_name2 ( CONF_SECTION const *  ,
char const *  name1,
char const *  name2 
)

Find a CONF_SECTION with both names.

Definition at line 3728 of file conffile.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.

Definition at line 224 of file conffile.c.

+ Here is the caller graph for this function:

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

Definition at line 3629 of file conffile.c.

+ Here is the call graph for this function:

CONF_SECTION* cf_subsection_find_next ( CONF_SECTION const *  section,
CONF_SECTION const *  subsection,
char const *  name1 
)

Definition at line 3799 of file conffile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CONF_SECTION* cf_top_section ( CONF_SECTION cs)

Definition at line 1041 of file conffile.c.

+ Here is the caller graph for this function:

int dump_config ( CONF_SECTION const *  cs)

Variable Documentation

bool check_config

Definition at line 45 of file conffile.c.