<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16250">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_dtmfstore: New application to store digits<br><br>Adds application to asynchronously collect digits<br>dialed on a channel in the TX or RX direction<br>using a framehook and stores them in a specified<br>variable, up to a configurable number of digits.<br><br>ASTERISK-29477<br><br>Change-Id: I51aa93fc9507f7636ac44806c4420ce690423e6f<br>---<br>A apps/app_dtmfstore.c<br>A doc/CHANGES-staging/app_dtmfstore.txt<br>2 files changed, 292 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_dtmfstore.c b/apps/app_dtmfstore.c</span><br><span>new file mode 100644</span><br><span>index 0000000..4e97334</span><br><span>--- /dev/null</span><br><span>+++ b/apps/app_dtmfstore.c</span><br><span>@@ -0,0 +1,286 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Asterisk -- An open source telephony toolkit.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2021, Naveen Albert</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Naveen Albert <asterisk@phreaknet.org></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * See http://www.asterisk.org for more information about</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Asterisk project. Please do not directly contact</span><br><span style="color: hsl(120, 100%, 40%);">+ * any of the maintainers of this project for assistance;</span><br><span style="color: hsl(120, 100%, 40%);">+ * the project provides a web site, mailing lists and IRC</span><br><span style="color: hsl(120, 100%, 40%);">+ * channels for your use.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software, distributed under the terms of</span><br><span style="color: hsl(120, 100%, 40%);">+ * the GNU General Public License Version 2. See the LICENSE file</span><br><span style="color: hsl(120, 100%, 40%);">+ * at the top of the source tree.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Technology independent asynchronous DTMF collection</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \author Naveen Albert <asterisk@phreaknet.org></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \ingroup functions</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*** MODULEINFO</span><br><span style="color: hsl(120, 100%, 40%);">+ <support_level>extended</support_level></span><br><span style="color: hsl(120, 100%, 40%);">+ ***/</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/module.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/channel.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/pbx.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/framehook.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/app.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/conversions.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*** DOCUMENTATION</span><br><span style="color: hsl(120, 100%, 40%);">+ <application name="StoreDTMF" language="en_US"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ Stores DTMF digits transmitted or received on a channel.</span><br><span style="color: hsl(120, 100%, 40%);">+ </synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ <syntax></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="direction" required="true"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>Must be <literal>TX</literal> or <literal>RX</literal>.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+ </syntax></span><br><span style="color: hsl(120, 100%, 40%);">+ <description></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>The StoreDTMF function can be used to obtain digits sent in the</span><br><span style="color: hsl(120, 100%, 40%);">+ <literal>TX</literal> or <literal>RX</literal> direction of any channel.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>The arguments are:</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para><replaceable>var_name</replaceable>: Name of variable to which to append</span><br><span style="color: hsl(120, 100%, 40%);">+ digits.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para><replaceable>max_digits</replaceable>: The maximum number of digits to</span><br><span style="color: hsl(120, 100%, 40%);">+ store in the variable. Defaults to 0 (no maximum). After reading <literal></span><br><span style="color: hsl(120, 100%, 40%);">+ maximum</literal> digits, no more digits will be stored.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>For example:</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>StoreDTMF(TX,CDR(digits))</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>StoreDTMF(RX,testvar,24)</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>StoreDTMF(remove)</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </description></span><br><span style="color: hsl(120, 100%, 40%);">+ </application></span><br><span style="color: hsl(120, 100%, 40%);">+ ***/</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static char *app = "StoreDTMF";</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Private data structure used with the function's datastore */</span><br><span style="color: hsl(120, 100%, 40%);">+struct dtmf_store_data {</span><br><span style="color: hsl(120, 100%, 40%);">+ int framehook_id;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *rx_var;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *tx_var;</span><br><span style="color: hsl(120, 100%, 40%);">+ int maxdigits;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void datastore_destroy_cb(void *data) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dtmf_store_data *d;</span><br><span style="color: hsl(120, 100%, 40%);">+ d = data;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (d) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (d->rx_var) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(d->rx_var);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (d->tx_var) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(d->tx_var);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(data);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief The channel datastore the function uses to store state */</span><br><span style="color: hsl(120, 100%, 40%);">+static const struct ast_datastore_info dtmf_store_datastore = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .type = "dtmf_store",</span><br><span style="color: hsl(120, 100%, 40%);">+ .destroy = datastore_destroy_cb</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \internal \brief Store digits tx/rx on the channel */</span><br><span style="color: hsl(120, 100%, 40%);">+static int remove_dtmf_store(struct ast_channel *chan)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_datastore *datastore = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dtmf_store_data *data;</span><br><span style="color: hsl(120, 100%, 40%);">+ SCOPED_CHANNELLOCK(chan_lock, chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ datastore = ast_channel_datastore_find(chan, &dtmf_store_datastore, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!datastore) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_WARNING, "Cannot remove StoreDTMF from %s: StoreDTMF not currently enabled\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ data = datastore->data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_framehook_detach(chan, data->framehook_id)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_WARNING, "Failed to remove StoreDTMF framehook from channel %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_channel_datastore_remove(chan, datastore)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_WARNING, "Failed to remove StoreDTMF datastore from channel %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_datastore_free(datastore);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Frame hook that is called to intercept digit/undigit */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct ast_frame *dtmf_store_framehook(struct ast_channel *chan,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_frame *f, enum ast_framehook_event event, void *data)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ char currentdata[512];</span><br><span style="color: hsl(120, 100%, 40%);">+ char varnamesub[64];</span><br><span style="color: hsl(120, 100%, 40%);">+ char *varname = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dtmf_store_data *framedata = data;</span><br><span style="color: hsl(120, 100%, 40%);">+ int len;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!f || !framedata) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return f;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((event != AST_FRAMEHOOK_EVENT_WRITE) && (event != AST_FRAMEHOOK_EVENT_READ)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return f;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (f->frametype != AST_FRAME_DTMF_END) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return f;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If this is DTMF then store the digits */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (event == AST_FRAMEHOOK_EVENT_READ && framedata->rx_var) { /* coming from source */</span><br><span style="color: hsl(120, 100%, 40%);">+ varname = framedata->rx_var;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (event == AST_FRAMEHOOK_EVENT_WRITE && framedata->tx_var) { /* going to source */</span><br><span style="color: hsl(120, 100%, 40%);">+ varname = framedata->tx_var;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!varname) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return f;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ sprintf(varnamesub, "${%s}", varname);</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_substitute_variables_helper(chan, varnamesub, currentdata, 511);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* pbx_builtin_getvar_helper works for regular vars but not CDR vars */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(currentdata)) { /* var doesn't exist yet */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "Creating new digit store: %s\n", varname);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ len = strlen(currentdata);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (framedata->maxdigits > 0 && len >= framedata->maxdigits) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "Reached digit limit: %d\n", framedata->maxdigits);</span><br><span style="color: hsl(120, 100%, 40%);">+ remove_dtmf_store(chan); /* reached max digit count, stop now */</span><br><span style="color: hsl(120, 100%, 40%);">+ return f;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ char newdata[len + 2]; /* one more char + terminator */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (len > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(newdata, currentdata, len + 2);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ newdata[len] = (unsigned) f->subclass.integer;</span><br><span style="color: hsl(120, 100%, 40%);">+ newdata[len + 1] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "Appending to digit store: now %s\n", newdata);</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, varname, newdata);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return f;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \internal \brief Enable digit interception on the channel */</span><br><span style="color: hsl(120, 100%, 40%);">+static int dtmfstore_exec(struct ast_channel *chan, const char *appdata)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_datastore *datastore;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dtmf_store_data *data;</span><br><span style="color: hsl(120, 100%, 40%);">+ static struct ast_framehook_interface digit_framehook_interface = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .version = AST_FRAMEHOOK_INTERFACE_VERSION,</span><br><span style="color: hsl(120, 100%, 40%);">+ .event_cb = dtmf_store_framehook,</span><br><span style="color: hsl(120, 100%, 40%);">+ .disable_inheritance = 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ };</span><br><span style="color: hsl(120, 100%, 40%);">+ char *parse = ast_strdupa(appdata);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_DECLARE_APP_ARGS(args,</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_ARG(direction);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_ARG(varname);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_ARG(maxdigits);</span><br><span style="color: hsl(120, 100%, 40%);">+ );</span><br><span style="color: hsl(120, 100%, 40%);">+ SCOPED_CHANNELLOCK(chan_lock, chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_STANDARD_APP_ARGS(args, parse);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(appdata)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_WARNING, "StoreDTMF requires an argument\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strcasecmp(args.direction, "remove")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return remove_dtmf_store(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ datastore = ast_channel_datastore_find(chan, &dtmf_store_datastore, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (datastore) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_WARNING, "StoreDTMF already set on '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ datastore = ast_datastore_alloc(&dtmf_store_datastore, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!datastore) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ data = ast_calloc(1, sizeof(*data));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!data) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_datastore_free(datastore);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ digit_framehook_interface.data = data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ data->rx_var = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ data->tx_var = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ data->maxdigits = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strcasecmp(args.direction, "tx")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ data->tx_var = ast_strdup(args.varname);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(args.direction, "rx")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ data->rx_var = ast_strdup(args.varname);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "Direction must be either RX or TX\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(args.maxdigits)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_str_to_int(args.maxdigits,&(data->maxdigits))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "Invalid integer: %s\n", args.maxdigits);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (data->maxdigits < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "Invalid natural number: %d\n", data->maxdigits);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (data->maxdigits == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "No maximum digit count set\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ data->framehook_id = ast_framehook_attach(chan, &digit_framehook_interface);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (data->framehook_id < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_WARNING, "Failed to attach StoreDTMF framehook to '%s'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_datastore_free(datastore);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(data);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ datastore->data = data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_datastore_add(chan, datastore);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int unload_module(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_unregister_application(app);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int load_module(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_register_application_xml(app, dtmfstore_exec);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Technology independent async DTMF storage");</span><br><span>diff --git a/doc/CHANGES-staging/app_dtmfstore.txt b/doc/CHANGES-staging/app_dtmfstore.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..a82b543</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_dtmfstore.txt</span><br><span>@@ -0,0 +1,6 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_dtmfstore</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+New application which collects digits</span><br><span style="color: hsl(120, 100%, 40%);">+dialed and stores them into</span><br><span style="color: hsl(120, 100%, 40%);">+a specified variable.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16250">change 16250</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/+/16250"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: I51aa93fc9507f7636ac44806c4420ce690423e6f </div>
<div style="display:none"> Gerrit-Change-Number: 16250 </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-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>