summaryrefslogtreecommitdiff
path: root/pbx/pbx_realtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'pbx/pbx_realtime.c')
-rw-r--r--pbx/pbx_realtime.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c
index 1d5800716..2b17cbcee 100644
--- a/pbx/pbx_realtime.c
+++ b/pbx/pbx_realtime.c
@@ -143,6 +143,13 @@ static void *cleanup(void *unused)
return NULL;
}
+static int extension_length_comparator(struct ast_category *p, struct ast_category *q)
+{
+ const char *extenp = S_OR(ast_variable_find(p, "exten"), "");
+ const char *extenq = S_OR(ast_variable_find(q, "exten"), "");
+
+ return strlen(extenp) - strlen(extenq);
+}
/* Realtime switch looks up extensions in the supplied realtime table.
@@ -193,6 +200,9 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
if (cfg) {
char *cat = NULL;
+ /* Sort so that longer patterns are checked first */
+ ast_config_sort_categories(cfg, 1, extension_length_comparator);
+
while ((cat = ast_category_browse(cfg, cat))) {
const char *realtime_exten = ast_variable_retrieve(cfg, cat, "exten");