Asterisk - The Open Source Telephony Project
21.4.1
|
Configuration File Parser. More...
Go to the source code of this file.
Data Structures | |
struct | ast_config_engine |
Configuration engine structure, used to define realtime drivers. More... | |
struct | ast_variable |
Structure for variables, used for configurations and for channel variables. More... | |
Macros | |
#define | ast_category_new_anonymous() ast_category_new_dynamic("") |
Create a nameless category that is not backed by a file. | |
#define | ast_category_new_dynamic(name) ast_category_new(name, "", -1) |
Create a category that is not backed by a file. More... | |
#define | ast_config_load(filename, flags) ast_config_load2(filename, AST_MODULE, flags) |
Load a config file. More... | |
#define | ast_variable_list_append(head, new_var) ast_variable_list_append_hint(head, NULL, new_var) |
#define | ast_variable_new(name, value, filename) _ast_variable_new(name, value, filename, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
#define | CONFIG_STATUS_FILEINVALID (void *)-2 |
#define | CONFIG_STATUS_FILEMISSING (void *)0 |
#define | CONFIG_STATUS_FILEUNCHANGED (void *)-1 |
#define | CV_BOOL(__x, __dst) CV_F(__x, (__dst) = ast_true(__val) ) |
helper macros to assign the value to a BOOL, UINT, static string and dynamic string | |
#define | CV_DSTR(__x, __dst) CV_F(__x, ast_free(__dst); __dst = ast_strdup(__val)) |
#define | CV_END } while (0) |
close a variable parsing block | |
#define | CV_F(__pattern, __body) if (!strcasecmp((__var), __pattern)) { __body; break; } |
call a generic function if the name matches. | |
#define | CV_START(__in_var, __in_val) |
the macro to open a block for variable parsing More... | |
#define | CV_STR(__x, __dst) CV_F(__x, ast_copy_string(__dst, __val, sizeof(__dst))) |
#define | CV_STRFIELD(__x, __obj, __field) CV_F(__x, ast_string_field_set(__obj, __field, __val)) |
#define | CV_UINT(__x, __dst) CV_F(__x, (__dst) = strtoul(__val, NULL, 0) ) |
Typedefs | |
typedef int(* | config_hook_cb) (struct ast_config *cfg) |
Callback when configuration is updated. More... | |
typedef struct ast_config * | config_load_func(const char *database, const char *table, const char *configfile, struct ast_config *config, struct ast_flags flags, const char *suggested_include_file, const char *who_asked) |
typedef int | realtime_destroy(const char *database, const char *table, const char *keyfield, const char *entity, const struct ast_variable *fields) |
typedef struct ast_config * | realtime_multi_get(const char *database, const char *table, const struct ast_variable *fields) |
typedef int | realtime_require(const char *database, const char *table, va_list ap) |
Function pointer called to ensure database schema is properly configured for realtime use. More... | |
typedef int | realtime_store(const char *database, const char *table, const struct ast_variable *fields) |
typedef int | realtime_unload(const char *database, const char *table) |
Function pointer called to clear the database cache and free resources used for such. More... | |
typedef int | realtime_update(const char *database, const char *table, const char *keyfield, const char *entity, const struct ast_variable *fields) |
typedef int | realtime_update2(const char *database, const char *table, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields) |
typedef struct ast_variable * | realtime_var_get(const char *database, const char *table, const struct ast_variable *fields) |
Enumerations | |
enum | { CONFIG_FLAG_WITHCOMMENTS = (1 << 0), CONFIG_FLAG_FILEUNCHANGED = (1 << 1), CONFIG_FLAG_NOCACHE = (1 << 2), CONFIG_FLAG_NOREALTIME = (1 << 3) } |
enum | ast_parse_flags { PARSE_TYPE = 0x000f, PARSE_INT32 = 0x0001, PARSE_UINT32 = 0x0002, PARSE_DOUBLE = 0x0003, PARSE_TIMELEN = 0x0006, PARSE_ADDR = 0x000e, PARSE_INADDR = 0x000f, PARSE_DEFAULT = 0x0010, PARSE_IN_RANGE = 0x0020, PARSE_OUT_RANGE = 0x0040, PARSE_RANGE_DEFAULTS = 0x0080, PARSE_PORT_MASK = 0x0300, PARSE_PORT_IGNORE = 0x0100, PARSE_PORT_REQUIRE = 0x0200, PARSE_PORT_FORBID = 0x0300 } |
Support code to parse config file arguments. More... | |
enum | config_hook_flags { butt } |
Flags that affect the behaviour of config hooks. | |
enum | config_save_flags { CONFIG_SAVE_FLAG_NONE = (0), CONFIG_SAVE_FLAG_PRESERVE_EFFECTIVE_CONTEXT = (1 << 0) } |
enum | require_type { RQ_INTEGER1, RQ_UINTEGER1, RQ_INTEGER2, RQ_UINTEGER2, RQ_INTEGER3, RQ_UINTEGER3, RQ_INTEGER4, RQ_UINTEGER4, RQ_INTEGER8, RQ_UINTEGER8, RQ_CHAR, RQ_FLOAT, RQ_DATE, RQ_DATETIME } |
Types used in ast_realtime_require_field. | |
Functions | |
struct ast_variable * | _ast_variable_new (const char *name, const char *value, const char *filename, const char *file, const char *function, int lineno) |
void | ast_category_append (struct ast_config *config, struct ast_category *category) |
Appends a category to a config. More... | |
char * | ast_category_browse (struct ast_config *config, const char *prev_name) |
Browse categories. More... | |
struct ast_category * | ast_category_browse_filtered (struct ast_config *config, const char *category_name, struct ast_category *prev, const char *filter) |
Browse categories with filters. More... | |
struct ast_category * | ast_category_delete (struct ast_config *cfg, struct ast_category *cat) |
Delete a category. More... | |
void | ast_category_destroy (struct ast_category *cat) |
struct ast_variable * | ast_category_detach_variables (struct ast_category *cat) |
int | ast_category_empty (struct ast_category *category) |
Removes and destroys all variables in a category. More... | |
int | ast_category_exist (const struct ast_config *config, const char *category_name, const char *filter) |
Check for category duplicates. More... | |
struct ast_variable * | ast_category_first (struct ast_category *cat) |
given a pointer to a category, return the root variable. More... | |
struct ast_category * | ast_category_get (const struct ast_config *config, const char *category_name, const char *filter) |
Retrieve a category if it exists. More... | |
const char * | ast_category_get_name (const struct ast_category *category) |
Return the name of the category. More... | |
struct ast_str * | ast_category_get_templates (const struct ast_category *category) |
Return the template names this category inherits from. More... | |
int | ast_category_inherit (struct ast_category *existing, const struct ast_category *base) |
Applies base (template) to category. More... | |
int | ast_category_insert (struct ast_config *config, struct ast_category *cat, const char *match) |
Inserts new category. More... | |
int | ast_category_is_template (const struct ast_category *category) |
Check if category is a template. More... | |
struct ast_category * | ast_category_new (const char *name, const char *in_file, int lineno) |
Create a category. More... | |
struct ast_category * | ast_category_new_template (const char *name, const char *in_file, int lineno) |
Create a category making it a template. More... | |
void | ast_category_rename (struct ast_category *cat, const char *name) |
struct ast_variable * | ast_category_root (struct ast_config *config, char *cat) |
returns the root ast_variable of a config More... | |
int | ast_check_realtime (const char *family) |
Check if realtime engine is configured for family. More... | |
struct ast_config * | ast_config_copy (const struct ast_config *orig) |
Copies the contents of one ast_config into another. More... | |
void | ast_config_destroy (struct ast_config *cfg) |
Destroys a config. More... | |
int | ast_config_engine_deregister (struct ast_config_engine *del) |
Deregister config engine. More... | |
int | ast_config_engine_register (struct ast_config_engine *newconfig) |
Register config engine. More... | |
struct ast_category * | ast_config_get_current_category (const struct ast_config *cfg) |
Retrieve the current category name being built. More... | |
int | ast_config_hook_register (const char *name, const char *filename, const char *module, enum config_hook_flags flags, config_hook_cb hook) |
Register a config hook for a particular file and module. More... | |
void | ast_config_hook_unregister (const char *name) |
Unregister a config hook. More... | |
struct ast_config * | ast_config_internal_load (const char *configfile, struct ast_config *cfg, struct ast_flags flags, const char *suggested_incl_file, const char *who_asked) |
struct ast_config * | ast_config_load2 (const char *filename, const char *who_asked, struct ast_flags flags) |
Load a config file. More... | |
struct ast_config * | ast_config_new (void) |
Create a new base configuration structure. | |
const char * | ast_config_option (struct ast_config *cfg, const char *cat, const char *var) |
Retrieve a configuration variable within the configuration set. More... | |
void | ast_config_set_current_category (struct ast_config *cfg, const struct ast_category *cat) |
Set the category within the configuration as being current. More... | |
void | ast_config_sort_categories (struct ast_config *config, int descending, int(*comparator)(struct ast_category *p, struct ast_category *q)) |
Sorts categories in a config in the order of a numerical value contained within them. More... | |
int | ast_config_text_file_save (const char *filename, const struct ast_config *cfg, const char *generator) |
Save a config text file preserving the pre 13.2 behavior. More... | |
int | ast_config_text_file_save2 (const char *filename, const struct ast_config *cfg, const char *generator, uint32_t flags) |
Save a config text file. More... | |
int | ast_destroy_realtime (const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel |
Destroy realtime configuration. More... | |
int | ast_destroy_realtime_fields (const char *family, const char *keyfield, const char *lookup, const struct ast_variable *fields) |
Destroy realtime configuration. More... | |
struct ast_config_include * | ast_include_find (struct ast_config *conf, const char *included_file) |
struct ast_config_include * | ast_include_new (struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size) |
void | ast_include_rename (struct ast_config *conf, const char *from_file, const char *to_file) |
struct ast_variable * | ast_load_realtime (const char *family,...) attribute_sentinel |
struct ast_variable * | ast_load_realtime_all (const char *family,...) attribute_sentinel |
struct ast_variable * | ast_load_realtime_all_fields (const char *family, const struct ast_variable *fields) |
struct ast_variable * | ast_load_realtime_fields (const char *family, const struct ast_variable *fields) |
Retrieve realtime configuration. More... | |
struct ast_config * | ast_load_realtime_multientry (const char *family,...) attribute_sentinel |
Retrieve realtime configuration. More... | |
struct ast_config * | ast_load_realtime_multientry_fields (const char *family, const struct ast_variable *fields) |
Retrieve realtime configuration. More... | |
int | ast_parse_arg (const char *arg, enum ast_parse_flags flags, void *p_result,...) |
The argument parsing routine. More... | |
char * | ast_realtime_decode_chunk (char *chunk) |
Remove standard encoding from realtime values, which ensures that a semicolon embedded within a single value is not treated upon retrieval as multiple values. More... | |
int | ast_realtime_enabled (void) |
Check if there's any realtime engines loaded. | |
char * | ast_realtime_encode_chunk (struct ast_str **dest, ssize_t maxlen, const char *chunk) |
Encodes a chunk of data for realtime. More... | |
int | ast_realtime_is_mapping_defined (const char *family) |
Determine if a mapping exists for a given family. More... | |
int | ast_realtime_require_field (const char *family,...) attribute_sentinel |
Inform realtime what fields that may be stored. More... | |
int | ast_rq_is_int (require_type type) |
Check if require type is an integer type. | |
int | ast_store_realtime (const char *family,...) attribute_sentinel |
Create realtime configuration. More... | |
int | ast_store_realtime_fields (const char *family, const struct ast_variable *fields) |
Create realtime configuration. More... | |
int | ast_unload_realtime (const char *family) |
Release any resources cached for a realtime family. More... | |
int | ast_update2_realtime (const char *family,...) attribute_sentinel |
Update realtime configuration. More... | |
int | ast_update2_realtime_fields (const char *family, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields) |
Update realtime configuration. More... | |
int | ast_update_realtime (const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel |
Update realtime configuration. More... | |
int | ast_update_realtime_fields (const char *family, const char *keyfield, const char *lookup, const struct ast_variable *fields) |
Update realtime configuration. More... | |
void | ast_variable_append (struct ast_category *category, struct ast_variable *variable) |
struct ast_variable * | ast_variable_browse (const struct ast_config *config, const char *category_name) |
struct ast_variable * | ast_variable_browse_filtered (const struct ast_config *config, const char *category_name, const char *filter) |
Browse variables. More... | |
int | ast_variable_delete (struct ast_category *category, const char *variable, const char *match, const char *line) |
const char * | ast_variable_find (const struct ast_category *category, const char *variable) |
Gets a variable value from a specific category structure by name. More... | |
const char * | ast_variable_find_in_list (const struct ast_variable *list, const char *variable) |
Gets the value of a variable from a variable list by name. More... | |
const char * | ast_variable_find_last_in_list (const struct ast_variable *list, const char *variable) |
Gets the value of the LAST occurrence of a variable from a variable list. More... | |
const struct ast_variable * | ast_variable_find_variable_in_list (const struct ast_variable *list, const char *variable_name) |
Gets a variable from a variable list by name. More... | |
void | ast_variable_insert (struct ast_category *category, struct ast_variable *variable, const char *line) |
struct ast_variable * | ast_variable_list_append_hint (struct ast_variable **head, struct ast_variable *search_hint, struct ast_variable *new_var) |
Appends a variable list to the end of another list. More... | |
struct ast_variable * | ast_variable_list_from_quoted_string (const char *input, const char *item_separator, const char *name_value_separator, const char *quote_str) |
Parse a string into an ast_variable list. The reverse of ast_variable_list_join. More... | |
struct ast_variable * | ast_variable_list_from_string (const char *input, const char *item_separator, const char *name_value_separator) |
Parse a string into an ast_variable list. The reverse of ast_variable_list_join. More... | |
struct ast_str * | ast_variable_list_join (const struct ast_variable *head, const char *item_separator, const char *name_value_separator, const char *quote_char, struct ast_str **str) |
Join an ast_variable list with specified separators and quoted values. More... | |
int | ast_variable_list_replace (struct ast_variable **head, struct ast_variable *replacement) |
Replace a variable in the given list with a new value. More... | |
int | ast_variable_list_replace_variable (struct ast_variable **head, struct ast_variable *oldvar, struct ast_variable *newvar) |
Replace a variable in the given list with a new variable. More... | |
struct ast_variable * | ast_variable_list_sort (struct ast_variable *head) |
Performs an in-place sort on the variable list by ascending name. More... | |
int | ast_variable_lists_match (const struct ast_variable *left, const struct ast_variable *right, int exact_match) |
Tests 2 variable lists to see if they match. More... | |
const char * | ast_variable_retrieve (struct ast_config *config, const char *category, const char *variable) |
const char * | ast_variable_retrieve_filtered (struct ast_config *config, const char *category, const char *variable, const char *filter) |
Gets a variable by context and variable names. More... | |
int | ast_variable_update (struct ast_category *category, const char *variable, const char *value, const char *match, unsigned int object) |
Update variable value within a config. More... | |
void | ast_variables_destroy (struct ast_variable *var) |
Free variable list. More... | |
struct ast_variable * | ast_variables_dup (struct ast_variable *var) |
Duplicate variable list. More... | |
int | ast_variables_match (const struct ast_variable *left, const struct ast_variable *right) |
Tests 2 variable values to see if they match. More... | |
struct ast_variable * | ast_variables_reverse (struct ast_variable *var) |
Reverse a variable list. More... | |
int | register_config_cli (void) |
Exposed initialization method for core process. More... | |
Configuration File Parser.
Definition in file include/asterisk/config.h.
#define ast_category_new_dynamic | ( | name | ) | ast_category_new(name, "", -1) |
Create a category that is not backed by a file.
name | name of new category |
Definition at line 833 of file include/asterisk/config.h.
Referenced by config_ldap().
#define ast_config_load | ( | filename, | |
flags | |||
) | ast_config_load2(filename, AST_MODULE, flags) |
Load a config file.
filename | path of file to open. If no preceding '/' character, path is considered relative to AST_CONFIG_DIR |
flags | Optional flags: CONFIG_FLAG_WITHCOMMENTS - load the file with comments intact; CONFIG_FLAG_FILEUNCHANGED - check the file mtime and return CONFIG_STATUS_FILEUNCHANGED if the mtime is the same; or CONFIG_FLAG_NOCACHE - don't cache file mtime (main purpose of this option is to save memory on temporary files). |
Create a config structure from a given configuration file.
NULL | on error |
Definition at line 179 of file include/asterisk/config.h.
Referenced by aco_process_config(), advanced_options(), conf_exec(), forward_message(), handle_cli_dialplan_save(), load_config(), load_config_force(), load_module(), make_email_file(), message_range_and_existence_check(), notify_new_message(), parse_config(), pbx_load_users(), reload(), reload_followme(), reload_queue_rules(), reload_queues(), set_config(), vm_change_password(), vm_forwardoptions(), and vm_msg_snapshot_create().
#define CV_START | ( | __in_var, | |
__in_val | |||
) |
the macro to open a block for variable parsing
Definition at line 1278 of file include/asterisk/config.h.
Referenced by store_config_core().
typedef int(* config_hook_cb) (struct ast_config *cfg) |
Callback when configuration is updated.
cfg | A copy of the configuration that is being changed. This MUST be freed by the callback before returning. |
Definition at line 1114 of file include/asterisk/config.h.
typedef int realtime_require(const char *database, const char *table, va_list ap) |
Function pointer called to ensure database schema is properly configured for realtime use.
Definition at line 121 of file include/asterisk/config.h.
typedef int realtime_unload(const char *database, const char *table) |
Function pointer called to clear the database cache and free resources used for such.
Definition at line 127 of file include/asterisk/config.h.
anonymous enum |
Options for ast_config_load()
Definition at line 39 of file include/asterisk/config.h.
enum ast_parse_flags |
Support code to parse config file arguments.
The function ast_parse_arg() provides a generic interface to parse strings (e.g. numbers, network addresses and so on) in a flexible way, e.g. by doing proper error and bound checks, provide default values, and so on. The function (described later) takes a string as an argument, a set of flags to specify the result format and checks to perform, a pointer to the result, and optionally some additional arguments.
Definition at line 1159 of file include/asterisk/config.h.
enum config_save_flags |
Flags for ast_config_text_file_save2()
Enumerator | |
---|---|
CONFIG_SAVE_FLAG_PRESERVE_EFFECTIVE_CONTEXT |
Insure a context doesn't effectively change if a template changes (pre 13.2 behavior) |
Definition at line 52 of file include/asterisk/config.h.
static void ast_category_append | ( | struct ast_config * | config, |
struct ast_category * | category | ||
) |
Appends a category to a config.
config | which config to use |
category | category to insert |
Definition at line 2833 of file extconf.c.
References ast_category_append(), ast_config::last, ast_category::next, ast_category::prev, and ast_config::root.
Referenced by append_row_to_cfg(), ast_category_append(), ast_config_copy(), build_cfg(), config_ldap(), handle_updates(), process_text_line(), realtime_multi_curl(), realtime_multi_ldap(), and realtime_multi_odbc().
static char * ast_category_browse | ( | struct ast_config * | config, |
const char * | prev_name | ||
) |
Browse categories.
config | Which config structure you wish to "browse" |
prev_name | A pointer to a previous category name. |
This function is kind of non-intuitive in it's use. To begin, one passes NULL as the second argument. It will return a pointer to the string of the first category in the file. From here on after, one must then pass the previous usage's return value as the second pointer, and it will return a pointer to the category name afterwards.
a | category name on success |
NULL | on failure/no-more-categories |
Definition at line 3326 of file extconf.c.
References ast_category_browse(), ast_config::last_browse, ast_category::next, and ast_config::root.
Referenced by __queues_show(), ast_category_browse(), ast_cli_perms_init(), conf_exec(), find_queue_by_name_rt(), load_config(), load_indications(), load_realtime_rules(), parse_config(), pbx_load_users(), reload_followme(), reload_queue_rules(), reload_queues(), set_config(), test_config_validity(), and vm_change_password().
struct ast_category* ast_category_browse_filtered | ( | struct ast_config * | config, |
const char * | category_name, | ||
struct ast_category * | prev, | ||
const char * | filter | ||
) |
Browse categories with filters.
config | Which config structure you wish to "browse" |
category_name | An optional category name. Pass NULL to not restrict by category name. |
prev | A pointer to the starting category structure. Pass NULL to start at the beginning. |
filter | An optional comma-separated list of <name_regex>=<value_regex> pairs. Only categories with matching variables will be returned. The special name 'TEMPLATES' can be used with the special values 'include' or 'restrict' to include templates in the result or restrict the result to only templates. |
a | category on success |
NULL | on failure/no-more-categories |
Definition at line 1424 of file main/config.c.
References ast_category::next, and ast_config::root.
Referenced by ast_variable_retrieve_filtered(), handle_updates(), and object_type_loaded_observer().
struct ast_category* ast_category_delete | ( | struct ast_config * | cfg, |
struct ast_category * | cat | ||
) |
Delete a category.
cfg | which config to use |
cat | category to delete |
Definition at line 1567 of file main/config.c.
References ast_config::last, ast_config::last_browse, ast_category::next, ast_category::prev, and ast_config::root.
Referenced by handle_updates(), and object_type_loaded_observer().
int ast_category_empty | ( | struct ast_category * | category | ) |
Removes and destroys all variables in a category.
category | category to empty |
0 | if succeeded |
-1 | if category is NULL |
Definition at line 1599 of file main/config.c.
References ast_variables_destroy(), ast_category::last, and ast_category::root.
Referenced by handle_updates().
int ast_category_exist | ( | const struct ast_config * | config, |
const char * | category_name, | ||
const char * | filter | ||
) |
Check for category duplicates.
config | which config to use |
category_name | name of the category you're looking for |
filter | an optional comma-separated list of <name_regex>=<value_regex> pairs. Only categories with matching variables will be returned. The special name 'TEMPLATES' can be used with the special values 'include' or 'restrict' to include templates in the result or restrict the result to only templates. |
This will search through the categories within a given config file for a match.
Definition at line 1150 of file main/config.c.
References ast_category_get().
struct ast_variable* ast_category_first | ( | struct ast_category * | cat | ) |
given a pointer to a category, return the root variable.
This is equivalent to ast_variable_browse(), but more efficient if we already have the struct ast_category * (e.g. from ast_category_get())
return the first var of a category
Definition at line 1246 of file main/config.c.
References ast_category::root.
Referenced by object_type_loaded_observer(), process_text_line(), sorcery_is_criteria_met(), and sorcery_is_explicit_name_met().
struct ast_category* ast_category_get | ( | const struct ast_config * | config, |
const char * | category_name, | ||
const char * | filter | ||
) |
Retrieve a category if it exists.
config | which config to use |
category_name | name of the category you're looking for |
filter | If a config contains more than 1 category with the same name, you can specify a filter to narrow the search. The filter is a comma-separated list of <name_regex>=<value_regex> pairs. Only a category with matching variables will be returned. The special name 'TEMPLATES' can be used with the special values 'include' or 'restrict' to include templates in the result or restrict the result to only templates. |
This will search through the categories within a given config file for a match.
pointer | to category if found |
NULL | if not. |
Definition at line 1111 of file main/config.c.
Referenced by ast_category_exist(), ast_category_root(), handle_updates(), object_type_loaded_observer(), vm_change_password(), and vm_forwardoptions().
const char* ast_category_get_name | ( | const struct ast_category * | category | ) |
Return the name of the category.
category | category structure |
pointer | to category name if found |
NULL | if not. |
Definition at line 1117 of file main/config.c.
Referenced by object_type_loaded_observer(), and sorcery_is_explicit_name_met().
struct ast_str* ast_category_get_templates | ( | const struct ast_category * | category | ) |
Return the template names this category inherits from.
category | category structure |
Definition at line 1127 of file main/config.c.
References AST_LIST_EMPTY, AST_LIST_TRAVERSE, ast_str_append(), ast_str_create, and ast_category::next.
int ast_category_inherit | ( | struct ast_category * | existing, |
const struct ast_category * | base | ||
) |
Applies base (template) to category.
existing | existing category |
base | base category |
This function is used to apply a base (template) to an existing category
0 | if succeeded |
-1 | if the memory allocation failed |
Definition at line 1456 of file main/config.c.
References ast_calloc, AST_LIST_INSERT_TAIL, ast_variable::inherited, ast_variable::next, ast_category::next, and ast_category::root.
Referenced by handle_updates(), and process_text_line().
int ast_category_insert | ( | struct ast_config * | config, |
struct ast_category * | cat, | ||
const char * | match | ||
) |
Inserts new category.
config | which config to use |
cat | newly created category to insert |
match | which category to insert above |
This function is used to insert a new category above another category matching the match parameter.
0 | if succeeded |
-1 | if the specified match category wasn't found |
Definition at line 1172 of file main/config.c.
References ast_category::next, ast_category::prev, and ast_config::root.
Referenced by handle_updates().
int ast_category_is_template | ( | const struct ast_category * | category | ) |
Check if category is a template.
category | category structure |
1 | if a template. |
0 | if not. |
Definition at line 1122 of file main/config.c.
References ast_category::ignored.
static struct ast_category * ast_category_new | ( | const char * | name, |
const char * | in_file, | ||
int | lineno | ||
) |
Create a category.
name | name of new category |
in_file | filename which contained the new config |
lineno | line number |
Definition at line 2788 of file extconf.c.
References ast_calloc, ast_category_new(), ast_copy_string(), and ast_category::file.
Referenced by ast_category_new(), ast_config_copy(), build_cfg(), handle_updates(), and process_text_line().
struct ast_category* ast_category_new_template | ( | const char * | name, |
const char * | in_file, | ||
int | lineno | ||
) |
Create a category making it a template.
name | name of new template |
in_file | filename which contained the new config |
lineno | line number |
Definition at line 1084 of file main/config.c.
Referenced by handle_updates().
struct ast_variable* ast_category_root | ( | struct ast_config * | config, |
char * | cat | ||
) |
returns the root ast_variable of a config
config | pointer to an ast_config data structure |
cat | name of the category for which you want the root |
Definition at line 1251 of file main/config.c.
References ast_category_get(), and ast_category::root.
int ast_check_realtime | ( | const char * | family | ) |
Check if realtime engine is configured for family.
family | which family/config to be checked |
Definition at line 3530 of file main/config.c.
References ast_realtime_enabled(), and find_engine().
Referenced by __queues_show(), ast_named_acl_find(), copy_plain_file(), handle_voicemail_show_users(), leave_voicemail(), load_module(), load_realtime_rules(), manager_queues_status(), manager_queues_summary(), rename_file(), and vm_delete().
struct ast_config* ast_config_copy | ( | const struct ast_config * | orig | ) |
Copies the contents of one ast_config into another.
orig | the config to copy |
Definition at line 3246 of file main/config.c.
References ast_category_append(), ast_category_new(), ast_config_destroy(), ast_config_new(), ast_variables_dup(), ast_category::file, ast_category::last, ast_category::next, ast_category::root, and ast_config::root.
static void ast_config_destroy | ( | struct ast_config * | cfg | ) |
Destroys a config.
cfg | pointer to config data structure |
Free memory associated with a given config
Definition at line 1289 of file extconf.c.
References ast_config_destroy(), ast_variables_destroy(), ast_config::includes, ast_category::next, ast_category::root, and ast_config::root.
Referenced by __ast_sorcery_apply_config(), __queues_show(), aco_process_config(), advanced_options(), ast_cli_perms_init(), ast_config_copy(), ast_config_destroy(), ast_config_load2(), ast_init_logger_for_socket_console(), ast_load_realtime_multientry_fields(), build_cfg(), conf_exec(), find_load_queue_rt_friendly(), forward_message(), handle_cli_dialplan_save(), init_logger_chain(), load_config(), load_config_force(), load_indications(), load_module(), load_realtime_rules(), make_email_file(), message_range_and_existence_check(), notify_new_message(), object_type_loaded_observer(), parse_config(), pbx_load_users(), private_enum_init(), realtime_sqlite3_multi(), reload(), reload_followme(), reload_queue_rules(), reload_queues(), rtp_reload(), set_config(), vm_change_password(), vm_forwardoptions(), and vm_msg_snapshot_create().
int ast_config_engine_deregister | ( | struct ast_config_engine * | del | ) |
Deregister config engine.
0 | Always |
Definition at line 3173 of file main/config.c.
References ast_category::last, lock, and SCOPED_MUTEX.
Referenced by parse_config(), and unload_module().
int ast_config_engine_register | ( | struct ast_config_engine * | newconfig | ) |
Register config engine.
1 | Always |
Definition at line 3157 of file main/config.c.
References lock, and SCOPED_MUTEX.
Referenced by load_module().
struct ast_category * ast_config_get_current_category | ( | const struct ast_config * | cfg | ) |
Retrieve the current category name being built.
API for backend configuration engines while building a configuration set.
Definition at line 2781 of file extconf.c.
Referenced by config_text_file_load().
int ast_config_hook_register | ( | const char * | name, |
const char * | filename, | ||
const char * | module, | ||
enum config_hook_flags | flags, | ||
config_hook_cb | hook | ||
) |
Register a config hook for a particular file and module.
name | The name of the hook you are registering. |
filename | The file whose config you wish to hook into. |
module | The module that is reloading the config. This can be useful if multiple modules may possibly reload the same file, but you are only interested when a specific module reloads the file |
flags | Flags that affect the way hooks work. |
hook | The callback to be called when config is loaded. return 0 Success return -1 Unsuccess, also known as UTTER AND COMPLETE FAILURE |
Definition at line 4302 of file main/config.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_link, ao2_ref, and ast_strdup.
void ast_config_hook_unregister | ( | const char * | name | ) |
Unregister a config hook.
name | The name of the hook to unregister |
Definition at line 4274 of file main/config.c.
References ast_strdupa, OBJ_NODATA, OBJ_POINTER, and OBJ_UNLINK.
struct ast_config* ast_config_load2 | ( | const char * | filename, |
const char * | who_asked, | ||
struct ast_flags | flags | ||
) |
Load a config file.
filename | path of file to open. If no preceding '/' character, path is considered relative to AST_CONFIG_DIR |
who_asked | The module which is making this request. |
flags | Optional flags: CONFIG_FLAG_WITHCOMMENTS - load the file with comments intact; CONFIG_FLAG_FILEUNCHANGED - check the file mtime and return CONFIG_STATUS_FILEUNCHANGED if the mtime is the same; or CONFIG_FLAG_NOCACHE - don't cache file mtime (main purpose of this option is to save memory on temporary files). |
Create a config structure from a given configuration file.
NULL | on error |
Definition at line 3321 of file main/config.c.
References ast_config_destroy(), and ast_config_new().
Referenced by __ast_sorcery_apply_config(), ast_cli_perms_init(), ast_init_logger_for_socket_console(), init_logger_chain(), load_indications(), object_type_loaded_observer(), private_enum_init(), rtp_reload(), and set_config().
const char* ast_config_option | ( | struct ast_config * | cfg, |
const char * | cat, | ||
const char * | var | ||
) |
Retrieve a configuration variable within the configuration set.
Retrieves the named variable var
within category cat
of configuration set cfg
. If not found, attempts to retrieve the named variable var
from within category general.
var
, or NULL if not found. Definition at line 773 of file main/config.c.
Referenced by pbx_load_users().
void ast_config_set_current_category | ( | struct ast_config * | cfg, |
const struct ast_category * | cat | ||
) |
Set the category within the configuration as being current.
API for backend configuration engines while building a configuration set.
Definition at line 3362 of file extconf.c.
Referenced by process_text_line().
void ast_config_sort_categories | ( | struct ast_config * | config, |
int | descending, | ||
int(*)(struct ast_category *p, struct ast_category *q) | comparator | ||
) |
Sorts categories in a config in the order of a numerical value contained within them.
config | The config structure you wish to sort |
comparator | variable Which numerical value you wish to sort by |
descending | If true, we sort highest to lowest instead of lowest to highest |
This function will assume a value of 0 for any non-numerical strings and NULL fields.
Definition at line 1260 of file main/config.c.
References ast_category::next, and ast_config::root.
int ast_config_text_file_save | ( | const char * | filename, |
const struct ast_config * | cfg, | ||
const char * | generator | ||
) |
Save a config text file preserving the pre 13.2 behavior.
filename | Filename |
cfg | ast_config |
generator | generator |
0 | on success. |
-1 | on failure. |
Definition at line 2701 of file main/config.c.
References ast_config_text_file_save2(), and CONFIG_SAVE_FLAG_PRESERVE_EFFECTIVE_CONTEXT.
Referenced by vm_change_password(), and vm_forwardoptions().
int ast_config_text_file_save2 | ( | const char * | filename, |
const struct ast_config * | cfg, | ||
const char * | generator, | ||
uint32_t | flags | ||
) |
Save a config text file.
filename | Filename |
cfg | ast_config |
generator | generator |
flags | List of config_save_flags |
0 | on success. |
-1 | on failure. |
Definition at line 2725 of file main/config.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, ast_debug, ast_escape_semicolons(), AST_LIST_EMPTY, AST_LIST_LAST, AST_LIST_TRAVERSE, ast_variable::blanklines, ast_comment::cmt, CONFIG_SAVE_FLAG_PRESERVE_EFFECTIVE_CONTEXT, ast_config_include::exec, ast_config_include::exec_file, ast_variable::file, ast_category::file, ast_category::ignored, ast_config_include::include_location_file, ast_config_include::include_location_lineno, ast_config_include::included_file, ast_config::includes, ast_variable::inherited, ast_variable::name, ast_variable::next, ast_category::next, ast_config_include::next, ast_variable::object, ast_config_include::output, ast_category::root, ast_config::root, ast_variable::trailing, ast_category::trailing, and ast_variable::value.
Referenced by ast_config_text_file_save().
int ast_destroy_realtime | ( | const char * | family, |
const char * | keyfield, | ||
const char * | lookup, | ||
... | |||
) |
Destroy realtime configuration.
family | which family/config to be destroyed |
keyfield | which field to use as the key |
lookup | which value to look for in the key field to match the entry. |
This function is used to destroy an entry in realtime configuration space. Additional params are used as keys.
Definition at line 3776 of file main/config.c.
References ast_destroy_realtime_fields(), ast_variables_destroy(), and RAII_VAR.
Referenced by leave_voicemail(), and vm_delete().
int ast_destroy_realtime_fields | ( | const char * | family, |
const char * | keyfield, | ||
const char * | lookup, | ||
const struct ast_variable * | fields | ||
) |
Destroy realtime configuration.
family | which family/config to be destroyed |
keyfield | which field to use as the key |
lookup | which value to look for in the key field to match the entry. |
fields | fields themselves |
This function is used to destroy an entry in realtime configuration space. Additional params are used as keys.
Definition at line 3756 of file main/config.c.
References find_engine().
Referenced by ast_destroy_realtime().
struct ast_variable* ast_load_realtime_fields | ( | const char * | family, |
const struct ast_variable * | fields | ||
) |
Retrieve realtime configuration.
family | which family/config to lookup |
fields | which fields to lookup |
This will use builtin configuration backends to look up a particular entity in realtime and return a variable list of its parameters.
Definition at line 3471 of file main/config.c.
References ast_variable::next, ast_category::next, ast_category::prev, and ast_variable::value.
struct ast_config* ast_load_realtime_multientry | ( | const char * | family, |
... | |||
) |
Retrieve realtime configuration.
family | which family/config to lookup |
This will use builtin configuration backends to look up a particular entity in realtime and return a variable list of its parameters. Unlike the ast_load_realtime, this function can return more than one entry and is thus stored inside a traditional ast_config structure rather than just returning a linked list of variables.
NULL | Error or no results returned |
Definition at line 3622 of file main/config.c.
References ast_load_realtime_multientry_fields(), ast_variables_destroy(), and RAII_VAR.
Referenced by __queues_show(), conf_exec(), find_load_queue_rt_friendly(), load_module(), and load_realtime_rules().
struct ast_config* ast_load_realtime_multientry_fields | ( | const char * | family, |
const struct ast_variable * | fields | ||
) |
Retrieve realtime configuration.
family | which family/config to lookup |
fields | list of fields |
This will use builtin configuration backends to look up a particular entity in realtime and return a variable list of its parameters. Unlike the ast_load_realtime, this function can return more than one entry and is thus stored inside a traditional ast_config structure rather than just returning a linked list of variables.
NULL | Error or no results returned |
Definition at line 3596 of file main/config.c.
References ast_config_destroy(), find_engine(), and ast_config::root.
Referenced by ast_load_realtime_multientry().
int ast_parse_arg | ( | const char * | arg, |
enum ast_parse_flags | flags, | ||
void * | p_result, | ||
... | |||
) |
The argument parsing routine.
arg | the string to parse. It is not modified. |
flags | combination of ast_parse_flags to specify the return type and additional checks. |
p_result | pointer to the result. NULL is valid here, and can be used to perform only the validity checks. |
... | extra arguments are required according to flags. |
0 | in case of success, != 0 otherwise. |
result | returns the parsed value in case of success, the default value in case of error, or it is left unchanged in case of error and no default specified. Note that in certain cases (e.g. sockaddr_in, with multi-field return values) some of the fields in result may be changed even if an error occurs. |
Examples of use: ast_parse_arg("223", PARSE_INT32|PARSE_IN_RANGE, &a, -1000, 1000); returns 0, a = 223 ast_parse_arg("22345", PARSE_INT32|PARSE_IN_RANGE|PARSE_DEFAULT, &a, 9999, 10, 100); returns 1, a = 9999 ast_parse_arg("22345ssf", PARSE_UINT32|PARSE_IN_RANGE, &b, 10, 100); returns 1, b unchanged ast_parse_arg("12", PARSE_UINT32|PARSE_IN_RANGE|PARSE_RANGE_DEFAULTS, &a, 1, 10); returns 1, a = 10 ast_parse_arg("223", PARSE_TIMELEN|PARSE_IN_RANGE, &a, TIMELEN_SECONDS, -1000, 1000); returns 0, a = 1000 ast_parse_arg("223", PARSE_TIMELEN|PARSE_IN_RANGE, &a, TIMELEN_SECONDS, -1000, 250000); returns 0, a = 223000 ast_parse_arg("223", PARSE_TIMELEN|PARSE_IN_RANGE|PARSE_DEFAULT, &a, TIMELEN_SECONDS, 9999, -1000, 250000); returns 0, a = 9999 ast_parse_arg("www.foo.biz:44", PARSE_INADDR, &sa); returns 0, sa contains address and port ast_parse_arg("www.foo.biz", PARSE_INADDR|PARSE_PORT_REQUIRE, &sa); returns 1 because port is missing, sa contains address
The argument parsing routine.
Definition at line 3827 of file main/config.c.
References ast_app_parse_timelen(), ast_debug, ast_inet_ntoa(), ast_skip_blanks(), ast_sockaddr_parse(), ast_sockaddr_resolve_first_af(), ast_sockaddr_stringify(), ast_sockaddr_to_sin, and ast_strdupa.
Referenced by ast_tls_read_conf(), build_peer(), double_handler_fn(), int_handler_fn(), new_realtime_sqlite3_db(), realtime_peer(), rtp_reload(), set_config(), sockaddr_handler_fn(), timelen_handler_fn(), and uint_handler_fn().
char* ast_realtime_decode_chunk | ( | char * | chunk | ) |
Remove standard encoding from realtime values, which ensures that a semicolon embedded within a single value is not treated upon retrieval as multiple values.
chunk | Data to be decoded |
Definition at line 3795 of file main/config.c.
char* ast_realtime_encode_chunk | ( | struct ast_str ** | dest, |
ssize_t | maxlen, | ||
const char * | chunk | ||
) |
Encodes a chunk of data for realtime.
dest | Destination buffer |
maxlen | Length passed through to ast_str_* functions |
chunk | Source data to be encoded |
Definition at line 3807 of file main/config.c.
References ast_str_append(), ast_str_buffer(), ast_str_reset(), and ast_str_set().
int ast_realtime_is_mapping_defined | ( | const char * | family | ) |
Determine if a mapping exists for a given family.
family | which family you are looking to see if a mapping exists for |
1 | if it is mapped |
0 | if it is not |
Definition at line 3193 of file main/config.c.
References ast_debug, lock, ast_config_map::name, and SCOPED_MUTEX.
Referenced by ast_named_acl_find().
int ast_realtime_require_field | ( | const char * | family, |
... | |||
) |
Inform realtime what fields that may be stored.
family | which family/config is referenced |
This will inform builtin configuration backends that particular fields may be updated during the use of that configuration section. This is mainly to be used during startup routines, to ensure that various fields exist in the backend. The backends may take various actions, such as creating new fields in the data store or warning the administrator that new fields may need to be created, in order to ensure proper function.
The arguments are specified in groups of 3: column name, column type, and column size. The column types are specified as integer constants, defined by the enum require_type. Note that the size is specified as the number of equivalent character fields that a field may take up, even if a field is otherwise specified as an integer type. This is due to the fact that some fields have historically been specified as character types, even if they contained integer values.
A family should always specify its fields to the minimum necessary requirements to fulfill all possible values (within reason; for example, a timeout value may reasonably be specified as an INTEGER2, with size 5. Even though values above 32767 seconds are possible, they are unlikely to be useful, and we should not complain about that size).
0 | Required fields met specified standards |
-1 | One or more fields was missing or insufficient |
TODO The return value of this function is routinely ignored. Ignoring the return value means that it's mostly pointless to be calling this. You'll see some warning messages potentially, but that's it.
XXX This function is super useful for detecting configuration problems early, but unfortunately, the latest in configuration management, sorcery, doesn't work well with this. Users of sorcery are familiar with the fields they will need to write but don't know if realtime is being used. Sorcery knows what storage mechanism is being used but has no high-level knowledge of what sort of data is going to be written.
Definition at line 3549 of file main/config.c.
References find_engine().
Referenced by change_password_realtime(), and load_module().
int ast_store_realtime | ( | const char * | family, |
... | |||
) |
Create realtime configuration.
family | which family/config to be created |
This function is used to create a parameter in realtime configuration space.
Definition at line 3740 of file main/config.c.
References ast_store_realtime_fields(), ast_variables_destroy(), and RAII_VAR.
Referenced by copy_plain_file(), and leave_voicemail().
int ast_store_realtime_fields | ( | const char * | family, |
const struct ast_variable * | fields | ||
) |
Create realtime configuration.
family | which family/config to be created |
fields | fields themselves |
This function is used to create a parameter in realtime configuration space.
Definition at line 3719 of file main/config.c.
References find_engine().
Referenced by ast_store_realtime().
int ast_unload_realtime | ( | const char * | family | ) |
Release any resources cached for a realtime family.
family | which family/config to destroy |
Various backends may cache attributes about a realtime data storage facility; on reload, a front end resource may request to purge that cache.
0 | If any cache was purged |
-1 | If no cache was found |
Definition at line 3576 of file main/config.c.
References find_engine().
Referenced by load_config_force(), and set_config().
int ast_update2_realtime | ( | const char * | family, |
... | |||
) |
Update realtime configuration.
family | which family/config to be updated |
This function is used to update a parameter in realtime configuration space. It includes the ability to lookup a row based upon multiple key criteria. As a result, this function includes two sentinel values, one to terminate lookup values and the other to terminate the listing of fields to update.
Definition at line 3695 of file main/config.c.
References ast_update2_realtime_fields(), ast_variables_destroy(), and RAII_VAR.
Referenced by change_password_realtime().
int ast_update2_realtime_fields | ( | const char * | family, |
const struct ast_variable * | lookup_fields, | ||
const struct ast_variable * | update_fields | ||
) |
Update realtime configuration.
family | which family/config to be updated |
lookup_fields | fields used to look up entries |
update_fields | fields to update |
This function is used to update a parameter in realtime configuration space. It includes the ability to lookup a row based upon multiple key criteria. As a result, this function includes two sentinel values, one to terminate lookup values and the other to terminate the listing of fields to update.
Definition at line 3675 of file main/config.c.
References find_engine().
Referenced by ast_update2_realtime().
int ast_update_realtime | ( | const char * | family, |
const char * | keyfield, | ||
const char * | lookup, | ||
... | |||
) |
Update realtime configuration.
family | which family/config to be updated |
keyfield | which field to use as the key |
lookup | which value to look for in the key field to match the entry. |
This function is used to update a parameter in realtime configuration space.
Definition at line 3659 of file main/config.c.
References ast_update_realtime_fields(), ast_variables_destroy(), and RAII_VAR.
Referenced by leave_voicemail(), and rename_file().
int ast_update_realtime_fields | ( | const char * | family, |
const char * | keyfield, | ||
const char * | lookup, | ||
const struct ast_variable * | fields | ||
) |
Update realtime configuration.
family | which family/config to be updated |
keyfield | which field to use as the key |
lookup | which value to look for in the key field to match the entry. |
fields | fields to update |
This function is used to update a parameter in realtime configuration space.
Definition at line 3638 of file main/config.c.
References find_engine().
Referenced by ast_update_realtime().
struct ast_variable* ast_variable_browse_filtered | ( | const struct ast_config * | config, |
const char * | category_name, | ||
const char * | filter | ||
) |
Browse variables.
config | Which config structure you wish to "browse" |
category_name | Which category to "browse" |
filter | an optional comma-separated list of <name_regex>=<value_regex> pairs. Only categories with matching variables will be browsed. The special name 'TEMPLATES' can be used with the special values 'include' or 'restrict' to include templates in the result or restrict the result to only templates. |
Somewhat similar in intent as the ast_category_browse. List variables of config file category
ast_variable | list on success |
NULL | on failure |
const char* ast_variable_find | ( | const struct ast_category * | category, |
const char * | variable | ||
) |
Gets a variable value from a specific category structure by name.
category | category structure under which the variable lies |
variable | which variable you wish to get the data for |
Goes through a given category and searches for the given variable
The | variable value on success |
NULL | if unable to find it. |
Definition at line 824 of file main/config.c.
References ast_variable_find_in_list(), and ast_category::root.
Referenced by ast_variable_retrieve_filtered().
const char* ast_variable_find_in_list | ( | const struct ast_variable * | list, |
const char * | variable | ||
) |
Gets the value of a variable from a variable list by name.
list | variable list to search |
variable | which variable you wish to get the data for |
Goes through a given variable list and searches for the given variable
The | variable value on success |
NULL | if unable to find it. |
Definition at line 919 of file main/config.c.
References ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by ast_sorcery_changeset_create(), and ast_variable_find().
const char* ast_variable_find_last_in_list | ( | const struct ast_variable * | list, |
const char * | variable | ||
) |
Gets the value of the LAST occurrence of a variable from a variable list.
list | The ast_variable list to search |
variable | The name of the ast_variable you wish to fetch data for |
Iterates over a given ast_variable list to search for the last occurrence of an ast_variable entry with a name attribute matching the given name (variable). This is useful if the list has duplicate entries (such as in cases where entries are created by a template)
The | variable value on success |
NULL | if unable to find it. |
Definition at line 931 of file main/config.c.
References ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by is_variable_true().
const struct ast_variable* ast_variable_find_variable_in_list | ( | const struct ast_variable * | list, |
const char * | variable_name | ||
) |
Gets a variable from a variable list by name.
list | variable list to search |
variable_name | name you wish to get the data for |
Goes through a given variable list and searches for the given variable
The | variable (not the value) on success |
NULL | if unable to find it. |
Definition at line 829 of file main/config.c.
References ast_variable::name, and ast_variable::next.
Referenced by ast_variable_lists_match().
struct ast_variable* ast_variable_list_append_hint | ( | struct ast_variable ** | head, |
struct ast_variable * | search_hint, | ||
struct ast_variable * | new_var | ||
) |
Appends a variable list to the end of another list.
head | A pointer to an ast_variable * of the existing variable list head. May NOT be NULL but the content may be to initialize a new list. If so, upon return, this parameter will be updated with a pointer to the new list head. |
search_hint | The place in the current list to start searching for the end of the list. Might help performance on longer lists. If NULL, it defaults to head. |
new_var | The head of the new variable list to be appended |
Definition at line 646 of file main/config.c.
References ast_variable::next.
Referenced by ast_json_to_ast_variables(), and ast_sorcery_objectset_create2().
struct ast_variable* ast_variable_list_from_quoted_string | ( | const char * | input, |
const char * | item_separator, | ||
const char * | name_value_separator, | ||
const char * | quote_str | ||
) |
Parse a string into an ast_variable list. The reverse of ast_variable_list_join.
input | The name-value pair string to parse. |
item_separator | The string used to separate the list items. Only the first character in the string will be used. If NULL, "," will be used. |
name_value_separator | The string used to separate each item's name and value. Only the first character in the string will be used. If NULL, "=" will be used. |
quote_str | The string used to quote values. Only the first character in the string will be used. If NULL, '"' will be used. |
A | pointer to a list of ast_variables. |
NULL | if there was an error or no variables could be parsed. |
Definition at line 726 of file main/config.c.
References ast_strdupa, ast_strip(), AST_STRSEP_ALL, ast_strsep_quoted(), and ast_variables_destroy().
Referenced by ast_variable_list_from_string().
struct ast_variable* ast_variable_list_from_string | ( | const char * | input, |
const char * | item_separator, | ||
const char * | name_value_separator | ||
) |
Parse a string into an ast_variable list. The reverse of ast_variable_list_join.
input | The name-value pair string to parse. |
item_separator | The string used to separate the list items. Only the first character in the string will be used. If NULL, "," will be used. |
name_value_separator | The string used to separate each item's name and value. Only the first character in the string will be used. If NULL, "=" will be used. |
A | pointer to a list of ast_variables. |
NULL | if there was an error or no variables could be parsed. |
Definition at line 767 of file main/config.c.
References ast_variable_list_from_quoted_string().
struct ast_str* ast_variable_list_join | ( | const struct ast_variable * | head, |
const char * | item_separator, | ||
const char * | name_value_separator, | ||
const char * | quote_char, | ||
struct ast_str ** | str | ||
) |
Join an ast_variable list with specified separators and quoted values.
head | A pointer to an ast_variable list head. |
item_separator | The string to use to separate the list items. If NULL, "," will be used. |
name_value_separator | The string to use to separate each item's name and value. If NULL, "=" will be used. |
str | A pointer to a pre-allocated ast_str in which to put the results. If NULL, one will be allocated and returned. |
quote_char | The quote char to use for the values. May be NULL or empty for no quoting. |
A | pointer to the result ast_str. This may NOT be the same as the pointer passed in if the original ast_str wasn't large enough to hold the result. Regardless, the pointer MUST be freed after use. |
NULL | if there was an error. |
Definition at line 700 of file main/config.c.
References AST_MAX_USER_FIELD, ast_str_append(), ast_str_create, ast_variable::name, ast_variable::next, S_OR, and ast_variable::value.
int ast_variable_list_replace | ( | struct ast_variable ** | head, |
struct ast_variable * | replacement | ||
) |
Replace a variable in the given list with a new value.
head | A pointer to an ast_variable * of the existing variable list head. May NOT be NULL but the content may be to initialize a new list. If so, upon return, this parameter will be updated with a pointer to the new list head. |
replacement | The variable that replaces another variable in the list with the same name. |
0 | if a variable was replaced in the list |
-1 | if no replacement occured |
Definition at line 667 of file main/config.c.
References ast_variable::name, and ast_variable::next.
Referenced by build_user(), and mkintf().
int ast_variable_list_replace_variable | ( | struct ast_variable ** | head, |
struct ast_variable * | oldvar, | ||
struct ast_variable * | newvar | ||
) |
Replace a variable in the given list with a new variable.
head | A pointer to the current variable list head. Since the variable to be replaced, this pointer may be updated with the new head. |
oldvar | A pointer to the existing variable to be replaced. |
newvar | A pointer to the new variable that will replace the old one. |
0 | if a variable was replaced in the list |
-1 | if no replacement occured |
Definition at line 683 of file main/config.c.
References ast_variable::next.
struct ast_variable* ast_variable_list_sort | ( | struct ast_variable * | head | ) |
Performs an in-place sort on the variable list by ascending name.
head | The variable list head |
Definition at line 620 of file main/config.c.
References ast_variable::name, and ast_variable::next.
int ast_variable_lists_match | ( | const struct ast_variable * | left, |
const struct ast_variable * | right, | ||
int | exact_match | ||
) |
Tests 2 variable lists to see if they match.
left | Variable list to test |
right | Variable list with an optional realtime-style operator in the names |
exact_match | If true, all variables in left must match all variables in right and vice versa. This does exact value matches only. Operators aren't supported. Except for order, the left and right lists must be equal. |
If false, every variable in the right list must match some variable in the left list using the operators supplied. Variables in the left list that aren't in the right list are ignored for matching purposes.
1 | matches |
0 | doesn't match |
Iterates over the variable lists calling ast_variables_match. If any match fails or a variable in the right list isn't in the left list, 0 is returned.
Definition at line 861 of file main/config.c.
References ast_strdup, ast_variable_find_variable_in_list(), ast_variables_match(), ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by object_type_loaded_observer(), and sorcery_astdb_retrieve_fields_common().
const char* ast_variable_retrieve_filtered | ( | struct ast_config * | config, |
const char * | category, | ||
const char * | variable, | ||
const char * | filter | ||
) |
Gets a variable by context and variable names.
config | which (opened) config to use |
category | category under which the variable lies |
variable | which variable you wish to get the data for |
filter | an optional comma-separated list of <name_regex>=<value_regex> pairs. Only categories with matching variables will be searched. The special name 'TEMPLATES' can be used with the special values 'include' or 'restrict' to include templates in the result or restrict the result to only templates. |
The | variable value on success |
NULL | if unable to find it. |
Definition at line 808 of file main/config.c.
References ast_category_browse_filtered(), and ast_variable_find().
int ast_variable_update | ( | struct ast_category * | category, |
const char * | variable, | ||
const char * | value, | ||
const char * | match, | ||
unsigned int | object | ||
) |
Update variable value within a config.
category | Category element within the config |
variable | Name of the variable to change |
value | New value of the variable |
match | If set, previous value of the variable (if NULL or zero-length, no matching will be done) |
object | Boolean of whether to make the new variable an object |
Definition at line 1533 of file main/config.c.
References ast_variable::file, ast_category::last, ast_variable::name, ast_variable::next, ast_category::root, and ast_variable::value.
Referenced by handle_updates(), process_text_line(), vm_change_password(), and vm_forwardoptions().
static void ast_variables_destroy | ( | struct ast_variable * | var | ) |
Free variable list.
var | the linked list of variables to free |
This function frees a list of variables.
Definition at line 1262 of file extconf.c.
References ast_variables_destroy(), and ast_variable::next.
Referenced by aco_set_defaults(), ast_aeap_client_configs_get(), ast_ari_asterisk_update_object(), ast_ari_channels_create(), ast_ari_channels_originate(), ast_ari_channels_originate_with_id(), ast_ari_endpoints_refer(), ast_ari_endpoints_refer_to_endpoint(), ast_ari_endpoints_send_message(), ast_ari_endpoints_send_message_to_endpoint(), ast_category_empty(), ast_config_destroy(), ast_destroy_realtime(), ast_http_get_cookies(), ast_http_manid_from_vars(), ast_json_to_ast_variables(), ast_load_realtime_multientry(), ast_sorcery_changeset_create(), ast_sorcery_copy(), ast_sorcery_diff(), ast_sorcery_object_set_extended(), ast_sorcery_objectset_apply(), ast_sorcery_objectset_json_create(), ast_store_realtime(), ast_stream_free(), ast_stream_get_metadata_list(), ast_update2_realtime(), ast_update_realtime(), ast_variable_list_from_quoted_string(), ast_variables_destroy(), ast_variables_dup(), copy_plain_file(), fields_handler(), find_load_queue_rt_friendly(), find_user_realtime(), generic_http_callback(), get_object_variables(), handle_showchan(), ldap_loadentry(), leave_queue(), mkintf(), object_type_loaded_observer(), queue_function_queuegetchannel(), queue_function_queuewaitingcount(), realtime_ldap_base(), realtime_ldap_base_ap(), realtime_ldap_result_to_vars(), realtime_odbc(), realtime_peer(), realtime_user(), row_to_varlist(), sorcery_astdb_filter_objectset(), sorcery_astdb_retrieve_fields_common(), sorcery_config_destructor(), sorcery_is_criteria_met(), sorcery_realtime_filter_objectset(), table_configs_free(), test_sorcery_object_destroy(), and test_sorcery_transform().
struct ast_variable* ast_variables_dup | ( | struct ast_variable * | var | ) |
Duplicate variable list.
var | the linked list of variables to clone |
Definition at line 543 of file main/config.c.
References ast_variables_destroy(), ast_variable::file, ast_variable::name, ast_variable::next, and ast_variable::value.
Referenced by ast_config_copy().
int ast_variables_match | ( | const struct ast_variable * | left, |
const struct ast_variable * | right | ||
) |
Tests 2 variable values to see if they match.
left | Variable to test |
right | Variable to match against with an optional realtime-style operator in the name |
1 | matches |
0 | doesn't match |
The values of the variables are passed to ast_strings_match. If right->name is suffixed with a space and an operator, that operator is also passed to ast_strings_match.
Examples:
left->name = "id" (ignored) left->value = "abc" right->name = "id regex" (id is ignored) right->value = "a[bdef]c"
will result in ast_strings_match("abc", "regex", "a[bdef]c") which will return 1.
left->name = "id" (ignored) left->value = "abc" right->name = "id" (ignored) right->value = "abc"
will result in ast_strings_match("abc", NULL, "abc") which will return 1.
See the documentation for ast_strings_match for the valid operators.
Definition at line 841 of file main/config.c.
References ast_strdupa, ast_strings_match(), ast_variable::name, and ast_variable::value.
Referenced by ast_variable_lists_match().
struct ast_variable* ast_variables_reverse | ( | struct ast_variable * | var | ) |
Reverse a variable list.
var | the linked list of variables to reverse |
Definition at line 565 of file main/config.c.
References ast_variable::next.
Referenced by astman_get_variables_order().
int register_config_cli | ( | void | ) |
Exposed initialization method for core process.
This method is intended for use only with the core initialization and is not designed to be called from any user applications.
Definition at line 4236 of file main/config.c.
References ast_cli_register_multiple, and ast_register_cleanup().