From 035d9c05063775e76679d96c21340f6c91812b8b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 22 Jan 2010 02:42:05 +0000 Subject: [PATCH] make banner an api command so you can fetch it over event socket git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16451 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 1 + .../applications/mod_commands/mod_commands.c | 9 ++++- src/switch_core.c | 38 ++++++++++--------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 2997f56705..3a6c76e10c 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2070,6 +2070,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ SWITCH_DECLARE(void) switch_cache_db_detach(void); SWITCH_DECLARE(uint32_t) switch_core_debug_level(void); SWITCH_DECLARE(void) switch_cache_db_flush_handles(void); +SWITCH_DECLARE(const char *) switch_core_banner(void); SWITCH_END_EXTERN_C #endif diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 7f4a42256a..e5b66c2c92 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -45,11 +45,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown); SWITCH_MODULE_DEFINITION(mod_commands, mod_commands_load, mod_commands_shutdown, NULL); +SWITCH_STANDARD_API(banner_function) +{ + stream->write_function(stream, "%s", switch_core_banner()); + return SWITCH_STATUS_SUCCESS; +} + SWITCH_STANDARD_API(hostname_api_function) { char hostname[256]=""; gethostname(hostname, sizeof(hostname)); - stream->write_function(stream, "%s",hostname); + stream->write_function(stream, "%s", hostname); return SWITCH_STATUS_SUCCESS; } @@ -4065,6 +4071,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "acl", "compare an ip to an acl list", acl_function, " "); SWITCH_ADD_API(commands_api_interface, "alias", "Alias", alias_function, ALIAS_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "banner", "Returns the system banner", banner_function, ""); SWITCH_ADD_API(commands_api_interface, "bgapi", "Execute an api command in a thread", bgapi_function, "[ ]"); SWITCH_ADD_API(commands_api_interface, "bg_system", "Execute a system command in the background", bg_system_function, SYSTEM_SYNTAX); SWITCH_ADD_API(commands_api_interface, "break", "Break", break_function, BREAK_SYNTAX); diff --git a/src/switch_core.c b/src/switch_core.c index d9fb3f0da1..ee8f313e72 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1484,25 +1484,25 @@ static void switch_load_core_config(const char *file) } -static void print_banner(void) +SWITCH_DECLARE(const char *) switch_core_banner(void) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, - "\n" - " _____ ______ _____ _____ ____ _ _ \n" - " | ___| __ ___ ___/ ___\\ \\ / /_ _|_ _/ ___| | | | \n" - " | |_ | '__/ _ \\/ _ \\___ \\\\ \\ /\\ / / | | | || | | |_| | \n" - " | _|| | | __/ __/___) |\\ V V / | | | || |___| _ | \n" - " |_| |_| \\___|\\___|____/ \\_/\\_/ |___| |_| \\____|_| |_| \n" - "\n" - "************************************************************\n" - "* Anthony Minessale II, Michael Jerris, Brian West, Others *\n" - "* FreeSWITCH (http://www.freeswitch.org) *\n" - "* Paypal Donations Appreciated: paypal@freeswitch.org *\n" - "* Brought to you by ClueCon http://www.cluecon.com/ *\n" - "************************************************************\n" - "\n" - ); + + return ("\n" + " _____ ______ _____ _____ ____ _ _ \n" + " | ___| __ ___ ___/ ___\\ \\ / /_ _|_ _/ ___| | | | \n" + " | |_ | '__/ _ \\/ _ \\___ \\\\ \\ /\\ / / | | | || | | |_| | \n" + " | _|| | | __/ __/___) |\\ V V / | | | || |___| _ | \n" + " |_| |_| \\___|\\___|____/ \\_/\\_/ |___| |_| \\____|_| |_| \n" + "\n" + "************************************************************\n" + "* Anthony Minessale II, Michael Jerris, Brian West, Others *\n" + "* FreeSWITCH (http://www.freeswitch.org) *\n" + "* Paypal Donations Appreciated: paypal@freeswitch.org *\n" + "* Brought to you by ClueCon http://www.cluecon.com/ *\n" + "************************************************************\n" + "\n" + ); } @@ -1560,7 +1560,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Ready"); switch_event_fire(&event); } - print_banner(); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s", switch_core_banner()); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nFreeSWITCH Version %s Started.\nMax Sessions[%u]\nSession Rate[%d]\nSQL [%s]\n", SWITCH_VERSION_FULL,