mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-17 01:02:12 +00:00
add ;; delim to console
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16166 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
13c414ea25
commit
135360ba58
@ -295,36 +295,61 @@ char *expand_alias(char *cmd, char *arg)
|
|||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int switch_console_process(char *cmd, int rec)
|
static int switch_console_process(char *xcmd, int rec)
|
||||||
{
|
{
|
||||||
char *arg = NULL, *alias = NULL;
|
char *arg = NULL, *alias = NULL;
|
||||||
switch_stream_handle_t stream = { 0 };
|
switch_stream_handle_t stream = { 0 };
|
||||||
|
char *delim = ";;";
|
||||||
|
FILE *handle = switch_core_get_console();
|
||||||
|
int argc;
|
||||||
|
char *argv[128];
|
||||||
|
int x;
|
||||||
|
char *dup = strdup(xcmd);
|
||||||
|
char *cmd;
|
||||||
|
int r = 1;
|
||||||
|
|
||||||
if (!strcmp(cmd, "shutdown") || !strcmp(cmd, "...")) {
|
if (rec > 100) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bye!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Too much recursion!\n");
|
||||||
return 0;
|
goto end;
|
||||||
}
|
|
||||||
if (!strcmp(cmd, "version")) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "FreeSWITCH Version %s\n", SWITCH_VERSION_FULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if ((arg = strchr(cmd, '\r')) != 0 || (arg = strchr(cmd, '\n')) != 0) {
|
|
||||||
*arg = '\0';
|
|
||||||
arg = NULL;
|
|
||||||
}
|
|
||||||
if ((arg = strchr(cmd, ' ')) != 0) {
|
|
||||||
*arg++ = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rec && (alias = expand_alias(cmd, arg)) && alias != cmd) {
|
if (!strncasecmp(xcmd, "alias", 5)) {
|
||||||
int r = switch_console_process(alias, ++rec);
|
argc = 1;
|
||||||
free(alias);
|
argv[0] = xcmd;
|
||||||
return r;
|
} else {
|
||||||
|
argc = switch_separate_string_string(dup, delim, argv, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_STREAM(stream);
|
for (x = 0; x < argc; x++) {
|
||||||
if (stream.data) {
|
cmd = argv[x];
|
||||||
FILE *handle = switch_core_get_console();
|
|
||||||
|
if (!strcmp(cmd, "shutdown") || !strcmp(cmd, "...")) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bye!\n");
|
||||||
|
r = 0;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (!strcmp(cmd, "version")) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "FreeSWITCH Version %s\n", SWITCH_VERSION_FULL);
|
||||||
|
r = 1;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if ((arg = strchr(cmd, '\r')) != 0 || (arg = strchr(cmd, '\n')) != 0) {
|
||||||
|
*arg = '\0';
|
||||||
|
arg = NULL;
|
||||||
|
}
|
||||||
|
if ((arg = strchr(cmd, ' ')) != 0) {
|
||||||
|
*arg++ = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((alias = expand_alias(cmd, arg)) && alias != cmd) {
|
||||||
|
switch_console_process(alias, ++rec);
|
||||||
|
free(alias);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_STANDARD_STREAM(stream);
|
||||||
|
switch_assert(stream.data);
|
||||||
|
|
||||||
if (switch_api_execute(cmd, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
|
if (switch_api_execute(cmd, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (handle) {
|
if (handle) {
|
||||||
@ -337,12 +362,16 @@ static int switch_console_process(char *cmd, int rec)
|
|||||||
fflush(handle);
|
fflush(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(stream.data);
|
free(stream.data);
|
||||||
} else {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
end:
|
||||||
|
|
||||||
|
switch_safe_free(dup);
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...)
|
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user