aboutsummaryrefslogtreecommitdiffstats
path: root/asterisk.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-26 21:47:52 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-26 21:47:52 +0000
commitb5b239798d30a54cf0c444371c55da57ee1301ff (patch)
treeb95b4a3ff52ff6be585b68f0fbe19dfdaf3965d2 /asterisk.c
parent4189c29a159b9d7d9cefdc2906da7e97dfb41d60 (diff)
Fix various problems in the addition of the ability to mute log/verbose
output to remove consoles. The prototypes added to logger.h still need doxygen documentation, as well. - Add the new command line option to the man page - make the mute option a flag instead of an int since it is only a binary option - remove useless extern keywords for prototypes added to logger.h - rename ast_console_mute() to ast_console_toggle_mute() since that is what it actually does - actually apply the mute option to newly created remote consoles instead of only working when the CLI command is used - don't imply the NO_FORK option if the mute command line option is provided - place the new CLI command in the correct place in the list which has to be in alphabetical order - Finally, clean up a few spacing issues to conform to the coding guidelines git-svn-id: http://svn.digium.com/svn/asterisk/trunk@30630 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rw-r--r--asterisk.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/asterisk.c b/asterisk.c
index 203e18560..718e0f20c 100644
--- a/asterisk.c
+++ b/asterisk.c
@@ -160,7 +160,6 @@ struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };
int option_verbose = 0; /*!< Verbosity level */
int option_debug = 0; /*!< Debug level */
-int option_mute = 0; /*!< Mute console */
double option_maxload = 0.0; /*!< Max load avg on system */
int option_maxcalls = 0; /*!< Max number of active calls */
@@ -685,15 +684,15 @@ int ast_safe_system(const char *s)
/*!
* mute or unmute a console from logging
*/
-void ast_console_mute(int fd) {
+void ast_console_toggle_mute(int fd) {
int x;
- for (x=0;x<AST_MAX_CONNECTS; x++) {
+ for (x = 0;x < AST_MAX_CONNECTS; x++) {
if (fd == consoles[x].fd) {
if (consoles[x].mute) {
- consoles[x].mute=0;
+ consoles[x].mute = 0;
ast_cli(fd, "Console is not muted anymore.\n");
} else {
- consoles[x].mute=1;
+ consoles[x].mute = 1;
ast_cli(fd, "Console is muted.\n");
}
return;
@@ -708,9 +707,9 @@ void ast_console_mute(int fd) {
static void ast_network_puts_mutable(const char *string)
{
int x;
- for (x=0;x < AST_MAX_CONNECTS; x++) {
+ for (x = 0;x < AST_MAX_CONNECTS; x++) {
if (consoles[x].mute)
- continue;;
+ continue;
if (consoles[x].fd > -1)
fdprint(consoles[x].p[1], string);
}
@@ -866,7 +865,7 @@ static void *listener(void *unused)
flags = fcntl(consoles[x].p[1], F_GETFL);
fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK);
consoles[x].fd = s;
- consoles[x].mute = 0;
+ consoles[x].mute = ast_opt_mute;
if (ast_pthread_create(&consoles[x].t, &attr, netconsole, &consoles[x])) {
ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
close(consoles[x].p[0]);
@@ -2073,8 +2072,8 @@ static void ast_remotecontrol(char * data)
fdprint(ast_consock, tmp);
snprintf(tmp, sizeof(tmp), "set debug atleast %d", option_debug);
fdprint(ast_consock, tmp);
- if (option_mute) {
- snprintf(tmp, sizeof(tmp), "logger mute");
+ if (ast_opt_mute) {
+ snprintf(tmp, sizeof(tmp), "log and verbose output currently muted ('logger unmute' to unmute)");
fdprint(ast_consock, tmp);
}
ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid);
@@ -2396,8 +2395,7 @@ int main(int argc, char *argv[])
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
break;
case 'm':
- option_mute++;
- ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
+ ast_set_flag(&ast_options, AST_OPT_FLAG_MUTE);
break;
case 'M':
if ((sscanf(optarg, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0))