save history when stoping now

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16312 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2010-01-14 21:00:32 +00:00
parent 99b45eb1fb
commit f4a50a5e91
5 changed files with 29 additions and 1 deletions

View File

@ -88,6 +88,7 @@ SWITCH_DECLARE(void) switch_console_free_matches(switch_console_callback_match_t
SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const char *last_word,
FILE *console_out, switch_stream_handle_t *stream, switch_xml_t xml);
SWITCH_DECLARE(void) switch_console_sort_matches(switch_console_callback_match_t *matches);
SWITCH_DECLARE(void) switch_console_save_history(void);
SWITCH_END_EXTERN_C
#endif

View File

@ -1437,7 +1437,9 @@ typedef enum {
SCSC_DEBUG_LEVEL,
SCSC_FLUSH_DB_HANDLES,
SCSC_SHUTDOWN_NOW,
SCSC_CALIBRATE_CLOCK
SCSC_CALIBRATE_CLOCK,
SCSC_SAVE_HISTORY,
SCSC_CRASH
} switch_session_ctl_t;
typedef enum {

View File

@ -1472,6 +1472,13 @@ SWITCH_STANDARD_API(ctl_function)
stream->write_function(stream, "+OK\n");
} else if (!strcasecmp(argv[0], "calibrate_clock")) {
switch_core_session_ctl(SCSC_CALIBRATE_CLOCK, NULL);
stream->write_function(stream, "+OK\n");
} else if (!strcasecmp(argv[0], "crash")) {
switch_core_session_ctl(SCSC_CRASH, NULL);
stream->write_function(stream, "+OK\n");
} else if (!strcasecmp(argv[0], "save_history")) {
switch_core_session_ctl(SCSC_SAVE_HISTORY, NULL);
stream->write_function(stream, "+OK\n");
} else if (!strcasecmp(argv[0], "shutdown")) {
switch_session_ctl_t command = SCSC_SHUTDOWN;
int x = 0;

View File

@ -842,6 +842,15 @@ static unsigned char console_fnkey_pressed(int i)
return CC_REDISPLAY;
}
SWITCH_DECLARE(void) switch_console_save_history(void)
{
#ifdef SWITCH_HAVE_LIBEDIT
history(myhistory, &ev, H_SAVE, hfile);
#else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "NOT IMPLEMENTED!\n");
#endif
}
#ifdef SWITCH_HAVE_LIBEDIT
static char prompt_str[512] = "";

View File

@ -1633,7 +1633,16 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_
case SCSC_CANCEL_SHUTDOWN:
switch_clear_flag((&runtime), SCF_SHUTDOWN_REQUESTED);
break;
case SCSC_SAVE_HISTORY:
switch_console_save_history();
break;
case SCSC_CRASH:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Declinatio Mortuus Obfirmo!\n");
switch_console_save_history();
abort();
break;
case SCSC_SHUTDOWN_NOW:
switch_console_save_history();
exit(0);
break;
case SCSC_SHUTDOWN_ELEGANT: