aboutsummaryrefslogtreecommitdiffstats
path: root/main/channel.c
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-03 23:21:18 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-03 23:21:18 +0000
commit58c677376bcc0c5d6b2bacb5cf7f4de97668d7c5 (patch)
tree2fd0a6b4707320506831b0594014dd1a8fa27e25 /main/channel.c
parentad19b153c4df13455e5fe62d92ecdba3e4ceac5b (diff)
app_read does not break from prompt loop with user terminated empty string
In app.c, ast_app_getdata is called to stream the prompts and receive DTMF input. If ast_app_getdata() receives an empty string caused by the user inputing the end of string character, in this case '#', it should break from the prompt loop and return to app_read, but instead it cycles through all the prompts. I've added a return value for this special case in ast_readstring() which uses an enum I've delcared in apps.h. This enum is now used as a return value for ast_app_getdata(). (closes issue #14279) Reported by: Marquis Patches: fix_app_read.patch uploaded by Marquis (license 32) read-ampersanmd.patch2 uploaded by dvossel (license 671) Tested by: Marquis, dvossel Review: http://reviewboard.digium.com/r/177/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@180032 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/main/channel.c b/main/channel.c
index a39dfb906..c457e28a7 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3709,20 +3709,25 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
}
if (d < 0)
- return -1;
+ return AST_GETDATA_FAILED;
if (d == 0) {
- s[pos]='\0';
- return 1;
+ s[pos] = '\0';
+ return AST_GETDATA_TIMEOUT;
}
if (d == 1) {
- s[pos]='\0';
- return 2;
+ s[pos] = '\0';
+ return AST_GETDATA_INTERRUPTED;
+ }
+ if (strchr(enders, d) && (pos == 0)) {
+ s[pos] = '\0';
+ return AST_GETDATA_EMPTY_END_TERMINATED;
}
- if (!strchr(enders, d))
+ if (!strchr(enders, d)) {
s[pos++] = d;
+ }
if (strchr(enders, d) || (pos >= len)) {
- s[pos]='\0';
- return 0;
+ s[pos] = '\0';
+ return AST_GETDATA_COMPLETE;
}
to = timeout;
}