aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-03 23:35:18 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-03 23:35:18 +0000
commit410e3b05bb72a98104cb3b15b5f6354eca84f578 (patch)
tree29c64df6b69cd4caa781ea652375704d22cb56c3 /main
parent5d81fa4632200e814e7374e5f05460fcfeafc38a (diff)
Merged revisions 180032 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r180032 | dvossel | 2009-03-03 17:21:18 -0600 (Tue, 03 Mar 2009) | 14 lines 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/branches/1.6.0@180078 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/app.c10
-rw-r--r--main/channel.c21
2 files changed, 20 insertions, 11 deletions
diff --git a/main/app.c b/main/app.c
index 757df2155..56ddff438 100644
--- a/main/app.c
+++ b/main/app.c
@@ -108,7 +108,7 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect,
* \param maxlen How many digits to read (maximum)
* \param timeout set timeout to 0 for "standard" timeouts. Set timeout to -1 for
* "ludicrous time" (essentially never times out) */
-int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
+enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
{
int res = 0, to, fto;
char *front, *filename;
@@ -145,10 +145,14 @@ int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxl
to = c->pbx ? c->pbx->dtimeout * 1000 : 2000;
}
res = ast_readstring(c, s, maxlen, to, fto, "#");
- if (!ast_strlen_zero(s))
+ if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
return res;
+ }
+ if (!ast_strlen_zero(s)) {
+ return res;
+ }
}
-
+
return res;
}
diff --git a/main/channel.c b/main/channel.c
index d788e79a2..e7b2c8626 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3692,20 +3692,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;
}