]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
save history when stoping now
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 14 Jan 2010 21:00:32 +0000 (21:00 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 14 Jan 2010 21:00:32 +0000 (21:00 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16312 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_console.h
src/include/switch_types.h
src/mod/applications/mod_commands/mod_commands.c
src/switch_console.c
src/switch_core.c

index e31600defb1a370aafd00d9697bc3e668fdbc776..022441d258386ddbfaff7a13e7eff3501bba9c19 100644 (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
index b0e73eae1073e24f6db6f2cc64db639899dde739..d664aa8030e803ad66a7567d8848778504cffc48 100644 (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 {
index 085c5cfe10471428751eccd0908602b83df0dbb7..7ad64f393d32ccf5aafd5ccfea8aec476c84f1df 100644 (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;
index b69d9908ac054d344925ce3ad4c5e566d8c3d541..1121a4aaed5768975944b82c8cbf4f8d8c6598e8 100644 (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] = "";
 
index f0e6bd113cf988ef7f2e91387eef469768f59925..4dab1649094308a479439e2dd394395bca72ce55 100644 (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: