<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16486">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_channel: Add CHANNEL_EXISTS function<br><br>Adds a function to check for the existence of a full channel name.<br><br>ASTERISK-29656 #close<br><br>Change-Id: Ib464e9eb6e13dc683a846286798fecff4fd943cb<br>---<br>A doc/CHANGES-staging/func_channel.txt<br>M funcs/func_channel.c<br>2 files changed, 30 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/86/16486/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/func_channel.txt b/doc/CHANGES-staging/func_channel.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..1c5df0f</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/func_channel.txt</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: func_channel</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Adds the CHANNEL_EXISTS function to check for the existence</span><br><span style="color: hsl(120, 100%, 40%);">+of a named channel.</span><br><span>diff --git a/funcs/func_channel.c b/funcs/func_channel.c</span><br><span>index d143fdc..0e4c33c 100644</span><br><span>--- a/funcs/func_channel.c</span><br><span>+++ b/funcs/func_channel.c</span><br><span>@@ -20,6 +20,7 @@</span><br><span> *</span><br><span> * \author Kevin P. Fleming <kpfleming@digium.com></span><br><span> * \author Ben Winslow</span><br><span style="color: hsl(120, 100%, 40%);">+ * \author Naveen Albert <asterisk@phreaknet.org></span><br><span> *</span><br><span> * \ingroup functions</span><br><span> */</span><br><span>@@ -62,6 +63,18 @@</span><br><span> will be space-delimited.</para></span><br><span> </description></span><br><span> </function></span><br><span style="color: hsl(120, 100%, 40%);">+ <function name="CHANNEL_EXISTS" language="en_US"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ Checks if the specified channel name exists.</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="channel_name" /></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>Returns whether or not <replaceable>channel_name</replaceable> is a currently existing channel.</span><br><span style="color: hsl(120, 100%, 40%);">+ <replaceable>channel_name</replaceable> must be a full channel name, not simply a tech/device.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </description></span><br><span style="color: hsl(120, 100%, 40%);">+ </function></span><br><span> <function name="MASTER_CHANNEL" language="en_US"></span><br><span> <synopsis></span><br><span> Gets or sets variables on the master channel</span><br><span>@@ -711,6 +724,17 @@</span><br><span> .read = func_channels_read,</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int func_chan_exists_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t maxlen)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ snprintf(buf, maxlen, "%d", (ast_channel_get_by_name(data) ? 1 : 0));</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 struct ast_custom_function chan_exists_function = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .name = "CHANNEL_EXISTS",</span><br><span style="color: hsl(120, 100%, 40%);">+ .read = func_chan_exists_read,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int func_mchan_read(struct ast_channel *chan, const char *function,</span><br><span> char *data, struct ast_str **buf, ssize_t len)</span><br><span> {</span><br><span>@@ -761,6 +785,7 @@</span><br><span> </span><br><span> res |= ast_custom_function_unregister(&channel_function);</span><br><span> res |= ast_custom_function_unregister(&channels_function);</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= ast_custom_function_unregister(&chan_exists_function);</span><br><span> res |= ast_custom_function_unregister(&mchan_function);</span><br><span> </span><br><span> return res;</span><br><span>@@ -772,6 +797,7 @@</span><br><span> </span><br><span> res |= ast_custom_function_register(&channel_function);</span><br><span> res |= ast_custom_function_register(&channels_function);</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= ast_custom_function_register(&chan_exists_function);</span><br><span> res |= ast_custom_function_register(&mchan_function);</span><br><span> </span><br><span> return res;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16486">change 16486</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/+/16486"/><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: Ib464e9eb6e13dc683a846286798fecff4fd943cb </div>
<div style="display:none"> Gerrit-Change-Number: 16486 </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>