<p>Michael Bradeen has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19905">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_read: Add an option to return terminator on empty digits.<br><br>Adds 'e' option to allow Read() to return the terminator as the<br>dialed digits in the case where only the terminator is entered.<br><br>ie; if "#" is entered, return "#" if the 'e' option is set and ""<br>if it is not.<br><br>ASTERISK-30411<br><br>Change-Id: I49f3221824330a193a20c660f99da0f1fc2cbbc5<br>---<br>M apps/app_read.c<br>A doc/CHANGES-staging/app_read_return_terminator.txt<br>2 files changed, 42 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/05/19905/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_read.c b/apps/app_read.c</span><br><span>index f4a965c..e2ac60c 100644</span><br><span>--- a/apps/app_read.c</span><br><span>+++ b/apps/app_read.c</span><br><span>@@ -85,6 +85,13 @@</span><br><span> and you will need to rely on duration and max digits</span><br><span> for ending input.</para></span><br><span> </option></span><br><span style="color: hsl(120, 100%, 40%);">+ <option name="e"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>to read the terminator as the digit string if the</span><br><span style="color: hsl(120, 100%, 40%);">+ only digit read is the terminator. This is for cases</span><br><span style="color: hsl(120, 100%, 40%);">+ where the terminator is a valid digit, but only by itself.</span><br><span style="color: hsl(120, 100%, 40%);">+ ie; <literal>1234</literal> and <literal>#</literal> are</span><br><span style="color: hsl(120, 100%, 40%);">+ valid, but <literal>1234#</literal> is not.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </option></span><br><span> </optionlist></span><br><span> </parameter></span><br><span> <parameter name="attempts"></span><br><span>@@ -125,6 +132,7 @@</span><br><span> OPT_INDICATION = (1 << 1),</span><br><span> OPT_NOANSWER = (1 << 2),</span><br><span> OPT_TERMINATOR = (1 << 3),</span><br><span style="color: hsl(120, 100%, 40%);">+ OPT_KEEP_TERMINATOR = (1 << 4),</span><br><span> };</span><br><span> </span><br><span> enum {</span><br><span>@@ -138,6 +146,7 @@</span><br><span> AST_APP_OPTION('i', OPT_INDICATION),</span><br><span> AST_APP_OPTION('n', OPT_NOANSWER),</span><br><span> AST_APP_OPTION_ARG('t', OPT_TERMINATOR, OPT_ARG_TERMINATOR),</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_OPTION('e', OPT_KEEP_TERMINATOR),</span><br><span> });</span><br><span> </span><br><span> static char *app = "Read";</span><br><span>@@ -261,12 +270,20 @@</span><br><span> }</span><br><span> } else {</span><br><span> res = ast_app_getdata_terminator(chan, arglist.filename, tmp, maxdigits, to, terminator);</span><br><span style="color: hsl(0, 100%, 40%);">- if (res == AST_GETDATA_COMPLETE || res == AST_GETDATA_EMPTY_END_TERMINATED)</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res == AST_GETDATA_COMPLETE) {</span><br><span> status = "OK";</span><br><span style="color: hsl(0, 100%, 40%);">- else if (res == AST_GETDATA_TIMEOUT)</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (res == AST_GETDATA_EMPTY_END_TERMINATED) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_test_flag(&flags, OPT_KEEP_TERMINATOR)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* if the option is set to do so, read the</span><br><span style="color: hsl(120, 100%, 40%);">+ returned string as the terminator string */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(tmp, terminator, sizeof(tmp));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ status = "OK";</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (res == AST_GETDATA_TIMEOUT) {</span><br><span> status = "TIMEOUT";</span><br><span style="color: hsl(0, 100%, 40%);">- else if (res == AST_GETDATA_INTERRUPTED)</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (res == AST_GETDATA_INTERRUPTED) {</span><br><span> status = "INTERRUPTED";</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> if (res > -1) {</span><br><span> pbx_builtin_setvar_helper(chan, arglist.variable, tmp);</span><br><span>diff --git a/doc/CHANGES-staging/app_read_return_terminator.txt b/doc/CHANGES-staging/app_read_return_terminator.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..2987f77</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_read_return_terminator.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_read</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+A new option 'e' has been added to allow Read() to return the</span><br><span style="color: hsl(120, 100%, 40%);">+terminator as the dialed digits in the case where only the terminator</span><br><span style="color: hsl(120, 100%, 40%);">+is entered.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19905">change 19905</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19905"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 20 </div>
<div style="display:none"> Gerrit-Change-Id: I49f3221824330a193a20c660f99da0f1fc2cbbc5 </div>
<div style="display:none"> Gerrit-Change-Number: 19905 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>