From c2a1935850010a9f49c0bc3d09ece65a161fbc79 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Mon, 4 Jul 2011 11:25:18 -0400 Subject: [PATCH] skip initial space in switch console and API execution - resolve issue #778 --- src/switch_console.c | 8 +++++++- src/switch_loadable_module.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/switch_console.c b/src/switch_console.c index 7323a5f6a3..8f7238d257 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -346,7 +346,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_execute(char *xcmd, int rec, swit int argc; char *argv[128]; int x; - char *dup = strdup(xcmd); + char *dup = NULL; char *cmd; switch_status_t status = SWITCH_STATUS_FALSE; @@ -357,6 +357,12 @@ SWITCH_DECLARE(switch_status_t) switch_console_execute(char *xcmd, int rec, swit goto end; } + while (xcmd && *xcmd == ' ') { + xcmd++; + } + + dup = strdup(xcmd); + if (!strncasecmp(xcmd, "alias", 5)) { argc = 1; argv[0] = xcmd; diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index f8a56d98bd..0938fd55ab 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -1789,6 +1789,10 @@ SWITCH_DECLARE(switch_status_t) switch_api_execute(const char *cmd, const char * switch_assert(stream->data != NULL); switch_assert(stream->write_function != NULL); + while (cmd && *cmd == ' ') { + cmd++; + } + if (strcasecmp(cmd, "console_complete")) { cmd_used = switch_strip_whitespace(cmd); arg_used = switch_strip_whitespace(arg);