realtime: Fix ast_load_realtime_multientry handling

ast_load_realtime_multientry() returns an ast_config structure whose
ast_categorys are keyed with the empty strings. Several modules were
giving semantic meaning to the category names causing problems at
runtime.

* app_directory: Treated the category name as the mailbox name, and
  would fail to direct calls to the appropriate extension after an
  entry was chosen.

* app_queue: Queues, queue members, and queue rules were all affected
  and needed to be updated.

* pbx_realtime: Pattern matching would never succeed because the
  extension entered by the user was always compared to the empty
  string.

Change-Id: Ie7e44986344b0b76ea8f6ddb5879f5040c6ca8a7
This commit is contained in:
Sean Bright
2017-02-21 11:47:28 -05:00
parent f29ea24d9f
commit d5522de597
3 changed files with 52 additions and 44 deletions

View File

@@ -191,25 +191,26 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
if (!var && !ast_test_flag(&flags, OPTION_PATTERNS_DISABLED)) {
cfg = ast_load_realtime_multientry(table, "exten LIKE", "\\_%", "context", context, "priority", pri, SENTINEL);
if (cfg) {
char *cat = ast_category_browse(cfg, NULL);
char *cat = NULL;
while ((cat = ast_category_browse(cfg, cat))) {
const char *realtime_exten = ast_variable_retrieve(cfg, cat, "exten");
while(cat) {
switch(mode) {
case MODE_MATCHMORE:
match = ast_extension_close(cat, exten, 1);
match = ast_extension_close(realtime_exten, exten, 1);
break;
case MODE_CANMATCH:
match = ast_extension_close(cat, exten, 0);
match = ast_extension_close(realtime_exten, exten, 0);
break;
case MODE_MATCH:
default:
match = ast_extension_match(cat, exten);
match = ast_extension_match(realtime_exten, exten);
}
if (match) {
var = ast_category_detach_variables(ast_category_get(cfg, cat, NULL));
break;
}
cat = ast_category_browse(cfg, cat);
}
ast_config_destroy(cfg);
}