Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
|
Configuration option-handling. More...
Go to the source code of this file.
Data Structures | |
struct | aco_file |
The representation of a single configuration file to be processed. More... | |
struct | aco_info |
struct | aco_type |
Type information about a category-level configurable object. More... | |
Macros | |
#define | ACO_FILES(...) { __VA_ARGS__, NULL, } |
#define | aco_option_register(info, name, matchtype, types, default_val, opt_type, flags, ...) __aco_option_register(info, name, matchtype, types, default_val, opt_type, NULL, flags, 0, VA_NARGS(__VA_ARGS__), __VA_ARGS__); |
Register a config option. More... | |
#define | aco_option_register_custom(info, name, matchtype, types, default_val, handler, flags) __aco_option_register(info, name, matchtype, types, default_val, OPT_CUSTOM_T, handler, flags, 0, 0); |
Register a config option. More... | |
#define | aco_option_register_custom_nodoc(info, name, matchtype, types, default_val, handler, flags) __aco_option_register(info, name, matchtype, types, default_val, OPT_CUSTOM_T, handler, flags, 1, 0); |
Register a config option with no expected documentation. More... | |
#define | ACO_TYPES(...) { __VA_ARGS__, NULL, } |
A helper macro to ensure that aco_info types always have a sentinel. More... | |
#define | ARGIFY(...) __VA_ARGS__ |
Take a comma-separated list and allow it to be passed as a single argument to another macro. More... | |
#define | ARGMAP(func, func_arg, x, ...) ARGMAP_(VA_NARGS(x, ##__VA_ARGS__), func, func_arg, x, __VA_ARGS__) |
Map func(func_arg, field) across all fields including x. More... | |
#define | ARGMAP_(N, func, func_arg, x, ...) PASTE(ARGMAP_, N)(func, func_arg, N, x, __VA_ARGS__) |
#define | ARGMAP_1(func, func_arg, in, x, ...) ARGIFY(in, func(func_arg, x)) |
The individual field handlers for ARGMAP. More... | |
#define | ARGMAP_2(func, func_arg, in, x, ...) ARGMAP_1(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
#define | ARGMAP_3(func, func_arg, in, x, ...) ARGMAP_2(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
#define | ARGMAP_4(func, func_arg, in, x, ...) ARGMAP_3(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
#define | ARGMAP_5(func, func_arg, in, x, ...) ARGMAP_4(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
#define | ARGMAP_6(func, func_arg, in, x, ...) ARGMAP_5(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
#define | ARGMAP_7(func, func_arg, in, x, ...) ARGMAP_6(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
#define | ARGMAP_8(func, func_arg, in, x, ...) ARGMAP_7(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
#define | CHARFLDSET(type, field) ARGIFY(offsetof(type, field), sizeof(((type *)0)->field)) |
A helper macro to pass the appropriate arguments to aco_option_register for OPT_CHAR_ARRAY_T. More... | |
#define | CONFIG_INFO_CORE(mod, name, arr, alloc, ...) |
#define | CONFIG_INFO_STANDARD(name, arr, alloc, ...) |
Declare an aco_info struct with default module and preload values. More... | |
#define | CONFIG_INFO_TEST(name, arr, alloc, ...) |
#define | FLDSET(type, ...) FLDSET1(type, ##__VA_ARGS__) |
Convert a struct and list of fields to an argument list of field offsets. More... | |
#define | FLDSET1(type, ...) POPPED(ARGMAP(offsetof, type, ##__VA_ARGS__)) |
#define | PASTE(arg1, arg2) PASTE1(arg1, arg2) |
Paste two arguments together, even if they are macros themselves. More... | |
#define | PASTE1(arg1, arg2) arg1##arg2 |
#define | POPPED(...) POPPED1(__VA_ARGS__) |
A list of arguments without the first argument. More... | |
#define | POPPED1(x, ...) __VA_ARGS__ |
#define | STRFLDSET(type, ...) FLDSET(type, __VA_ARGS__, __field_mgr_pool, __field_mgr) |
Convert a struct and a list of stringfield fields to an argument list of field offsets. More... | |
#define | VA_NARGS(...) VA_NARGS1(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0) |
Results in the number of arguments passed to it. More... | |
#define | VA_NARGS1(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N |
Typedefs | |
typedef int(* | aco_matchvalue_func) (const char *text) |
A function for determining whether the value for the matchfield in an aco_type is sufficient for a match. More... | |
typedef int(* | aco_option_handler) (const struct aco_option *opt, struct ast_variable *var, void *obj) |
A callback function for handling a particular option. More... | |
typedef void(* | aco_post_apply_config) (void) |
A callback function called only if config changes have been applied. More... | |
typedef int(* | aco_pre_apply_config) (void) |
A callback function to run just prior to applying config changes. More... | |
typedef void *(* | aco_snapshot_alloc) (void) |
A callback function for allocating an object to hold all config objects. More... | |
typedef void *(* | aco_type_item_alloc) (const char *category) |
Allocate a configurable ao2 object. More... | |
typedef void *(* | aco_type_item_find) (struct ao2_container *newcontainer, const char *category) |
Find a item given a category and container of items. More... | |
typedef int(* | aco_type_item_pre_process) (void *newitem) |
Callback function that is called after a config object is initialized with defaults. More... | |
typedef int(* | aco_type_prelink) (void *newitem) |
Callback function that is called after config processing, but before linking. More... | |
Enumerations | |
enum | aco_category_op { ACO_BLACKLIST = 0 , ACO_WHITELIST , ACO_BLACKLIST_EXACT , ACO_WHITELIST_EXACT , ACO_BLACKLIST_ARRAY , ACO_WHITELIST_ARRAY } |
enum | aco_matchtype { ACO_EXACT = 1 , ACO_REGEX , ACO_PREFIX } |
What kind of matching should be done on an option name. More... | |
enum | aco_option_type { OPT_ACL_T , OPT_BOOL_T , OPT_BOOLFLAG_T , OPT_CHAR_ARRAY_T , OPT_CODEC_T , OPT_CUSTOM_T , OPT_DOUBLE_T , OPT_INT_T , OPT_NOOP_T , OPT_SOCKADDR_T , OPT_STRINGFIELD_T , OPT_UINT_T , OPT_YESNO_T , OPT_TIMELEN_T } |
The option types. More... | |
enum | aco_process_status { ACO_PROCESS_OK , ACO_PROCESS_UNCHANGED , ACO_PROCESS_ERROR } |
Return values for the aco_process functions. More... | |
enum | aco_type_t { ACO_GLOBAL , ACO_ITEM , ACO_IGNORE } |
Functions | |
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 More... | |
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... | |
struct ao2_container * | aco_option_container_alloc (void) |
Allocate a container to hold config options. More... | |
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... | |
Configuration option-handling.
Definition in file config_options.h.
#define ACO_FILES | ( | ... | ) | { __VA_ARGS__, NULL, } |
Definition at line 182 of file config_options.h.
#define aco_option_register | ( | info, | |
name, | |||
matchtype, | |||
types, | |||
default_val, | |||
opt_type, | |||
flags, | |||
... | |||
) | __aco_option_register(info, name, matchtype, types, default_val, opt_type, NULL, flags, 0, VA_NARGS(__VA_ARGS__), __VA_ARGS__); |
Register a config option.
info | A pointer to the aco_info struct |
name | The name of the option |
matchtype | |
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 |
opt_type | The option type for default option type handling |
flags | a type specific flags, stored in the option and available to the handler |
... |
0 | Success |
-1 | Failure |
Definition at line 623 of file config_options.h.
#define aco_option_register_custom | ( | info, | |
name, | |||
matchtype, | |||
types, | |||
default_val, | |||
handler, | |||
flags | |||
) | __aco_option_register(info, name, matchtype, types, default_val, OPT_CUSTOM_T, handler, flags, 0, 0); |
Register a config option.
info | A pointer to the aco_info struct |
name | The name of the option |
matchtype | |
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 |
handler | The handler callback for the option |
flags | type specific flags, stored in the option and available to the handler |
0 | Success |
-1 | Failure |
Definition at line 638 of file config_options.h.
#define aco_option_register_custom_nodoc | ( | info, | |
name, | |||
matchtype, | |||
types, | |||
default_val, | |||
handler, | |||
flags | |||
) | __aco_option_register(info, name, matchtype, types, default_val, OPT_CUSTOM_T, handler, flags, 1, 0); |
Register a config option with no expected documentation.
info | A pointer to the aco_info struct |
name | The name of the option |
matchtype | |
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 |
handler | The handler callback for the option |
flags | type specific flags, stored in the option and available to the handler |
0 | Success |
-1 | Failure |
Definition at line 656 of file config_options.h.
#define ACO_TYPES | ( | ... | ) | { __VA_ARGS__, NULL, } |
A helper macro to ensure that aco_info types always have a sentinel.
Definition at line 181 of file config_options.h.
#define ARGIFY | ( | ... | ) | __VA_ARGS__ |
Take a comma-separated list and allow it to be passed as a single argument to another macro.
Definition at line 754 of file config_options.h.
#define ARGMAP | ( | func, | |
func_arg, | |||
x, | |||
... | |||
) | ARGMAP_(VA_NARGS(x, ##__VA_ARGS__), func, func_arg, x, __VA_ARGS__) |
Map func(func_arg, field) across all fields including x.
func | The function (almost certainly offsetof) to map across the fields |
func_arg | The first argument (almost certainly a type (e.g. "struct mystruct") |
x | The first field |
... | varargs The rest of the fields |
Example usage:
produces the string:
which can be passed as the varargs to some other function
The macro isn't limited to offsetof, but that is the only purpose for which it has been tested.
As an example of how the processing works:
* ARGMAP(offsetof, struct foo, a, b, c) -> * ARGMAP_(3, offsetof, struct foo, a, b, c) -> * ARGMAP_3(offsetof, struct foo, 3, a, b, c) -> * ARGMAP_2(offsetof, struct foo, ARGIFY(3, offsetof(struct foo, a)), b, c) -> * ARGMAP_1(offsetof, struct foo, ARGIFY(3, offsetof(struct foo, a), offsetof(struct foo, b)), c) -> * ARGIFY(3, offsetof(struct foo, a), offsetof(struct foo, b), offsetof(struct foo, c)) -> * 3, offsetof(struct foo, a), offsetof(struct foo, b), offsetof(struct foo, c) *
Definition at line 738 of file config_options.h.
#define ARGMAP_ | ( | N, | |
func, | |||
func_arg, | |||
x, | |||
... | |||
) | PASTE(ARGMAP_, N)(func, func_arg, N, x, __VA_ARGS__) |
Definition at line 744 of file config_options.h.
The individual field handlers for ARGMAP.
func | The function (most likely offsetof) |
func_arg | The first argument to func (most likely a type e.g. "struct my_struct") |
in | The accumulated function-mapped field names so far |
x | The next field name |
... | varargs The rest of the field names |
Definition at line 763 of file config_options.h.
#define ARGMAP_2 | ( | func, | |
func_arg, | |||
in, | |||
x, | |||
... | |||
) | ARGMAP_1(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
Definition at line 764 of file config_options.h.
#define ARGMAP_3 | ( | func, | |
func_arg, | |||
in, | |||
x, | |||
... | |||
) | ARGMAP_2(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
Definition at line 766 of file config_options.h.
#define ARGMAP_4 | ( | func, | |
func_arg, | |||
in, | |||
x, | |||
... | |||
) | ARGMAP_3(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
Definition at line 768 of file config_options.h.
#define ARGMAP_5 | ( | func, | |
func_arg, | |||
in, | |||
x, | |||
... | |||
) | ARGMAP_4(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
Definition at line 770 of file config_options.h.
#define ARGMAP_6 | ( | func, | |
func_arg, | |||
in, | |||
x, | |||
... | |||
) | ARGMAP_5(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
Definition at line 772 of file config_options.h.
#define ARGMAP_7 | ( | func, | |
func_arg, | |||
in, | |||
x, | |||
... | |||
) | ARGMAP_6(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
Definition at line 774 of file config_options.h.
#define ARGMAP_8 | ( | func, | |
func_arg, | |||
in, | |||
x, | |||
... | |||
) | ARGMAP_7(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__) |
Definition at line 776 of file config_options.h.
A helper macro to pass the appropriate arguments to aco_option_register for OPT_CHAR_ARRAY_T.
type | The type with the char array field (e.g. "struct my_struct") |
field | The name of char array field |
Definition at line 835 of file config_options.h.
#define CONFIG_INFO_CORE | ( | mod, | |
name, | |||
arr, | |||
alloc, | |||
... | |||
) |
Definition at line 221 of file config_options.h.
#define CONFIG_INFO_STANDARD | ( | name, | |
arr, | |||
alloc, | |||
... | |||
) |
Declare an aco_info struct with default module and preload values.
name | The name of the struct |
arr | The global object array for holding the user-defined config object |
alloc | The allocater for the user-defined config object |
Example:
Definition at line 213 of file config_options.h.
#define CONFIG_INFO_TEST | ( | name, | |
arr, | |||
alloc, | |||
... | |||
) |
Definition at line 229 of file config_options.h.
Convert a struct and list of fields to an argument list of field offsets.
type | The type with the fields (e.g. "struct my_struct") |
... | varags The fields in the struct whose offsets are needed as arguments |
For example:
produces
Definition at line 816 of file config_options.h.
Definition at line 817 of file config_options.h.
#define PASTE | ( | arg1, | |
arg2 | |||
) | PASTE1(arg1, arg2) |
Paste two arguments together, even if they are macros themselves.
Definition at line 750 of file config_options.h.
#define PASTE1 | ( | arg1, | |
arg2 | |||
) | arg1##arg2 |
Definition at line 751 of file config_options.h.
#define POPPED | ( | ... | ) | POPPED1(__VA_ARGS__) |
A list of arguments without the first argument.
... | varags A list of arguments * POPPED(a, b, c) -> b, c * |
Definition at line 848 of file config_options.h.
#define POPPED1 | ( | x, | |
... | |||
) | __VA_ARGS__ |
Definition at line 849 of file config_options.h.
Convert a struct and a list of stringfield fields to an argument list of field offsets.
type | The type with the fields (e.g. "struct my_struct") |
... | varargs The fields in the struct whose offsets are needed as arguments |
Definition at line 827 of file config_options.h.
#define VA_NARGS | ( | ... | ) | VA_NARGS1(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0) |
Results in the number of arguments passed to it.
* VA_NARGS(one, two, three) -> v * VA_NARGS1(one, two, three, 8, 7, 6, 5, 4, 3, 2, 1, 0) -> * VA_NARGS1( _1, _2, _3, _4, _5, _6, _7, _8, N, ... ) N -> 3 * * Note that VA_NARGS *does not* work when there are no arguments passed. Pasting an empty * __VA_ARGS__ with a comma like ", ##__VA_ARGS__" will delete the leading comma, but it * does not work when __VA_ARGS__ is the first argument. Instead, 1 is returned instead of 0: * * VA_NARGS() -> v * VA_NARGS1( , 8, 7, 6, 5, 4, 3, 2, 1, 0) -> * VA_NARGS1(_1, _2, _3, _4, _5, _6, _7, _8, N) -> 1 *
Definition at line 797 of file config_options.h.
#define VA_NARGS1 | ( | _1, | |
_2, | |||
_3, | |||
_4, | |||
_5, | |||
_6, | |||
_7, | |||
_8, | |||
N, | |||
... | |||
) | N |
Definition at line 798 of file config_options.h.
typedef int(* aco_matchvalue_func) (const char *text) |
A function for determining whether the value for the matchfield in an aco_type is sufficient for a match.
text | The value of the option |
-1 | The value is sufficient for a match |
0 | The value is not sufficient for a match |
Definition at line 116 of file config_options.h.
typedef int(* aco_option_handler) (const struct aco_option *opt, struct ast_variable *var, void *obj) |
A callback function for handling a particular option.
opt | The option being configured |
var | The config variable to use to configure obj |
obj | The object to be configured |
0 | Parsing and recording the config value succeeded |
non-zero | Failure. Parsing should stop and no reload applied |
Definition at line 517 of file config_options.h.
typedef void(* aco_post_apply_config) (void) |
A callback function called only if config changes have been applied.
Definition at line 152 of file config_options.h.
typedef int(* aco_pre_apply_config) (void) |
A callback function to run just prior to applying config changes.
0 | Success |
non-zero | Failure. Changes not applied |
Definition at line 145 of file config_options.h.
typedef void *(* aco_snapshot_alloc) (void) |
A callback function for allocating an object to hold all config objects.
NULL | error |
non-NULL | a config object container |
Definition at line 158 of file config_options.h.
typedef void *(* aco_type_item_alloc) (const char *category) |
Allocate a configurable ao2 object.
Callback functions for option parsing via aco_process_config()
category | The config category the object is being generated for |
NULL | error |
non-NULL | a new configurable ao2 object |
Definition at line 76 of file config_options.h.
typedef void *(* aco_type_item_find) (struct ao2_container *newcontainer, const char *category) |
Find a item given a category and container of items.
newcontainer | The container to search for the item |
category | The category associated with the item |
non-NULL | item from the container |
NULL | item does not exist in container |
Definition at line 84 of file config_options.h.
typedef int(* aco_type_item_pre_process) (void *newitem) |
Callback function that is called after a config object is initialized with defaults.
newitem | The newly allocated config object with defaults populated |
0 | succes, continue processing |
non-zero | failure, stop processing |
Definition at line 97 of file config_options.h.
typedef int(* aco_type_prelink) (void *newitem) |
Callback function that is called after config processing, but before linking.
newitem | The newly configured object |
0 | success, continue processing |
non-zero | failure, stop processing |
Definition at line 109 of file config_options.h.
enum aco_category_op |
Type of category matching to perform
Definition at line 47 of file config_options.h.
enum aco_matchtype |
What kind of matching should be done on an option name.
Enumerator | |
---|---|
ACO_EXACT | |
ACO_REGEX | |
ACO_PREFIX |
Definition at line 63 of file config_options.h.
enum aco_option_type |
The option types.
Enumerator | |
---|---|
OPT_ACL_T | Type for default option handler for ACLs.
Example: struct test_item {
struct ast_ha *ha;
};
aco_option_register(&cfg_info, "permit", ACO_EXACT, my_types, NULL, OPT_ACL_T, 1, FLDSET(struct test_item, ha));
aco_option_register(&cfg_info, "deny", ACO_EXACT, my_types, NULL, OPT_ACL_T, 0, FLDSET(struct test_item, ha));
|
OPT_BOOL_T | Type for default option handler for bools (ast_true/ast_false)
Example: struct test_item {
int enabled;
};
aco_option_register(&cfg_info, "enabled", ACO_EXACT, my_types, "no", OPT_BOOL_T, 1, FLDSET(struct test_item, enabled));
|
OPT_BOOLFLAG_T | Type for default option handler for bools (ast_true/ast_false) that are stored in a flag.
Example: #define MY_TYPE_ISQUIET 1 << 4
struct test_item {
unsigned int flags;
};
aco_option_register(&cfg_info, "quiet", ACO_EXACT, my_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct test_item, flags), MY_TYPE_ISQUIET);
|
OPT_CHAR_ARRAY_T | Type for default option handler for character array strings.
Example: struct test_item {
char description[128];
};
aco_option_register(&cfg_info, "description", ACO_EXACT, my_types, "none", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct test_item, description));
|
OPT_CODEC_T | Type for default option handler for format capabilities.
Example: struct test_item {
struct ast_format cap *cap;
};
aco_option_register(&cfg_info, "allow", ACO_EXACT, my_types, "ulaw,alaw", OPT_CODEC_T, 1, FLDSET(struct test_item, cap));
aco_option_register(&cfg_info, "disallow", ACO_EXACT, my_types, "all", OPT_CODEC_T, 0, FLDSET(struct test_item, cap));
|
OPT_CUSTOM_T | Type for a custom (user-defined) option handler. |
OPT_DOUBLE_T | Type for default option handler for doubles.
Example: struct test_item { double dub; }; aco_option_register(&cfg_info, "doubleopt", ACO_EXACT, my_types, "3", OPT_DOUBLE_T, 0, FLDSET(struct test_item, dub));
|
OPT_INT_T | Type for default option handler for signed integers.
Example: struct test_item { int32_t intopt; }; aco_option_register(&cfg_info, "intopt", ACO_EXACT, my_types, "3", OPT_INT_T, PARSE_IN_RANGE, FLDSET(struct test_item, intopt), -10, 10);
|
OPT_NOOP_T | Type for a default handler that should do nothing.
|
OPT_SOCKADDR_T | Type for default handler for ast_sockaddrs.
Example: struct test_item {
struct ast_sockaddr addr;
};
aco_option_register(&cfg_info, "sockaddropt", ACO_EXACT, my_types, "0.0.0.0:1234", OPT_SOCKADDR_T, 0, FLDSET(struct test_item, addr));
|
OPT_STRINGFIELD_T | Type for default option handler for stringfields.
Example: struct test_item {
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(thing);
);
};
aco_option_register(&cfg_info, "thing", ACO_EXACT, my_types, NULL, OPT_STRINGFIELD_T, 0, STRFLDSET(struct test_item, thing));
|
OPT_UINT_T | Type for default option handler for unsigned integers.
Example: struct test_item { int32_t intopt; }; aco_option_register(&cfg_info, "uintopt", ACO_EXACT, my_types, "3", OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct test_item, uintopt), 1, 10);
|
OPT_YESNO_T | Type for default option handler for bools (ast_true/ast_false)
This is exactly the same as OPT_BOOL_T. The only difference is that when translated to a string, OPT_BOOL_T becomes "true" or "false"; OPT_YESNO_T becomes "yes" or "no". Example: struct test_item {
int enabled;
};
aco_option_register(&cfg_info, "enabled", ACO_EXACT, my_types, "no", OPT_YESNO_T, 1, FLDSET(struct test_item, enabled));
|
OPT_TIMELEN_T | Type for default option handler for time length signed integers.
Example: struct test_item { int timelen; }; aco_option_register(&cfg_info, "timelen", ACO_EXACT, my_types, "3", OPT_TIMELEN_T, PARSE_IN_RANGE, FLDSET(struct test_item, intopt), TIMELEN_MILLISECONDS, -10, 10);
|
Definition at line 259 of file config_options.h.
enum aco_process_status |
Return values for the aco_process functions.
Definition at line 524 of file config_options.h.
enum aco_type_t |
Enumerator | |
---|---|
ACO_GLOBAL | |
ACO_ITEM | |
ACO_IGNORE |
Definition at line 40 of file config_options.h.
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 ACO_REGEX, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, aco_option::argc, aco_option::args, ast_config_option_default_handler(), ast_log, build_regex(), config_option_destroy(), aco_option::default_val, aco_option::flags, aco_option::handler, handler(), sip_to_pjsip::info(), link_option_to_types(), LOG_ERROR, aco_option::match_type, name, aco_option::name, aco_option::name_regex, aco_option::no_doc, OPT_CUSTOM_T, tmp(), and aco_option::type.
Referenced by __ast_sorcery_object_field_register(), and ast_sorcery_object_fields_register().
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 ast_free, sip_to_pjsip::info(), internal_file_types_destroy(), and NULL.
Referenced by aco_info_init(), ast_ari_config_destroy(), ast_ari_config_init(), AST_TEST_DEFINE(), cdr_engine_shutdown(), conf_destroy_config(), destroy_config(), load_module(), sorcery_object_type_destructor(), stasis_cleanup(), unload_features_config(), 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_IGNORE, aco_info_destroy(), ast_calloc, error(), make_ari_stubs::file, sip_to_pjsip::info(), internal_type_init(), type, and xmldoc_update_config_type().
Referenced by __ast_sorcery_object_register(), ast_ari_config_init(), AST_TEST_DEFINE(), conf_load_config(), load_config(), load_module(), process_config(), and stasis_init().
struct ao2_container * aco_option_container_alloc | ( | void | ) |
Allocate a container to hold config options.
Definition at line 406 of file config_options.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, CONFIG_OPT_BUCKETS, config_opt_cmp(), config_opt_hash(), and NULL.
Referenced by internal_type_init().
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.
References aco_option::args.
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.
References aco_option::flags.
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 ACO_EXACT, aco_option::aliased_to, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_strlen_zero(), config_option_destroy(), aco_option::deprecated, sip_to_pjsip::info(), link_option_to_types(), aco_option::match_type, name, and aco_option::name.
Referenced by AST_TEST_DEFINE().
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 ast_log, sip_to_pjsip::info(), LOG_ERROR, and NULL.
Referenced by cel_pre_apply_config(), configure_parking_extensions(), features_pre_apply_config(), hepv3_config_pre_apply(), http_media_cache_config_pre_apply(), prometheus_config_pre_apply(), udptl_pre_apply_config(), unbound_config_preapply_callback(), verify_default_parking_lot(), and verify_default_profiles().
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, ao2_cleanup, apply_config(), ast_log, error(), make_ari_stubs::file, sip_to_pjsip::info(), internal_process_ast_config(), LOG_ERROR, and NULL.
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(), ast_variable_browse(), type, and var.
Referenced by process_category().
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_GLOBAL, ACO_IGNORE, ACO_PROCESS_ERROR, ACO_PROCESS_OK, ACO_PROCESS_UNCHANGED, aco_set_defaults(), ao2_cleanup, apply_config(), ast_clear_flag, ast_config_destroy(), ast_config_load, ast_debug, ast_log, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, end, make_ari_stubs::file, aco_file::filename, sip_to_pjsip::info(), internal_process_ast_config(), LOG_ERROR, match(), NULL, and reload().
Referenced by __ast_udptl_reload(), AST_TEST_DEFINE(), conf_load_config(), conf_reload_config(), load_config(), load_module(), process_config(), reload(), reload_features_config(), 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 aco_option_find(), ao2_cleanup, ao2_ref, ast_log, ast_strdupa, ast_strlen_zero(), LOG_ERROR, LOG_WARNING, RAII_VAR, type, and var.
Referenced by aco_process_category_options(), ast_sorcery_objectset_apply(), and func_confbridge_helper().
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_iterator_next, ao2_ref, ast_log, ast_strlen_zero(), ast_variable_new, ast_variables_destroy(), aco_option::default_val, aco_option::handler, LOG_ERROR, aco_option::name, NULL, RAII_VAR, type, and var.
Referenced by __ast_udptl_reload(), aco_process_config(), ast_sorcery_alloc(), conf_alloc(), load_config(), load_module(), process_category(), process_config(), stasis_init(), unbound_config_apply_default(), verify_default_parking_lot(), and verify_default_profiles().