SIP-router core :: Standalone Configuration File Parser. More...
#include "str.h"#include <stdio.h>

Go to the source code of this file.
Configuration flags.
More...Module: SIP-router core
See ConfigEngine
Definition in file cfg_parser.h.
| typedef struct cfg_option cfg_option_t |
This structure is used to map tokens to values or function calls. Arrays of such structures are typically provided by the caller of the parser.
| enum cfg_flags |
| CFG_EXTENDED_ALPHA |
Extended tokens can contain also delimiters, in addition to alpha-numeric characters, this is used on the righ side of assignments where no quotes are used. |
| CFG_CASE_SENSITIVE |
The parser performs case-insensitive comparisons of token strings by default. The parser will use case-sensitive comparison instead if this flag is set. |
| CFG_DEFAULT |
This is a flag that can be set in the last element of cfg_option arrays (this is the one with 0 as token name). When this flag is set then the value or parsing function of the element will be used for options that do not match any other element in the array. |
| CFG_PREFIX |
When this flag is set then the name of the options is a prefix and all options that have the same prefix will be matched by this entry. |
| CFG_STR_PKGMEM |
The result of cfg_parse_str_val will be in a buffer allocated by pkg_malloc, if the destination varaiable contains a pointer to a buffer already then it will be freed with pkg_free first. |
| CFG_STR_SHMMEM |
The result of cfg_parse_str_val will be in a buffer allocated by shm_malloc, if the destination variable contains a pointer to a buffer already then it will be freed with shm_free first. |
| CFG_STR_MALLOC |
The result of cfg_parse_str_val will be in a buffer allocated by malloc, if the destination variable contains a pointer to a buffer already then it will be freed with free first. |
| CFG_STR_STATIC |
The result of cfg_parse_str_val will be copied into a pre-allocated buffer with a fixed size, a pointer to str variable which contains the buffer and its size is passed to the function in parameter 'param'. |
Definition at line 45 of file cfg_parser.h.
| int cfg_get_token | ( | struct cfg_token * | token, | |
| struct cfg_parser * | st, | |||
| unsigned int | flags | |||
| ) |
Interface to the lexical scanner
Definition at line 311 of file cfg_parser.c.
References CFG_EXTENDED_ALPHA, cfg_parser::col, cfg_parser::file, IS_ALPHA, IS_DELIM, IS_WHITESPACE, _str::len, cfg_parser::line, PUSH, RETURN, _str::s, ST_A, ST_AE, ST_C, ST_CE, ST_E, ST_Q, ST_QE, ST_S, and cfg_token::val.
Referenced by cfg_parse_section().

| int cfg_parse_section | ( | void * | param, | |
| struct cfg_parser * | st, | |||
| unsigned int | flags | |||
| ) |
The function expects parameter param to be of type (str*). The result string is allocated using pkg_malloc and is zero terminated. To free the memory use pkg_free(((str*)param)->s)
Definition at line 539 of file cfg_parser.c.
References cfg_get_token(), CFG_STR_MALLOC, CFG_STR_PKGMEM, CFG_STR_SHMMEM, cfg_token::col, cfg_parser::col, cfg_parser::file, cfg_token::line, cfg_parser::line, and cfg_token::type.

| struct cfg_parser* cfg_parser_init | ( | str * | basedir, | |
| str * | filename | |||
| ) | [read] |
| basedir | - path to the config file name. If 0 the path (base directory) of the main ser.cfg file will be used, else basedir will be concatenated to the filename. It will be used only if filename is not an absolute path. | |
| filename | - config filename (can include path elements). |
Definition at line 624 of file cfg_parser.c.
References cfg_parser::col, cfg_parser::f, cfg_parser::file, get_abs_pathname(), _str::len, cfg_parser::line, _str::s, and STR_FMT.

1.7.1