app_externalivr.c: Fix mixed leading whitespace in source code.

No functional changes.

Change-Id: I46514152c0af67f395526374aaa847ccd6a85378
16.22
Sean Bright 4 years ago committed by Kevin Harwell
parent 5f4d3e2822
commit d406cc2acd

@ -254,9 +254,9 @@ static struct ast_frame *gen_readframe(struct gen_state *state)
if (!(state->stream && (f = ast_readframe(state->stream)))) { if (!(state->stream && (f = ast_readframe(state->stream)))) {
if (state->current) { if (state->current) {
/* remove finished file from playlist */ /* remove finished file from playlist */
AST_LIST_LOCK(&u->playlist); AST_LIST_LOCK(&u->playlist);
AST_LIST_REMOVE_HEAD(&u->playlist, list); AST_LIST_REMOVE_HEAD(&u->playlist, list);
AST_LIST_UNLOCK(&u->playlist); AST_LIST_UNLOCK(&u->playlist);
/* add finished file to finishlist */ /* add finished file to finishlist */
AST_LIST_LOCK(&u->finishlist); AST_LIST_LOCK(&u->finishlist);
AST_LIST_INSERT_TAIL(&u->finishlist, state->current, list); AST_LIST_INSERT_TAIL(&u->finishlist, state->current, list);
@ -581,7 +581,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
} }
} }
exit: exit:
if (u->gen_active) { if (u->gen_active) {
ast_deactivate_generator(chan); ast_deactivate_generator(chan);
} }
@ -622,21 +622,21 @@ static int app_exec(struct ast_channel *chan, const char *data)
} }
static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
struct ast_iostream *eivr_events, struct ast_iostream *eivr_events,
struct ast_iostream *eivr_commands, struct ast_iostream *eivr_commands,
struct ast_iostream *eivr_errors, struct ast_iostream *eivr_errors,
const struct ast_str *args, const struct ast_flags flags) const struct ast_str *args, const struct ast_flags flags)
{ {
char input[1024]; char input[1024];
struct playlist_entry *entry; struct playlist_entry *entry;
struct ast_frame *f; struct ast_frame *f;
int ms; int ms;
int exception; int exception;
int ready_fd; int ready_fd;
int waitfds[2]; int waitfds[2];
int r; int r;
struct ast_channel *rchan; struct ast_channel *rchan;
int res = -1; int res = -1;
int hangup_info_sent = 0; int hangup_info_sent = 0;
waitfds[0] = ast_iostream_get_fd(eivr_commands); waitfds[0] = ast_iostream_get_fd(eivr_commands);
@ -645,78 +645,78 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
while (1) { while (1) {
if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)) { if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)) {
ast_chan_log(LOG_ERROR, chan, "Is a zombie\n"); ast_chan_log(LOG_ERROR, chan, "Is a zombie\n");
break; break;
} }
if (!hangup_info_sent && !(ast_test_flag(&flags, run_dead)) && ast_check_hangup(chan)) { if (!hangup_info_sent && !(ast_test_flag(&flags, run_dead)) && ast_check_hangup(chan)) {
if (ast_test_flag(&flags, ignore_hangup)) { if (ast_test_flag(&flags, ignore_hangup)) {
ast_verb(3, "Got check_hangup, but ignore_hangup set so sending 'I' command\n"); ast_verb(3, "Got check_hangup, but ignore_hangup set so sending 'I' command\n");
send_eivr_event(eivr_events, 'I', "HANGUP", chan); send_eivr_event(eivr_events, 'I', "HANGUP", chan);
hangup_info_sent = 1; hangup_info_sent = 1;
} else { } else {
ast_verb(3, "Got check_hangup\n"); ast_verb(3, "Got check_hangup\n");
send_eivr_event(eivr_events, 'H', NULL, chan); send_eivr_event(eivr_events, 'H', NULL, chan);
break; break;
} }
} }
ready_fd = 0; ready_fd = 0;
ms = 100; ms = 100;
errno = 0; errno = 0;
exception = 0; exception = 0;
rchan = ast_waitfor_nandfds(&chan, 1, waitfds, (eivr_errors) ? 2 : 1, &exception, &ready_fd, &ms); rchan = ast_waitfor_nandfds(&chan, 1, waitfds, (eivr_errors) ? 2 : 1, &exception, &ready_fd, &ms);
if (ast_channel_state(chan) == AST_STATE_UP && !AST_LIST_EMPTY(&u->finishlist)) { if (ast_channel_state(chan) == AST_STATE_UP && !AST_LIST_EMPTY(&u->finishlist)) {
AST_LIST_LOCK(&u->finishlist); AST_LIST_LOCK(&u->finishlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->finishlist, list))) { while ((entry = AST_LIST_REMOVE_HEAD(&u->finishlist, list))) {
send_eivr_event(eivr_events, 'F', entry->filename, chan); send_eivr_event(eivr_events, 'F', entry->filename, chan);
ast_free(entry); ast_free(entry);
} }
AST_LIST_UNLOCK(&u->finishlist); AST_LIST_UNLOCK(&u->finishlist);
} }
if (ast_channel_state(chan) == AST_STATE_UP && !(ast_check_hangup(chan)) && rchan) { if (ast_channel_state(chan) == AST_STATE_UP && !(ast_check_hangup(chan)) && rchan) {
/* the channel has something */ /* the channel has something */
f = ast_read(chan); f = ast_read(chan);
if (!f) { if (!f) {
ast_verb(3, "Returned no frame\n"); ast_verb(3, "Returned no frame\n");
send_eivr_event(eivr_events, 'H', NULL, chan); send_eivr_event(eivr_events, 'H', NULL, chan);
break; break;
} }
if (f->frametype == AST_FRAME_DTMF) { if (f->frametype == AST_FRAME_DTMF) {
send_eivr_event(eivr_events, f->subclass.integer, NULL, chan); send_eivr_event(eivr_events, f->subclass.integer, NULL, chan);
if (u->option_autoclear) { if (u->option_autoclear) {
AST_LIST_LOCK(&u->playlist); AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) { if (!u->abort_current_sound && !u->playing_silence) {
/* send interrupted file as T data */ /* send interrupted file as T data */
if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'T', entry->filename, chan); send_eivr_event(eivr_events, 'T', entry->filename, chan);
ast_free(entry); ast_free(entry);
} }
} }
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan); send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry); ast_free(entry);
} }
if (!u->playing_silence) if (!u->playing_silence)
u->abort_current_sound = 1; u->abort_current_sound = 1;
AST_LIST_UNLOCK(&u->playlist); AST_LIST_UNLOCK(&u->playlist);
} }
} else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) { } else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
ast_verb(3, "Got AST_CONTROL_HANGUP\n"); ast_verb(3, "Got AST_CONTROL_HANGUP\n");
send_eivr_event(eivr_events, 'H', NULL, chan); send_eivr_event(eivr_events, 'H', NULL, chan);
if (f->data.uint32) { if (f->data.uint32) {
ast_channel_hangupcause_set(chan, f->data.uint32); ast_channel_hangupcause_set(chan, f->data.uint32);
} }
ast_frfree(f); ast_frfree(f);
break; break;
} }
ast_frfree(f); ast_frfree(f);
} else if (ready_fd == waitfds[0]) { } else if (ready_fd == waitfds[0]) {
if (exception) { if (exception) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n"); ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break; break;
} }
r = ast_iostream_gets(eivr_commands, input, sizeof(input)); r = ast_iostream_gets(eivr_commands, input, sizeof(input));
if (r <= 0) { if (r <= 0) {
@ -784,112 +784,112 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
u->abort_current_sound = 1; u->abort_current_sound = 1;
} }
AST_LIST_UNLOCK(&u->playlist); AST_LIST_UNLOCK(&u->playlist);
} else if (input[0] == EIVR_CMD_SQUE) { } else if (input[0] == EIVR_CMD_SQUE) {
if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) { if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Queue re'S'et called on unanswered channel\n"); ast_chan_log(LOG_WARNING, chan, "Queue re'S'et called on unanswered channel\n");
send_eivr_event(eivr_events, 'Z', NULL, chan); send_eivr_event(eivr_events, 'Z', NULL, chan);
continue; continue;
} }
if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) { if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) {
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]); ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan); send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else { } else {
AST_LIST_LOCK(&u->playlist); AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) { if (!u->abort_current_sound && !u->playing_silence) {
/* send interrupted file as T data */ /* send interrupted file as T data */
if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'T', entry->filename, chan); send_eivr_event(eivr_events, 'T', entry->filename, chan);
ast_free(entry); ast_free(entry);
} }
} }
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan); send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry); ast_free(entry);
} }
if (!u->playing_silence) { if (!u->playing_silence) {
u->abort_current_sound = 1; u->abort_current_sound = 1;
} }
entry = make_entry(&input[2]); entry = make_entry(&input[2]);
if (entry) { if (entry) {
AST_LIST_INSERT_TAIL(&u->playlist, entry, list); AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
} }
AST_LIST_UNLOCK(&u->playlist); AST_LIST_UNLOCK(&u->playlist);
} }
} else if (input[0] == EIVR_CMD_APND) { } else if (input[0] == EIVR_CMD_APND) {
if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) { if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n"); ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n");
send_eivr_event(eivr_events, 'Z', NULL, chan); send_eivr_event(eivr_events, 'Z', NULL, chan);
continue; continue;
} }
if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) { if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) {
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]); ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan); send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else { } else {
entry = make_entry(&input[2]); entry = make_entry(&input[2]);
if (entry) { if (entry) {
AST_LIST_LOCK(&u->playlist); AST_LIST_LOCK(&u->playlist);
AST_LIST_INSERT_TAIL(&u->playlist, entry, list); AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
AST_LIST_UNLOCK(&u->playlist); AST_LIST_UNLOCK(&u->playlist);
} }
} }
} else if (input[0] == EIVR_CMD_GET) { } else if (input[0] == EIVR_CMD_GET) {
char response[2048]; char response[2048];
ast_verb(4, "Retriving Variables from channel: %s\n", &input[2]); ast_verb(4, "Retriving Variables from channel: %s\n", &input[2]);
ast_eivr_getvariable(chan, &input[2], response, sizeof(response)); ast_eivr_getvariable(chan, &input[2], response, sizeof(response));
send_eivr_event(eivr_events, 'G', response, chan); send_eivr_event(eivr_events, 'G', response, chan);
} else if (input[0] == EIVR_CMD_SVAR) { } else if (input[0] == EIVR_CMD_SVAR) {
ast_verb(4, "Setting Variables in channel: %s\n", &input[2]); ast_verb(4, "Setting Variables in channel: %s\n", &input[2]);
ast_eivr_setvariable(chan, &input[2]); ast_eivr_setvariable(chan, &input[2]);
} else if (input[0] == EIVR_CMD_LOG) { } else if (input[0] == EIVR_CMD_LOG) {
ast_chan_log(LOG_NOTICE, chan, "Log message from EIVR: %s\n", &input[2]); ast_chan_log(LOG_NOTICE, chan, "Log message from EIVR: %s\n", &input[2]);
} else if (input[0] == EIVR_CMD_XIT) { } else if (input[0] == EIVR_CMD_XIT) {
ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]); ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
ast_chan_log(LOG_WARNING, chan, "e'X'it command is depricated, use 'E'xit instead\n"); ast_chan_log(LOG_WARNING, chan, "e'X'it command is depricated, use 'E'xit instead\n");
res = 0; res = 0;
break; break;
} else if (input[0] == EIVR_CMD_EXIT) { } else if (input[0] == EIVR_CMD_EXIT) {
ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]); ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
send_eivr_event(eivr_events, 'E', NULL, chan); send_eivr_event(eivr_events, 'E', NULL, chan);
res = 0; res = 0;
break; break;
} else if (input[0] == EIVR_CMD_HGUP) { } else if (input[0] == EIVR_CMD_HGUP) {
ast_chan_log(LOG_NOTICE, chan, "Hanging up: %s\n", &input[2]); ast_chan_log(LOG_NOTICE, chan, "Hanging up: %s\n", &input[2]);
send_eivr_event(eivr_events, 'H', NULL, chan); send_eivr_event(eivr_events, 'H', NULL, chan);
break; break;
} else if (input[0] == EIVR_CMD_OPT) { } else if (input[0] == EIVR_CMD_OPT) {
if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) { if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Option called on unanswered channel\n"); ast_chan_log(LOG_WARNING, chan, "Option called on unanswered channel\n");
send_eivr_event(eivr_events, 'Z', NULL, chan); send_eivr_event(eivr_events, 'Z', NULL, chan);
continue; continue;
} }
if (!strcasecmp(&input[2], "autoclear")) if (!strcasecmp(&input[2], "autoclear"))
u->option_autoclear = 1; u->option_autoclear = 1;
else if (!strcasecmp(&input[2], "noautoclear")) else if (!strcasecmp(&input[2], "noautoclear"))
u->option_autoclear = 0; u->option_autoclear = 0;
else else
ast_chan_log(LOG_WARNING, chan, "Unknown option requested: %s\n", &input[2]); ast_chan_log(LOG_WARNING, chan, "Unknown option requested: %s\n", &input[2]);
}
} else if (ready_fd == waitfds[1]) {
if (exception) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
}
r = ast_iostream_gets(eivr_errors, input, sizeof(input));
if (r > 0) {
ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", ast_strip(input));
} else if (r == 0) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
} }
} else if ((ready_fd < 0) && ms) { } else if (ready_fd == waitfds[1]) {
if (errno == 0 || errno == EINTR) if (exception) {
continue; ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
ast_chan_log(LOG_ERROR, chan, "Wait failed (%s)\n", strerror(errno)); }
break;
} r = ast_iostream_gets(eivr_errors, input, sizeof(input));
} if (r > 0) {
ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", ast_strip(input));
} else if (r == 0) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
}
} else if ((ready_fd < 0) && ms) {
if (errno == 0 || errno == EINTR)
continue;
ast_chan_log(LOG_ERROR, chan, "Wait failed (%s)\n", strerror(errno));
break;
}
}
return res; return res;
} }

Loading…
Cancel
Save