24#ifndef _ASTERISK_CONFIG_OPTIONS_H
25#define _ASTERISK_CONFIG_OPTIONS_H
27#if defined(__cplusplus) || defined(c_plusplus)
76typedef void *(*aco_type_item_alloc)(
const char *category);
84typedef void *(*aco_type_item_find)(
struct ao2_container *newcontainer,
const char *category);
158typedef void *(*aco_snapshot_alloc)(void);
181#define ACO_TYPES(...) { __VA_ARGS__, NULL, }
182#define ACO_FILES(...) { __VA_ARGS__, NULL, }
213#define CONFIG_INFO_STANDARD(name, arr, alloc, ...) \
214static struct aco_info name = { \
215 .module = AST_MODULE, \
216 .global_obj = &arr, \
217 .snapshot_alloc = alloc, \
221#define CONFIG_INFO_CORE(mod, name, arr, alloc, ...) \
222static struct aco_info name = { \
224 .global_obj = &arr, \
225 .snapshot_alloc = alloc, \
229#define CONFIG_INFO_TEST(name, arr, alloc, ...) \
230static struct aco_info name = { \
231 .module = AST_MODULE, \
232 .global_obj = &arr, \
233 .snapshot_alloc = alloc, \
623#define aco_option_register(info, name, matchtype, types, default_val, opt_type, flags, ...) \
624 __aco_option_register(info, name, matchtype, types, default_val, opt_type, NULL, flags, 0, VA_NARGS(__VA_ARGS__), __VA_ARGS__);
638#define aco_option_register_custom(info, name, matchtype, types, default_val, handler, flags) \
639 __aco_option_register(info, name, matchtype, types, default_val, OPT_CUSTOM_T, handler, flags, 0, 0);
656#define aco_option_register_custom_nodoc(info, name, matchtype, types, default_val, handler, flags) \
657 __aco_option_register(info, name, matchtype, types, default_val, OPT_CUSTOM_T, handler, flags, 1, 0);
738#define ARGMAP(func, func_arg, x, ...) ARGMAP_(VA_NARGS(x, ##__VA_ARGS__), func, func_arg, x, __VA_ARGS__)
744#define ARGMAP_(N, func, func_arg, x, ...) PASTE(ARGMAP_, N)(func, func_arg, N, x, __VA_ARGS__)
750#define PASTE(arg1, arg2) PASTE1(arg1, arg2)
751#define PASTE1(arg1, arg2) arg1##arg2
754#define ARGIFY(...) __VA_ARGS__
763#define ARGMAP_1(func, func_arg, in, x, ...) ARGIFY(in, func(func_arg, x))
764#define ARGMAP_2(func, func_arg, in, x, ...)\
765 ARGMAP_1(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__)
766#define ARGMAP_3(func, func_arg, in, x, ...)\
767 ARGMAP_2(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__)
768#define ARGMAP_4(func, func_arg, in, x, ...)\
769 ARGMAP_3(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__)
770#define ARGMAP_5(func, func_arg, in, x, ...)\
771 ARGMAP_4(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__)
772#define ARGMAP_6(func, func_arg, in, x, ...)\
773 ARGMAP_5(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__)
774#define ARGMAP_7(func, func_arg, in, x, ...)\
775 ARGMAP_6(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__)
776#define ARGMAP_8(func, func_arg, in, x, ...)\
777 ARGMAP_7(func, func_arg, ARGIFY(in, func(func_arg, x)), __VA_ARGS__)
797#define VA_NARGS(...) VA_NARGS1(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0)
798#define VA_NARGS1(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
816#define FLDSET(type, ...) FLDSET1(type, ##__VA_ARGS__)
817#define FLDSET1(type, ...) POPPED(ARGMAP(offsetof, type, ##__VA_ARGS__))
827#define STRFLDSET(type, ...) FLDSET(type, __VA_ARGS__, __field_mgr_pool, __field_mgr)
835#define CHARFLDSET(type, field) ARGIFY(offsetof(type, field), sizeof(((type *)0)->field))
848#define POPPED(...) POPPED1(__VA_ARGS__)
849#define POPPED1(x, ...) __VA_ARGS__
851#if defined(__cplusplus) || defined(c_plusplus)
struct ao2_container * aco_option_container_alloc(void)
Allocate a container to hold config options.
int(* aco_option_handler)(const struct aco_option *opt, struct ast_variable *var, void *obj)
A callback function for handling a particular option.
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.
aco_matchtype
What kind of matching should be done on an option name.
int aco_set_defaults(struct aco_type *type, const char *category, void *obj)
Set all default options of obj.
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
aco_process_status
Return values for the aco_process functions.
@ ACO_PROCESS_UNCHANGED
The config had not been edited and no changes applied.
@ ACO_PROCESS_ERROR
Their was an error and no changes were applied.
@ ACO_PROCESS_OK
The config was processed and applied.
int aco_info_init(struct aco_info *info)
Initialize an aco_info structure.
void *(* aco_snapshot_alloc)(void)
A callback function for allocating an object to hold all config objects.
aco_option_type
The option types.
@ OPT_UINT_T
Type for default option handler for unsigned integers.
@ OPT_NOOP_T
Type for a default handler that should do nothing.
@ OPT_CODEC_T
Type for default option handler for format capabilities.
@ OPT_BOOL_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_BOOLFLAG_T
Type for default option handler for bools (ast_true/ast_false) that are stored in a flag.
@ OPT_CUSTOM_T
Type for a custom (user-defined) option handler.
@ OPT_CHAR_ARRAY_T
Type for default option handler for character array strings.
@ OPT_ACL_T
Type for default option handler for ACLs.
@ OPT_SOCKADDR_T
Type for default handler for ast_sockaddrs.
@ OPT_YESNO_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_INT_T
Type for default option handler for signed integers.
@ OPT_TIMELEN_T
Type for default option handler for time length signed integers.
@ OPT_DOUBLE_T
Type for default option handler for doubles.
@ OPT_STRINGFIELD_T
Type for default option handler for stringfields.
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.
void(* aco_post_apply_config)(void)
A callback function called only if config changes have been applied.
void *(* aco_type_item_alloc)(const char *category)
Allocate a configurable ao2 object.
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.
int(* aco_type_item_pre_process)(void *newitem)
Callback function that is called after a config object is initialized with defaults.
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.
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.
int(* aco_pre_apply_config)(void)
A callback function to run just prior to applying config changes.
int(* aco_type_prelink)(void *newitem)
Callback function that is called after config processing, but before linking.
void *(* aco_type_item_find)(struct ao2_container *newcontainer, const char *category)
Find a item given a category and container of items.
void * aco_pending_config(struct aco_info *info)
Get pending config changes.
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
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 ma...
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.
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.
Configuration File Parser.
The representation of a single configuration file to be processed.
struct aco_type * types[]
const char * skip_category
Bits of aco_info that shouldn't be assigned outside this file.
struct aco_file * files[]
struct ao2_global_obj * global_obj
aco_snapshot_alloc snapshot_alloc
struct aco_info_internal * internal
aco_post_apply_config post_apply_config
aco_pre_apply_config pre_apply_config
Type information about a category-level configurable object.
aco_type_prelink item_prelink
aco_type_item_pre_process item_pre_process
aco_type_item_find item_find
aco_matchvalue_func matchfunc
aco_type_item_alloc item_alloc
struct aco_type_internal * internal
enum aco_category_op category_match
Structure for variables, used for configurations and for channel variables.
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)