mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-24 06:53:41 +00:00
More formatting cleanups.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3337 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -216,7 +216,6 @@ static void ast_network_puts(const char *string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* write the string to the console, and all attached
|
* write the string to the console, and all attached
|
||||||
* console clients
|
* console clients
|
||||||
@@ -1596,7 +1595,7 @@ int main(int argc, char *argv[])
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
/* Test recursive mutex locking. */
|
/* Test recursive mutex locking. */
|
||||||
if(test_for_thread_safety())
|
if (test_for_thread_safety())
|
||||||
ast_verbose("Warning! Asterisk is not thread safe.\n");
|
ast_verbose("Warning! Asterisk is not thread safe.\n");
|
||||||
|
|
||||||
if (option_console && !option_verbose)
|
if (option_console && !option_verbose)
|
||||||
|
14
logger.c
14
logger.c
@@ -41,6 +41,7 @@ static int syslog_level_map[] = {
|
|||||||
LOG_ERR,
|
LOG_ERR,
|
||||||
LOG_DEBUG
|
LOG_DEBUG
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SYSLOG_NLEVELS 6
|
#define SYSLOG_NLEVELS 6
|
||||||
|
|
||||||
#include <asterisk/logger.h>
|
#include <asterisk/logger.h>
|
||||||
@@ -389,7 +390,8 @@ static struct ast_cli_entry rotate_logger_cli =
|
|||||||
handle_logger_rotate, "Rotates and reopens the log files",
|
handle_logger_rotate, "Rotates and reopens the log files",
|
||||||
logger_rotate_help };
|
logger_rotate_help };
|
||||||
|
|
||||||
static int handle_SIGXFSZ(int sig) {
|
static int handle_SIGXFSZ(int sig)
|
||||||
|
{
|
||||||
/* Indicate need to reload */
|
/* Indicate need to reload */
|
||||||
pending_logger_reload = 1;
|
pending_logger_reload = 1;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -446,15 +448,16 @@ void close_logger(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *fmt, va_list args) {
|
static void ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *fmt, va_list args)
|
||||||
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
|
|
||||||
if(level >= SYSLOG_NLEVELS) {
|
if (level >= SYSLOG_NLEVELS) {
|
||||||
/* we are locked here, so cannot ast_log() */
|
/* we are locked here, so cannot ast_log() */
|
||||||
fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
|
fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(level == __LOG_VERBOSE) {
|
if (level == __LOG_VERBOSE) {
|
||||||
snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self());
|
snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self());
|
||||||
level = __LOG_DEBUG;
|
level = __LOG_DEBUG;
|
||||||
} else {
|
} else {
|
||||||
@@ -489,7 +492,6 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||||||
localtime_r(&t, &tm);
|
localtime_r(&t, &tm);
|
||||||
strftime(date, sizeof(date), dateformat, &tm);
|
strftime(date, sizeof(date), dateformat, &tm);
|
||||||
|
|
||||||
|
|
||||||
if (level == __LOG_EVENT) {
|
if (level == __LOG_EVENT) {
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
@@ -513,7 +515,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||||||
char linestr[128];
|
char linestr[128];
|
||||||
char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
|
char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
|
||||||
|
|
||||||
if(level != __LOG_VERBOSE) {
|
if (level != __LOG_VERBOSE) {
|
||||||
sprintf(linestr, "%d", line);
|
sprintf(linestr, "%d", line);
|
||||||
snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ",
|
snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ",
|
||||||
date,
|
date,
|
||||||
|
@@ -174,48 +174,43 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
|
|||||||
{
|
{
|
||||||
char *execute;
|
char *execute;
|
||||||
int soxmix =0;
|
int soxmix =0;
|
||||||
if(need_lock) {
|
|
||||||
if(ast_mutex_lock(&chan->lock)) {
|
if (need_lock) {
|
||||||
|
if (ast_mutex_lock(&chan->lock)) {
|
||||||
ast_log(LOG_WARNING, "Unable to lock channel\n");
|
ast_log(LOG_WARNING, "Unable to lock channel\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chan->monitor) {
|
if (chan->monitor) {
|
||||||
char filename[ FILENAME_MAX ];
|
char filename[ FILENAME_MAX ];
|
||||||
|
|
||||||
if(chan->monitor->read_stream) {
|
if (chan->monitor->read_stream) {
|
||||||
ast_closestream( chan->monitor->read_stream );
|
ast_closestream( chan->monitor->read_stream );
|
||||||
}
|
}
|
||||||
if(chan->monitor->write_stream) {
|
if (chan->monitor->write_stream) {
|
||||||
ast_closestream( chan->monitor->write_stream );
|
ast_closestream( chan->monitor->write_stream );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chan->monitor->filename_changed&&strlen(chan->monitor->filename_base)) {
|
if (chan->monitor->filename_changed&&strlen(chan->monitor->filename_base)) {
|
||||||
if( ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0 ) {
|
if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0 ) {
|
||||||
snprintf( filename, FILENAME_MAX, "%s-in",
|
snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base);
|
||||||
chan->monitor->filename_base );
|
if (ast_fileexists( filename, NULL, NULL ) > 0) {
|
||||||
if(ast_fileexists( filename, NULL, NULL ) > 0) {
|
|
||||||
ast_filedelete( filename, NULL );
|
ast_filedelete( filename, NULL );
|
||||||
}
|
}
|
||||||
ast_filerename( chan->monitor->read_filename, filename,
|
ast_filerename(chan->monitor->read_filename, filename, chan->monitor->format );
|
||||||
chan->monitor->format );
|
|
||||||
} else {
|
} else {
|
||||||
ast_log( LOG_WARNING, "File %s not found\n",
|
ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->read_filename );
|
||||||
chan->monitor->read_filename );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
|
if (ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
|
||||||
snprintf( filename, FILENAME_MAX, "%s-out",
|
snprintf(filename, FILENAME_MAX, "%s-out", chan->monitor->filename_base );
|
||||||
chan->monitor->filename_base );
|
if (ast_fileexists(filename, NULL, NULL) > 0 ) {
|
||||||
if( ast_fileexists( filename, NULL, NULL ) > 0 ) {
|
ast_filedelete(filename, NULL);
|
||||||
ast_filedelete( filename, NULL );
|
|
||||||
}
|
}
|
||||||
ast_filerename( chan->monitor->write_filename, filename,
|
ast_filerename(chan->monitor->write_filename, filename, chan->monitor->format );
|
||||||
chan->monitor->format );
|
|
||||||
} else {
|
} else {
|
||||||
ast_log( LOG_WARNING, "File %s not found\n",
|
ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->write_filename );
|
||||||
chan->monitor->write_filename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,37 +238,33 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
|
|||||||
ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
|
ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
free( chan->monitor->format );
|
free(chan->monitor->format);
|
||||||
free( chan->monitor );
|
free(chan->monitor);
|
||||||
chan->monitor = NULL;
|
chan->monitor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( need_lock ) {
|
if (need_lock)
|
||||||
ast_mutex_unlock(&chan->lock);
|
ast_mutex_unlock(&chan->lock);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Change monitoring filename of a channel */
|
/* Change monitoring filename of a channel */
|
||||||
int ast_monitor_change_fname( struct ast_channel *chan,
|
int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, int need_lock)
|
||||||
const char *fname_base, int need_lock )
|
|
||||||
{
|
{
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
if( (!fname_base) || (!strlen(fname_base)) ) {
|
if ((!fname_base) || (!strlen(fname_base))) {
|
||||||
ast_log( LOG_WARNING,
|
ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to null", chan->name );
|
||||||
"Cannot change monitor filename of channel %s to null",
|
|
||||||
chan->name );
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( need_lock ) {
|
if (need_lock) {
|
||||||
if (ast_mutex_lock(&chan->lock)) {
|
if (ast_mutex_lock(&chan->lock)) {
|
||||||
ast_log(LOG_WARNING, "Unable to lock channel\n");
|
ast_log(LOG_WARNING, "Unable to lock channel\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( chan->monitor ) {
|
if (chan->monitor) {
|
||||||
int directory = strchr(fname_base, '/') ? 1 : 0;
|
int directory = strchr(fname_base, '/') ? 1 : 0;
|
||||||
/* try creating the directory just in case it doesn't exist */
|
/* try creating the directory just in case it doesn't exist */
|
||||||
if (directory) {
|
if (directory) {
|
||||||
@@ -283,18 +274,14 @@ int ast_monitor_change_fname( struct ast_channel *chan,
|
|||||||
system(tmp);
|
system(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf( chan->monitor->filename_base, FILENAME_MAX, "%s/%s",
|
snprintf(chan->monitor->filename_base, FILENAME_MAX, "%s/%s", directory ? "" : AST_MONITOR_DIR, fname_base );
|
||||||
directory ? "" : AST_MONITOR_DIR, fname_base );
|
|
||||||
} else {
|
} else {
|
||||||
ast_log( LOG_WARNING,
|
ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to %s, monitoring not started", chan->name, fname_base );
|
||||||
"Cannot change monitor filename of channel %s to %s, monitoring not started",
|
|
||||||
chan->name, fname_base );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( need_lock ) {
|
if (need_lock)
|
||||||
ast_mutex_unlock(&chan->lock);
|
ast_mutex_unlock(&chan->lock);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,11 +295,11 @@ static int start_monitor_exec(struct ast_channel *chan, void *data)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
/* Parse arguments. */
|
/* Parse arguments. */
|
||||||
if( data && strlen((char*)data) ) {
|
if (data && strlen((char*)data)) {
|
||||||
arg = strdup( (char*)data );
|
arg = strdup((char*)data);
|
||||||
format = arg;
|
format = arg;
|
||||||
fname_base = strchr( arg, '|' );
|
fname_base = strchr(arg, '|');
|
||||||
if( fname_base ) {
|
if (fname_base) {
|
||||||
*fname_base = 0;
|
*fname_base = 0;
|
||||||
fname_base++;
|
fname_base++;
|
||||||
if ((options = strchr(fname_base, '|'))) {
|
if ((options = strchr(fname_base, '|'))) {
|
||||||
@@ -325,27 +312,25 @@ static int start_monitor_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ast_monitor_start( chan, format, fname_base, 1 );
|
res = ast_monitor_start(chan, format, fname_base, 1);
|
||||||
if( res < 0 ) {
|
if (res < 0)
|
||||||
res = ast_monitor_change_fname( chan, fname_base, 1 );
|
res = ast_monitor_change_fname( chan, fname_base, 1 );
|
||||||
}
|
|
||||||
ast_monitor_setjoinfiles(chan, joinfiles);
|
ast_monitor_setjoinfiles(chan, joinfiles);
|
||||||
|
|
||||||
if( arg ) {
|
if (arg)
|
||||||
free( arg );
|
free( arg );
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stop_monitor_exec(struct ast_channel *chan, void *data)
|
static int stop_monitor_exec(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
return ast_monitor_stop( chan, 1 );
|
return ast_monitor_stop(chan, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int change_monitor_exec(struct ast_channel *chan, void *data)
|
static int change_monitor_exec(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
return ast_monitor_change_fname( chan, (const char*)data, 1 );
|
return ast_monitor_change_fname(chan, (const char*)data, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int start_monitor_action(struct mansession *s, struct message *m)
|
static int start_monitor_action(struct mansession *s, struct message *m)
|
||||||
@@ -357,12 +342,12 @@ static int start_monitor_action(struct mansession *s, struct message *m)
|
|||||||
char *mix = astman_get_header(m, "Mix");
|
char *mix = astman_get_header(m, "Mix");
|
||||||
char *d;
|
char *d;
|
||||||
|
|
||||||
if((!name)||(!strlen(name))) {
|
if ((!name)||(!strlen(name))) {
|
||||||
astman_send_error(s, m, "No channel specified");
|
astman_send_error(s, m, "No channel specified");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
c = ast_channel_walk_locked(NULL);
|
c = ast_channel_walk_locked(NULL);
|
||||||
while(c) {
|
while (c) {
|
||||||
if (!strcasecmp(c->name, name)) {
|
if (!strcasecmp(c->name, name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -374,7 +359,7 @@ static int start_monitor_action(struct mansession *s, struct message *m)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (!fname) || (!strlen(fname)) ) {
|
if ((!fname) || (!strlen(fname))) {
|
||||||
// No filename base specified, default to channel name as per CLI
|
// No filename base specified, default to channel name as per CLI
|
||||||
fname = malloc (FILENAME_MAX);
|
fname = malloc (FILENAME_MAX);
|
||||||
memset( fname, 0, FILENAME_MAX);
|
memset( fname, 0, FILENAME_MAX);
|
||||||
@@ -383,15 +368,15 @@ static int start_monitor_action(struct mansession *s, struct message *m)
|
|||||||
if( (d=strchr( fname, '/')) ) *d='-';
|
if( (d=strchr( fname, '/')) ) *d='-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ast_monitor_start( c, format, fname, 1 ) ) {
|
if (ast_monitor_start( c, format, fname, 1)) {
|
||||||
if( ast_monitor_change_fname( c, fname, 1 ) ) {
|
if (ast_monitor_change_fname(c, fname, 1)) {
|
||||||
astman_send_error(s, m, "Could not start monitoring channel");
|
astman_send_error(s, m, "Could not start monitoring channel");
|
||||||
ast_mutex_unlock(&c->lock);
|
ast_mutex_unlock(&c->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ast_true(mix)) {
|
if (ast_true(mix)) {
|
||||||
ast_monitor_setjoinfiles( c, 1);
|
ast_monitor_setjoinfiles( c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +390,7 @@ static int stop_monitor_action(struct mansession *s, struct message *m)
|
|||||||
struct ast_channel *c = NULL;
|
struct ast_channel *c = NULL;
|
||||||
char *name = astman_get_header(m, "Channel");
|
char *name = astman_get_header(m, "Channel");
|
||||||
int res;
|
int res;
|
||||||
if((!name)||(!strlen(name))) {
|
if ((!name)||(!strlen(name))) {
|
||||||
astman_send_error(s, m, "No channel specified");
|
astman_send_error(s, m, "No channel specified");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -421,9 +406,9 @@ static int stop_monitor_action(struct mansession *s, struct message *m)
|
|||||||
astman_send_error(s, m, "No such channel");
|
astman_send_error(s, m, "No such channel");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
res = ast_monitor_stop( c, 1 );
|
res = ast_monitor_stop(c, 1);
|
||||||
ast_mutex_unlock(&c->lock);
|
ast_mutex_unlock(&c->lock);
|
||||||
if( res ) {
|
if (res) {
|
||||||
astman_send_error(s, m, "Could not stop monitoring channel");
|
astman_send_error(s, m, "Could not stop monitoring channel");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -436,7 +421,7 @@ static int change_monitor_action(struct mansession *s, struct message *m)
|
|||||||
struct ast_channel *c = NULL;
|
struct ast_channel *c = NULL;
|
||||||
char *name = astman_get_header(m, "Channel");
|
char *name = astman_get_header(m, "Channel");
|
||||||
char *fname = astman_get_header(m, "File");
|
char *fname = astman_get_header(m, "File");
|
||||||
if((!name) || (!strlen(name))) {
|
if ((!name) || (!strlen(name))) {
|
||||||
astman_send_error(s, m, "No channel specified");
|
astman_send_error(s, m, "No channel specified");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -456,7 +441,7 @@ static int change_monitor_action(struct mansession *s, struct message *m)
|
|||||||
astman_send_error(s, m, "No such channel");
|
astman_send_error(s, m, "No such channel");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if( ast_monitor_change_fname( c, fname, 1 ) ) {
|
if (ast_monitor_change_fname(c, fname, 1)) {
|
||||||
astman_send_error(s, m, "Could not change monitored filename of channel");
|
astman_send_error(s, m, "Could not change monitored filename of channel");
|
||||||
ast_mutex_unlock(&c->lock);
|
ast_mutex_unlock(&c->lock);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user