<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16416] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16416">16416</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2010-01-20 11:45:53 -0600 (Wed, 20 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>allow alias expansion from fs_cli</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibseslfs_clic">freeswitch/trunk/libs/esl/fs_cli.c</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_consoleh">freeswitch/trunk/src/include/switch_console.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc">freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_event_socketmod_event_socketc">freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_consolec">freeswitch/trunk/src/switch_console.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunklibseslfs_clic"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/esl/fs_cli.c (16415 => 16416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/esl/fs_cli.c        2010-01-20 17:37:12 UTC (rev 16415)
+++ freeswitch/trunk/libs/esl/fs_cli.c        2010-01-20 17:45:53 UTC (rev 16416)
</span><span class="lines">@@ -703,8 +703,11 @@
</span><span class="cx">                 char cmd_str[1024] = &quot;&quot;;
</span><span class="cx">                 const char *err = NULL;
</span><span class="cx">                 
</span><del>-                snprintf(cmd_str, sizeof(cmd_str), &quot;api %s\n\n&quot;, cmd);
-                esl_send_recv(handle, cmd_str);
</del><ins>+                snprintf(cmd_str, sizeof(cmd_str), &quot;api %s\nconsole_execute: true\n\n&quot;, cmd);
+                if (esl_send_recv(handle, cmd_str)) {
+                        printf(&quot;Socket Interrupted, bye!\n&quot;);
+                        return 1;
+                }
</ins><span class="cx">                 if (handle-&gt;last_sr_event) {
</span><span class="cx">                         if (handle-&gt;last_sr_event-&gt;body) {
</span><span class="cx">                                 printf(&quot;%s\n&quot;, handle-&gt;last_sr_event-&gt;body);
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_consoleh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_console.h (16415 => 16416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_console.h        2010-01-20 17:37:12 UTC (rev 16415)
+++ freeswitch/trunk/src/include/switch_console.h        2010-01-20 17:45:53 UTC (rev 16416)
</span><span class="lines">@@ -89,6 +89,8 @@
</span><span class="cx">                                                                                                           FILE *console_out, switch_stream_handle_t *stream, switch_xml_t xml);
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_sort_matches(switch_console_callback_match_t *matches);
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_save_history(void);
</span><ins>+SWITCH_DECLARE(char *) switch_console_expand_alias(char *cmd, char *arg);
+SWITCH_DECLARE(switch_status_t) switch_console_execute(char *xcmd, int rec, switch_stream_handle_t *istream);
</ins><span class="cx"> 
</span><span class="cx"> SWITCH_END_EXTERN_C
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (16415 => 16416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2010-01-20 17:37:12 UTC (rev 16415)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2010-01-20 17:45:53 UTC (rev 16416)
</span><span class="lines">@@ -53,6 +53,22 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+SWITCH_STANDARD_API(shutdown_function)
+{
+        switch_session_ctl_t command = SCSC_SHUTDOWN;
+        int arg = 0;
+        switch_core_session_ctl(command, &amp;arg);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_STANDARD_API(version_function)
+{
+        stream-&gt;write_function(stream, &quot;FreeSWITCH Version %s\n&quot;, SWITCH_VERSION_FULL);
+        return SWITCH_STATUS_SUCCESS;
+}
+
</ins><span class="cx"> SWITCH_STANDARD_API(db_cache_function) {
</span><span class="cx">         int argc;
</span><span class="cx">         char *mydata = NULL, *argv[2];
</span><span class="lines">@@ -3421,15 +3437,6 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SWITCH_STANDARD_API(version_function)
-{
-        char version_string[1024];
-        switch_snprintf(version_string, sizeof(version_string) - 1, &quot;FreeSWITCH Version %s\n&quot;, SWITCH_VERSION_FULL);
-
-        stream-&gt;write_function(stream, version_string);
-        return SWITCH_STATUS_SUCCESS;
-}
-
</del><span class="cx"> SWITCH_STANDARD_API(help_function)
</span><span class="cx"> {
</span><span class="cx">         char showcmd[1024];
</span><span class="lines">@@ -4079,6 +4086,9 @@
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;expand&quot;, &quot;expand vars and execute&quot;, expand_function, &quot;[uuid:&lt;uuid&gt; ]&lt;cmd&gt; &lt;args&gt;&quot;);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;find_user_xml&quot;, &quot;find a user&quot;, find_user_function, &quot;&lt;key&gt; &lt;user&gt; &lt;domain&gt;&quot;);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;fsctl&quot;, &quot;control messages&quot;, ctl_function, CTL_SYNTAX);
</span><ins>+        SWITCH_ADD_API(commands_api_interface, &quot;...&quot;, &quot;shutdown&quot;, shutdown_function, &quot;&quot;);
+        SWITCH_ADD_API(commands_api_interface, &quot;shutdown&quot;, &quot;shutdown&quot;, shutdown_function, &quot;&quot;);
+        SWITCH_ADD_API(commands_api_interface, &quot;version&quot;, &quot;version&quot;, version_function, &quot;&quot;);
</ins><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;global_getvar&quot;, &quot;global_getvar&quot;, global_getvar_function, GLOBAL_GETVAR_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;global_setvar&quot;, &quot;global_setvar&quot;, global_setvar_function, GLOBAL_SETVAR_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;group_call&quot;, &quot;Generate a dial string to call a group&quot;, group_call_function, &quot;&lt;group&gt;[@&lt;domain&gt;]&quot;);
</span><span class="lines">@@ -4143,7 +4153,6 @@
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;uuid_setvar&quot;, &quot;uuid_setvar&quot;, uuid_setvar_function, SETVAR_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;uuid_transfer&quot;, &quot;Transfer a session&quot;, transfer_function, TRANSFER_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;uuid_warning&quot;, &quot;send popup&quot;, uuid_warning_function, WARNING_SYNTAX);
</span><del>-        SWITCH_ADD_API(commands_api_interface, &quot;version&quot;, &quot;Show version of the switch&quot;, version_function, &quot;&quot;);
</del><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;xml_locate&quot;, &quot;find some xml&quot;, xml_locate_function, &quot;[root | &lt;section&gt; &lt;tag&gt; &lt;tag_attr_name&gt; &lt;tag_attr_val&gt;]&quot;);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, &quot;xml_wrap&quot;, &quot;Wrap another api command in xml&quot;, xml_wrap_api_function, &quot;&lt;command&gt; &lt;args&gt;&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add alias add&quot;);
</span><span class="lines">@@ -4207,6 +4216,7 @@
</span><span class="cx">         switch_console_set_complete(&quot;add show nat_map&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add show say&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add show timer&quot;);
</span><ins>+        switch_console_set_complete(&quot;add shutdown&quot;);
</ins><span class="cx">         switch_console_set_complete(&quot;add uuid_audio ::console::list_uuid start read mute&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add uuid_audio ::console::list_uuid start read level&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add uuid_audio ::console::list_uuid start write mute&quot;);
</span><span class="lines">@@ -4243,10 +4253,11 @@
</span><span class="cx">         switch_console_set_complete(&quot;add uuid_setvar_multi ::console::list_uuid&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add uuid_setvar ::console::list_uuid&quot;);
</span><span class="cx">         switch_console_set_complete(&quot;add uuid_transfer ::console::list_uuid&quot;);
</span><ins>+        switch_console_set_complete(&quot;add version&quot;);
</ins><span class="cx">         switch_console_set_complete(&quot;add uuid_warning ::console::list_uuid&quot;);
</span><ins>+        switch_console_set_complete(&quot;add ...&quot;);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-
</del><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_NOUNLOAD;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_event_socketmod_event_socketc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (16415 => 16416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c        2010-01-20 17:37:12 UTC (rev 16415)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c        2010-01-20 17:45:53 UTC (rev 16416)
</span><span class="lines">@@ -1304,6 +1304,7 @@
</span><span class="cx">         char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">         int bg;
</span><span class="cx">         int ack;
</span><ins>+        int console_execute;
</ins><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -1336,7 +1337,15 @@
</span><span class="cx">         
</span><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><span class="cx">         
</span><del>-        if ((status = switch_api_execute(acs-&gt;api_cmd, acs-&gt;arg, NULL, &amp;stream)) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (acs-&gt;console_execute) {
+                if ((status = switch_console_execute(acs-&gt;api_cmd, 0, &amp;stream)) != SWITCH_STATUS_SUCCESS) {
+                        stream.write_function(&amp;stream, &quot;%s: Command not found!\n&quot;, acs-&gt;api_cmd);
+                }
+        } else {
+                status = switch_api_execute(acs-&gt;api_cmd, acs-&gt;arg, NULL, &amp;stream);
+        }
+
+        if (status == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 reply = stream.data;
</span><span class="cx">         } else {
</span><span class="cx">                 freply = switch_mprintf(&quot;%s: Command not found!\n&quot;, acs-&gt;api_cmd);
</span><span class="lines">@@ -1991,12 +2000,16 @@
</span><span class="cx">                 goto done;
</span><span class="cx">         } else if (!strncasecmp(cmd, &quot;api &quot;, 4)) {
</span><span class="cx">                 struct api_command_struct acs = { 0 };
</span><ins>+                char *console_execute = switch_event_get_header(*event, &quot;console_execute&quot;);
+                
</ins><span class="cx">                 char *api_cmd = cmd + 4;
</span><span class="cx">                 char *arg = NULL;
</span><span class="cx">                 strip_cr(api_cmd);
</span><span class="cx"> 
</span><del>-                if ((arg = strchr(api_cmd, ' '))) {
-                        *arg++ = '\0';
</del><ins>+                if (!(acs.console_execute = switch_true(console_execute))) {
+                        if ((arg = strchr(api_cmd, ' '))) {
+                                *arg++ = '\0';
+                        }
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (listener-&gt;allowed_api_hash) {
</span><span class="lines">@@ -2012,6 +2025,7 @@
</span><span class="cx">                 acs.api_cmd = api_cmd;
</span><span class="cx">                 acs.arg = arg;
</span><span class="cx">                 acs.bg = 0;
</span><ins>+                
</ins><span class="cx"> 
</span><span class="cx">                 api_exec(NULL, (void *) &amp;acs);
</span><span class="cx"> 
</span><span class="lines">@@ -2047,6 +2061,8 @@
</span><span class="cx">                 switch_assert(acs);
</span><span class="cx">                 acs-&gt;pool = pool;
</span><span class="cx">                 acs-&gt;listener = listener;
</span><ins>+                acs-&gt;console_execute = 0;
+
</ins><span class="cx">                 if (api_cmd) {
</span><span class="cx">                         acs-&gt;api_cmd = switch_core_strdup(acs-&gt;pool, api_cmd);
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_consolec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_console.c (16415 => 16416)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_console.c        2010-01-20 17:37:12 UTC (rev 16415)
+++ freeswitch/trunk/src/switch_console.c        2010-01-20 17:45:53 UTC (rev 16416)
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx">         return -1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-char *expand_alias(char *cmd, char *arg)
</del><ins>+SWITCH_DECLARE(char *) switch_console_expand_alias(char *cmd, char *arg)
</ins><span class="cx"> {
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">         char *r = NULL;
</span><span class="lines">@@ -295,18 +295,49 @@
</span><span class="cx">         return exp;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static int switch_console_process(char *xcmd, int rec)
</del><ins>+
+static int switch_console_process(char *xcmd) {
+        switch_stream_handle_t stream = { 0 };
+        switch_status_t status;
+        FILE *handle = switch_core_get_console();
+        
+        SWITCH_STANDARD_STREAM(stream);
+        switch_assert(stream.data);
+
+        status = switch_console_execute(xcmd, 0, &amp;stream);
+
+        if (status == SWITCH_STATUS_SUCCESS) {
+                if (handle) {
+                        fprintf(handle, &quot;\n%s\n&quot;, (char *) stream.data);
+                        fflush(handle);
+                }
+        } else {
+                if (handle) {
+                        fprintf(handle, &quot;Unknown Command: %s\n&quot;, xcmd);
+                        fflush(handle);
+                }
+        }
+
+        switch_safe_free(stream.data);
+
+        return 1;
+        
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_console_execute(char *xcmd, int rec, switch_stream_handle_t *istream)
</ins><span class="cx"> {
</span><span class="cx">         char *arg = NULL, *alias = NULL;
</span><del>-        switch_stream_handle_t stream = { 0 };
</del><ins>+
</ins><span class="cx">         char *delim = &quot;;;&quot;;
</span><del>-        FILE *handle = switch_core_get_console();
</del><span class="cx">         int argc;
</span><span class="cx">         char *argv[128];
</span><span class="cx">         int x;
</span><span class="cx">         char *dup = strdup(xcmd);
</span><span class="cx">         char *cmd;
</span><del>-        int r = 1;
</del><ins>+
+        switch_status_t status = SWITCH_STATUS_FALSE;
+
</ins><span class="cx">         
</span><span class="cx">         if (rec &gt; 100) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Too much recursion!\n&quot;);
</span><span class="lines">@@ -322,17 +353,6 @@
</span><span class="cx"> 
</span><span class="cx">         for (x = 0; x &lt; argc; x++) {
</span><span class="cx">                 cmd = argv[x];
</span><del>-
-                if (!strcmp(cmd, &quot;shutdown&quot;) || !strcmp(cmd, &quot;...&quot;)) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, &quot;Bye!\n&quot;);
-                        r = 0;
-                        goto end;
-                }
-                if (!strcmp(cmd, &quot;version&quot;)) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, &quot;FreeSWITCH Version %s\n&quot;, SWITCH_VERSION_FULL);
-                        r = 1;
-                        goto end;
-                }
</del><span class="cx">                 if ((arg = strchr(cmd, '\r')) != 0 || (arg = strchr(cmd, '\n')) != 0) {
</span><span class="cx">                         *arg = '\0';
</span><span class="cx">                         arg = NULL;
</span><span class="lines">@@ -341,37 +361,22 @@
</span><span class="cx">                         *arg++ = '\0';
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if ((alias = expand_alias(cmd, arg)) &amp;&amp; alias != cmd) {
-                        switch_console_process(alias, ++rec);
</del><ins>+                if ((alias = switch_console_expand_alias(cmd, arg)) &amp;&amp; alias != cmd) {
+                        istream-&gt;write_function(istream, &quot;\nExpand Alias [%s]-&gt;[%s]\n\n&quot;, cmd, alias);
+                        status = switch_console_execute(alias, ++rec, istream);
</ins><span class="cx">                         free(alias);
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-                SWITCH_STANDARD_STREAM(stream);
-                switch_assert(stream.data);
-
-                if (switch_api_execute(cmd, arg, NULL, &amp;stream) == SWITCH_STATUS_SUCCESS) {
-                        if (handle) {
-                                fprintf(handle, &quot;API CALL [%s(%s)] output:\n%s\n&quot;, cmd, arg ? arg : &quot;&quot;, (char *) stream.data);
-                                fflush(handle);
-                        }
-                } else {
-                        if (handle) {
-                                fprintf(handle, &quot;Unknown Command: %s\n&quot;, cmd);
-                                fflush(handle);
-                        }
-                }
-                
-                free(stream.data);
-
</del><ins>+                status = switch_api_execute(cmd, arg, NULL, istream);                
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">  end:
</span><span class="cx"> 
</span><span class="cx">         switch_safe_free(dup);
</span><span class="cx"> 
</span><del>-        return r;
</del><ins>+        return status;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...)
</span><span class="lines">@@ -836,7 +841,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         cmd = strdup(c);
</span><del>-        switch_console_process(cmd, 0);
</del><ins>+        switch_console_process(cmd);
</ins><span class="cx">         free(cmd);
</span><span class="cx"> 
</span><span class="cx">         return CC_REDISPLAY;
</span><span class="lines">@@ -945,7 +950,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 assert(cmd != NULL);
</span><span class="cx">                                 history(myhistory, &amp;ev, H_ENTER, line);
</span><del>-                                running = switch_console_process(cmd, 0);
</del><ins>+                                running = switch_console_process(cmd);
</ins><span class="cx">                                 el_deletestr(el, strlen(foo) + 1);
</span><span class="cx">                                 memset(foo, 0, strlen(foo));
</span><span class="cx">                                 free(cmd);
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>