]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
cleanup whitespace in commands
authorMichael Jerris <mike@jerris.com>
Thu, 2 Sep 2010 21:17:41 +0000 (17:17 -0400)
committerMichael Jerris <mike@jerris.com>
Thu, 2 Sep 2010 21:17:56 +0000 (17:17 -0400)
src/mod/applications/mod_commands/mod_commands.c

index e1eb2a6b6a41a0e8d5b60d759dc2f48c5c5f7ba9..55520b1765a465704b479b104c85d2e5e2cab04f 100644 (file)
@@ -1714,18 +1714,23 @@ SWITCH_STANDARD_API(ctl_function)
 SWITCH_STANDARD_API(load_function)
 {
        const char *err;
+       char *mod;
 
        if (zstr(cmd)) {
                stream->write_function(stream, "-USAGE: %s\n", LOAD_SYNTAX);
                return SWITCH_STATUS_SUCCESS;
        }
 
-       if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
+       mod = switch_strip_whitespace(cmd);
+
+       if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, mod, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "+OK\n");
        } else {
                stream->write_function(stream, "-ERR [%s]\n", err);
        }
 
+       switch_safe_free(mod);
+
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1735,6 +1740,7 @@ SWITCH_STANDARD_API(unload_function)
        const char *err;
        switch_bool_t force = SWITCH_FALSE;
        const char *p = cmd;
+       char *mod;
 
        if (zstr(cmd)) {
                stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX);
@@ -1765,12 +1771,16 @@ SWITCH_STANDARD_API(unload_function)
                return SWITCH_STATUS_SUCCESS;
        }
 
-       if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, force, &err) == SWITCH_STATUS_SUCCESS) {
+       mod = switch_strip_whitespace(cmd);
+
+       if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, mod, force, &err) == SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "+OK\n");
        } else {
                stream->write_function(stream, "-ERR [%s]\n", err);
        }
 
+       switch_safe_free(mod);
+
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1779,6 +1789,7 @@ SWITCH_STANDARD_API(reload_function)
        const char *err;
        switch_bool_t force = SWITCH_FALSE;
        const char *p = cmd;
+       char *mod;
 
        if (zstr(cmd)) {
                stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX);
@@ -1808,18 +1819,24 @@ SWITCH_STANDARD_API(reload_function)
                return SWITCH_STATUS_SUCCESS;
        }
 
-       if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, force, &err) == SWITCH_STATUS_SUCCESS) {
+       mod = switch_strip_whitespace(cmd);
+
+
+       printf("WTF XXX [%s] [%s] \n", cmd, mod);
+
+       if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, mod, force, &err) == SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "+OK module unloaded\n");
        } else {
                stream->write_function(stream, "-ERR unloading module [%s]\n", err);
        }
 
-       if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
+       if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, mod, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "+OK module loaded\n");
        } else {
                stream->write_function(stream, "-ERR loading module [%s]\n", err);
        }
 
+       switch_safe_free(mod);
        return SWITCH_STATUS_SUCCESS;
 }