From 76f98bd0346ed59f8b406cb9d1a73378484959d0 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 15 Jun 2006 06:02:08 +0000 Subject: [PATCH] add options to show api command to show applications, codecs, file formats, ect. and cleanup the output format of this command. Thanks jkr888 (Johny Kadarisman) for the contribution. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1630 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- AUTHORS | 1 + .../applications/mod_commands/mod_commands.c | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 28efc0884f..b96e74fdec 100644 --- a/AUTHORS +++ b/AUTHORS @@ -21,6 +21,7 @@ that much better: and moral support. Michal "cypromis" Bielicki (michal.bielicki AT halo2.pl) - Solaris porting, and autotools enhancements. James Martelletti - All around cool guy (mod_syslog) + Johny Kadarisman A big THANK YOU goes to: diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 3cb543ef0e..c8a6e64567 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -24,6 +24,8 @@ * Contributor(s): * * Anthony Minessale II + * Michael Jerris + * Johny Kadarisman * * * mod_commands.c -- Misc. Command Module @@ -185,7 +187,7 @@ static switch_status_t pause_function(char *cmd, switch_stream_handle_t *stream) static int show_callback(void *pArg, int argc, char **argv, char **columnNames){ switch_stream_handle_t *stream = (switch_stream_handle_t *) pArg; - stream->write_function(stream, "%s\n", argv[1]); + stream->write_function(stream, "%s|%s\n", argv[0], argv[1] ? argv[1] : "NULL"); return 0; } @@ -196,7 +198,22 @@ static switch_status_t show_function(char *cmd, switch_stream_handle_t *stream) char *errmsg; switch_core_db_t *db = switch_core_db_handle(); - sprintf (sql, "select * from interfaces"); + if (!cmd) { + sprintf (sql, "select * from interfaces"); + } + else if ( !strcmp(cmd,"codec") || !strcmp(cmd,"application") || + !strcmp(cmd,"api") || !strcmp(cmd,"dialplan") || + !strcmp(cmd,"file") || !strcmp(cmd,"timer") + ) { + sprintf (sql, "select * from interfaces where type = '%s'", cmd); + } + else { + stream->write_function(stream, "Invalid interfaces type!\n"); + stream->write_function(stream, "Example:\n"); + stream->write_function(stream, "show |codec|application|api|dialplan|file|timer\n"); + return SWITCH_STATUS_SUCCESS; + } + switch_core_db_exec(db, sql, show_callback, stream, &errmsg); if (errmsg) {