<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18063">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_channel: Adds TECH_EXISTS function.<br><br>Adds a TECH_EXISTS function which can be used to check<br>if a particular channel technology is available for use<br>on the system.<br><br>ASTERISK-29926 #close<br><br>Change-Id: Idf110464ed69a757b3e0c9d0e8d95d4d24559b46<br>---<br>A doc/CHANGES-staging/func_channel_tech.txt<br>M funcs/func_channel.c<br>2 files changed, 35 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/63/18063/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/func_channel_tech.txt b/doc/CHANGES-staging/func_channel_tech.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..7673581</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/func_channel_tech.txt</span><br><span>@@ -0,0 +1,5 @@</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%);">+A TECH_EXISTS function now allows users to check</span><br><span style="color: hsl(120, 100%, 40%);">+whether a particular channel technology is available</span><br><span style="color: hsl(120, 100%, 40%);">+for use.</span><br><span>diff --git a/funcs/func_channel.c b/funcs/func_channel.c</span><br><span>index c6e5ec1..dc49f87 100644</span><br><span>--- a/funcs/func_channel.c</span><br><span>+++ b/funcs/func_channel.c</span><br><span>@@ -63,6 +63,19 @@</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="TECH_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 technology exists and is usable.</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="tech" required="true"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>The name of the channel technology (e.g. DAHDI, PJSIP, IAX2, etc.).</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>Returns 1 if the channel technology <replaceable>tech</replaceable> exists, 0 if not.</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="CHANNEL_EXISTS" language="en_US"></span><br><span> <synopsis></span><br><span> Checks if the specified channel exists.</span><br><span>@@ -760,6 +773,21 @@</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_tech_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%);">+ if (ast_strlen_zero(data)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "%s: Channel tech required\n", function);</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%);">+ snprintf(buf, maxlen, "%d", (ast_get_channel_tech(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 tech_exists_function = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .name = "TECH_EXISTS",</span><br><span style="color: hsl(120, 100%, 40%);">+ .read = func_tech_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_chan_exists_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t maxlen)</span><br><span> {</span><br><span> struct ast_channel *chan_found = NULL;</span><br><span>@@ -833,6 +861,7 @@</span><br><span> res |= ast_custom_function_unregister(&channel_function);</span><br><span> res |= ast_custom_function_unregister(&channels_function);</span><br><span> res |= ast_custom_function_unregister(&chan_exists_function);</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= ast_custom_function_unregister(&tech_exists_function);</span><br><span> res |= ast_custom_function_unregister(&mchan_function);</span><br><span> </span><br><span> return res;</span><br><span>@@ -845,6 +874,7 @@</span><br><span> res |= ast_custom_function_register(&channel_function);</span><br><span> res |= ast_custom_function_register(&channels_function);</span><br><span> res |= ast_custom_function_register(&chan_exists_function);</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= ast_custom_function_register(&tech_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/+/18063">change 18063</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/+/18063"/><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: Idf110464ed69a757b3e0c9d0e8d95d4d24559b46 </div>
<div style="display:none"> Gerrit-Change-Number: 18063 </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>