From bf2d35931d65c73bbb3efec5ce9d284a730cae5e 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 --- apps/app_agent_pool.c | 14 ++++++++++---- apps/app_skel.c | 18 ++++++++++++------ apps/confbridge/conf_config_parser.c | 20 ++++++++++---------- 3 files changed, 32 insertions(+), 20 deletions(-) (limited to 'apps') diff --git a/apps/app_agent_pool.c b/apps/app_agent_pool.c index 6a8c3955b..3c2ea3870 100644 --- a/apps/app_agent_pool.c +++ b/apps/app_agent_pool.c @@ -455,11 +455,17 @@ struct agents_cfg { struct ao2_container *agents; }; +static const char *agent_type_blacklist[] = { + "general", + "agents", + NULL, +}; + static struct aco_type agent_type = { .type = ACO_ITEM, .name = "agent-id", - .category_match = ACO_BLACKLIST, - .category = "^(general|agents)$", + .category_match = ACO_BLACKLIST_ARRAY, + .category = (const char *)agent_type_blacklist, .item_alloc = agent_cfg_alloc, .item_find = agent_cfg_find, .item_offset = offsetof(struct agents_cfg, agents), @@ -471,8 +477,8 @@ static struct aco_type *agent_types[] = ACO_TYPES(&agent_type); static struct aco_type general_type = { .type = ACO_GLOBAL, .name = "global", - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", }; static struct aco_file agents_conf = { diff --git a/apps/app_skel.c b/apps/app_skel.c index b3c887685..68f313fee 100644 --- a/apps/app_skel.c +++ b/apps/app_skel.c @@ -242,8 +242,8 @@ static struct aco_type global_option = { .type = ACO_GLOBAL, .name = "globals", .item_offset = offsetof(struct skel_config, global), - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", }; struct aco_type *global_options[] = ACO_TYPES(&global_option); @@ -253,18 +253,24 @@ static struct aco_type sound_option = { .type = ACO_GLOBAL, .name = "sounds", .item_offset = offsetof(struct skel_config, global), - .category_match = ACO_WHITELIST, - .category = "^sounds$", + .category_match = ACO_WHITELIST_EXACT, + .category = "sounds", }; struct aco_type *sound_options[] = ACO_TYPES(&sound_option); +static const char *level_categories[] = { + "general", + "sounds", + NULL, +}; + /*! \brief An aco_type structure to link the everything but the "general" and "sounds" categories to the skel_level type */ static struct aco_type level_option = { .type = ACO_ITEM, .name = "level", - .category_match = ACO_BLACKLIST, - .category = "^(general|sounds)$", + .category_match = ACO_BLACKLIST_ARRAY, + .category = (const char *)level_categories, .item_alloc = skel_level_alloc, .item_find = skel_level_find, .item_offset = offsetof(struct skel_config, levels), diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c index 665930576..99eea0a27 100644 --- a/apps/confbridge/conf_config_parser.c +++ b/apps/confbridge/conf_config_parser.c @@ -409,7 +409,7 @@ regardless if this limit is reached or not. - + Override the various conference bridge sound files All sounds in the conference are customizable using the bridge profile options below. @@ -639,8 +639,8 @@ static void *bridge_profile_find(struct ao2_container *container, const char *ca static struct aco_type bridge_type = { .type = ACO_ITEM, .name = "bridge_profile", - .category_match = ACO_BLACKLIST, - .category = "^general$", + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", .matchfield = "type", .matchvalue = "bridge", .item_alloc = bridge_profile_alloc, @@ -676,8 +676,8 @@ static void *user_profile_find(struct ao2_container *container, const char *cate static struct aco_type user_type = { .type = ACO_ITEM, .name = "user_profile", - .category_match = ACO_BLACKLIST, - .category = "^general$", + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", .matchfield = "type", .matchvalue = "user", .item_alloc = user_profile_alloc, @@ -707,8 +707,8 @@ static void *menu_find(struct ao2_container *container, const char *category) static struct aco_type menu_type = { .type = ACO_ITEM, .name = "menu", - .category_match = ACO_BLACKLIST, - .category = "^general$", + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", .matchfield = "type", .matchvalue = "menu", .item_alloc = menu_alloc, @@ -725,8 +725,8 @@ static struct aco_type *user_types[] = ACO_TYPES(&user_type); static struct aco_type general_type = { .type = ACO_GLOBAL, .name = "global", - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", }; static struct aco_file confbridge_conf = { @@ -2235,7 +2235,7 @@ int conf_load_config(void) aco_option_register(&cfg_info, "record_command", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, rec_command)); aco_option_register(&cfg_info, "regcontext", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, regcontext)); aco_option_register(&cfg_info, "language", ACO_EXACT, bridge_types, "en", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, language)); - aco_option_register_custom(&cfg_info, "^sound_", ACO_REGEX, bridge_types, NULL, sound_option_handler, 0); + aco_option_register_custom(&cfg_info, "sound_", ACO_PREFIX, bridge_types, NULL, sound_option_handler, 0); aco_option_register(&cfg_info, "video_update_discard", ACO_EXACT, bridge_types, "2000", OPT_UINT_T, 0, FLDSET(struct bridge_profile, video_update_discard)); /* This option should only be used with the CONFBRIDGE dialplan function */ aco_option_register_custom(&cfg_info, "template", ACO_EXACT, bridge_types, NULL, bridge_template_handler, 0); -- cgit v1.2.3