mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 00:04:53 +00:00
partly convert to new style set-verbose, with completion fixes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47619 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
82
main/cli.c
82
main/cli.c
@@ -105,12 +105,6 @@ static char reload_help[] =
|
|||||||
" Reloads configuration files for all listed modules which support\n"
|
" Reloads configuration files for all listed modules which support\n"
|
||||||
" reloading, or for all supported modules if none are listed.\n";
|
" reloading, or for all supported modules if none are listed.\n";
|
||||||
|
|
||||||
static char verbose_help[] =
|
|
||||||
"Usage: core set verbose <level>\n"
|
|
||||||
" Sets level of verbose messages to be displayed. 0 means\n"
|
|
||||||
" no messages should be displayed. Equivalent to -v[v[v...]]\n"
|
|
||||||
" on startup\n";
|
|
||||||
|
|
||||||
static char logger_mute_help[] =
|
static char logger_mute_help[] =
|
||||||
"Usage: logger mute\n"
|
"Usage: logger mute\n"
|
||||||
" Disables logging output to the current console, making it possible to\n"
|
" Disables logging output to the current console, making it possible to\n"
|
||||||
@@ -148,13 +142,14 @@ static int handle_load_deprecated(int fd, int argc, char *argv[])
|
|||||||
static int handle_reload(int fd, int argc, char *argv[])
|
static int handle_reload(int fd, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
/* "module reload [mod_1 ... mod_N]" */
|
/* "module reload [mod_1 ... mod_N]" */
|
||||||
int x;
|
struct ast_cli_entry *e = (struct ast_cli_entry *)argv[-1];
|
||||||
int res;
|
|
||||||
if (argc < 2)
|
if (argc == e->args)
|
||||||
return RESULT_SHOWUSAGE;
|
ast_module_reload(NULL);
|
||||||
if (argc > 2) {
|
else {
|
||||||
for (x = 2; x < argc; x++) {
|
int x;
|
||||||
res = ast_module_reload(argv[x]);
|
for (x = e->args; x < argc; x++) {
|
||||||
|
int res = ast_module_reload(argv[x]);
|
||||||
switch(res) {
|
switch(res) {
|
||||||
case 0:
|
case 0:
|
||||||
ast_cli(fd, "No such module '%s'\n", argv[x]);
|
ast_cli(fd, "No such module '%s'\n", argv[x]);
|
||||||
@@ -164,8 +159,7 @@ static int handle_reload(int fd, int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
ast_module_reload(NULL);
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,29 +170,53 @@ static int handle_reload_deprecated(int fd, int argc, char *argv[])
|
|||||||
|
|
||||||
static int handle_verbose(int fd, int argc, char *argv[])
|
static int handle_verbose(int fd, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
/* "core set verbose [atleast] <n>" */
|
||||||
int oldval = option_verbose;
|
int oldval = option_verbose;
|
||||||
int newlevel;
|
int newlevel;
|
||||||
int atleast = 0;
|
int atleast = 0;
|
||||||
|
struct ast_cli_entry *e = (struct ast_cli_entry *)argv[-1];
|
||||||
|
static char *choices[] = { "off", "atleast", NULL };
|
||||||
|
struct ast_cli_args *a;
|
||||||
|
|
||||||
if ((argc < 4) || (argc > 5))
|
switch (argc) {
|
||||||
|
case CLI_CMD_STRING:
|
||||||
|
return (int)"core set verbose";
|
||||||
|
|
||||||
|
case CLI_USAGE:
|
||||||
|
return (int)
|
||||||
|
"Usage: core set verbose [atleast] <level>\n"
|
||||||
|
" core set verbose off\n"
|
||||||
|
" Sets level of verbose messages to be displayed. 0 or off means\n"
|
||||||
|
" no messages should be displayed. Equivalent to -v[v[v...]]\n"
|
||||||
|
" on startup\n";
|
||||||
|
|
||||||
|
case CLI_GENERATE:
|
||||||
|
a = (struct ast_cli_args *)argv[0];
|
||||||
|
if (a->pos > e->args)
|
||||||
|
return NULL;
|
||||||
|
return (int)ast_cli_complete(a->word, choices, a->n);
|
||||||
|
}
|
||||||
|
/* all the above return, so we proceed with the handler.
|
||||||
|
* we are guaranteed to be called with argc >= e->args;
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (argc < e->args + 1)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
|
|
||||||
if (!strcasecmp(argv[3], "atleast"))
|
if (argc == e->args + 1 && !strcasecmp(argv[e->args], "off")) {
|
||||||
|
newlevel = 0;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (!strcasecmp(argv[e->args], "atleast"))
|
||||||
atleast = 1;
|
atleast = 1;
|
||||||
|
if (argc != e->args + atleast + 1)
|
||||||
|
return RESULT_SHOWUSAGE;
|
||||||
|
if (sscanf(argv[e->args + atleast], "%d", &newlevel) != 1)
|
||||||
|
return RESULT_SHOWUSAGE;
|
||||||
|
|
||||||
if (!atleast) {
|
done:
|
||||||
if (argc > 4)
|
if (!atleast || newlevel > option_verbose)
|
||||||
return RESULT_SHOWUSAGE;
|
option_verbose = newlevel;
|
||||||
|
|
||||||
option_verbose = atoi(argv[3]);
|
|
||||||
} else {
|
|
||||||
if (argc < 5)
|
|
||||||
return RESULT_SHOWUSAGE;
|
|
||||||
|
|
||||||
newlevel = atoi(argv[4]);
|
|
||||||
if (newlevel > option_verbose)
|
|
||||||
option_verbose = newlevel;
|
|
||||||
}
|
|
||||||
if (oldval > 0 && option_verbose == 0)
|
if (oldval > 0 && option_verbose == 0)
|
||||||
ast_cli(fd, "Verbosity is now OFF\n");
|
ast_cli(fd, "Verbosity is now OFF\n");
|
||||||
else if (option_verbose > 0) {
|
else if (option_verbose > 0) {
|
||||||
@@ -1112,9 +1130,7 @@ static struct ast_cli_entry cli_cli[] = {
|
|||||||
|
|
||||||
NEW_CLI(handle_set_debug, "Set level of debug chattiness"),
|
NEW_CLI(handle_set_debug, "Set level of debug chattiness"),
|
||||||
|
|
||||||
{ { "core", "set", "verbose", NULL },
|
NEW_CLI(handle_verbose, "Set level of verboseness"),
|
||||||
handle_verbose, "Set level of verboseness",
|
|
||||||
verbose_help },
|
|
||||||
|
|
||||||
{ { "group", "show", "channels", NULL },
|
{ { "group", "show", "channels", NULL },
|
||||||
group_show_channels, "Display active channels with group(s)",
|
group_show_channels, "Display active channels with group(s)",
|
||||||
|
Reference in New Issue
Block a user