Asterisk - The Open Source Telephony Project
21.4.1
|
Configuration Option-handling. More...
#include "asterisk.h"
#include <regex.h>
#include "asterisk/_private.h"
#include "asterisk/config.h"
#include "asterisk/config_options.h"
#include "asterisk/stringfields.h"
#include "asterisk/acl.h"
#include "asterisk/app.h"
#include "asterisk/frame.h"
#include "asterisk/xmldoc.h"
#include "asterisk/cli.h"
#include "asterisk/term.h"
#include "asterisk/format_cap.h"
Go to the source code of this file.
Data Structures | |
struct | aco_info_internal |
Bits of aco_info that shouldn't be assigned outside this file. More... | |
struct | aco_option |
struct | aco_type_internal |
Macros | |
#define | CONFIG_OPT_BUCKETS 53 |
#define | XMLDOC_STRICT 1 |
Functions | |
int | __aco_option_register (struct aco_info *info, const char *name, enum aco_matchtype matchtype, struct aco_type **types, const char *default_val, enum aco_option_type kind, aco_option_handler handler, unsigned int flags, unsigned int no_doc, size_t argc,...) |
register a config option More... | |
static int | acl_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default handler for ACLs. More... | |
static void | aco_deinit (void) |
void | aco_info_destroy (struct aco_info *info) |
Destroy an initialized aco_info struct. More... | |
int | aco_info_init (struct aco_info *info) |
Initialize an aco_info structure. More... | |
int | aco_init (void) |
struct ao2_container * | aco_option_container_alloc (void) |
Allocate a container to hold config options. | |
static struct aco_option * | aco_option_find (struct aco_type *type, const char *name) |
intptr_t | aco_option_get_argument (const struct aco_option *option, unsigned int position) |
Get the offset position for an argument within a config option. More... | |
unsigned int | aco_option_get_flags (const struct aco_option *option) |
Read the flags of a config option - useful when using a custom callback for a config option. More... | |
int | aco_option_register_deprecated (struct aco_info *info, const char *name, struct aco_type **types, const char *aliased_to) |
Register a deprecated (and aliased) config option. More... | |
void * | aco_pending_config (struct aco_info *info) |
Get pending config changes. More... | |
enum aco_process_status | aco_process_ast_config (struct aco_info *info, struct aco_file *file, struct ast_config *cfg) |
Process config info from an ast_config via options registered with an aco_info. More... | |
int | aco_process_category_options (struct aco_type *type, struct ast_config *cfg, const char *cat, void *obj) |
Parse each option defined in a config category. More... | |
enum aco_process_status | aco_process_config (struct aco_info *info, int reload) |
Process a config info via the options registered with an aco_info. More... | |
int | aco_process_var (struct aco_type *type, const char *cat, struct ast_variable *var, void *obj) |
Parse a single ast_variable and apply it to an object. More... | |
int | aco_set_defaults (struct aco_type *type, const char *category, void *obj) |
Set all default options of obj. More... | |
static int | apply_config (struct aco_info *info) |
static aco_option_handler | ast_config_option_default_handler (enum aco_option_type type) |
static int | bool_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for bools (ast_true/ast_false) More... | |
static int | boolflag_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for bools (ast_true/ast_false) that are stored as flags. More... | |
static regex_t * | build_regex (const char *text) |
static int | chararray_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default handler for character arrays. More... | |
static char * | cli_show_help (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static void | cli_show_module_options (struct ast_cli_args *a) |
static void | cli_show_module_type (struct ast_cli_args *a) |
static void | cli_show_module_types (struct ast_cli_args *a) |
static void | cli_show_modules (struct ast_cli_args *a) |
static int | codec_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for codec preferences/capabilities. More... | |
static char * | complete_config_module (const char *word) |
static char * | complete_config_option (const char *module, const char *option, const char *word) |
static char * | complete_config_type (const char *module, const char *word) |
static int | config_opt_cmp (void *obj, void *arg, int flags) |
static int | config_opt_hash (const void *obj, const int flags) |
static void | config_option_destroy (void *obj) |
static struct ast_str * | derive_category_text (enum aco_category_op category_match, const char *category) |
static int | double_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for doubles. More... | |
static int | find_option_cb (void *obj, void *arg, int flags) |
static struct ast_xml_doc_item * | find_xmldoc_option (struct ast_xml_doc_item *config_info, struct aco_type **types, const char *name) |
static struct ast_xml_doc_item * | find_xmldoc_type (struct ast_xml_doc_item *config_info, const char *name) |
static int | int_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for signed integers. More... | |
static int | internal_aco_type_category_check (struct aco_type *match, const char *category) |
static struct aco_type * | internal_aco_type_find (struct aco_file *file, struct ast_config *cfg, const char *category) |
static void | internal_file_types_destroy (struct aco_file *file) |
static enum aco_process_status | internal_process_ast_config (struct aco_info *info, struct aco_file *file, struct ast_config *cfg) |
static void | internal_type_destroy (struct aco_type *type) |
static int | internal_type_init (struct aco_type *type) |
static int | is_preload (struct aco_file *file, const char *cat) |
static int | link_option_to_types (struct aco_info *info, struct aco_type **types, struct aco_option *opt) |
static int | noop_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default handler for doing nothing. | |
static int | process_category (struct ast_config *cfg, struct aco_info *info, struct aco_file *file, const char *cat, int preload) |
static int | sockaddr_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default handler for ast_sockaddrs. More... | |
static int | stringfield_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for stringfields. More... | |
static int | timelen_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for timelen signed integers. More... | |
static int | uint_handler_fn (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Default option handler for unsigned integers. More... | |
static int | xmldoc_update_config_option (struct aco_type **types, const char *module, const char *name, const char *object_name, const char *default_value, unsigned int regex, enum aco_option_type type) |
static int | xmldoc_update_config_type (const char *module, const char *name, const char *category, const char *matchfield, const char *matchvalue, enum aco_category_op category_match) |
Variables | |
static char * | aco_option_type_string [] |
Value of the aco_option_type enum as strings. | |
static struct ast_cli_entry | cli_aco [] |
static struct ao2_container * | xmldocs |
Configuration Option-handling.
Definition in file config_options.c.
int __aco_option_register | ( | struct aco_info * | info, |
const char * | name, | ||
enum aco_matchtype | match_type, | ||
struct aco_type ** | types, | ||
const char * | default_val, | ||
enum aco_option_type | type, | ||
aco_option_handler | handler, | ||
unsigned int | flags, | ||
unsigned int | no_doc, | ||
size_t | argc, | ||
... | |||
) |
register a config option
info | The aco_info holding this module's config information |
name | The name of the option |
match_type | |
types | An array of valid option types for matching categories to the correct struct type |
default_val | The default value of the option in the same format as defined in a config file |
type | The option type (only for default handlers) |
handler | The handler function for the option (only for non-default types) |
flags | a type specific flags, stored in the option and available to the handler |
no_doc | if non-zero, this option should not have documentation |
argc | The number for variadic arguments |
... | field offsets to store for default handlers |
0 | success |
-1 | failure |
Definition at line 300 of file config_options.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_ref, and OPT_CUSTOM_T.
Referenced by __ast_sorcery_object_field_register(), and ast_sorcery_object_fields_register().
|
static |
Default handler for ACLs.
Definition at line 1549 of file config_options.c.
References ast_append_ha(), and ast_variable::value.
void aco_info_destroy | ( | struct aco_info * | info | ) |
Destroy an initialized aco_info struct.
info | The address of the aco_info struct to destroy |
Definition at line 910 of file config_options.c.
References aco_info::files.
Referenced by aco_info_init(), ast_ari_config_destroy(), ast_ari_config_init(), conf_destroy_config(), load_module(), sorcery_object_type_destructor(), stasis_cleanup(), and unload_module().
int aco_info_init | ( | struct aco_info * | info | ) |
Initialize an aco_info structure.
info | The address of an aco_info struct to initialize |
0 | Success |
non-zero | Failure |
Definition at line 877 of file config_options.c.
References aco_info_destroy(), ast_calloc, aco_type::category, aco_type::category_match, aco_info::files, aco_type::hidden, aco_info::hidden, aco_type::matchfield, aco_type::matchvalue, aco_info::module, aco_type::name, aco_type::type, and aco_file::types.
Referenced by __ast_sorcery_object_register(), ast_ari_config_init(), conf_load_config(), load_module(), and stasis_init().
int aco_init | ( | void | ) |
Provided by config_options.c
Definition at line 1428 of file config_options.c.
References ast_cli_register_multiple, ast_register_cleanup(), and ast_xmldoc_build_documentation().
intptr_t aco_option_get_argument | ( | const struct aco_option * | option, |
unsigned int | position | ||
) |
Get the offset position for an argument within a config option.
option | Pointer to the aco_option struct |
position | Argument number |
position | of the argument |
Definition at line 248 of file config_options.c.
Referenced by timeval_str2struct().
unsigned int aco_option_get_flags | ( | const struct aco_option * | option | ) |
Read the flags of a config option - useful when using a custom callback for a config option.
option | Pointer to the aco_option struct |
value | of the flags on the config option |
Definition at line 243 of file config_options.c.
Referenced by option_handler_parkedfeature().
int aco_option_register_deprecated | ( | struct aco_info * | info, |
const char * | name, | ||
struct aco_type ** | types, | ||
const char * | aliased_to | ||
) |
Register a deprecated (and aliased) config option.
info | A pointer to the aco_info struct |
name | The name of the deprecated option |
types | An array of valid option types for matching categories to the correct struct type |
aliased_to | The name of the option that this deprecated option matches to |
0 | Success |
-1 | Failure |
Definition at line 217 of file config_options.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, and ao2_ref.
void* aco_pending_config | ( | struct aco_info * | info | ) |
Get pending config changes.
info | An initialized aco_info |
NULL | error |
non-NULL | A pointer to the user-defined config object with un-applied changes |
Definition at line 103 of file config_options.c.
References aco_info_internal::pending.
Referenced by hepv3_config_pre_apply(), http_media_cache_config_pre_apply(), and prometheus_config_pre_apply().
enum aco_process_status aco_process_ast_config | ( | struct aco_info * | info, |
struct aco_file * | file, | ||
struct ast_config * | cfg | ||
) |
Process config info from an ast_config via options registered with an aco_info.
info | The aco_info to be used for handling the config |
file | The file attached to aco_info that the config represents |
cfg | A pointer to a loaded ast_config to parse |
ACO_PROCESS_OK | Success |
ACO_PROCESS_ERROR | Failure |
Definition at line 617 of file config_options.c.
References ACO_PROCESS_ERROR, ACO_PROCESS_OK, aco_file::filename, aco_info_internal::pending, aco_info::pre_apply_config, and aco_info::snapshot_alloc.
int aco_process_category_options | ( | struct aco_type * | type, |
struct ast_config * | cfg, | ||
const char * | cat, | ||
void * | obj | ||
) |
Parse each option defined in a config category.
type | The aco_type with the options for parsing |
cfg | The ast_config being parsed |
cat | The config category being parsed |
obj | The user-defined config object that will store the parsed config items |
0 | Success |
-1 | Failure |
Definition at line 805 of file config_options.c.
References aco_process_var(), and ast_variable::next.
enum aco_process_status aco_process_config | ( | struct aco_info * | info, |
int | reload | ||
) |
Process a config info via the options registered with an aco_info.
info | The config_options_info to be used for handling the config |
reload | Non-zero if this is for a reload. |
ACO_PROCESS_OK | Success |
ACO_PROCESS_ERROR | Failure |
ACO_PROCESS_UNCHANGED | No change due to unedited config file |
Definition at line 652 of file config_options.c.
References ACO_PROCESS_ERROR, ACO_PROCESS_OK, ACO_PROCESS_UNCHANGED, aco_set_defaults(), aco_file::alias, ast_config_destroy(), ast_config_load, ast_debug, aco_type::category, CONFIG_FLAG_FILEUNCHANGED, aco_file::filename, aco_info::files, aco_type::item_offset, aco_info::module, aco_info_internal::pending, aco_info::post_apply_config, aco_info::pre_apply_config, aco_info::snapshot_alloc, aco_type::type, and aco_file::types.
Referenced by conf_load_config(), conf_reload_config(), load_module(), process_config(), reload(), reload_module(), and stasis_init().
int aco_process_var | ( | struct aco_type * | type, |
const char * | cat, | ||
struct ast_variable * | var, | ||
void * | obj | ||
) |
Parse a single ast_variable and apply it to an object.
type | The aco_type associated with the object |
cat | The category to use |
var | A variable to apply to the object |
obj | A pointer to the object to be configured |
0 | Success |
-1 | Failure |
Definition at line 769 of file config_options.c.
References ao2_ref, ast_strdupa, ast_variable::file, ast_variable::name, aco_type::name, RAII_VAR, and ast_variable::value.
Referenced by aco_process_category_options(), and ast_sorcery_objectset_apply().
int aco_set_defaults | ( | struct aco_type * | type, |
const char * | category, | ||
void * | obj | ||
) |
Set all default options of obj.
type | The aco_type with the options |
category | The configuration category from which obj is being configured |
obj | The object being configured |
0 | Success |
-1 | Failure |
Definition at line 924 of file config_options.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_ref, ast_variables_destroy(), aco_type_internal::opts, and RAII_VAR.
Referenced by aco_process_config(), ast_sorcery_alloc(), conf_alloc(), and stasis_init().
|
static |
Default option handler for bools (ast_true/ast_false)
Definition at line 1586 of file config_options.c.
References ast_false(), ast_true(), and ast_variable::value.
|
static |
Default option handler for bools (ast_true/ast_false) that are stored as flags.
Definition at line 1597 of file config_options.c.
References ast_false(), ast_true(), and ast_variable::value.
|
static |
Default handler for character arrays.
Definition at line 1631 of file config_options.c.
References ast_copy_string(), and ast_variable::value.
|
static |
Default option handler for codec preferences/capabilities.
Definition at line 1560 of file config_options.c.
References ast_format_cap_update_by_allow_disallow(), and ast_variable::value.
|
static |
Default option handler for doubles.
Definition at line 1540 of file config_options.c.
References ast_parse_arg(), and ast_variable::value.
|
static |
Default option handler for signed integers.
Definition at line 1447 of file config_options.c.
References ast_parse_arg(), ast_variable::name, and ast_variable::value.
|
static |
Default handler for ast_sockaddrs.
Definition at line 1614 of file config_options.c.
References ast_parse_arg(), and ast_variable::value.
|
static |
Default option handler for stringfields.
Definition at line 1569 of file config_options.c.
References pool, and ast_variable::value.
|
static |
Default option handler for timelen signed integers.
Definition at line 1507 of file config_options.c.
References ast_parse_arg(), ast_variable::name, and ast_variable::value.
|
static |
Default option handler for unsigned integers.
Definition at line 1477 of file config_options.c.
References ast_parse_arg(), ast_variable::name, and ast_variable::value.
|
static |
Definition at line 1417 of file config_options.c.