diff options
author | Jonathan Rose <jrose@digium.com> | 2011-04-04 17:32:05 +0000 |
---|---|---|
committer | Jonathan Rose <jrose@digium.com> | 2011-04-04 17:32:05 +0000 |
commit | 7fa7d9c36b7eebb8848e44feb7e17c8b66390fbc (patch) | |
tree | 98044fa3be5c28ef9311401729567492abc079dd /pbx/pbx_config.c | |
parent | e1ceb52b5148d23ebeed76380944406c1b551d22 (diff) |
Makes 'dialplan add extension' create the specified context if it does not already exist.
If the user invokes 'dialplan add extension' into a non-existing context, the context will be created
and a message informing the user of the context being created will be issued in cli.
(closes issue #17431)
Reported by: leearcher
Patches:
context_auto_create.diff uploaded by kobaz (license 834)
Tested by: leearcher, kobaz, jrose
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@312678 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx/pbx_config.c')
-rw-r--r-- | pbx/pbx_config.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 0baa8e17c..8d025815b 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -969,6 +969,16 @@ static char *handle_cli_dialplan_add_extension(struct ast_cli_entry *e, int cmd, if (!exten || !prior || !app || (!app_data && iprior != PRIORITY_HINT)) return CLI_SHOWUSAGE; + if (!ast_context_find(a->argv[5])) { + ast_cli(a->fd, "Context '%s' did not exist prior to add extension - the context will be created.\n", a->argv[5]); + } + + if (!ast_context_find_or_create(NULL, NULL, a->argv[5], registrar)) { + ast_cli(a->fd, "ast_context_find_or_create() failed\n"); + ast_cli(a->fd, "Failed to add '%s,%s,%s,%s' extension into '%s' context\n", exten, prior, app, app_data, a->argv[5]); + return CLI_FAILURE; + } + if (!app_data) app_data=""; if (ast_add_extension(a->argv[5], a->argc == 7 ? 1 : 0, exten, iprior, NULL, cidmatch, app, |