Merge the cli_cleanup branch.
authorMichiel van Baak <michiel@vanbaak.info>
Sun, 28 Sep 2008 23:32:14 +0000 (23:32 +0000)
committerMichiel van Baak <michiel@vanbaak.info>
Sun, 28 Sep 2008 23:32:14 +0000 (23:32 +0000)
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

21 files changed:
apps/app_meetme.c
apps/app_mixmonitor.c
apps/app_queue.c
channels/chan_console.c
channels/chan_dahdi.c
channels/chan_features.c
channels/chan_h323.c
channels/chan_misdn.c
channels/chan_oss.c
channels/chan_unistim.c
main/astobj2.c
main/cli.c
main/manager.c
main/taskprocessor.c
res/ais/clm.c
res/ais/evt.c
res/res_agi.c
res/res_clioriginate.c
res/res_config_ldap.c
res/res_config_pgsql.c
res/res_limit.c

index 9ca81eb..78bc881 100644 (file)
@@ -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] <confno> <usernumber>\n"
-                       "       Executes a command for the conference or on a conferee\n";
+                       "Usage: meetme list [concise] <confno> \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 <confno> <usernumber>\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"),
 };
index 066103b..1a5922b 100644 (file)
@@ -365,7 +365,7 @@ static char *handle_cli_mixmonitor(struct ast_cli_entry *e, int cmd, struct ast_
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "mixmonitor [start|stop]";
+               e->command = "mixmonitor {start|stop} {<chan_name>} [args]";
                e->usage =
                        "Usage: mixmonitor <start|stop> <chan_name> [args]\n"
                        "       The optional arguments are passed to the MixMonitor\n"
index f4289d3..a4704bc 100644 (file)
@@ -6264,9 +6264,9 @@ static char *handle_queue_rule_show(struct ast_cli_entry *e, int cmd, struct ast
        struct penalty_rule *pr_iter;
        switch (cmd) {
        case CLI_INIT:
-               e->command = "queue rules show";
+               e->command = "queue show rules";
                e->usage =
-               "Usage: queue rules show [rulename]\n"
+               "Usage: queue show rules [rulename]\n"
                "Show the list of rules associated with rulename. If no\n"
                "rulename is specified, list all rules defined in queuerules.conf\n";
                return NULL;
@@ -6295,9 +6295,9 @@ static char *handle_queue_rule_reload(struct ast_cli_entry *e, int cmd, struct a
 {
        switch (cmd) {
                case CLI_INIT:
-                       e->command = "queue rules reload";
+                       e->command = "queue reload rules";
                        e->usage = 
-                               "Usage: queue rules reload\n"
+                               "Usage: queue reload rules\n"
                                "Reloads rules defined in queuerules.conf\n";
                        return NULL;
                case CLI_GENERATE:
index 3511e0b..c7090a1 100644 (file)
@@ -694,9 +694,9 @@ static char *cli_console_autoanswer(struct ast_cli_entry *e, int cmd,
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "console set autoanswer [on|off]";
+               e->command = "console {set|show} autoanswer [on|off]";
                e->usage =
-                       "Usage: console set autoanswer [on|off]\n"
+                       "Usage: console {set|show} autoanswer [on|off]\n"
                        "       Enables or disables autoanswer feature.  If used without\n"
                        "       argument, displays the current on/off status of autoanswer.\n"
                        "       The default value of autoanswer is in 'oss.conf'.\n";
@@ -1154,12 +1154,10 @@ static char *cli_console_active(struct ast_cli_entry *e, int cmd, struct ast_cli
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "console active";
+               e->command = "console {set|show} active [<device>]";
                e->usage =
-                       "Usage: console active [device]\n"
-                       "       If no device is specified.  The active console device will be shown.\n"
-                       "Otherwise, the specified device will become the console device active for\n"
-                       "the Asterisk CLI.\n";
+                       "Usage: console {set|show} active [<device>]\n"
+                       "       Set or show the active console device for the Asterisk CLI.\n";
                return NULL;
        case CLI_GENERATE:
                if (a->pos == e->args) {
@@ -1181,7 +1179,7 @@ static char *cli_console_active(struct ast_cli_entry *e, int cmd, struct ast_cli
        if (a->argc < e->args)
                return CLI_SHOWUSAGE;
 
-       if (a->argc == e->args) {
+       if (a->argc == 3) {
                pvt = get_active_pvt();
 
                if (!pvt)
index f6e37cb..db24a6d 100644 (file)
@@ -11604,32 +11604,6 @@ static char *complete_span_4(const char *line, const char *word, int pos, int st
        return complete_span_helper(line,word,pos,state,3);
 }
 
-static char *complete_span_5(const char *line, const char *word, int pos, int state)
-{
-       return complete_span_helper(line,word,pos,state,4);
-}
-
-static char *handle_pri_unset_debug_file(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-       switch (cmd) {
-       case CLI_INIT:
-               e->command = "pri unset debug file";
-               e->usage = "Usage: pri unset debug file\n"
-                          "       Stop sending debug output to the previously \n"
-                          "       specified file\n";
-               return NULL;
-       case CLI_GENERATE:
-               return NULL;    
-       }
-       /* Assume it is unset */
-       ast_mutex_lock(&pridebugfdlock);
-       close(pridebugfd);
-       pridebugfd = -1;
-       ast_cli(a->fd, "PRI debug output to file disabled\n");
-       ast_mutex_unlock(&pridebugfdlock);
-       return CLI_SUCCESS;
-}
-
 static char *handle_pri_set_debug_file(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
        int myfd;
@@ -11670,92 +11644,29 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
 {
        int span;
        int x;
+       int level = 0;
        switch (cmd) {
        case CLI_INIT:  
-               e->command = "pri debug span";
+               e->command = "pri set debug {<level>|on|off} span";
                e->usage = 
-                       "Usage: pri debug span <span>\n"
+                       "Usage: pri set debug <level|on|off> span <span>\n"
                        "       Enables debugging on a given PRI span\n";
                return NULL;
        case CLI_GENERATE:      
                return complete_span_4(a->line, a->word, a->pos, a->n);
        }
-       if (a->argc < 4) {
-               return CLI_SHOWUSAGE;
-       }
-       span = atoi(a->argv[3]);
-       if ((span < 1) || (span > NUM_SPANS)) {
-               ast_cli(a->fd, "Invalid span %s.  Should be a number %d to %d\n", a->argv[3], 1, NUM_SPANS);
-               return CLI_SUCCESS;
-       }
-       if (!pris[span-1].pri) {
-               ast_cli(a->fd, "No PRI running on span %d\n", span);
-               return CLI_SUCCESS;
-       }
-       for (x = 0; x < NUM_DCHANS; x++) {
-               if (pris[span-1].dchans[x])
-                       pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
-                                                             PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
-                                                             PRI_DEBUG_Q921_STATE);
-       }
-       ast_cli(a->fd, "Enabled debugging on span %d\n", span);
-       return CLI_SUCCESS;
-}
-
-
-
-static char *handle_pri_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-       int span;
-       int x;
-       switch (cmd) {
-       case CLI_INIT:
-               e->command = "pri no debug span";
-               e->usage = 
-                       "Usage: pri no debug span <span>\n"
-                       "       Disables debugging on a given PRI span\n";
-               return NULL;
-       case CLI_GENERATE:
-               return complete_span_5(a->line, a->word, a->pos, a->n);
-       }
-       if (a->argc < 5)
+       if (a->argc < 6) {
                return CLI_SHOWUSAGE;
-
-       span = atoi(a->argv[4]);
-       if ((span < 1) || (span > NUM_SPANS)) {
-               ast_cli(a->fd, "Invalid span %s.  Should be a number %d to %d\n", a->argv[4], 1, NUM_SPANS);
-               return CLI_SUCCESS;
-       }
-       if (!pris[span-1].pri) {
-               ast_cli(a->fd, "No PRI running on span %d\n", span);
-               return CLI_SUCCESS;
-       }
-       for (x = 0; x < NUM_DCHANS; x++) {
-               if (pris[span-1].dchans[x])
-                       pri_set_debug(pris[span-1].dchans[x], 0);
        }
-       ast_cli(a->fd, "Disabled debugging on span %d\n", span);
-       return CLI_SUCCESS;
-}
 
-static char *handle_pri_really_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-       int span;
-       int x;
-       switch (cmd) {
-       case CLI_INIT:
-               e->command = "pri intensive debug span";
-               e->usage = 
-                       "Usage: pri intensive debug span <span>\n"
-                       "       Enables debugging down to the Q.921 level\n";
-               return NULL;
-       case CLI_GENERATE:
-               return complete_span_5(a->line, a->word, a->pos, a->n);
+       if (!strcasecmp(a->argv[4], "on")) {
+               level = 1;
+       } else if (!strcasecmp(a->argv[4], "off")) {
+               level = 0;
+       } else {
+               level = atoi(a->argv[4]);
        }
-
-       if (a->argc < 5)
-               return CLI_SHOWUSAGE;
-       span = atoi(a->argv[4]);
+       span = atoi(a->argv[5]);
        if ((span < 1) || (span > NUM_SPANS)) {
                ast_cli(a->fd, "Invalid span %s.  Should be a number %d to %d\n", a->argv[4], 1, NUM_SPANS);
                return CLI_SUCCESS;
@@ -11765,12 +11676,28 @@ static char *handle_pri_really_debug(struct ast_cli_entry *e, int cmd, struct as
                return CLI_SUCCESS;
        }
        for (x = 0; x < NUM_DCHANS; x++) {
-               if (pris[span-1].dchans[x])
-                       pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
-                                                             PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
-                                                             PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE);
+               if (pris[span-1].dchans[x]) {
+                       if (level == 1) {
+                               pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
+                                                                     PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
+                                                                     PRI_DEBUG_Q921_STATE);
+                               ast_cli(a->fd, "Enabled debugging on span %d\n", span);
+                       } else if (level == 0) {
+                               pri_set_debug(pris[span-1].dchans[x], 0);
+                               //close the file if it's set
+                               ast_mutex_lock(&pridebugfdlock);
+                               close(pridebugfd);
+                               pridebugfd = -1;
+                               ast_cli(a->fd, "PRI debug output to file disabled\n");
+                               ast_mutex_unlock(&pridebugfdlock);
+                       } else {
+                               pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
+                                                                     PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
+                                                                     PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE);
+                               ast_cli(a->fd, "Enabled debugging on span %d\n", span);
+                       }
+               }
        }
-       ast_cli(a->fd, "Enabled EXTENSIVE debugging on span %d\n", span);
        return CLI_SUCCESS;
 }
 
@@ -11935,13 +11862,10 @@ static char *handle_pri_version(struct ast_cli_entry *e, int cmd, struct ast_cli
 
 static struct ast_cli_entry dahdi_pri_cli[] = {
        AST_CLI_DEFINE(handle_pri_debug, "Enables PRI debugging on a span"),
-       AST_CLI_DEFINE(handle_pri_no_debug, "Disables PRI debugging on a span"),
-       AST_CLI_DEFINE(handle_pri_really_debug, "Enables REALLY INTENSE PRI debugging"),
        AST_CLI_DEFINE(handle_pri_show_spans, "Displays PRI Information"),
        AST_CLI_DEFINE(handle_pri_show_span, "Displays PRI Information"),
        AST_CLI_DEFINE(handle_pri_show_debug, "Displays current PRI debug settings"),
        AST_CLI_DEFINE(handle_pri_set_debug_file, "Sends PRI debug output to the specified file"),
-       AST_CLI_DEFINE(handle_pri_unset_debug_file, "Ends PRI debug output to file"),
        AST_CLI_DEFINE(handle_pri_version, "Displays libpri version"),
 };
 
@@ -13151,65 +13075,40 @@ static int linkset_addsigchan(int sigchan)
        return 0;
 }
 
-static char *handle_ss7_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-       int span;
-       switch (cmd) {
-       case CLI_INIT:
-               e->command = "ss7 no debug linkset";
-               e->usage = 
-                       "Usage: ss7 no debug linkset <span>\n"
-                       "       Disables debugging on a given SS7 linkset\n";
-               return NULL;
-       case CLI_GENERATE:
-               return NULL;
-       }
-       if (a->argc < 5)
-               return CLI_SHOWUSAGE;
-       span = atoi(a->argv[4]);
-       if ((span < 1) || (span > NUM_SPANS)) {
-               ast_cli(a->fd, "Invalid linkset %s.  Should be a number from %d to %d\n", a->argv[4], 1, NUM_SPANS);
-               return CLI_SUCCESS;
-       }
-       if (!linksets[span-1].ss7) {
-               ast_cli(a->fd, "No SS7 running on linkset %d\n", span);
-               return CLI_SUCCESS;
-       }
-       if (linksets[span-1].ss7)
-               ss7_set_debug(linksets[span-1].ss7, 0);
-
-       ast_cli(a->fd, "Disabled debugging on linkset %d\n", span);
-       return CLI_SUCCESS;
-}
-
 static char *handle_ss7_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
        int span;
        switch (cmd) {
        case CLI_INIT:
-               e->command = "ss7 debug linkset";
+               e->command = "ss7 set debug {on|off} linkset";
                e->usage = 
-                       "Usage: ss7 debug linkset <linkset>\n"
+                       "Usage: ss7 set debug {on|off} linkset <linkset>\n"
                        "       Enables debugging on a given SS7 linkset\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
        }
-       if (a->argc < 4)
+       if (a->argc < 6)
                return CLI_SHOWUSAGE;
-       span = atoi(a->argv[3]);
+       span = atoi(a->argv[5]);
        if ((span < 1) || (span > NUM_SPANS)) {
-               ast_cli(a->fd, "Invalid linkset %s.  Should be a number from %d to %d\n", a->argv[3], 1, NUM_SPANS);
+               ast_cli(a->fd, "Invalid linkset %s.  Should be a number from %d to %d\n", a->argv[5], 1, NUM_SPANS);
                return CLI_SUCCESS;
        }
        if (!linksets[span-1].ss7) {
                ast_cli(a->fd, "No SS7 running on linkset %d\n", span);
                return CLI_SUCCESS;
        }
-       if (linksets[span-1].ss7)
-               ss7_set_debug(linksets[span-1].ss7, SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP);
+       if (linksets[span-1].ss7) {
+               if (strcasecmp(a->argv[4], "on")) {
+                       ss7_set_debug(linksets[span-1].ss7, SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP);
+                       ast_cli(a->fd, "Enabled debugging on linkset %d\n", span);
+               } else {
+                       ss7_set_debug(linksets[span-1].ss7, 0);
+                       ast_cli(a->fd, "Disabled debugging on linkset %d\n", span);
+               }
+       }
 
-       ast_cli(a->fd, "Enabled debugging on linkset %d\n", span);
        return CLI_SUCCESS;
 }
 
@@ -13470,7 +13369,6 @@ static char *handle_ss7_version(struct ast_cli_entry *e, int cmd, struct ast_cli
 
 static struct ast_cli_entry dahdi_ss7_cli[] = {
        AST_CLI_DEFINE(handle_ss7_debug, "Enables SS7 debugging on a linkset"), 
-       AST_CLI_DEFINE(handle_ss7_no_debug, "Disables SS7 debugging on a linkset"), 
        AST_CLI_DEFINE(handle_ss7_block_cic, "Blocks the given CIC"),
        AST_CLI_DEFINE(handle_ss7_unblock_cic, "Unblocks the given CIC"),
        AST_CLI_DEFINE(handle_ss7_block_linkset, "Blocks all CICs on a linkset"),
index 3c41eb7..5da503f 100644 (file)
@@ -501,9 +501,9 @@ static char *features_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "feature show channels";
+               e->command = "features show channels";
                e->usage =
-                       "Usage: feature show channels\n"
+                       "Usage: features show channels\n"
                        "       Provides summary information on feature channels.\n";
                return NULL;
        case CLI_GENERATE:
index 36f8cd5..b374aff 100644 (file)
@@ -2619,16 +2619,16 @@ static char *handle_cli_h323_set_trace(struct ast_cli_entry *e, int cmd, struct
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "h323 set trace [off]";
+               e->command = "h323 set trace [on|off]";
                e->usage =
-                       "Usage: h323 set trace (off|<trace level>)\n"
+                       "Usage: h323 set trace (on|off|<trace level>)\n"
                        "       Enable/Disable H.323 stack tracing for debugging purposes\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
        }
 
-       if (a->argc != 4)
+       if (a->argc != e->args)
                return CLI_SHOWUSAGE;
        if (!strcasecmp(a->argv[3], "off")) {
                h323_debug(0, 0);
@@ -2645,21 +2645,21 @@ static char *handle_cli_h323_set_debug(struct ast_cli_entry *e, int cmd, struct
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "h323 set debug [off]";
+               e->command = "h323 set debug [on|off]";
                e->usage =
-                       "Usage: h323 set debug [off]\n"
+                       "Usage: h323 set debug [on|off]\n"
                        "       Enable/Disable H.323 debugging output\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
        }
 
-       if (a->argc < 3 || a->argc > 4)
+       if (a->argc != e->args)
                return CLI_SHOWUSAGE;
-       if (a->argc == 4 && strcasecmp(a->argv[3], "off"))
+       if (strcasecmp(a->argv[3], "on") && strcasecmp(a->argv[3], "off"))
                return CLI_SHOWUSAGE;
 
-       h323debug = (a->argc == 3) ? 1 : 0;
+       h323debug = (strcasecmp(a->argv[3], "on")) ? 0 : 1;
        ast_cli(a->fd, "H.323 Debugging %s\n", h323debug ? "Enabled" : "Disabled");
        return CLI_SUCCESS;
 }
index 5cec653..3d3da0c 100644 (file)
@@ -736,9 +736,9 @@ static char *handle_cli_misdn_set_debug(struct ast_cli_entry *e, int cmd, struct
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "misdn set debug";
+               e->command = "misdn set debug {on|off|<level>}";
                e->usage =
-                       "Usage: misdn set debug <level> [only] | [port <port> [only]]\n"
+                       "Usage: misdn set debug {on|off|<level>} [only] | [port <port> [only]]\n"
                        "       Set the debug level of the mISDN channel.\n";
                return NULL;
        case CLI_GENERATE:
@@ -747,8 +747,14 @@ static char *handle_cli_misdn_set_debug(struct ast_cli_entry *e, int cmd, struct
 
        if (a->argc < 4 || a->argc > 7)
                return CLI_SHOWUSAGE;
-
-       level = atoi(a->argv[3]);
+       
+       if (!strcasecmp(a->argv[3], "on")) {
+               level = 1;
+       } else if (!strcasecmp(a->argv[3], "off")) {
+               level = 0;
+       } else {
+               level = atoi(a->argv[3]);
+       }
 
        switch (a->argc) {
        case 4: 
index 20be029..ae4137c 100644 (file)
@@ -911,9 +911,9 @@ static char *console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "console autoanswer [on|off]";
+               e->command = "console {set|show} autoanswer [on|off]";
                e->usage =
-                       "Usage: console autoanswer [on|off]\n"
+                       "Usage: console {set|show} autoanswer [on|off]\n"
                        "       Enables or disables autoanswer feature.  If used without\n"
                        "       argument, displays the current on/off status of autoanswer.\n"
                        "       The default value of autoanswer is in 'oss.conf'.\n";
@@ -1200,7 +1200,7 @@ static char *console_active(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "console active";
+               e->command = "console {set|show} active [<device>]";
                e->usage =
                        "Usage: console active [device]\n"
                        "       If used without a parameter, displays which device is the current\n"
@@ -1211,20 +1211,20 @@ static char *console_active(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
                return NULL;
        }
 
-       if (a->argc == 2)
+       if (a->argc == 3)
                ast_cli(a->fd, "active console is [%s]\n", oss_active);
-       else if (a->argc != 3)
+       else if (a->argc != 4)
                return CLI_SHOWUSAGE;
        else {
                struct chan_oss_pvt *o;
-               if (strcmp(a->argv[2], "show") == 0) {
+               if (strcmp(a->argv[3], "show") == 0) {
                        for (o = oss_default.next; o; o = o->next)
                                ast_cli(a->fd, "device [%s] exists\n", o->name);
                        return CLI_SUCCESS;
                }
-               o = find_desc(a->argv[2]);
+               o = find_desc(a->argv[3]);
                if (o == NULL)
-                       ast_cli(a->fd, "No device [%s] exists\n", a->argv[2]);
+                       ast_cli(a->fd, "No device [%s] exists\n", a->argv[3]);
                else
                        oss_active = o->name;
        }
index 48a41fc..bd15f28 100644 (file)
@@ -4682,9 +4682,9 @@ static char *unistim_info(struct ast_cli_entry *e, int cmd, struct ast_cli_args
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "unistim info";
+               e->command = "unistim show info";
                e->usage =
-                       "Usage: unistim info\n" 
+                       "Usage: unistim show info\n" 
                        "       Dump internal structures.\n";
                return NULL;
 
@@ -4751,27 +4751,27 @@ static char *unistim_sp(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "unistim sp";
+               e->command = "unistim send packet";
                e->usage =
-                       "Usage: unistim sp USTM/line@name hexa\n"
-                       "       unistim sp USTM/1000@hans 19040004\n";
+                       "Usage: unistim send packet USTM/line@name hexa\n"
+                       "       unistim send packet USTM/1000@hans 19040004\n";
                return NULL;
 
        case CLI_GENERATE:
                return NULL;    /* no completion */
        }
        
-       if (a->argc < 4)
+       if (a->argc < 5)
                return CLI_SHOWUSAGE;
 
-       if (strlen(a->argv[2]) < 9)
+       if (strlen(a->argv[3]) < 9)
                return CLI_SHOWUSAGE;
 
-       len = strlen(a->argv[3]);
+       len = strlen(a->argv[4]);
        if (len % 2)
                return CLI_SHOWUSAGE;
 
-       ast_copy_string(tmp, a->argv[2] + 5, sizeof(tmp));
+       ast_copy_string(tmp, a->argv[3] + 5, sizeof(tmp));
        sub = find_subchannel_by_name(tmp);
        if (!sub) {
                ast_cli(a->fd, "Can't find '%s'\n", tmp);
@@ -4781,15 +4781,15 @@ static char *unistim_sp(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a
                ast_cli(a->fd, "'%s' is not connected\n", tmp);
                return CLI_SUCCESS;
        }
-       ast_cli(a->fd, "Sending '%s' to %s (%p)\n", a->argv[3], tmp, sub->parent->parent->session);
+       ast_cli(a->fd, "Sending '%s' to %s (%p)\n", a->argv[4], tmp, sub->parent->parent->session);
        for (i = 0; i < len; i++) {
-               c = a->argv[3][i];
+               c = a->argv[4][i];
                if (c >= 'a')
                        c -= 'a' - 10;
                else
                        c -= '0';
                i++;
-               cc = a->argv[3][i];
+               cc = a->argv[4][i];
                if (cc >= 'a')
                        cc -= 'a' - 10;
                else
index c665010..b80c407 100644 (file)
@@ -862,9 +862,9 @@ static char *handle_astobj2_stats(struct ast_cli_entry *e, int cmd, struct ast_c
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "astobj2 stats";
-               e->usage = "Usage: astobj2 stats\n"
-                          "       Show astobj2 stats\n";
+               e->command = "astobj2 show stats";
+               e->usage = "Usage: astobj2 show stats\n"
+                          "       Show astobj2 show stats\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
index f07d8b0..be62352 100644 (file)
@@ -756,18 +756,18 @@ static char *handle_softhangup(struct ast_cli_entry *e, int cmd, struct ast_cli_
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "soft hangup";
+               e->command = "channel request hangup";
                e->usage =
-                       "Usage: soft hangup <channel>\n"
+                       "Usage: channel request hangup <channel>\n"
                        "       Request that a channel be hung up. The hangup takes effect\n"
                        "       the next time the driver reads or writes from the channel\n";
                return NULL;
        case CLI_GENERATE:
                return ast_complete_channels(a->line, a->word, a->pos, a->n, 2);
        }
-       if (a->argc != 3)
+       if (a->argc != 4)
                return CLI_SHOWUSAGE;
-       c = ast_get_channel_by_name_locked(a->argv[2]);
+       c = ast_get_channel_by_name_locked(a->argv[3]);
        if (c) {
                ast_cli(a->fd, "Requested Hangup on channel '%s'\n", c->name);
                ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
index 7d57eb6..ee93dad 100644 (file)
@@ -519,18 +519,18 @@ static char *handle_mandebug(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
 {
        switch (cmd) {
        case CLI_INIT:
-               e->command = "manager debug [on|off]";
-               e->usage = "Usage: manager debug [on|off]\n     Show, enable, disable debugging of the manager code.\n";
+               e->command = "manager set debug [on|off]";
+               e->usage = "Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;    
        }
-       if (a->argc == 2)
+       if (a->argc == 3)
                ast_cli(a->fd, "manager debug is %s\n", manager_debug? "on" : "off");
-       else if (a->argc == 3) {
-               if (!strcasecmp(a->argv[2], "on"))
+       else if (a->argc == 4) {
+               if (!strcasecmp(a->argv[3], "on"))
                        manager_debug = 1;
-               else if (!strcasecmp(a->argv[2], "off"))
+               else if (!strcasecmp(a->argv[3], "off"))
                        manager_debug = 0;
                else
                        return CLI_SHOWUSAGE;
index 450d579..6ed939b 100644 (file)
@@ -196,9 +196,9 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "core taskprocessor ping";
+               e->command = "core ping taskprocessor";
                e->usage = 
-                       "Usage: core taskprocessor ping <taskprocessor>\n"
+                       "Usage: core ping taskprocessor <taskprocessor>\n"
                        "       Displays the time required for a task to be processed\n";
                return NULL;
        case CLI_GENERATE:
index 5d7a356..9788c26 100644 (file)
@@ -78,9 +78,9 @@ static char *ais_clm_show_members(struct ast_cli_entry *e, int cmd, struct ast_c
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "ais clm show members";
+               e->command = "ais show clm members";
                e->usage =
-                       "Usage: ais clm show members\n"
+                       "Usage: ais show clm members\n"
                        "       List members of the cluster using the CLM (Cluster Membership) service.\n";
                return NULL;
 
index 0057f04..2965df0 100644 (file)
@@ -271,9 +271,9 @@ static char *ais_evt_show_event_channels(struct ast_cli_entry *e, int cmd, struc
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "ais evt show event channels";
+               e->command = "ais show evt event channels";
                e->usage =
-                       "Usage: ais evt show event channels\n"
+                       "Usage: ais show evt event channels\n"
                        "       List configured event channels for the (EVT) Eventing service.\n";
                return NULL;
 
index 02b666c..d5cd096 100644 (file)
@@ -86,7 +86,7 @@ static char *descrip =
 "AGISIGHUP channel variable to \"no\" before executing the AGI application.\n"
 "  Using 'EAGI' provides enhanced AGI, with incoming audio available out of band\n"
 "on file descriptor 3.\n\n"
-"  Use the CLI command 'agi show' to list available agi commands.\n"
+"  Use the CLI command 'agi show commnands' to list available agi commands.\n"
 "  This application sets the following channel variable upon completion:\n"
 "     AGISTATUS      The status of the attempt to the run the AGI script\n"
 "                    text string, one of SUCCESS | FAILURE | NOTFOUND | HANGUP\n";
@@ -2727,9 +2727,9 @@ static char *handle_cli_agi_show(struct ast_cli_entry *e, int cmd, struct ast_cl
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "agi show";
+               e->command = "agi show commands [topic]";
                e->usage =
-                       "Usage: agi show [topic]\n"
+                       "Usage: agi show commands [topic]\n"
                        "       When called with a topic as an argument, displays usage\n"
                        "       information on the given command.  If called without a\n"
                        "       topic, it provides a list of AGI commands.\n";
index 6a63719..1052888 100644 (file)
@@ -122,26 +122,26 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
        char *res;
        switch (cmd) {
        case CLI_INIT:
-               e->command = "originate";
+               e->command = "channel originate";
                e->usage = 
                        "  There are two ways to use this command. A call can be originated between a\n"
                        "channel and a specific application, or between a channel and an extension in\n"
                        "the dialplan. This is similar to call files or the manager originate action.\n"
                        "Calls originated with this command are given a timeout of 30 seconds.\n\n"
 
-                       "Usage1: originate <tech/data> application <appname> [appdata]\n"
+                       "Usage1: channel originate <tech/data> application <appname> [appdata]\n"
                        "  This will originate a call between the specified channel tech/data and the\n"
                        "given application. Arguments to the application are optional. If the given\n"
                        "arguments to the application include spaces, all of the arguments to the\n"
                        "application need to be placed in quotation marks.\n\n"
 
-                       "Usage2: originate <tech/data> extension [exten@][context]\n"
+                       "Usage2: channel originate <tech/data> extension [exten@][context]\n"
                        "  This will originate a call between the specified channel tech/data and the\n"
                        "given extension. If no context is specified, the 'default' context will be\n"
                        "used. If no extension is given, the 's' extension will be used.\n";
                return NULL;
        case CLI_GENERATE:
-               if (a->pos != 2)
+               if (a->pos != 3)
                        return NULL;
 
                /* ugly, can be removed when CLI entries have ast_module pointers */
@@ -152,18 +152,20 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
                return res;
        }
 
-       if (ast_strlen_zero(a->argv[1]) || ast_strlen_zero(a->argv[2]))
+       if (ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3]))
                return CLI_SHOWUSAGE;
 
        /* ugly, can be removed when CLI entries have ast_module pointers */
        ast_module_ref(ast_module_info->self);
 
-       if (!strcasecmp("application", a->argv[2])) {
-               res = orig_app(a->fd, a->argv[1], a->argv[3], a->argv[4]);      
-       } else if (!strcasecmp("extension", a->argv[2])) {
-               res = orig_exten(a->fd, a->argv[1], a->argv[3]);
-       } else
+       if (!strcasecmp("application", a->argv[3])) {
+               res = orig_app(a->fd, a->argv[2], a->argv[4], a->argv[5]);      
+       } else if (!strcasecmp("extension", a->argv[3])) {
+               res = orig_exten(a->fd, a->argv[2], a->argv[4]);
+       } else {
+               ast_log(LOG_WARNING, "else");
                res = CLI_SHOWUSAGE;
+       }
 
        ast_module_unref(ast_module_info->self);
 
index 916ce8f..966da9e 100644 (file)
@@ -1529,9 +1529,9 @@ static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_c
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "realtime ldap status";
+               e->command = "realtime show ldap status";
                e->usage =
-                       "Usage: realtime ldap status\n"
+                       "Usage: realtime show ldap status\n"
                        "               Shows connection information for the LDAP RealTime driver\n";
                return NULL;
        case CLI_GENERATE:
index 5ef6cf6..f7c1f3a 100644 (file)
@@ -1315,13 +1315,13 @@ static char *handle_cli_realtime_pgsql_cache(struct ast_cli_entry *e, int cmd, s
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "realtime pgsql cache";
+               e->command = "realtime show pgsql cache";
                e->usage =
-                       "Usage: realtime pgsql cache [<table>]\n"
+                       "Usage: realtime show pgsql cache [<table>]\n"
                        "       Shows table cache for the PostgreSQL RealTime driver\n";
                return NULL;
        case CLI_GENERATE:
-               if (a->argc != 3) {
+               if (a->argc != 4) {
                        return NULL;
                }
                l = strlen(a->word);
@@ -1337,25 +1337,25 @@ static char *handle_cli_realtime_pgsql_cache(struct ast_cli_entry *e, int cmd, s
                return ret;
        }
 
-       if (a->argc == 3) {
+       if (a->argc == 4) {
                /* List of tables */
                AST_LIST_LOCK(&psql_tables);
                AST_LIST_TRAVERSE(&psql_tables, cur, list) {
                        ast_cli(a->fd, "%s\n", cur->name);
                }
                AST_LIST_UNLOCK(&psql_tables);
-       } else if (a->argc == 4) {
+       } else if (a->argc == 5) {
                /* List of columns */
-               if ((cur = find_table(a->argv[3]))) {
+               if ((cur = find_table(a->argv[4]))) {
                        struct columns *col;
-                       ast_cli(a->fd, "Columns for Table Cache '%s':\n", a->argv[3]);
+                       ast_cli(a->fd, "Columns for Table Cache '%s':\n", a->argv[4]);
                        ast_cli(a->fd, "%-20.20s %-20.20s %-3.3s %-8.8s\n", "Name", "Type", "Len", "Nullable");
                        AST_LIST_TRAVERSE(&cur->columns, col, list) {
                                ast_cli(a->fd, "%-20.20s %-20.20s %3d %-8.8s\n", col->name, col->type, col->len, col->notnull ? "NOT NULL" : "");
                        }
                        ast_mutex_unlock(&cur->lock);
                } else {
-                       ast_cli(a->fd, "No such table '%s'\n", a->argv[3]);
+                       ast_cli(a->fd, "No such table '%s'\n", a->argv[4]);
                }
        }
        return 0;
@@ -1368,16 +1368,16 @@ static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd,
 
        switch (cmd) {
        case CLI_INIT:
-               e->command = "realtime pgsql status";
+               e->command = "realtime show pgsql status";
                e->usage =
-                       "Usage: realtime pgsql status\n"
+                       "Usage: realtime show pgsql status\n"
                        "       Shows connection information for the PostgreSQL RealTime driver\n";
                return NULL;
        case CLI_GENERATE:
                return NULL;
        }
 
-       if (a->argc != 3)
+       if (a->argc != 4)
                return CLI_SHOWUSAGE;
 
        if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
index b1cf025..35bd9d3 100644 (file)
@@ -44,22 +44,23 @@ static struct limits {
        int resource;
        char limit[3];
        char desc[40];
+       char clicmd[15];
 } limits[] = {
-       { RLIMIT_CPU,     "-t", "cpu time" },
-       { RLIMIT_FSIZE,   "-f", "file size" },
-       { RLIMIT_DATA,    "-d", "program data segment" },
-       { RLIMIT_STACK,   "-s", "program stack size" },
-       { RLIMIT_CORE,    "-c", "core file size" },
+       { RLIMIT_CPU,     "-t", "cpu time", "time" },
+       { RLIMIT_FSIZE,   "-f", "file size" , "file" },
+       { RLIMIT_DATA,    "-d", "program data segment", "data" },
+       { RLIMIT_STACK,   "-s", "program stack size", "stack" },
+       { RLIMIT_CORE,    "-c", "core file size", "core" },
 #ifdef RLIMIT_RSS
-       { RLIMIT_RSS,     "-m", "resident memory" },
-       { RLIMIT_MEMLOCK, "-l", "amount of memory locked into RAM" },
+       { RLIMIT_RSS,     "-m", "resident memory", "memory" },
+       { RLIMIT_MEMLOCK, "-l", "amount of memory locked into RAM", "locked" },
 #endif
 #ifdef RLIMIT_NPROC
-       { RLIMIT_NPROC,   "-u", "number of processes" },
+       { RLIMIT_NPROC,   "-u", "number of processes", "processes" },
 #endif
-       { RLIMIT_NOFILE,  "-n", "number of file descriptors" },
+       { RLIMIT_NOFILE,  "-n", "number of file descriptors", "descriptors" },
 #ifdef VMEM_DEF
-       { VMEM_DEF,       "-v", "virtual memory" },
+       { VMEM_DEF,       "-v", "virtual memory", "virtual" },
 #endif
 };
 
@@ -67,7 +68,7 @@ static int str2limit(const char *string)
 {
        size_t i;
        for (i = 0; i < ARRAY_LEN(limits); i++) {
-               if (!strcasecmp(string, limits[i].limit))
+               if (!strcasecmp(string, limits[i].clicmd))
                        return limits[i].resource;
        }
        return -1;
@@ -77,7 +78,7 @@ static const char *str2desc(const char *string)
 {
        size_t i;
        for (i = 0; i < ARRAY_LEN(limits); i++) {
-               if (!strcmp(string, limits[i].limit))
+               if (!strcmp(string, limits[i].clicmd))
                        return limits[i].desc;
        }
        return "<unknown>";
@@ -91,9 +92,9 @@ static char *complete_ulimit(struct ast_cli_args *a)
        if (a->pos > 1)
                return NULL;
        for (i = 0; i < ARRAY_LEN(limits); i++) {
-               if (!strncasecmp(limits[i].limit, a->word, wordlen)) {
+               if (!strncasecmp(limits[i].clicmd, a->word, wordlen)) {
                        if (++which > a->n)
-                               return ast_strdup(limits[i].limit);
+                               return ast_strdup(limits[i].clicmd);
                }
        }
        return NULL;
@@ -108,41 +109,41 @@ static char *handle_cli_ulimit(struct ast_cli_entry *e, int cmd, struct ast_cli_
        case CLI_INIT:
                e->command = "ulimit";
                e->usage =
-                       "Usage: ulimit {-d|"
+                       "Usage: ulimit {data|"
 #ifdef RLIMIT_RSS
-                       "-l|"
+                       "limit|"
 #endif
-                       "-f|"
+                       "file|"
 #ifdef RLIMIT_RSS
-                       "-m|"
+                       "memory|"
 #endif
-                       "-s|-t|"
+                       "stack|time|"
 #ifdef RLIMIT_NPROC
-                       "-u|"
+                       "processes|"
 #endif
 #ifdef VMEM_DEF
-                       "-v|"
+                       "virtual|"
 #endif
-                       "-c|-n} [<num>]\n"
+                       "core|descriptors} [<num>]\n"
                        "       Shows or sets the corresponding resource limit.\n"
-                       "         -d  Process data segment [readonly]\n"
+                       "         data          Process data segment [readonly]\n"
 #ifdef RLIMIT_RSS
-                       "         -l  Memory lock size [readonly]\n"
+                       "         lock          Memory lock size [readonly]\n"
 #endif
-                       "         -f  File size\n"
+                       "         file          File size\n"
 #ifdef RLIMIT_RSS
-                       "         -m  Process resident memory [readonly]\n"
+                       "         memory        Process resident memory [readonly]\n"
 #endif
-                       "         -s  Process stack size [readonly]\n"
-                       "         -t  CPU usage [readonly]\n"
+                       "         stack         Process stack size [readonly]\n"
+                       "         time          CPU usage [readonly]\n"
 #ifdef RLIMIT_NPROC
-                       "         -u  Child processes\n"
+                       "         processes     Child processes\n"
 #endif
 #ifdef VMEM_DEF
-                       "         -v  Process virtual memory [readonly]\n"
+                       "         virtual       Process virtual memory [readonly]\n"
 #endif
-                       "         -c  Core dump file size\n"
-                       "         -n  Number of file descriptors\n";
+                       "         core          Core dump file size\n"
+                       "         descriptors   Number of file descriptors\n";
                return NULL;
        case CLI_GENERATE:
                return complete_ulimit(a);
@@ -152,11 +153,11 @@ static char *handle_cli_ulimit(struct ast_cli_entry *e, int cmd, struct ast_cli_
                return CLI_SHOWUSAGE;
 
        if (a->argc == 1) {
-               char arg2[3];
+               char arg2[15];
                char *newargv[2] = { "ulimit", arg2 };
                for (resource = 0; resource < ARRAY_LEN(limits); resource++) {
                        struct ast_cli_args newArgs = { .argv = newargv, .argc = 2 };
-                       ast_copy_string(arg2, limits[resource].limit, sizeof(arg2));
+                       ast_copy_string(arg2, limits[resource].clicmd, sizeof(arg2));
                        handle_cli_ulimit(e, CLI_HANDLER, &newArgs);
                }
                return CLI_SUCCESS;