Index: asterisk/apps/app_externalivr.c =================================================================== --- asterisk/apps/app_externalivr.c (revision 227422) +++ asterisk/apps/app_externalivr.c (working copy) @@ -361,8 +361,13 @@ char *buf; int j; char *s, **app_args, *e; - struct ast_str *pipe_delim_args = ast_str_create(100); + struct ast_str *comma_delim_args = ast_str_create(100); + if (ast_strlen_zero(data)) { + ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n"); + return -1; + } + AST_DECLARE_APP_ARGS(eivr_args, AST_APP_ARG(cmd)[32]; ); @@ -376,6 +381,8 @@ buf = ast_strdupa(data); AST_STANDARD_APP_ARGS(eivr_args, buf); + /* If there is a parenthesis in the line it is expected to + contain the arguments to the command or server connection */ if ((s = strchr(eivr_args.cmd[0], '('))) { s[0] = ','; if (( e = strrchr(s, ')')) ) { @@ -383,39 +390,30 @@ } else { ast_log(LOG_ERROR, "Parse error, no closing paren?\n"); } - AST_STANDARD_APP_ARGS(application_args, eivr_args.cmd[0]); - app_args = application_args.argv; + } - /* Put the application + the arguments in a | delimited list */ - ast_str_reset(pipe_delim_args); - for (j = 0; application_args.cmd[j] != NULL; j++) { - ast_str_append(&pipe_delim_args, 0, "%s%s", j == 0 ? "" : ",", application_args.cmd[j]); - } + AST_STANDARD_APP_ARGS(application_args, eivr_args.cmd[0]); + app_args = application_args.argv; - /* Parse the ExternalIVR() arguments */ - if (option_debug) - ast_debug(1, "Parsing options from: [%s]\n", eivr_args.cmd[1]); - ast_app_parse_options(app_opts, &flags, opts, eivr_args.cmd[1]); - if (option_debug) { - if (ast_test_flag(&flags, noanswer)) - ast_debug(1, "noanswer is set\n"); - if (ast_test_flag(&flags, ignore_hangup)) - ast_debug(1, "ignore_hangup is set\n"); - if (ast_test_flag(&flags, run_dead)) - ast_debug(1, "run_dead is set\n"); - } + /* Put the application + the arguments in a , delimited list */ + ast_str_reset(comma_delim_args); + for (j = 0; application_args.cmd[j] != NULL; j++) { + ast_str_append(&comma_delim_args, 0, "%s%s", j == 0 ? "" : ",", application_args.cmd[j]); + } - } else { - app_args = eivr_args.argv; - for (j = 0; eivr_args.cmd[j] != NULL; j++) { - ast_str_append(&pipe_delim_args, 0, "%s%s", j == 0 ? "" : "|", eivr_args.cmd[j]); - } + /* Parse the ExternalIVR() arguments */ + printf("Debug: %i\n", option_debug); + if (option_debug) + ast_debug(1, "Parsing options from: [%s]\n", eivr_args.cmd[1]); + ast_app_parse_options(app_opts, &flags, opts, eivr_args.cmd[1]); + if (option_debug) { + if (ast_test_flag(&flags, noanswer)) + ast_debug(1, "noanswer is set\n"); + if (ast_test_flag(&flags, ignore_hangup)) + ast_debug(1, "ignore_hangup is set\n"); + if (ast_test_flag(&flags, run_dead)) + ast_debug(1, "run_dead is set\n"); } - - if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n"); - return -1; - } if (!(ast_test_flag(&flags, noanswer))) { ast_chan_log(LOG_WARNING, chan, "Answering channel and starting generator\n"); @@ -460,7 +458,7 @@ if (!(ser = ast_tcptls_client_create(&ivr_desc)) || !(ser = ast_tcptls_client_start(ser))) { goto exit; } - res = eivr_comm(chan, u, ser->fd, ser->fd, -1, pipe_delim_args, flags); + res = eivr_comm(chan, u, ser->fd, ser->fd, -1, comma_delim_args, flags); } else { @@ -503,7 +501,7 @@ child_stdout[1] = 0; close(child_stderr[1]); child_stderr[1] = 0; - res = eivr_comm(chan, u, child_stdin[1], child_stdout[0], child_stderr[0], pipe_delim_args, flags); + res = eivr_comm(chan, u, child_stdin[1], child_stdout[0], child_stderr[0], comma_delim_args, flags); } }