--- pbx_config.bak 2010-09-07 16:56:07.000000000 -0400 +++ pbx_config.c 2011-05-31 17:05:30.000000000 -0400 @@ -1429,9 +1429,12 @@ char realext[256] = ""; char *stringp, *ext; + /* get filename for error reporting from top level or an #include */ + const char *vfile = !*v->file ? config_file : v->file; + if (!strncasecmp(v->name, "same", 4)) { if (ast_strlen_zero(lastextension)) { - ast_log(LOG_ERROR, "No previous pattern in the first entry of context '%s' to match '%s' at line %d!\n", cxt, v->name, v->lineno); + ast_log(LOG_ERROR, "No previous pattern in the first entry of context '%s' to match '%s' at line %d of %s!\n", cxt, v->name, v->lineno, vfile); continue; } if ((stringp = tc = ast_strdup(v->value))) { @@ -1462,7 +1465,7 @@ if ((end = strchr(label, ')'))) { *end = '\0'; } else { - ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno); + ast_log(LOG_WARNING, "Label missing trailing ')' at line %d of%s\n", v->lineno, vfile); ast_free(tc); continue; } @@ -1476,7 +1479,7 @@ if (lastpri > -2) { ipri = lastpri + 1; } else { - ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry at line %d!\n", v->lineno); + ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry at line %d of %s!\n", v->lineno, vfile); ast_free(tc); continue; } @@ -1484,18 +1487,18 @@ if (lastpri > -2) { ipri = lastpri; } else { - ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry at line %d!\n", v->lineno); + ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry at line %d of %s!\n", v->lineno, vfile); ast_free(tc); continue; } } else if (sscanf(pri, "%30d", &ipri) != 1 && (ipri = ast_findlabel_extension2(NULL, con, realext, pri, cidmatch)) < 1) { - ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno); + ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d of %s\n", pri, v->lineno, vfile); ipri = 0; ast_free(tc); continue; } else if (ipri < 1) { - ast_log(LOG_WARNING, "Invalid priority '%s' at line %d\n", pri, v->lineno); + ast_log(LOG_WARNING, "Invalid priority '%s' at line %d of %s\n", pri, v->lineno, vfile); ast_free(tc); continue; } @@ -1526,7 +1529,7 @@ if ((end = strrchr(data, ')'))) { *end = '\0'; } else { - ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s' at line %d\n", appl, data, v->lineno); + ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s' at line %d of %s\n", appl, data, v->lineno, vfile); } } ast_free(orig_appl); @@ -1539,10 +1542,10 @@ } lastpri = ipri; if (!ast_opt_dont_warn && (!strcmp(realext, "_.") || !strcmp(realext, "_!"))) { - ast_log(LOG_WARNING, "The use of '%s' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X%c' instead at line %d\n", realext, realext[1], v->lineno); + ast_log(LOG_WARNING, "The use of '%s' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X%c' instead at line %d of %s\n", realext, realext[1], v->lineno, vfile); } if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free_ptr, registrar)) { - ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno); + ast_log(LOG_WARNING, "Unable to register extension at line %d of %s\n", v->lineno, vfile); } } free(tc); @@ -1559,26 +1562,26 @@ break; case EEXIST: - ast_log(LOG_WARNING, "Context '%s' already included in '%s' context on include at line %d\n", - v->value, cxt, v->lineno); + ast_log(LOG_WARNING, "Context '%s' already included in '%s' context on include at line %d of %s\n", + v->value, cxt, v->lineno, vfile); break; case ENOENT: case EINVAL: - ast_log(LOG_WARNING, "There is no existence of context '%s' included at line %d\n", - errno == ENOENT ? v->value : cxt, v->lineno); + ast_log(LOG_WARNING, "There is no existence of context '%s' included at line %d of %s\n", + errno == ENOENT ? v->value : cxt, v->lineno, vfile); break; default: - ast_log(LOG_WARNING, "Failed to include '%s' in '%s' context at line %d\n", - v->value, cxt, v->lineno); + ast_log(LOG_WARNING, "Failed to include '%s' in '%s' context at line %d of %s\n", + v->value, cxt, v->lineno, vfile); break; } } } else if (!strcasecmp(v->name, "ignorepat")) { pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1); if (ast_context_add_ignorepat2(con, realvalue, registrar)) { - ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s' at line %d\n", v->value, cxt, v->lineno); + ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s' at line %d of %s\n", v->value, cxt, v->lineno, vfile); } } else if (!strcasecmp(v->name, "switch") || !strcasecmp(v->name, "lswitch") || !strcasecmp(v->name, "eswitch")) { char *stringp = realvalue; @@ -1592,10 +1595,10 @@ appl = strsep(&stringp, "/"); data = S_OR(stringp, ""); if (ast_context_add_switch2(con, appl, data, !strcasecmp(v->name, "eswitch"), registrar)) { - ast_log(LOG_WARNING, "Unable to include switch '%s' in context '%s' at line %d\n", v->value, cxt, v->lineno); + ast_log(LOG_WARNING, "Unable to include switch '%s' in context '%s' at line %d of %s\n", v->value, cxt, v->lineno, vfile); } } else { - ast_log(LOG_WARNING, "==!!== Unknown directive: %s at line %d -- IGNORING!!!\n", v->name, v->lineno); + ast_log(LOG_WARNING, "==!!== Unknown directive: %s at line %d of %s-- IGNORING!!!\n", v->name, v->lineno, vfile); } } }