From 501f4dcdd8790283e1db809e23133dbeb3a1f27c Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Tue, 12 Dec 2017 13:55:12 -0500 Subject: aco: Minimize use of regex. Remove nearly all use of regex from ACO users. Still remaining: * app_confbridge has a legitamate use of option name regex. * ast_sorcery_object_fields_register is implemented with regex, all callers use simple prefix based regex. I haven't decided the best way to fix this in both 13/15 and master. Change-Id: Ib5ed478218d8a661ace4d2eaaea98b59a897974b --- main/cdr.c | 28 ++++++++++++++++++++++++---- main/cel.c | 21 +++++++++++++++++---- main/features_config.c | 22 +++++++++++----------- main/named_acl.c | 4 ++-- main/stasis.c | 8 ++++---- main/udptl.c | 4 ++-- 6 files changed, 60 insertions(+), 27 deletions(-) (limited to 'main') diff --git a/main/cdr.c b/main/cdr.c index 60532fe9f..501589aba 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -241,8 +241,29 @@ static struct aco_type general_option = { .type = ACO_GLOBAL, .name = "general", .item_offset = offsetof(struct module_config, general), - .category = "^general$", - .category_match = ACO_WHITELIST, + .category = "general", + .category_match = ACO_WHITELIST_EXACT, +}; + +/*! Config sections used by existing modules. Do not add to this list. */ +static const char *ignore_categories[] = { + "csv", + "custom", + "manager", + "odbc", + "pgsql", + "radius", + "sqlite", + "tds", + "mysql", + NULL, +}; + +static struct aco_type ignore_option = { + .type = ACO_IGNORE, + .name = "modules", + .category = (const char*)ignore_categories, + .category_match = ACO_WHITELIST_ARRAY, }; static void *module_config_alloc(void); @@ -252,8 +273,7 @@ static void module_config_post_apply(void); /*! \brief The file definition */ static struct aco_file module_file_conf = { .filename = "cdr.conf", - .skip_category = "(^csv$|^custom$|^manager$|^odbc$|^pgsql$|^radius$|^sqlite$|^tds$|^mysql$)", - .types = ACO_TYPES(&general_option), + .types = ACO_TYPES(&general_option, &ignore_option), }; CONFIG_INFO_CORE("cdr", cfg_info, module_configs, module_config_alloc, diff --git a/main/cel.c b/main/cel.c index 0cdf1be00..d46f185cf 100644 --- a/main/cel.c +++ b/main/cel.c @@ -244,15 +244,28 @@ static struct aco_type general_option = { .type = ACO_GLOBAL, .name = "general", .item_offset = offsetof(struct cel_config, general), - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", +}; + +/*! Config sections used by existing modules. Do not add to this list. */ +static const char *ignore_categories[] = { + "manager", + "radius", + NULL, +}; + +static struct aco_type ignore_option = { + .type = ACO_IGNORE, + .name = "modules", + .category = (const char*)ignore_categories, + .category_match = ACO_WHITELIST_ARRAY, }; /*! \brief The config file to be processed for the module. */ static struct aco_file cel_conf = { .filename = "cel.conf", /*!< The name of the config file */ - .types = ACO_TYPES(&general_option), /*!< The mapping object types to be processed */ - .skip_category = "(^manager$|^radius$)", /*!< Config sections used by existing modules. Do not add to this list. */ + .types = ACO_TYPES(&general_option, &ignore_option), /*!< The mapping object types to be processed */ }; static int cel_pre_apply_config(void); diff --git a/main/features_config.c b/main/features_config.c index 2689687cc..e2d405740 100644 --- a/main/features_config.c +++ b/main/features_config.c @@ -219,7 +219,7 @@ The DYNAMIC_FEATURES is a # separated list of either applicationmap item names or featuregroup names. - + A custom feature to invoke during a bridged call Each item listed here is a comma-separated list of parameters that determine @@ -272,7 +272,7 @@ DTMF sequence used to invoke an applicationmap item to be overridden with a different sequence. - + Applicationmap item to place in the feature group Each item here must be a name of an item in the applicationmap. The @@ -578,24 +578,24 @@ struct features_config { static struct aco_type global_option = { .type = ACO_GLOBAL, .name = "globals", - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", .item_offset = offsetof(struct features_config, global), }; static struct aco_type featuremap_option = { .type = ACO_GLOBAL, .name = "featuremap", - .category_match = ACO_WHITELIST, - .category = "^featuremap$", + .category_match = ACO_WHITELIST_EXACT, + .category = "featuremap", .item_offset = offsetof(struct features_config, featuremap), }; static struct aco_type applicationmap_option = { .type = ACO_GLOBAL, .name = "applicationmap", - .category_match = ACO_WHITELIST, - .category = "^applicationmap$", + .category_match = ACO_WHITELIST_EXACT, + .category = "applicationmap", .item_offset = offsetof(struct features_config, applicationmap), }; @@ -1851,13 +1851,13 @@ static int load_config(void) aco_option_register_custom(&cfg_info, "automixmon", ACO_EXACT, featuremap_options, DEFAULT_FEATUREMAP_AUTOMIXMON, featuremap_handler, 0); - aco_option_register_custom(&cfg_info, "^.*$", ACO_REGEX, applicationmap_options, + aco_option_register_custom(&cfg_info, "", ACO_PREFIX, applicationmap_options, "", applicationmap_handler, 0); - aco_option_register_custom(&cfg_info, "^.*$", ACO_REGEX, featuregroup_options, + aco_option_register_custom(&cfg_info, "", ACO_PREFIX, featuregroup_options, "", featuregroup_handler, 0); - aco_option_register_custom_nodoc(&cfg_info, "^.*$", ACO_REGEX, parkinglot_options, + aco_option_register_custom_nodoc(&cfg_info, "", ACO_PREFIX, parkinglot_options, "", unsupported_handler, 0); if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) { diff --git a/main/named_acl.c b/main/named_acl.c index 3b81c8c38..47787e921 100644 --- a/main/named_acl.c +++ b/main/named_acl.c @@ -82,8 +82,8 @@ static void *named_acl_find(struct ao2_container *container, const char *cat); static struct aco_type named_acl_type = { .type = ACO_ITEM, /*!< named_acls are items stored in containers, not individual global objects */ .name = "named_acl", - .category_match = ACO_BLACKLIST, - .category = "^general$", /*!< Match everything but "general" */ + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", /*!< Match everything but "general" */ .item_alloc = named_acl_alloc, /*!< A callback to allocate a new named_acl based on category */ .item_find = named_acl_find, /*!< A callback to find a named_acl in some container of named_acls */ .item_offset = offsetof(struct named_acl_config, named_acl_list), /*!< Could leave this out since 0 */ diff --git a/main/stasis.c b/main/stasis.c index 63d17dfaf..d9785ce73 100644 --- a/main/stasis.c +++ b/main/stasis.c @@ -1436,8 +1436,8 @@ static struct aco_type threadpool_option = { .type = ACO_GLOBAL, .name = "threadpool", .item_offset = offsetof(struct stasis_config, threadpool_options), - .category = "^threadpool$", - .category_match = ACO_WHITELIST, + .category = "threadpool", + .category_match = ACO_WHITELIST_EXACT, }; static struct aco_type *threadpool_options[] = ACO_TYPES(&threadpool_option); @@ -1447,8 +1447,8 @@ static struct aco_type declined_option = { .type = ACO_GLOBAL, .name = "declined_message_types", .item_offset = offsetof(struct stasis_config, declined_message_types), - .category_match = ACO_WHITELIST, - .category = "^declined_message_types$", + .category_match = ACO_WHITELIST_EXACT, + .category = "declined_message_types", }; struct aco_type *declined_options[] = ACO_TYPES(&declined_option); diff --git a/main/udptl.c b/main/udptl.c index 44e9eb9bb..83989f738 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -239,9 +239,9 @@ static int udptl_pre_apply_config(void); static struct aco_type general_option = { .type = ACO_GLOBAL, .name = "global", - .category_match = ACO_WHITELIST, + .category_match = ACO_WHITELIST_EXACT, .item_offset = offsetof(struct udptl_config, general), - .category = "^general$", + .category = "general", }; static struct aco_type *general_options[] = ACO_TYPES(&general_option); -- cgit v1.2.3