45 #define CONFIG_OPT_BUCKETS 5 47 #define CONFIG_OPT_BUCKETS 53 106 ast_log(
LOG_ERROR,
"This may not be called without an initialized aco_info!\n");
174 if ((res = regcomp(regex, text, REG_EXTENDED | REG_ICASE | REG_NOSUB))) {
175 size_t len = regerror(res, regex,
NULL, 0);
177 regerror(res, regex, buf, len);
191 while ((type = types[idx++])) {
193 ast_log(
LOG_ERROR,
"Attempting to register option using uninitialized type\n");
245 return option->
flags;
250 return option->
args[position];
267 if (strcasecmp(iter->
name, name)) {
270 for (x = 0; types[x]; x++) {
272 if (!strcasecmp(types[x]->name, iter->
ref)) {
291 if (!strcasecmp(iter->
type,
"configObject") && !strcasecmp(iter->
name, name)) {
302 unsigned int no_doc,
size_t argc, ...)
313 if (!(types && types[0])) {
329 for (tmp = 0; tmp <
argc; tmp++) {
330 opt->
args[
tmp] = va_arg(ap,
size_t);
345 ast_log(
LOG_ERROR,
"No handler provided, and no default handler exists for type %u\n", opt->
type);
368 const char *
name = (flags &
OBJ_KEY) ? arg : opt2->name;
375 const char *
name = arg;
424 return strcasecmp(match->
category, category);
427 return !strcasecmp(match->
category, category);
430 while (*categories) {
431 if (!strcasecmp(*categories, category)) {
439 while (*categories) {
440 if (!strcasecmp(*categories, category)) {
457 for (x = 0, match = file->
types[x]; match; match = file->
types[++x]) {
473 }
else if (strcasecmp(val, match->
matchvalue)) {
493 if (!strcasecmp(cat, file->
preload[i])) {
517 if (!regexec(regex_skip, cat, 0,
NULL, 0)) {
553 if (!(new_item = type->
item_find(*field, cat))) {
581 if (
new && !
ao2_link(*field, new_item)) {
598 const char *cat =
NULL;
665 if (!(info->
files[0])) {
681 for (i = 0, match = file->
types[i]; match; match = file->
types[++i]) {
706 if (file->
alias && strcmp(file->
alias, filename)) {
707 filename = file->
alias;
730 if (file_count != 1) {
786 ast_log(
LOG_ERROR,
"BUG! Somehow a config option for %s/%s was created with no handler!\n", cat, var->
name);
792 ast_log(
LOG_ERROR,
"Config option '%s' of type '%s' is not completely documented and can not be set\n", var->
name, type->
name);
797 if (opt->
handler(opt, var, obj)) {
842 for (x = 0, t = file->
types[x]; t; t = file->
types[++x]) {
887 while ((file = info->
files[x++])) {
888 while ((type = file->
types[y++])) {
919 for (x = 0; info->
files[x]; x++) {
947 if (opt->
handler(opt, var, obj)) {
967 size_t wordlen = strlen(word);
973 if (!strncasecmp(word, cur->
name, wordlen)) {
991 size_t wordlen = strlen(word);
1002 if (!strcasecmp(cur->
type,
"configObject") && !strncasecmp(word, cur->
name, wordlen)) {
1018 size_t wordlen = strlen(word);
1029 if (!strcasecmp(cur->
type,
"configOption") && !strcasecmp(cur->
ref, option) && !strncasecmp(word, cur->
name, wordlen)) {
1043 #define XMLDOC_STRICT 1 1053 struct ast_xml_node *
type, *syntax, *matchinfo, *
tmp;
1057 if ((results =
ast_xmldoc_query(
"/docs/configInfo[@name='%s']/configFile/configObject[@name='%s']/syntax", module, name))) {
1061 if (!(results =
ast_xmldoc_query(
"/docs/configInfo[@name='%s']/configFile/configObject[@name='%s']", module, name))) {
1062 ast_log(
LOG_WARNING,
"Cannot update type '%s' in module '%s' because it has no existing documentation!\n", name, module);
1067 ast_log(
LOG_WARNING,
"Could not retrieve documentation for type '%s' in module '%s'\n", name, module);
1072 ast_log(
LOG_WARNING,
"Could not create syntax node for type '%s' in module '%s'\n", name, module);
1077 ast_log(
LOG_WARNING,
"Could not create matchInfo node for type '%s' in module '%s'\n", name, module);
1082 ast_log(
LOG_WARNING,
"Could not create category node for type '%s' in module '%s'\n", name, module);
1087 switch (category_match) {
1101 ast_log(
LOG_WARNING,
"Could not add %s attribute for type '%s' in module '%s'\n", matchfield, name, module);
1108 if (!config_info || !(config_type =
find_xmldoc_type(config_info, name))) {
1109 ast_log(
LOG_WARNING,
"Could not obtain XML documentation item for config type %s\n", name);
1114 ast_log(
LOG_WARNING,
"Could not update type '%s' with values from config type registration\n", name);
1129 struct ast_xml_node *option;
1133 if (!config_info || !(config_option =
find_xmldoc_option(config_info, types, name))) {
1134 ast_log(
LOG_ERROR,
"XML Documentation for option '%s' in modules '%s' not found!\n", name, module);
1138 if (!(results =
ast_xmldoc_query(
"/docs/configInfo[@name='%s']/configFile/configObject[@name='%s']/configOption[@name='%s']", module, object_name, name))) {
1139 ast_log(
LOG_WARNING,
"Could not find option '%s' with type '%s' in module '%s'\n", name, object_name, module);
1144 ast_log(
LOG_WARNING,
"Could not obtain results for option '%s' with type '%s' in module '%s'\n", name, object_name, module);
1152 ast_log(
LOG_WARNING,
"Could not update option '%s' with values from config option registration\n", name);
1175 ast_cli(a->
fd,
"The following modules have configuration information:\n");
1206 ast_cli(a->
fd,
"Configuration option types for %s:\n", tmp->
name);
1208 if (!strcasecmp(tmp->
type,
"configObject")) {
1222 char option_type[64];
1234 if (!strcasecmp(tmp->
type,
"configObject") && !strcasecmp(tmp->
name, a->
argv[4])) {
1253 ast_cli(a->
fd,
"Unknown configuration type %s\n", a->
argv[4]);
1260 if (!strcasecmp(tmp->
type,
"configOption") && !strcasecmp(tmp->
ref, a->
argv[4])) {
1274 char option_name[64];
1285 if (!strcasecmp(tmp->
type,
"configOption") && !strcasecmp(tmp->
ref, a->
argv[4]) && !strcasecmp(tmp->
name, a->
argv[5])) {
1317 e->
command =
"config show help";
1319 "Usage: config show help [<module> [<type> [<option>]]]\n" 1320 " Display detailed information about module configuration.\n" 1321 " * If nothing is specified, the modules that have\n" 1322 " configuration information are listed.\n" 1323 " * If <module> is specified, the configuration types\n" 1324 " for that module will be listed, along with brief\n" 1325 " information about that type.\n" 1326 " * If <module> and <type> are specified, detailed\n" 1327 " information about the type is displayed, as well\n" 1328 " as the available options.\n" 1329 " * If <module>, <type>, and <option> are specified,\n" 1330 " detailed information will be displayed about that\n" 1332 " NOTE: the help documentation is partially generated at run\n" 1333 " time when a module is loaded. If a module is not loaded,\n" 1334 " configuration help for that module may be incomplete.\n";
1400 int *field = (
int *)(obj + opt->
args[0]);
1430 unsigned int *field = (
unsigned int *)(obj + opt->
args[0]);
1461 int *field = (
int *)(obj + opt->
args[0]);
1493 double *field = (
double *)(obj + opt->
args[0]);
1540 unsigned int *field = (
unsigned int *)(obj + opt->
args[0]);
1551 unsigned int *flags_field = (
unsigned int *)(obj + opt->
args[0]);
1555 *flags_field |=
flag;
1557 *flags_field &= ~flag;
1585 char *field = (
char *)(obj + opt->
args[0]);
aco_type_item_pre_process item_pre_process
static struct aco_option * aco_option_find(struct aco_type *type, const char *name)
Type for default handler for ast_sockaddrs.
struct ast_variable * next
Type for default option handler for format capabilities.
int(* aco_option_handler)(const struct aco_option *opt, struct ast_variable *var, void *obj)
A callback function for handling a particular option.
aco_pre_apply_config pre_apply_config
int aco_info_init(struct aco_info *info)
Initialize an aco_info structure.
static int sockaddr_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default handler for ast_sockaddrs.
aco_type_item_find item_find
#define AST_CLI_DEFINE(fn, txt,...)
struct ao2_global_obj * global_obj
aco_option_handler handler
Asterisk main include file. File version handling, generic pbx functions.
static void cli_show_module_types(struct ast_cli_args *a)
static int chararray_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default handler for character arrays.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct aco_info_internal * internal
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
static void cli_show_module_type(struct ast_cli_args *a)
struct ast_xml_doc_item * next
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static void aco_deinit(void)
const ast_string_field ref
static int config_opt_cmp(void *obj, void *arg, int flags)
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...
int ast_cli_unregister(struct ast_cli_entry *e)
Unregisters a command or an array of commands.
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
struct aco_type_internal * internal
#define ao2_callback(c, flags, cb_fn, arg)
#define CONFIG_STATUS_FILEINVALID
static struct ast_cli_entry cli_aco[]
Structure for variables, used for configurations and for channel variables.
static pj_pool_t * pool
Global memory pool for configuration and timers.
aco_type_prelink item_prelink
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.
struct ao2_container * ast_xmldoc_build_documentation(const char *type)
Build the documentation for a particular source type.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
static int uint_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default option handler for unsigned integers.
Type for a default handler that should do nothing.
static regex_t * build_regex(const char *text)
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.
static enum aco_process_status internal_process_ast_config(struct aco_info *info, struct aco_file *file, struct ast_config *cfg)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
struct ast_xml_xpath_results * ast_xmldoc_query(const char *fmt,...)
Execute an XPath query on the loaded XML documentation.
static struct aco_type item
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static int codec_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default option handler for codec preferences/capabilities.
const char * ast_string_field
unsigned int doc_unavailable
#define ao2_alloc_options(data_size, destructor_fn, options)
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Type for default option handler for bools (ast_true/ast_false) that are stored in a flag...
#define ast_strdup(str)
A wrapper for strdup()
static char * complete_config_module(const char *word)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
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.
The representation of a single configuration file to be processed.
void ast_cli(int fd, const char *fmt,...)
Bits of aco_info that shouldn't be assigned outside this file.
static void cli_show_modules(struct ast_cli_args *a)
aco_matchtype
What kind of matching should be done on an option name.
Socket address structure.
static char * cli_show_help(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
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)
struct ast_xml_node * ast_xml_new_child(struct ast_xml_node *parent, const char *child_name)
Add a child node inside a passed parent node.
#define ast_strlen_zero(foo)
Type for a custom (user-defined) option handler.
static int is_preload(struct aco_file *file, const char *cat)
static char * complete_config_type(const char *module, const char *word)
Type for default option handler for character array strings.
internal representation of ACL entries In principle user applications would have no need for this...
Type for default option handler for bools (ast_true/ast_false)
Configuration File Parser.
struct ao2_container * opts
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)
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_config_load(filename, flags)
Load a config file.
static int noop_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default handler for doing nothing.
const ast_string_field type
enum aco_matchtype match_type
static int int_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default option handler for signed integers.
static int stringfield_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default option handler for stringfields.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
static struct ao2_container * xmldocs
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Type for default option handler for unsigned integers.
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.
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)
static aco_option_handler ast_config_option_default_handler(enum aco_option_type type)
static void internal_type_destroy(struct aco_type *type)
Access Control of various sorts.
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.
Asterisk internal frame definitions.
#define ao2_ref(o, delta)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
aco_process_status
Return values for the aco_process functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
static char * complete_config_option(const char *module, const char *option, const char *word)
#define ast_malloc(len)
A wrapper for malloc()
aco_type_item_alloc item_alloc
#define ast_variable_new(name, value, filename)
enum aco_category_op category_match
aco_option_type
The option types.
#define CONFIG_STATUS_FILEUNCHANGED
The config had not been edited and no changes applied.
Their was an error and no changes were applied.
struct ast_str * description
static int link_option_to_types(struct aco_info *info, struct aco_type **types, struct aco_option *opt)
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
static char * aco_option_type_string[]
Value of the aco_option_type enum as strings.
Configuration option-handling.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
struct aco_file * files[]
struct association categories[]
#define ao2_unlink(container, obj)
aco_post_apply_config post_apply_config
#define CONFIG_OPT_BUCKETS
Type for default option handler for bools (ast_true/ast_false)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ao2_iterator_next(iter)
enum aco_option_type type
static int find_option_cb(void *obj, void *arg, int flags)
void ast_xml_set_text(struct ast_xml_node *node, const char *content)
Set an element content string.
static int internal_aco_type_category_check(struct aco_type *match, const char *category)
const ast_string_field name
#define ast_calloc(num, len)
A wrapper for calloc()
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Type for default option handler for ACLs.
const char * ast_term_reset(void)
Returns the terminal reset code.
Type for default option handler for doubles.
static int timelen_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default option handler for timelen signed integers.
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
The config was processed and applied.
Asterisk XML Documentation API.
#define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data)
Prototypes for public functions only of internal interest,.
void ast_xml_xpath_results_free(struct ast_xml_xpath_results *results)
Free the XPath results.
#define ao2_find(container, arg, flags)
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.
int ast_xmldoc_regenerate_doc_item(struct ast_xml_doc_item *item)
Regenerate the documentation for a particular item.
Structure used to handle boolean flags.
static struct ast_xml_doc_item * find_xmldoc_option(struct ast_xml_doc_item *config_info, struct aco_type **types, const char *name)
#define ast_clear_flag(p, flag)
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
const char * skip_category
#define CONFIG_STATUS_FILEMISSING
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
static void cli_show_module_options(struct ast_cli_args *a)
#define ao2_global_obj_replace_unref(holder, obj)
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value)
Set an attribute to a node.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Type for default option handler for time length signed integers.
Standard Command Line Interface.
Type information about a category-level configurable object.
aco_snapshot_alloc snapshot_alloc
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
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.
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
static int internal_type_init(struct aco_type *type)
int aco_set_defaults(struct aco_type *type, const char *category, void *obj)
Set all default options of obj.
Type for default option handler for stringfields.
void * aco_pending_config(struct aco_info *info)
Get pending config changes.
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
Handy terminal functions for vt* terms.
int error(const char *format,...)
Struct that contains the XML documentation for a particular item. Note that this is an ao2 ref counte...
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.
static int apply_config(struct aco_info *info)
static int process_category(struct ast_config *cfg, struct aco_info *info, struct aco_file *file, const char *cat, int preload)
static int acl_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default handler for ACLs.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
struct aco_type * types[]
Type for default option handler for signed integers.
struct ao2_container * aco_option_container_alloc(void)
Allocate a container to hold config options.
static int double_handler_fn(const struct aco_option *opt, struct ast_variable *var, void *obj)
Default option handler for doubles.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
struct ast_xml_node * ast_xml_xpath_get_first_result(struct ast_xml_xpath_results *results)
Return the first result node of an XPath query.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
static int config_opt_hash(const void *obj, const int flags)
static struct ast_xml_doc_item * find_xmldoc_type(struct ast_xml_doc_item *config_info, const char *name)
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
aco_matchvalue_func matchfunc
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
static struct aco_type * internal_aco_type_find(struct aco_file *file, struct ast_config *cfg, const char *category)
struct ast_str * synopsis
static void internal_file_types_destroy(struct aco_file *file)
#define ao2_link(container, obj)
static void config_option_destroy(void *obj)