From 90751b16caec323d90ddf7d41db4a25085a3bd76 Mon Sep 17 00:00:00 2001 From: Michiel van Baak Date: Sun, 28 Sep 2008 23:32:14 +0000 Subject: Merge the cli_cleanup branch. This work is done by lmadsen, junky and mvanbaak during AstriDevCon. This is the second audit the CLI got, and this time lmadsen made sure he had _ALL_ modules loaded that have CLI commands in them. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@145121 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_meetme.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 9 deletions(-) (limited to 'apps/app_meetme.c') diff --git a/apps/app_meetme.c b/apps/app_meetme.c index 9ca81eb08..78bc881a3 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -883,7 +883,6 @@ cnfout: return cnf; } - static char *complete_meetmecmd(const char *line, const char *word, int pos, int state) { static char *cmds[] = {"concise", "lock", "unlock", "mute", "unmute", "kick", "list", NULL}; @@ -946,11 +945,10 @@ static char *complete_meetmecmd(const char *line, const char *word, int pos, int return NULL; } -static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *meetme_show_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { /* Process the command */ struct ast_conference *cnf; - struct ast_conf_user *user; int hr, min, sec; int i = 0, total = 0; time_t now; @@ -960,17 +958,15 @@ static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a switch (cmd) { case CLI_INIT: - e->command = "meetme"; + e->command = "meetme list [concise]"; e->usage = - "Usage: meetme (un)lock|(un)mute|kick|list [concise] \n" - " Executes a command for the conference or on a conferee\n"; + "Usage: meetme list [concise] \n" + " List all or a specific conference.\n"; return NULL; case CLI_GENERATE: return complete_meetmecmd(a->line, a->word, a->pos, a->n); } - if (a->argc > 8) - ast_cli(a->fd, "Invalid Arguments.\n"); /* Check for length so no buffer will overflow... */ for (i = 0; i < a->argc; i++) { if (strlen(a->argv[i]) > 100) @@ -1028,7 +1024,55 @@ static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a ast_free(cmdline); return CLI_SUCCESS; } - if (a->argc < 3) { + if (a->argc < 2) { + ast_free(cmdline); + return CLI_SHOWUSAGE; + } + + ast_debug(1, "Cmdline: %s\n", cmdline->str); + + admin_exec(NULL, cmdline->str); + ast_free(cmdline); + + return CLI_SUCCESS; +} + + +static char *meetme_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + /* Process the command */ + struct ast_conference *cnf; + struct ast_conf_user *user; + int hr, min, sec; + int i = 0; + time_t now; + struct ast_str *cmdline = NULL; + + switch (cmd) { + case CLI_INIT: + e->command = "meetme {lock|unlock|mute|unmute|kick}"; + e->usage = + "Usage: meetme (un)lock|(un)mute|kick \n" + " Executes a command for the conference or on a conferee\n"; + return NULL; + case CLI_GENERATE: + return complete_meetmecmd(a->line, a->word, a->pos, a->n); + } + + if (a->argc > 8) + ast_cli(a->fd, "Invalid Arguments.\n"); + /* Check for length so no buffer will overflow... */ + for (i = 0; i < a->argc; i++) { + if (strlen(a->argv[i]) > 100) + ast_cli(a->fd, "Invalid Arguments.\n"); + } + + /* Max confno length */ + if (!(cmdline = ast_str_create(MAX_CONFNUM))) { + return CLI_FAILURE; + } + + if (a->argc < 1) { ast_free(cmdline); return CLI_SHOWUSAGE; } @@ -1307,6 +1351,7 @@ static char *sla_show_stations(struct ast_cli_entry *e, int cmd, struct ast_cli_ static struct ast_cli_entry cli_meetme[] = { AST_CLI_DEFINE(meetme_cmd, "Execute a command on a conference or conferee"), + AST_CLI_DEFINE(meetme_show_cmd, "List all or one conference"), AST_CLI_DEFINE(sla_show_trunks, "Show SLA Trunks"), AST_CLI_DEFINE(sla_show_stations, "Show SLA Stations"), }; -- cgit v1.2.3