|
|
@ -5368,6 +5368,8 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
|
|
|
|
int pos = 0; /* index in the buffer where we accumulate digits */
|
|
|
|
int pos = 0; /* index in the buffer where we accumulate digits */
|
|
|
|
int to = ftimeout;
|
|
|
|
int to = ftimeout;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct ast_silence_generator *silgen = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* Stop if we're a zombie or need a soft hangup */
|
|
|
|
/* Stop if we're a zombie or need a soft hangup */
|
|
|
|
if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
|
|
|
|
if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
@ -5378,24 +5380,33 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
|
|
|
|
if (c->stream) {
|
|
|
|
if (c->stream) {
|
|
|
|
d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
|
|
|
|
d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
|
|
|
|
ast_stopstream(c);
|
|
|
|
ast_stopstream(c);
|
|
|
|
|
|
|
|
if (!silgen && ast_opt_transmit_silence)
|
|
|
|
|
|
|
|
silgen = ast_channel_start_silence_generator(c);
|
|
|
|
usleep(1000);
|
|
|
|
usleep(1000);
|
|
|
|
if (!d)
|
|
|
|
if (!d)
|
|
|
|
d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
|
|
|
|
d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!silgen && ast_opt_transmit_silence)
|
|
|
|
|
|
|
|
silgen = ast_channel_start_silence_generator(c);
|
|
|
|
d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
|
|
|
|
d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (d < 0)
|
|
|
|
if (d < 0) {
|
|
|
|
|
|
|
|
ast_channel_stop_silence_generator(c, silgen);
|
|
|
|
return AST_GETDATA_FAILED;
|
|
|
|
return AST_GETDATA_FAILED;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (d == 0) {
|
|
|
|
if (d == 0) {
|
|
|
|
s[pos] = '\0';
|
|
|
|
s[pos] = '\0';
|
|
|
|
|
|
|
|
ast_channel_stop_silence_generator(c, silgen);
|
|
|
|
return AST_GETDATA_TIMEOUT;
|
|
|
|
return AST_GETDATA_TIMEOUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (d == 1) {
|
|
|
|
if (d == 1) {
|
|
|
|
s[pos] = '\0';
|
|
|
|
s[pos] = '\0';
|
|
|
|
|
|
|
|
ast_channel_stop_silence_generator(c, silgen);
|
|
|
|
return AST_GETDATA_INTERRUPTED;
|
|
|
|
return AST_GETDATA_INTERRUPTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strchr(enders, d) && (pos == 0)) {
|
|
|
|
if (strchr(enders, d) && (pos == 0)) {
|
|
|
|
s[pos] = '\0';
|
|
|
|
s[pos] = '\0';
|
|
|
|
|
|
|
|
ast_channel_stop_silence_generator(c, silgen);
|
|
|
|
return AST_GETDATA_EMPTY_END_TERMINATED;
|
|
|
|
return AST_GETDATA_EMPTY_END_TERMINATED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!strchr(enders, d)) {
|
|
|
|
if (!strchr(enders, d)) {
|
|
|
@ -5403,6 +5414,7 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strchr(enders, d) || (pos >= len)) {
|
|
|
|
if (strchr(enders, d) || (pos >= len)) {
|
|
|
|
s[pos] = '\0';
|
|
|
|
s[pos] = '\0';
|
|
|
|
|
|
|
|
ast_channel_stop_silence_generator(c, silgen);
|
|
|
|
return AST_GETDATA_COMPLETE;
|
|
|
|
return AST_GETDATA_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
to = timeout;
|
|
|
|
to = timeout;
|
|
|
|