diff --git a/res/ael/pval.c b/res/ael/pval.c index bbfeb2d..87f84ab 100644 --- a/res/ael/pval.c +++ b/res/ael/pval.c @@ -55,6 +55,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/argdesc.h" #endif #include "asterisk/utils.h" +#include "asterisk/pbx.h" + extern int localized_pbx_load_module(void); @@ -1288,12 +1290,17 @@ static void check_goto(pval *item) pval *second = item->u1.list->next; pval *third = item->u1.list->next->next; + const char *context_name = (char*)first->u1.str; + const char *exten = (char*)second->u1.str; + const char *priority = (char*)third->u1.str; + /* printf("Calling find_label_in_current_db with args %s, %s, %s\n", (char*)first->u1.str, (char*)second->u1.str, (char*)third->u1.str); */ if (!strstr((item->u1.list)->u1.str,"${") && !strstr(item->u1.list->next->u1.str,"${") && !strstr(item->u1.list->next->next->u1.str,"${")) /* Don't try to match variables */ { struct pval *x = find_label_in_current_db((char*)first->u1.str, (char*)second->u1.str, (char*)third->u1.str); + if (!x) { struct pval *p3; struct pval *found = 0; @@ -1322,11 +1329,35 @@ static void check_goto(pval *item) } } } - if (!found) { - ast_log(LOG_ERROR,"Error: file %s, line %d-%d: goto: no label %s|%s exists in the context %s or its inclusions!\n", - item->filename, item->startline, item->endline, item->u1.list->next->u1.str, item->u1.list->next->next->u1.str, item->u1.list->u1.str ); - errs++; - } else { + + if (!found) { + struct pbx_find_info pfiq = {.stacklen = 0 }; + int priority_int = atoi(priority); +#ifdef STANDALONE + extern int localized_pbx_load_module(void); + /* if this is a standalone, we will need to make sure the + localized load of extensions.conf is done */ + if (!extensions_dot_conf_loaded) { + localized_pbx_load_module(); + extensions_dot_conf_loaded++; + } +#endif + + ast_log(LOG_NOTICE, "Locating context: %s %s %s\n", context_name, exten, priority); + pbx_find_extension(NULL, NULL, &pfiq, context_name, exten, priority_int, NULL, NULL, E_MATCH); + + if (pfiq.status == STATUS_SUCCESS) { + // Target is good and exists elsewhere outside ael + found = item; + } + else { + ast_log(LOG_ERROR,"Error: file %s, line %d-%d: goto: no label %s|%s exists in the context %s or its inclusions!\n", + item->filename, item->startline, item->endline, item->u1.list->next->u1.str, item->u1.list->next->next->u1.str, item->u1.list->u1.str); + errs++; + } + } + + if (found) { struct pval *mac = in_macro(item); /* is this goto inside a macro? */ if( mac ) { /* yes! */ struct pval *targ = in_context(found);