<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19867">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_directory: add ability to specify configuration file<br><br>Adds option to app_directory to specify a filename from which to<br>read configuration instead of voicemail.conf ie;<br><br>same => n,Directory(,,c(directory.conf))<br><br>This configuration should contain a list of extensions using the<br>voicemail.conf format, ie;<br><br>2020=2020,Dog Dog,,,,attach=no|saycid=no|envelope=no|delete=no<br><br>ASTERISK-30404<br><br>Change-Id: Id58ccb1344ad1e563fa10db12f172fbd104a9d13<br>---<br>M apps/app_directory.c<br>1 file changed, 36 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/67/19867/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_directory.c b/apps/app_directory.c</span><br><span>index d76d07a..a84b374 100644</span><br><span>--- a/apps/app_directory.c</span><br><span>+++ b/apps/app_directory.c</span><br><span>@@ -103,6 +103,10 @@</span><br><span>                                              receiver to their ear while entering DTMF.</para></span><br><span>                                              <argument name="n" required="true" /></span><br><span>                                      </option></span><br><span style="color: hsl(120, 100%, 40%);">+                                       <option name="c"></span><br><span style="color: hsl(120, 100%, 40%);">+                                             <para>Load the specified config file instead of voicemail.conf</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                             <argument name="filename" required="true" /></span><br><span style="color: hsl(120, 100%, 40%);">+                                        </option></span><br><span>                              </optionlist></span><br><span>                          <note><para>Only one of the <replaceable>f</replaceable>, <replaceable>l</replaceable>, or <replaceable>b</replaceable></span><br><span>                              options may be specified. <emphasis>If more than one is specified</emphasis>, then Directory will act as</span><br><span>@@ -114,7 +118,7 @@</span><br><span>           <description></span><br><span>                  <para>This application will present the calling channel with a directory of extensions from which they can search</span><br><span>                      by name. The list of names and corresponding extensions is retrieved from the</span><br><span style="color: hsl(0, 100%, 40%);">-                   voicemail configuration file, <filename>voicemail.conf</filename>.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                   voicemail configuration file, <filename>voicemail.conf</filename>, or from the specified filename.</para></span><br><span>                  <para>This application will immediately exit if one of the following DTMF digits are</span><br><span>                   received and the extension to jump to exists:</para></span><br><span>                   <para><literal>0</literal> - Jump to the 'o' extension, if it exists.</para></span><br><span>@@ -153,6 +157,7 @@</span><br><span>   OPT_PAUSE =           (1 << 5),</span><br><span>        OPT_NOANSWER =        (1 << 6),</span><br><span>        OPT_ALIAS =           (1 << 7),</span><br><span style="color: hsl(120, 100%, 40%);">+ OPT_CONFIG_FILE =     (1 << 8),</span><br><span> };</span><br><span> </span><br><span> enum {</span><br><span>@@ -160,8 +165,9 @@</span><br><span>      OPT_ARG_LASTNAME =    1,</span><br><span>     OPT_ARG_EITHER =      2,</span><br><span>     OPT_ARG_PAUSE =       3,</span><br><span style="color: hsl(120, 100%, 40%);">+      OPT_ARG_FILENAME =    4,</span><br><span>     /* This *must* be the last value in this enum! */</span><br><span style="color: hsl(0, 100%, 40%);">-       OPT_ARG_ARRAY_SIZE =  4,</span><br><span style="color: hsl(120, 100%, 40%);">+      OPT_ARG_ARRAY_SIZE =  5,</span><br><span> };</span><br><span> </span><br><span> struct directory_item {</span><br><span>@@ -183,6 +189,7 @@</span><br><span>  AST_APP_OPTION('m', OPT_SELECTFROMMENU),</span><br><span>     AST_APP_OPTION('n', OPT_NOANSWER),</span><br><span>   AST_APP_OPTION('a', OPT_ALIAS),</span><br><span style="color: hsl(120, 100%, 40%);">+       AST_APP_OPTION_ARG('c', OPT_CONFIG_FILE, OPT_ARG_FILENAME),</span><br><span> });</span><br><span> </span><br><span> static int compare(const char *text, const char *template)</span><br><span>@@ -456,7 +463,7 @@</span><br><span> </span><br><span> AST_THREADSTORAGE(commonbuf);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static struct ast_config *realtime_directory(char *context)</span><br><span style="color: hsl(120, 100%, 40%);">+static struct ast_config *realtime_directory(char *context, const char *filename)</span><br><span> {</span><br><span>       struct ast_config *cfg;</span><br><span>      struct ast_config *rtdata = NULL;</span><br><span>@@ -473,14 +480,14 @@</span><br><span>    }</span><br><span> </span><br><span>        /* Load flat file config. */</span><br><span style="color: hsl(0, 100%, 40%);">-    cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags);</span><br><span style="color: hsl(120, 100%, 40%);">+        cfg = ast_config_load(filename, config_flags);</span><br><span> </span><br><span>   if (!cfg) {</span><br><span>          /* Loading config failed. */</span><br><span>                 ast_log(LOG_WARNING, "Loading config failed.\n");</span><br><span>          return NULL;</span><br><span>         } else if (cfg == CONFIG_STATUS_FILEINVALID) {</span><br><span style="color: hsl(0, 100%, 40%);">-          ast_log(LOG_ERROR, "Config file %s is in an invalid format.  Aborting.\n", VOICEMAIL_CONFIG);</span><br><span style="color: hsl(120, 100%, 40%);">+               ast_log(LOG_ERROR, "Config file %s is in an invalid format.  Aborting.\n", filename);</span><br><span>              return NULL;</span><br><span>         }</span><br><span> </span><br><span>@@ -865,7 +872,9 @@</span><br><span>  if (args.options && ast_app_parse_options(directory_app_options, &flags, opts, args.options))</span><br><span>            return -1;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  if (!(cfg = realtime_directory(args.vmcontext))) {</span><br><span style="color: hsl(120, 100%, 40%);">+    cfg = realtime_directory(args.vmcontext, S_OR(opts[OPT_ARG_FILENAME], VOICEMAIL_CONFIG));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!cfg) {</span><br><span>          ast_log(LOG_ERROR, "Unable to read the configuration data!\n");</span><br><span>            return -1;</span><br><span>   }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19867">change 19867</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/+/19867"/><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: Id58ccb1344ad1e563fa10db12f172fbd104a9d13 </div>
<div style="display:none"> Gerrit-Change-Number: 19867 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-CC: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>