cleanup whitespace in commands

This commit is contained in:
Michael Jerris 2010-09-02 17:17:41 -04:00
parent 4da5c5cfa2
commit 7c0b748737
1 changed files with 21 additions and 4 deletions

View 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;
}