[asterisk-commits] dvossel: branch 1.6.0 r180078 - in /branches/1.6.0: ./ apps/ include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 3 17:35:23 CST 2009
Author: dvossel
Date: Tue Mar 3 17:35:18 2009
New Revision: 180078
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=180078
Log:
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/
........
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/apps/app_read.c
branches/1.6.0/include/asterisk/app.h
branches/1.6.0/main/app.c
branches/1.6.0/main/channel.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/apps/app_read.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/apps/app_read.c?view=diff&rev=180078&r1=180077&r2=180078
==============================================================================
--- branches/1.6.0/apps/app_read.c (original)
+++ branches/1.6.0/apps/app_read.c Tue Mar 3 17:35:18 2009
@@ -185,11 +185,11 @@
}
} else {
res = ast_app_getdata(chan, arglist.filename, tmp, maxdigits, to);
- if (res == 0)
+ if (res == AST_GETDATA_COMPLETE || res == AST_GETDATA_EMPTY_END_TERMINATED)
status = "OK";
- else if (res == 1)
+ else if (res == AST_GETDATA_TIMEOUT)
status = "TIMEOUT";
- else if (res == 2)
+ else if (res == AST_GETDATA_INTERRUPTED)
status = "INTERRUPTED";
}
if (res > -1) {
Modified: branches/1.6.0/include/asterisk/app.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/include/asterisk/app.h?view=diff&rev=180078&r1=180077&r2=180078
==============================================================================
--- branches/1.6.0/include/asterisk/app.h (original)
+++ branches/1.6.0/include/asterisk/app.h Tue Mar 3 17:35:18 2009
@@ -196,6 +196,16 @@
'silencethreshold' or use '-1' for either or both parameters for defaults. */
int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence_ms);
+enum ast_getdata_result {
+ AST_GETDATA_FAILED = -1,
+ AST_GETDATA_COMPLETE = 0,
+ AST_GETDATA_TIMEOUT = 1,
+ AST_GETDATA_INTERRUPTED = 2,
+ /*! indicates a user terminated empty string rather than an empty string resulting
+ * from a timeout or other factors */
+ AST_GETDATA_EMPTY_END_TERMINATED = 3,
+};
+
enum AST_LOCK_RESULT {
AST_LOCK_SUCCESS = 0,
AST_LOCK_TIMEOUT = -1,
Modified: branches/1.6.0/main/app.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/main/app.c?view=diff&rev=180078&r1=180077&r2=180078
==============================================================================
--- branches/1.6.0/main/app.c (original)
+++ branches/1.6.0/main/app.c Tue Mar 3 17:35:18 2009
@@ -108,7 +108,7 @@
* \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 @@
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;
}
Modified: branches/1.6.0/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/main/channel.c?view=diff&rev=180078&r1=180077&r2=180078
==============================================================================
--- branches/1.6.0/main/channel.c (original)
+++ branches/1.6.0/main/channel.c Tue Mar 3 17:35:18 2009
@@ -3692,20 +3692,25 @@
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;
- }
- if (!strchr(enders, d))
+ 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)) {
s[pos++] = d;
+ }
if (strchr(enders, d) || (pos >= len)) {
- s[pos]='\0';
- return 0;
+ s[pos] = '\0';
+ return AST_GETDATA_COMPLETE;
}
to = timeout;
}
More information about the asterisk-commits
mailing list