]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-2210 Add support for auto completion for uuid_simplify
authorJeff Lenk <jeff@jefflenk.com>
Wed, 8 Dec 2010 04:32:38 +0000 (22:32 -0600)
committerJeff Lenk <jeff@jefflenk.com>
Wed, 8 Dec 2010 04:32:38 +0000 (22:32 -0600)
src/mod/applications/mod_commands/mod_commands.c

index c7edfd542067b26ac271e33651484d1d89d38b27..eacde5994997e2d72bb379c77378da2edfc37ba6 100644 (file)
@@ -2491,24 +2491,47 @@ SWITCH_STANDARD_API(uuid_display_function)
 #define SIMPLIFY_SYNTAX "<uuid>"
 SWITCH_STANDARD_API(uuid_simplify_function)
 {
+       char *mydata = NULL, *argv[2] = { 0 };
+       int argc = 0;
+
        switch_status_t status = SWITCH_STATUS_FALSE;
 
        if (zstr(cmd)) {
-               stream->write_function(stream, "-USAGE: %s\n", SIMPLIFY_SYNTAX);
-       } else {
+               goto error;
+       }
+
+       mydata = strdup(cmd);
+       switch_assert(mydata);
+
+       argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+       if (argc < 1) {
+               goto error;
+       }
+       if (argv[0]) {
                switch_core_session_message_t msg = { 0 };
                switch_core_session_t *lsession = NULL;
 
                msg.message_id = SWITCH_MESSAGE_INDICATE_SIMPLIFY;
-               msg.string_arg = cmd;
+               msg.string_arg = argv[0];
                msg.from = __FILE__;
 
-               if ((lsession = switch_core_session_locate(cmd))) {
+               if ((lsession = switch_core_session_locate(argv[0]))) {
                        status = switch_core_session_receive_message(lsession, &msg);
                        switch_core_session_rwunlock(lsession);
                }
+               goto ok;
+       } else {
+               goto error;
        }
 
+  error:
+       stream->write_function(stream, "-USAGE: %s\n", SIMPLIFY_SYNTAX);
+       switch_safe_free(mydata);
+       return SWITCH_STATUS_SUCCESS;
+  ok:
+       switch_safe_free(mydata);
+
        if (status == SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "+OK Success\n");
        } else {
@@ -4853,6 +4876,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        switch_console_set_complete("add uuid_session_heartbeat ::console::list_uuid");
        switch_console_set_complete("add uuid_setvar_multi ::console::list_uuid");
        switch_console_set_complete("add uuid_setvar ::console::list_uuid");
+       switch_console_set_complete("add uuid_simplify ::console::list_uuid");
        switch_console_set_complete("add uuid_transfer ::console::list_uuid");
        switch_console_set_complete("add uuid_dual_transfer ::console::list_uuid");
        switch_console_set_complete("add version");