Index: pbx/pbx_ael.c =================================================================== --- pbx/pbx_ael.c (revision 78700) +++ pbx/pbx_ael.c (working copy) @@ -3697,6 +3697,7 @@ { struct ael_priority *pr; char *label=0; + char realext[256]=""; if (!exten) { ast_log(LOG_WARNING, "This file is Empty!\n" ); return; @@ -3704,8 +3705,9 @@ do { struct ael_priority *last = 0; + pbx_substitute_variables_helper(NULL, exten->name, realext, sizeof(realext) - 1); if (exten->hints) { - if (ast_add_extension2(exten->context, 0 /*no replace*/, exten->name, PRIORITY_HINT, NULL, exten->cidmatch, + if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, PRIORITY_HINT, NULL, exten->cidmatch, exten->hints, NULL, ast_free, registrar)) { ast_log(LOG_WARNING, "Unable to add step at priority 'hint' of extension '%s'\n", exten->name); @@ -3785,7 +3787,7 @@ else label = 0; - if (ast_add_extension2(exten->context, 0 /*no replace*/, exten->name, pr->priority_num, (label?label:NULL), exten->cidmatch, + if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, pr->priority_num, (label?label:NULL), exten->cidmatch, app, strdup(appargs), ast_free, registrar)) { ast_log(LOG_WARNING, "Unable to add step at priority '%d' of extension '%s'\n", pr->priority_num, exten->name); @@ -3885,6 +3887,22 @@ struct ael_extension *exten; struct ael_extension *exten_list = 0; + for (p=root; p; p=p->next ) { /* do the globals first, so they'll be there + when we try to eval them */ + switch (p->type) { + case PV_GLOBALS: + /* just VARDEC elements */ + for (p2=p->u1.list; p2; p2=p2->next) { + char buf2[2000]; + snprintf(buf2,sizeof(buf2),"%s=%s", p2->u1.str, p2->u2.val); + pbx_builtin_setvar(NULL, buf2); + } + break; + default: + break; + } + } + for (p=root; p; p=p->next ) { pval *lp; int argc; @@ -3948,12 +3966,7 @@ break; case PV_GLOBALS: - /* just VARDEC elements */ - for (p2=p->u1.list; p2; p2=p2->next) { - char buf2[2000]; - snprintf(buf2,sizeof(buf2),"%s=%s", p2->u1.str, p2->u2.val); - pbx_builtin_setvar(NULL, buf2); - } + /* already done */ break; case PV_CONTEXT: Index: utils/ael_main.c =================================================================== --- utils/ael_main.c (revision 78700) +++ utils/ael_main.c (working copy) @@ -164,6 +164,15 @@ /* I'm erasing this, because I don't think anyone really ever needs to see it anyway */ } +void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count); +void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count) +{ + if (cp1 && *cp1) + strncpy(cp2,cp1,strlen(cp2)); + else + *cp2 = 0; +} + int ast_add_extension2(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void (*datad)(void *),