]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix arg parsing in new command
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 21 Apr 2009 17:41:54 +0000 (17:41 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 21 Apr 2009 17:41:54 +0000 (17:41 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13102 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_commands/mod_commands.c

index d81ff925e13bfbc4763d0403fe5d7eaa445e72da..65ea73b275156408eafbb025b0b83e992f903fd1 100644 (file)
@@ -532,6 +532,11 @@ SWITCH_STANDARD_API(expand_function)
        switch_core_session_t *xsession;
        char uuid[80] = "";
        
+       if (switch_strlen_zero(cmd)) {
+               stream->write_function(stream, "-ERR, no input\n");
+               return SWITCH_STATUS_SUCCESS;
+       }
+
        dup = strdup(cmd);
        mycmd = dup;
 
@@ -558,8 +563,10 @@ SWITCH_STANDARD_API(expand_function)
                *arg++ = '\0';
        }
 
-       expanded = switch_event_expand_headers(stream->param_event, arg);
-       status = switch_api_execute(mycmd, expanded, session, stream);
+       expanded = arg ? switch_event_expand_headers(stream->param_event, arg) : arg;
+       if ((status = switch_api_execute(mycmd, expanded, session, stream)) != SWITCH_STATUS_SUCCESS) {
+               stream->write_function(stream, "-ERR, error executing command\n");
+       }
 
        if (expanded != arg) {
                free(expanded);
@@ -569,7 +576,7 @@ SWITCH_STANDARD_API(expand_function)
        free(dup);
        dup = NULL;
 
-       return status;
+       return SWITCH_STATUS_SUCCESS;
 }