|
|
|
@ -905,6 +905,7 @@ static char *handle_cli_dialplan_add_extension(struct ast_cli_entry *e, int cmd,
|
|
|
|
|
int iprior = -2;
|
|
|
|
|
char *cidmatch, *app, *app_data;
|
|
|
|
|
char *start, *end;
|
|
|
|
|
const char *into_context;
|
|
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
case CLI_INIT:
|
|
|
|
@ -969,19 +970,21 @@ 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]);
|
|
|
|
|
into_context = a->argv[5];
|
|
|
|
|
|
|
|
|
|
if (!ast_context_find(into_context)) {
|
|
|
|
|
ast_cli(a->fd, "Context '%s' did not exist prior to add extension - the context will be created.\n", into_context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ast_context_find_or_create(NULL, NULL, a->argv[5], registrar)) {
|
|
|
|
|
if (!ast_context_find_or_create(NULL, NULL, into_context, 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]);
|
|
|
|
|
ast_cli(a->fd, "Failed to add '%s,%s,%s,%s' extension into '%s' context\n", exten, prior, app, app_data, into_context);
|
|
|
|
|
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,
|
|
|
|
|
if (ast_add_extension(into_context, a->argc == 7 ? 1 : 0, exten, iprior, NULL, cidmatch, app,
|
|
|
|
|
(void *)strdup(app_data), ast_free_ptr, registrar)) {
|
|
|
|
|
switch (errno) {
|
|
|
|
|
case ENOMEM:
|
|
|
|
@ -993,17 +996,17 @@ static char *handle_cli_dialplan_add_extension(struct ast_cli_entry *e, int cmd,
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ENOENT:
|
|
|
|
|
ast_cli(a->fd, "No existence of '%s' context\n", a->argv[5]);
|
|
|
|
|
ast_cli(a->fd, "No existence of '%s' context\n", into_context);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EEXIST:
|
|
|
|
|
ast_cli(a->fd, "Extension %s@%s with priority %s already exists\n",
|
|
|
|
|
exten, a->argv[5], prior);
|
|
|
|
|
exten, into_context, prior);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
ast_cli(a->fd, "Failed to add '%s,%s,%s,%s' extension into '%s' context\n",
|
|
|
|
|
exten, prior, app, app_data, a->argv[5]);
|
|
|
|
|
exten, prior, app, app_data, into_context);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return CLI_FAILURE;
|
|
|
|
@ -1011,10 +1014,10 @@ static char *handle_cli_dialplan_add_extension(struct ast_cli_entry *e, int cmd,
|
|
|
|
|
|
|
|
|
|
if (a->argc == 7)
|
|
|
|
|
ast_cli(a->fd, "Extension %s@%s (%s) replace by '%s,%s,%s,%s'\n",
|
|
|
|
|
exten, a->argv[5], prior, exten, prior, app, app_data);
|
|
|
|
|
exten, into_context, prior, exten, prior, app, app_data);
|
|
|
|
|
else
|
|
|
|
|
ast_cli(a->fd, "Extension '%s,%s,%s,%s' added into '%s' context\n",
|
|
|
|
|
exten, prior, app, app_data, a->argv[5]);
|
|
|
|
|
exten, prior, app, app_data, into_context);
|
|
|
|
|
|
|
|
|
|
return CLI_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|