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
1.6.2
Michiel van Baak 17 years ago
parent 434c69b7fd
commit 90751b16ca

@ -883,7 +883,6 @@ cnfout:
return cnf; return cnf;
} }
static char *complete_meetmecmd(const char *line, const char *word, int pos, int state) 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}; 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; 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 */ /* Process the command */
struct ast_conference *cnf; struct ast_conference *cnf;
struct ast_conf_user *user;
int hr, min, sec; int hr, min, sec;
int i = 0, total = 0; int i = 0, total = 0;
time_t now; 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) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "meetme"; e->command = "meetme list [concise]";
e->usage = e->usage =
"Usage: meetme (un)lock|(un)mute|kick|list [concise] <confno> <usernumber>\n" "Usage: meetme list [concise] <confno> \n"
" Executes a command for the conference or on a conferee\n"; " List all or a specific conference.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return complete_meetmecmd(a->line, a->word, a->pos, a->n); 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... */ /* Check for length so no buffer will overflow... */
for (i = 0; i < a->argc; i++) { for (i = 0; i < a->argc; i++) {
if (strlen(a->argv[i]) > 100) 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); ast_free(cmdline);
return CLI_SUCCESS; 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); ast_free(cmdline);
return CLI_SHOWUSAGE; 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[] = { static struct ast_cli_entry cli_meetme[] = {
AST_CLI_DEFINE(meetme_cmd, "Execute a command on a conference or conferee"), 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_trunks, "Show SLA Trunks"),
AST_CLI_DEFINE(sla_show_stations, "Show SLA Stations"), AST_CLI_DEFINE(sla_show_stations, "Show SLA Stations"),
}; };

@ -365,7 +365,7 @@ static char *handle_cli_mixmonitor(struct ast_cli_entry *e, int cmd, struct ast_
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "mixmonitor [start|stop]"; e->command = "mixmonitor {start|stop} {<chan_name>} [args]";
e->usage = e->usage =
"Usage: mixmonitor <start|stop> <chan_name> [args]\n" "Usage: mixmonitor <start|stop> <chan_name> [args]\n"
" The optional arguments are passed to the MixMonitor\n" " The optional arguments are passed to the MixMonitor\n"

@ -6264,9 +6264,9 @@ static char *handle_queue_rule_show(struct ast_cli_entry *e, int cmd, struct ast
struct penalty_rule *pr_iter; struct penalty_rule *pr_iter;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "queue rules show"; e->command = "queue show rules";
e->usage = 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" "Show the list of rules associated with rulename. If no\n"
"rulename is specified, list all rules defined in queuerules.conf\n"; "rulename is specified, list all rules defined in queuerules.conf\n";
return NULL; return NULL;
@ -6295,9 +6295,9 @@ static char *handle_queue_rule_reload(struct ast_cli_entry *e, int cmd, struct a
{ {
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "queue rules reload"; e->command = "queue reload rules";
e->usage = e->usage =
"Usage: queue rules reload\n" "Usage: queue reload rules\n"
"Reloads rules defined in queuerules.conf\n"; "Reloads rules defined in queuerules.conf\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:

@ -694,9 +694,9 @@ static char *cli_console_autoanswer(struct ast_cli_entry *e, int cmd,
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "console set autoanswer [on|off]"; e->command = "console {set|show} autoanswer [on|off]";
e->usage = 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" " Enables or disables autoanswer feature. If used without\n"
" argument, displays the current on/off status of autoanswer.\n" " argument, displays the current on/off status of autoanswer.\n"
" The default value of autoanswer is in 'oss.conf'.\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) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "console active"; e->command = "console {set|show} active [<device>]";
e->usage = e->usage =
"Usage: console active [device]\n" "Usage: console {set|show} active [<device>]\n"
" If no device is specified. The active console device will be shown.\n" " Set or show the active console device for the Asterisk CLI.\n";
"Otherwise, the specified device will become the console device active for\n"
"the Asterisk CLI.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
if (a->pos == e->args) { 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) if (a->argc < e->args)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
if (a->argc == e->args) { if (a->argc == 3) {
pvt = get_active_pvt(); pvt = get_active_pvt();
if (!pvt) if (!pvt)

@ -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); 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) static char *handle_pri_set_debug_file(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
int myfd; int myfd;
@ -11670,22 +11644,31 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
{ {
int span; int span;
int x; int x;
int level = 0;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "pri debug span"; e->command = "pri set debug {<level>|on|off} span";
e->usage = 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"; " Enables debugging on a given PRI span\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return complete_span_4(a->line, a->word, a->pos, a->n); return complete_span_4(a->line, a->word, a->pos, a->n);
} }
if (a->argc < 4) { if (a->argc < 6) {
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
} }
span = atoi(a->argv[3]);
if (!strcasecmp(a->argv[4], "on")) {
level = 1;
} else if (!strcasecmp(a->argv[4], "off")) {
level = 0;
} else {
level = atoi(a->argv[4]);
}
span = atoi(a->argv[5]);
if ((span < 1) || (span > NUM_SPANS)) { 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); ast_cli(a->fd, "Invalid span %s. Should be a number %d to %d\n", a->argv[4], 1, NUM_SPANS);
return CLI_SUCCESS; return CLI_SUCCESS;
} }
if (!pris[span-1].pri) { if (!pris[span-1].pri) {
@ -11693,84 +11676,28 @@ static char *handle_pri_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
return CLI_SUCCESS; return CLI_SUCCESS;
} }
for (x = 0; x < NUM_DCHANS; x++) { for (x = 0; x < NUM_DCHANS; x++) {
if (pris[span-1].dchans[x]) if (pris[span-1].dchans[x]) {
if (level == 1) {
pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU | pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
PRI_DEBUG_Q921_STATE); PRI_DEBUG_Q921_STATE);
}
ast_cli(a->fd, "Enabled debugging on span %d\n", span); ast_cli(a->fd, "Enabled debugging on span %d\n", span);
return CLI_SUCCESS; } else if (level == 0) {
}
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)
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); pri_set_debug(pris[span-1].dchans[x], 0);
} //close the file if it's set
ast_cli(a->fd, "Disabled debugging on span %d\n", span); ast_mutex_lock(&pridebugfdlock);
return CLI_SUCCESS; close(pridebugfd);
} pridebugfd = -1;
ast_cli(a->fd, "PRI debug output to file disabled\n");
static char *handle_pri_really_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) ast_mutex_unlock(&pridebugfdlock);
{ } else {
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 (a->argc < 5)
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], PRI_DEBUG_APDU | pri_set_debug(pris[span-1].dchans[x], PRI_DEBUG_APDU |
PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_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; 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[] = { 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_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_spans, "Displays PRI Information"),
AST_CLI_DEFINE(handle_pri_show_span, "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_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_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"), AST_CLI_DEFINE(handle_pri_version, "Displays libpri version"),
}; };
@ -13151,65 +13075,40 @@ static int linkset_addsigchan(int sigchan)
return 0; return 0;
} }
static char *handle_ss7_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *handle_ss7_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
int span; int span;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "ss7 no debug linkset"; e->command = "ss7 set debug {on|off} linkset";
e->usage = e->usage =
"Usage: ss7 no debug linkset <span>\n" "Usage: ss7 set debug {on|off} linkset <linkset>\n"
" Disables debugging on a given SS7 linkset\n"; " Enables debugging on a given SS7 linkset\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return NULL; return NULL;
} }
if (a->argc < 5) if (a->argc < 6)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
span = atoi(a->argv[4]); span = atoi(a->argv[5]);
if ((span < 1) || (span > NUM_SPANS)) { 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); 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; return CLI_SUCCESS;
} }
if (!linksets[span-1].ss7) { if (!linksets[span-1].ss7) {
ast_cli(a->fd, "No SS7 running on linkset %d\n", span); ast_cli(a->fd, "No SS7 running on linkset %d\n", span);
return CLI_SUCCESS; return CLI_SUCCESS;
} }
if (linksets[span-1].ss7) 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); ss7_set_debug(linksets[span-1].ss7, 0);
ast_cli(a->fd, "Disabled debugging on linkset %d\n", span); 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->usage =
"Usage: ss7 debug linkset <linkset>\n"
" Enables debugging on a given SS7 linkset\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc < 4)
return CLI_SHOWUSAGE;
span = atoi(a->argv[3]);
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);
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);
ast_cli(a->fd, "Enabled debugging on linkset %d\n", span);
return CLI_SUCCESS; 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[] = { 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_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_block_cic, "Blocks the given CIC"),
AST_CLI_DEFINE(handle_ss7_unblock_cic, "Unblocks 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"), AST_CLI_DEFINE(handle_ss7_block_linkset, "Blocks all CICs on a linkset"),

@ -501,9 +501,9 @@ static char *features_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "feature show channels"; e->command = "features show channels";
e->usage = e->usage =
"Usage: feature show channels\n" "Usage: features show channels\n"
" Provides summary information on feature channels.\n"; " Provides summary information on feature channels.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:

@ -2619,16 +2619,16 @@ static char *handle_cli_h323_set_trace(struct ast_cli_entry *e, int cmd, struct
{ {
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "h323 set trace [off]"; e->command = "h323 set trace [on|off]";
e->usage = 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"; " Enable/Disable H.323 stack tracing for debugging purposes\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return NULL; return NULL;
} }
if (a->argc != 4) if (a->argc != e->args)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
if (!strcasecmp(a->argv[3], "off")) { if (!strcasecmp(a->argv[3], "off")) {
h323_debug(0, 0); 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) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "h323 set debug [off]"; e->command = "h323 set debug [on|off]";
e->usage = e->usage =
"Usage: h323 set debug [off]\n" "Usage: h323 set debug [on|off]\n"
" Enable/Disable H.323 debugging output\n"; " Enable/Disable H.323 debugging output\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return NULL; return NULL;
} }
if (a->argc < 3 || a->argc > 4) if (a->argc != e->args)
return CLI_SHOWUSAGE; 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; 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"); ast_cli(a->fd, "H.323 Debugging %s\n", h323debug ? "Enabled" : "Disabled");
return CLI_SUCCESS; return CLI_SUCCESS;
} }

@ -736,9 +736,9 @@ static char *handle_cli_misdn_set_debug(struct ast_cli_entry *e, int cmd, struct
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "misdn set debug"; e->command = "misdn set debug {on|off|<level>}";
e->usage = 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"; " Set the debug level of the mISDN channel.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
@ -748,7 +748,13 @@ static char *handle_cli_misdn_set_debug(struct ast_cli_entry *e, int cmd, struct
if (a->argc < 4 || a->argc > 7) if (a->argc < 4 || a->argc > 7)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
if (!strcasecmp(a->argv[3], "on")) {
level = 1;
} else if (!strcasecmp(a->argv[3], "off")) {
level = 0;
} else {
level = atoi(a->argv[3]); level = atoi(a->argv[3]);
}
switch (a->argc) { switch (a->argc) {
case 4: case 4:

@ -911,9 +911,9 @@ static char *console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "console autoanswer [on|off]"; e->command = "console {set|show} autoanswer [on|off]";
e->usage = 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" " Enables or disables autoanswer feature. If used without\n"
" argument, displays the current on/off status of autoanswer.\n" " argument, displays the current on/off status of autoanswer.\n"
" The default value of autoanswer is in 'oss.conf'.\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) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "console active"; e->command = "console {set|show} active [<device>]";
e->usage = e->usage =
"Usage: console active [device]\n" "Usage: console active [device]\n"
" If used without a parameter, displays which device is the current\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; return NULL;
} }
if (a->argc == 2) if (a->argc == 3)
ast_cli(a->fd, "active console is [%s]\n", oss_active); ast_cli(a->fd, "active console is [%s]\n", oss_active);
else if (a->argc != 3) else if (a->argc != 4)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
else { else {
struct chan_oss_pvt *o; 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) for (o = oss_default.next; o; o = o->next)
ast_cli(a->fd, "device [%s] exists\n", o->name); ast_cli(a->fd, "device [%s] exists\n", o->name);
return CLI_SUCCESS; return CLI_SUCCESS;
} }
o = find_desc(a->argv[2]); o = find_desc(a->argv[3]);
if (o == NULL) 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 else
oss_active = o->name; oss_active = o->name;
} }

@ -4682,9 +4682,9 @@ static char *unistim_info(struct ast_cli_entry *e, int cmd, struct ast_cli_args
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "unistim info"; e->command = "unistim show info";
e->usage = e->usage =
"Usage: unistim info\n" "Usage: unistim show info\n"
" Dump internal structures.\n"; " Dump internal structures.\n";
return NULL; return NULL;
@ -4751,27 +4751,27 @@ static char *unistim_sp(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "unistim sp"; e->command = "unistim send packet";
e->usage = e->usage =
"Usage: unistim sp USTM/line@name hexa\n" "Usage: unistim send packet USTM/line@name hexa\n"
" unistim sp USTM/1000@hans 19040004\n"; " unistim send packet USTM/1000@hans 19040004\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return NULL; /* no completion */ return NULL; /* no completion */
} }
if (a->argc < 4) if (a->argc < 5)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
if (strlen(a->argv[2]) < 9) if (strlen(a->argv[3]) < 9)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
len = strlen(a->argv[3]); len = strlen(a->argv[4]);
if (len % 2) if (len % 2)
return CLI_SHOWUSAGE; 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); sub = find_subchannel_by_name(tmp);
if (!sub) { if (!sub) {
ast_cli(a->fd, "Can't find '%s'\n", tmp); 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); ast_cli(a->fd, "'%s' is not connected\n", tmp);
return CLI_SUCCESS; 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++) { for (i = 0; i < len; i++) {
c = a->argv[3][i]; c = a->argv[4][i];
if (c >= 'a') if (c >= 'a')
c -= 'a' - 10; c -= 'a' - 10;
else else
c -= '0'; c -= '0';
i++; i++;
cc = a->argv[3][i]; cc = a->argv[4][i];
if (cc >= 'a') if (cc >= 'a')
cc -= 'a' - 10; cc -= 'a' - 10;
else else

@ -862,9 +862,9 @@ static char *handle_astobj2_stats(struct ast_cli_entry *e, int cmd, struct ast_c
{ {
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "astobj2 stats"; e->command = "astobj2 show stats";
e->usage = "Usage: astobj2 stats\n" e->usage = "Usage: astobj2 show stats\n"
" Show astobj2 stats\n"; " Show astobj2 show stats\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return NULL; return NULL;

@ -756,18 +756,18 @@ static char *handle_softhangup(struct ast_cli_entry *e, int cmd, struct ast_cli_
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "soft hangup"; e->command = "channel request hangup";
e->usage = 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" " Request that a channel be hung up. The hangup takes effect\n"
" the next time the driver reads or writes from the channel\n"; " the next time the driver reads or writes from the channel\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return ast_complete_channels(a->line, a->word, a->pos, a->n, 2); return ast_complete_channels(a->line, a->word, a->pos, a->n, 2);
} }
if (a->argc != 3) if (a->argc != 4)
return CLI_SHOWUSAGE; 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) { if (c) {
ast_cli(a->fd, "Requested Hangup on channel '%s'\n", c->name); ast_cli(a->fd, "Requested Hangup on channel '%s'\n", c->name);
ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);

@ -519,18 +519,18 @@ static char *handle_mandebug(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
{ {
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "manager debug [on|off]"; e->command = "manager set debug [on|off]";
e->usage = "Usage: manager debug [on|off]\n Show, enable, disable debugging of the manager code.\n"; e->usage = "Usage: manager set debug [on|off]\n Show, enable, disable debugging of the manager code.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return NULL; return NULL;
} }
if (a->argc == 2) if (a->argc == 3)
ast_cli(a->fd, "manager debug is %s\n", manager_debug? "on" : "off"); ast_cli(a->fd, "manager debug is %s\n", manager_debug? "on" : "off");
else if (a->argc == 3) { else if (a->argc == 4) {
if (!strcasecmp(a->argv[2], "on")) if (!strcasecmp(a->argv[3], "on"))
manager_debug = 1; manager_debug = 1;
else if (!strcasecmp(a->argv[2], "off")) else if (!strcasecmp(a->argv[3], "off"))
manager_debug = 0; manager_debug = 0;
else else
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;

@ -196,9 +196,9 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "core taskprocessor ping"; e->command = "core ping taskprocessor";
e->usage = 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"; " Displays the time required for a task to be processed\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:

@ -78,9 +78,9 @@ static char *ais_clm_show_members(struct ast_cli_entry *e, int cmd, struct ast_c
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "ais clm show members"; e->command = "ais show clm members";
e->usage = 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"; " List members of the cluster using the CLM (Cluster Membership) service.\n";
return NULL; return NULL;

@ -271,9 +271,9 @@ static char *ais_evt_show_event_channels(struct ast_cli_entry *e, int cmd, struc
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "ais evt show event channels"; e->command = "ais show evt event channels";
e->usage = 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"; " List configured event channels for the (EVT) Eventing service.\n";
return NULL; return NULL;

@ -86,7 +86,7 @@ static char *descrip =
"AGISIGHUP channel variable to \"no\" before executing the AGI application.\n" "AGISIGHUP channel variable to \"no\" before executing the AGI application.\n"
" Using 'EAGI' provides enhanced AGI, with incoming audio available out of band\n" " Using 'EAGI' provides enhanced AGI, with incoming audio available out of band\n"
"on file descriptor 3.\n\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" " This application sets the following channel variable upon completion:\n"
" AGISTATUS The status of the attempt to the run the AGI script\n" " AGISTATUS The status of the attempt to the run the AGI script\n"
" text string, one of SUCCESS | FAILURE | NOTFOUND | HANGUP\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) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "agi show"; e->command = "agi show commands [topic]";
e->usage = e->usage =
"Usage: agi show [topic]\n" "Usage: agi show commands [topic]\n"
" When called with a topic as an argument, displays usage\n" " When called with a topic as an argument, displays usage\n"
" information on the given command. If called without a\n" " information on the given command. If called without a\n"
" topic, it provides a list of AGI commands.\n"; " topic, it provides a list of AGI commands.\n";

@ -122,26 +122,26 @@ static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
char *res; char *res;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "originate"; e->command = "channel originate";
e->usage = e->usage =
" There are two ways to use this command. A call can be originated between a\n" " 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" "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" "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" "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" " 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" "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" "arguments to the application include spaces, all of the arguments to the\n"
"application need to be placed in quotation marks.\n\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" " 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" "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"; "used. If no extension is given, the 's' extension will be used.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
if (a->pos != 2) if (a->pos != 3)
return NULL; return NULL;
/* ugly, can be removed when CLI entries have ast_module pointers */ /* 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; 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; return CLI_SHOWUSAGE;
/* ugly, can be removed when CLI entries have ast_module pointers */ /* ugly, can be removed when CLI entries have ast_module pointers */
ast_module_ref(ast_module_info->self); ast_module_ref(ast_module_info->self);
if (!strcasecmp("application", a->argv[2])) { if (!strcasecmp("application", a->argv[3])) {
res = orig_app(a->fd, a->argv[1], a->argv[3], a->argv[4]); res = orig_app(a->fd, a->argv[2], a->argv[4], a->argv[5]);
} else if (!strcasecmp("extension", a->argv[2])) { } else if (!strcasecmp("extension", a->argv[3])) {
res = orig_exten(a->fd, a->argv[1], a->argv[3]); res = orig_exten(a->fd, a->argv[2], a->argv[4]);
} else } else {
ast_log(LOG_WARNING, "else");
res = CLI_SHOWUSAGE; res = CLI_SHOWUSAGE;
}
ast_module_unref(ast_module_info->self); ast_module_unref(ast_module_info->self);

@ -1529,9 +1529,9 @@ static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_c
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "realtime ldap status"; e->command = "realtime show ldap status";
e->usage = e->usage =
"Usage: realtime ldap status\n" "Usage: realtime show ldap status\n"
" Shows connection information for the LDAP RealTime driver\n"; " Shows connection information for the LDAP RealTime driver\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:

@ -1315,13 +1315,13 @@ static char *handle_cli_realtime_pgsql_cache(struct ast_cli_entry *e, int cmd, s
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "realtime pgsql cache"; e->command = "realtime show pgsql cache";
e->usage = e->usage =
"Usage: realtime pgsql cache [<table>]\n" "Usage: realtime show pgsql cache [<table>]\n"
" Shows table cache for the PostgreSQL RealTime driver\n"; " Shows table cache for the PostgreSQL RealTime driver\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
if (a->argc != 3) { if (a->argc != 4) {
return NULL; return NULL;
} }
l = strlen(a->word); 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; return ret;
} }
if (a->argc == 3) { if (a->argc == 4) {
/* List of tables */ /* List of tables */
AST_LIST_LOCK(&psql_tables); AST_LIST_LOCK(&psql_tables);
AST_LIST_TRAVERSE(&psql_tables, cur, list) { AST_LIST_TRAVERSE(&psql_tables, cur, list) {
ast_cli(a->fd, "%s\n", cur->name); ast_cli(a->fd, "%s\n", cur->name);
} }
AST_LIST_UNLOCK(&psql_tables); AST_LIST_UNLOCK(&psql_tables);
} else if (a->argc == 4) { } else if (a->argc == 5) {
/* List of columns */ /* List of columns */
if ((cur = find_table(a->argv[3]))) { if ((cur = find_table(a->argv[4]))) {
struct columns *col; 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_cli(a->fd, "%-20.20s %-20.20s %-3.3s %-8.8s\n", "Name", "Type", "Len", "Nullable");
AST_LIST_TRAVERSE(&cur->columns, col, list) { 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_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); ast_mutex_unlock(&cur->lock);
} else { } 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; return 0;
@ -1368,16 +1368,16 @@ static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd,
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "realtime pgsql status"; e->command = "realtime show pgsql status";
e->usage = e->usage =
"Usage: realtime pgsql status\n" "Usage: realtime show pgsql status\n"
" Shows connection information for the PostgreSQL RealTime driver\n"; " Shows connection information for the PostgreSQL RealTime driver\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return NULL; return NULL;
} }
if (a->argc != 3) if (a->argc != 4)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) { if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {

@ -44,22 +44,23 @@ static struct limits {
int resource; int resource;
char limit[3]; char limit[3];
char desc[40]; char desc[40];
char clicmd[15];
} limits[] = { } limits[] = {
{ RLIMIT_CPU, "-t", "cpu time" }, { RLIMIT_CPU, "-t", "cpu time", "time" },
{ RLIMIT_FSIZE, "-f", "file size" }, { RLIMIT_FSIZE, "-f", "file size" , "file" },
{ RLIMIT_DATA, "-d", "program data segment" }, { RLIMIT_DATA, "-d", "program data segment", "data" },
{ RLIMIT_STACK, "-s", "program stack size" }, { RLIMIT_STACK, "-s", "program stack size", "stack" },
{ RLIMIT_CORE, "-c", "core file size" }, { RLIMIT_CORE, "-c", "core file size", "core" },
#ifdef RLIMIT_RSS #ifdef RLIMIT_RSS
{ RLIMIT_RSS, "-m", "resident memory" }, { RLIMIT_RSS, "-m", "resident memory", "memory" },
{ RLIMIT_MEMLOCK, "-l", "amount of memory locked into RAM" }, { RLIMIT_MEMLOCK, "-l", "amount of memory locked into RAM", "locked" },
#endif #endif
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
{ RLIMIT_NPROC, "-u", "number of processes" }, { RLIMIT_NPROC, "-u", "number of processes", "processes" },
#endif #endif
{ RLIMIT_NOFILE, "-n", "number of file descriptors" }, { RLIMIT_NOFILE, "-n", "number of file descriptors", "descriptors" },
#ifdef VMEM_DEF #ifdef VMEM_DEF
{ VMEM_DEF, "-v", "virtual memory" }, { VMEM_DEF, "-v", "virtual memory", "virtual" },
#endif #endif
}; };
@ -67,7 +68,7 @@ static int str2limit(const char *string)
{ {
size_t i; size_t i;
for (i = 0; i < ARRAY_LEN(limits); 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 limits[i].resource;
} }
return -1; return -1;
@ -77,7 +78,7 @@ static const char *str2desc(const char *string)
{ {
size_t i; size_t i;
for (i = 0; i < ARRAY_LEN(limits); 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 limits[i].desc;
} }
return "<unknown>"; return "<unknown>";
@ -91,9 +92,9 @@ static char *complete_ulimit(struct ast_cli_args *a)
if (a->pos > 1) if (a->pos > 1)
return NULL; return NULL;
for (i = 0; i < ARRAY_LEN(limits); i++) { 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) if (++which > a->n)
return ast_strdup(limits[i].limit); return ast_strdup(limits[i].clicmd);
} }
} }
return NULL; return NULL;
@ -108,41 +109,41 @@ static char *handle_cli_ulimit(struct ast_cli_entry *e, int cmd, struct ast_cli_
case CLI_INIT: case CLI_INIT:
e->command = "ulimit"; e->command = "ulimit";
e->usage = e->usage =
"Usage: ulimit {-d|" "Usage: ulimit {data|"
#ifdef RLIMIT_RSS #ifdef RLIMIT_RSS
"-l|" "limit|"
#endif #endif
"-f|" "file|"
#ifdef RLIMIT_RSS #ifdef RLIMIT_RSS
"-m|" "memory|"
#endif #endif
"-s|-t|" "stack|time|"
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
"-u|" "processes|"
#endif #endif
#ifdef VMEM_DEF #ifdef VMEM_DEF
"-v|" "virtual|"
#endif #endif
"-c|-n} [<num>]\n" "core|descriptors} [<num>]\n"
" Shows or sets the corresponding resource limit.\n" " Shows or sets the corresponding resource limit.\n"
" -d Process data segment [readonly]\n" " data Process data segment [readonly]\n"
#ifdef RLIMIT_RSS #ifdef RLIMIT_RSS
" -l Memory lock size [readonly]\n" " lock Memory lock size [readonly]\n"
#endif #endif
" -f File size\n" " file File size\n"
#ifdef RLIMIT_RSS #ifdef RLIMIT_RSS
" -m Process resident memory [readonly]\n" " memory Process resident memory [readonly]\n"
#endif #endif
" -s Process stack size [readonly]\n" " stack Process stack size [readonly]\n"
" -t CPU usage [readonly]\n" " time CPU usage [readonly]\n"
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
" -u Child processes\n" " processes Child processes\n"
#endif #endif
#ifdef VMEM_DEF #ifdef VMEM_DEF
" -v Process virtual memory [readonly]\n" " virtual Process virtual memory [readonly]\n"
#endif #endif
" -c Core dump file size\n" " core Core dump file size\n"
" -n Number of file descriptors\n"; " descriptors Number of file descriptors\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
return complete_ulimit(a); 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; return CLI_SHOWUSAGE;
if (a->argc == 1) { if (a->argc == 1) {
char arg2[3]; char arg2[15];
char *newargv[2] = { "ulimit", arg2 }; char *newargv[2] = { "ulimit", arg2 };
for (resource = 0; resource < ARRAY_LEN(limits); resource++) { for (resource = 0; resource < ARRAY_LEN(limits); resource++) {
struct ast_cli_args newArgs = { .argv = newargv, .argc = 2 }; 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); handle_cli_ulimit(e, CLI_HANDLER, &newArgs);
} }
return CLI_SUCCESS; return CLI_SUCCESS;

Loading…
Cancel
Save