<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16352">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_read: Allow reading # as a digit<br><br>Allows for the digit # to be read as a digit,<br>just like any other DTMF digit, as opposed to<br>forcing it to be used as an end of input<br>indicator. The default behavior remains<br>unchanged.<br><br>ASTERISK-29615 #close<br><br>Change-Id: I3033432adb9d296ad227e76b540b8b4a2417665b<br>---<br>M apps/app_authenticate.c<br>M apps/app_confbridge.c<br>M apps/app_dictate.c<br>M apps/app_meetme.c<br>M apps/app_read.c<br>M apps/app_test.c<br>M apps/app_voicemail.c<br>A doc/CHANGES-staging/app_read.txt<br>M include/asterisk/app.h<br>M main/app.c<br>10 files changed, 31 insertions(+), 15 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/52/16352/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c</span><br><span>index 3ec04b7..7fd6a0b 100644</span><br><span>--- a/apps/app_authenticate.c</span><br><span>+++ b/apps/app_authenticate.c</span><br><span>@@ -159,7 +159,7 @@</span><br><span> </span><br><span> /* Start asking for password */</span><br><span> for (retries = 0; retries < 3; retries++) {</span><br><span style="color: hsl(0, 100%, 40%);">- if ((res = ast_app_getdata(chan, prompt, passwd, maxdigits, 0)) < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((res = ast_app_getdata(chan, prompt, passwd, maxdigits, 0, NULL)) < 0)</span><br><span> break;</span><br><span> </span><br><span> res = 0;</span><br><span>diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c</span><br><span>index 4290521..1eff43a 100644</span><br><span>--- a/apps/app_confbridge.c</span><br><span>+++ b/apps/app_confbridge.c</span><br><span>@@ -2364,7 +2364,7 @@</span><br><span> for (i = 0; i < 3; i++) {</span><br><span> if (ast_app_getdata(chan,</span><br><span> conf_get_sound(CONF_SOUND_GET_PIN, user->b_profile.sounds),</span><br><span style="color: hsl(0, 100%, 40%);">- tmp, len, 0) >= 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ tmp, len, 0, NULL) >= 0) {</span><br><span> if (!strcasecmp(pin, pin_guess)) {</span><br><span> return 0;</span><br><span> }</span><br><span>diff --git a/apps/app_dictate.c b/apps/app_dictate.c</span><br><span>index c64f275..d19bfe9 100644</span><br><span>--- a/apps/app_dictate.c</span><br><span>+++ b/apps/app_dictate.c</span><br><span>@@ -137,7 +137,7 @@</span><br><span> ast_safe_sleep(chan, 200);</span><br><span> for (res = 0; !res;) {</span><br><span> if (ast_strlen_zero(filename)) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_app_getdata(chan, "dictate/enter_filename", filein, sizeof(filein), 0) ||</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_app_getdata(chan, "dictate/enter_filename", filein, sizeof(filein), 0, NULL) ||</span><br><span> ast_strlen_zero(filein)) {</span><br><span> res = -1;</span><br><span> break;</span><br><span>diff --git a/apps/app_meetme.c b/apps/app_meetme.c</span><br><span>index 27d985b..28eab5d 100644</span><br><span>--- a/apps/app_meetme.c</span><br><span>+++ b/apps/app_meetme.c</span><br><span>@@ -4721,7 +4721,7 @@</span><br><span> if (dynamic_pin) {</span><br><span> if (dynamic_pin[0] == 'q') {</span><br><span> /* Query the user to enter a PIN */</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_app_getdata(chan, "conf-getpin", dynamic_pin, pin_buf_len - 1, 0) < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_app_getdata(chan, "conf-getpin", dynamic_pin, pin_buf_len - 1, 0, NULL) < 0)</span><br><span> return NULL;</span><br><span> }</span><br><span> cnf = build_conf(confno, dynamic_pin, "", make, dynamic, refcount, chan, NULL);</span><br><span>@@ -5015,7 +5015,7 @@</span><br><span> </span><br><span> while (allowretry && (ast_strlen_zero(confno)) && (++retrycnt < 4)) {</span><br><span> /* Prompt user for conference number */</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_app_getdata(chan, "conf-getconfno", confno, sizeof(confno) - 1, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_app_getdata(chan, "conf-getconfno", confno, sizeof(confno) - 1, 0, NULL);</span><br><span> if (res < 0) {</span><br><span> /* Don't try to validate when we catch an error */</span><br><span> confno[0] = '\0';</span><br><span>@@ -5079,7 +5079,7 @@</span><br><span> ast_test_suite_event_notify("PLAYBACK", "Message: conf-getpin\r\n"</span><br><span> "Channel: %s",</span><br><span> ast_channel_name(chan));</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_app_getdata(chan, "conf-getpin", pin + strlen(pin), sizeof(pin) - 1 - strlen(pin), 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_app_getdata(chan, "conf-getpin", pin + strlen(pin), sizeof(pin) - 1 - strlen(pin), 0, NULL);</span><br><span> }</span><br><span> if (res >= 0) {</span><br><span> if ((!strcasecmp(pin, cnf->pin) &&</span><br><span>diff --git a/apps/app_read.c b/apps/app_read.c</span><br><span>index 6398281..95890f1 100644</span><br><span>--- a/apps/app_read.c</span><br><span>+++ b/apps/app_read.c</span><br><span>@@ -75,6 +75,13 @@</span><br><span> <option name="n"></span><br><span> <para>to read digits even if the line is not up.</para></span><br><span> </option></span><br><span style="color: hsl(120, 100%, 40%);">+ <option name="p"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>to read <literal>#</literal> as a digit and not</span><br><span style="color: hsl(120, 100%, 40%);">+ an end of input indicator. This will not terminate</span><br><span style="color: hsl(120, 100%, 40%);">+ input and will include <literal>#</literal> in the</span><br><span style="color: hsl(120, 100%, 40%);">+ string of digits entered. You will need to rely</span><br><span style="color: hsl(120, 100%, 40%);">+ on duration and max digits for ending input.</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>@@ -114,12 +121,14 @@</span><br><span> OPT_SKIP = (1 << 0),</span><br><span> OPT_INDICATION = (1 << 1),</span><br><span> OPT_NOANSWER = (1 << 2),</span><br><span style="color: hsl(120, 100%, 40%);">+ OPT_POUND = (1 << 3),</span><br><span> };</span><br><span> </span><br><span> AST_APP_OPTIONS(read_app_options, {</span><br><span> AST_APP_OPTION('s', OPT_SKIP),</span><br><span> AST_APP_OPTION('i', OPT_INDICATION),</span><br><span> AST_APP_OPTION('n', OPT_NOANSWER),</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_OPTION('p', OPT_POUND),</span><br><span> });</span><br><span> </span><br><span> static char *app = "Read";</span><br><span>@@ -223,7 +232,7 @@</span><br><span> break;</span><br><span> }</span><br><span> tmp[x++] = res;</span><br><span style="color: hsl(0, 100%, 40%);">- if (tmp[x-1] == '#') {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tmp[x-1] == '#' && !ast_test_flag(&flags, OPT_POUND)) {</span><br><span> tmp[x-1] = '\0';</span><br><span> status = "OK";</span><br><span> break;</span><br><span>@@ -233,7 +242,7 @@</span><br><span> }</span><br><span> }</span><br><span> } else {</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_app_getdata(chan, arglist.filename, tmp, maxdigits, to);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_app_getdata(chan, arglist.filename, tmp, maxdigits, to, (ast_test_flag(&flags, OPT_POUND) ? "" : NULL));</span><br><span> if (res == AST_GETDATA_COMPLETE || res == AST_GETDATA_EMPTY_END_TERMINATED)</span><br><span> status = "OK";</span><br><span> else if (res == AST_GETDATA_TIMEOUT)</span><br><span>diff --git a/apps/app_test.c b/apps/app_test.c</span><br><span>index 9677270..9289bca 100644</span><br><span>--- a/apps/app_test.c</span><br><span>+++ b/apps/app_test.c</span><br><span>@@ -178,7 +178,7 @@</span><br><span> /* Read server version */</span><br><span> ast_debug(1, "Read server version\n");</span><br><span> if (!res)</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0, NULL);</span><br><span> if (res > 0)</span><br><span> res = 0;</span><br><span> ast_debug(1, "server version: %s\n", serverver);</span><br><span>@@ -336,7 +336,7 @@</span><br><span> /* Read version */</span><br><span> ast_debug(1, "Read client version\n");</span><br><span> if (!res)</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0, NULL);</span><br><span> if (res > 0)</span><br><span> res = 0;</span><br><span> </span><br><span>@@ -350,7 +350,7 @@</span><br><span> res = 0;</span><br><span> </span><br><span> if (!res)</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0, NULL);</span><br><span> ast_debug(1, "read test identifier: %s\n", testid);</span><br><span> /* Check for sneakyness */</span><br><span> if (strchr(testid, '/'))</span><br><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index db531e9..4b242ef 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -12318,7 +12318,7 @@</span><br><span> }</span><br><span> } else {</span><br><span> char temp[256];</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_app_getdata(chan, "vm-whichbox", temp, sizeof(temp) - 1, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_app_getdata(chan, "vm-whichbox", temp, sizeof(temp) - 1, 0, NULL);</span><br><span> if (res < 0)</span><br><span> return res;</span><br><span> if (ast_strlen_zero(temp))</span><br><span>diff --git a/doc/CHANGES-staging/app_read.txt b/doc/CHANGES-staging/app_read.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..df3247c</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_read.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 allows the digit '#' to be read literally,</span><br><span style="color: hsl(120, 100%, 40%);">+rather than used exclusively as the input terminator</span><br><span style="color: hsl(120, 100%, 40%);">+character.</span><br><span>diff --git a/include/asterisk/app.h b/include/asterisk/app.h</span><br><span>index 7690364..9555184 100644</span><br><span>--- a/include/asterisk/app.h</span><br><span>+++ b/include/asterisk/app.h</span><br><span>@@ -129,13 +129,14 @@</span><br><span> * \param s The location where the DTMF data will be stored</span><br><span> * \param maxlen Max Length of the data</span><br><span> * \param timeout Timeout length waiting for data(in milliseconds). Set to 0 for standard timeout(six seconds), or -1 for no time out.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param terminator A string of characters that may be used as terminators to end input. If NULL, "#" will be used.</span><br><span> *</span><br><span> * This function was designed for application programmers for situations where they need</span><br><span> * to play a message and then get some DTMF data in response to the message. If a digit</span><br><span> * is pressed during playback, it will immediately break out of the message and continue</span><br><span> * execution of your code.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout);</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator);</span><br><span> </span><br><span> /*! \brief Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other full functions */</span><br><span> int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd);</span><br><span>diff --git a/main/app.c b/main/app.c</span><br><span>index 09c0123..324e544 100644</span><br><span>--- a/main/app.c</span><br><span>+++ b/main/app.c</span><br><span>@@ -193,8 +193,9 @@</span><br><span> * \param s The string to read in to. Must be at least the size of your length</span><br><span> * \param maxlen How many digits to read (maximum)</span><br><span> * \param timeout set timeout to 0 for "standard" timeouts. Set timeout to -1 for</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param terminator A string of characters that may be used as terminators to end input. Typically "#"</span><br><span> * "ludicrous time" (essentially never times out) */</span><br><span style="color: hsl(0, 100%, 40%);">-enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)</span><br><span style="color: hsl(120, 100%, 40%);">+enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, char *terminator)</span><br><span> {</span><br><span> int res = 0, to, fto;</span><br><span> char *front, *filename;</span><br><span>@@ -232,7 +233,7 @@</span><br><span> fto = 50;</span><br><span> to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_readstring(c, s, maxlen, to, fto, "#");</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_readstring(c, s, maxlen, to, fto, (terminator ? terminator : "#"));</span><br><span> if (res == AST_GETDATA_EMPTY_END_TERMINATED) {</span><br><span> return res;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16352">change 16352</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/+/16352"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I3033432adb9d296ad227e76b540b8b4a2417665b </div>
<div style="display:none"> Gerrit-Change-Number: 16352 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>