summaryrefslogtreecommitdiff
path: root/pbx
diff options
context:
space:
mode:
authorJonathan R. Rose <jonathan.rose@motorolasolutions.com>2016-12-19 15:03:52 -0600
committerJonathan R. Rose <jonathan.rose@motorolasolutions.com>2017-01-04 14:06:20 -0600
commitd96e3502564508bf753aa637c5e1a0311924ab3d (patch)
tree41ec9b7747b59a87b846c984ae07b14cda9445bb /pbx
parent31268e0a280110748f33314a2c09563c576243de (diff)
core/pbx: dialplan show - display filename/line#
Adds the ability for extensions to be registered to include filename and line number so that dialplan show output can show the filename and line number of a config file responsible for generating a given extension. This only affects config modules that are written to use the new extension registering functions. In this patch, that only includes pbx_config, so extensions registered in extensions.conf and any included extension will be shown in this manner. Extensions registered in this manner will show the filename and line number *instead* of the registrar. ASTERISK-26658 #close Reported by: Jonathan R. Rose Change-Id: Ieccc6abccdff34ed5c7da3511fd24972b8f2dd30
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_config.c22
-rw-r--r--pbx/pbx_lua.c2
2 files changed, 16 insertions, 8 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 384bbc7c3..b96914ded 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1240,7 +1240,7 @@ static int manager_dialplan_extension_add(struct mansession *s, const struct mes
}
if (ast_add_extension2(add_context, replace, exten, ipriority, NULL, cidmatch,
- application, ast_strdup(application_data), ast_free_ptr, registrar)) {
+ application, ast_strdup(application_data), ast_free_ptr, registrar, NULL, 0)) {
ast_unlock_contexts();
switch (errno) {
case ENOMEM:
@@ -1855,6 +1855,7 @@ process_extension:
appl = ast_skip_blanks(appl);
if (ipri) {
+ const char *registrar_file;
if (plus) {
ipri += atoi(plus);
}
@@ -1864,7 +1865,14 @@ process_extension:
"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, ast_strdup(data), ast_free_ptr, registrar)) {
+ /* Don't include full path if the configuration file includes slashes */
+ registrar_file = strrchr(vfile, '/');
+ if (!registrar_file) {
+ registrar_file = vfile;
+ } else {
+ registrar_file++; /* Skip past the end slash */
+ }
+ if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, ast_strdup(data), ast_free_ptr, registrar, registrar_file, v->lineno)) {
ast_log(LOG_WARNING,
"Unable to register extension at line %d of %s\n",
v->lineno, vfile);
@@ -2031,19 +2039,19 @@ static void pbx_load_users(void)
}
/* Add hint */
- ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, NULL, NULL, registrar);
+ ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, NULL, NULL, registrar, NULL, 0);
/* If voicemail, use "stdexten" else use plain old dial */
if (hasvoicemail) {
if (ast_opt_stdexten_macro) {
/* Use legacy stdexten macro method. */
snprintf(tmp, sizeof(tmp), "stdexten,%s,${HINT}", cat);
- ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Macro", ast_strdup(tmp), ast_free_ptr, registrar);
+ ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Macro", ast_strdup(tmp), ast_free_ptr, registrar, NULL, 0);
} else {
snprintf(tmp, sizeof(tmp), "%s,stdexten(${HINT})", cat);
- ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Gosub", ast_strdup(tmp), ast_free_ptr, registrar);
+ ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Gosub", ast_strdup(tmp), ast_free_ptr, registrar, NULL, 0);
}
} else {
- ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", ast_strdup("${HINT}"), ast_free_ptr, registrar);
+ ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", ast_strdup("${HINT}"), ast_free_ptr, registrar, NULL, 0);
}
altexts = ast_variable_retrieve(cfg, cat, "alternateexts");
if (!ast_strlen_zero(altexts)) {
@@ -2052,7 +2060,7 @@ static void pbx_load_users(void)
c = altcopy;
ext = strsep(&c, ",");
while (ext) {
- ast_add_extension2(con, 0, ext, 1, NULL, NULL, "Goto", ast_strdup(tmp), ast_free_ptr, registrar);
+ ast_add_extension2(con, 0, ext, 1, NULL, NULL, "Goto", ast_strdup(tmp), ast_free_ptr, registrar, NULL, 0);
ext = strsep(&c, ",");
}
}
diff --git a/pbx/pbx_lua.c b/pbx/pbx_lua.c
index 0754990d6..088b160b4 100644
--- a/pbx/pbx_lua.c
+++ b/pbx/pbx_lua.c
@@ -1026,7 +1026,7 @@ static int lua_register_hints(lua_State *L)
continue;
}
- if (ast_add_extension2(con, 0, hint_name, PRIORITY_HINT, NULL, NULL, hint_value, NULL, NULL, registrar)) {
+ if (ast_add_extension2(con, 0, hint_name, PRIORITY_HINT, NULL, NULL, hint_value, NULL, NULL, registrar, NULL, 0)) {
/* remove hints table, hint name, hint value,
* key copy, context name, and contex table */
lua_pop(L, 6);