[Asterisk-cvs] asterisk asterisk.c,1.99,1.100 channel.c,1.123,1.124 logger.c,1.40,1.41
citats at lists.digium.com
citats at lists.digium.com
Tue Jun 29 00:56:27 CDT 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/home/citats/cvs/asterisk
Modified Files:
asterisk.c channel.c logger.c
Log Message:
More formatting cleanups.
Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- asterisk.c 25 Jun 2004 21:14:03 -0000 1.99
+++ asterisk.c 29 Jun 2004 04:42:19 -0000 1.100
@@ -209,29 +209,28 @@
*/
static void ast_network_puts(const char *string)
{
- int x;
- for (x=0;x<AST_MAX_CONNECTS; x++) {
- if (consoles[x].fd > -1)
- fdprint(consoles[x].p[1], string);
- }
+ int x;
+ for (x=0;x<AST_MAX_CONNECTS; x++) {
+ if (consoles[x].fd > -1)
+ fdprint(consoles[x].p[1], string);
+ }
}
-
/*
* write the string to the console, and all attached
* console clients
*/
void ast_console_puts(const char *string)
{
- fputs(string, stdout);
- fflush(stdout);
- ast_network_puts(string);
+ fputs(string, stdout);
+ fflush(stdout);
+ ast_network_puts(string);
}
static void network_verboser(const char *s, int pos, int replace, int complete)
- /* ARGUSED */
+ /* ARGUSED */
{
- ast_network_puts(s);
+ ast_network_puts(s);
}
static pthread_t lthread;
@@ -840,7 +839,7 @@
static int ast_el_read_char(EditLine *el, char *cp)
{
- int num_read=0;
+ int num_read=0;
int lastpos=0;
struct pollfd fds[2];
int res;
@@ -1065,24 +1064,24 @@
static char **ast_el_strtoarr(char *buf)
{
char **match_list = NULL, *retstr;
- size_t match_list_len;
+ size_t match_list_len;
int matches = 0;
- match_list_len = 1;
+ match_list_len = 1;
while ( (retstr = strsep(&buf, " ")) != NULL) {
if (!strcmp(retstr, AST_CLI_COMPLETE_EOF))
break;
- if (matches + 1 >= match_list_len) {
- match_list_len <<= 1;
- match_list = realloc(match_list, match_list_len * sizeof(char *));
+ if (matches + 1 >= match_list_len) {
+ match_list_len <<= 1;
+ match_list = realloc(match_list, match_list_len * sizeof(char *));
}
match_list[matches++] = strdup(retstr);
}
- if (!match_list)
- return (char **) NULL;
+ if (!match_list)
+ return (char **) NULL;
if (matches>= match_list_len)
match_list = realloc(match_list, (match_list_len + 1) * sizeof(char *));
@@ -1596,8 +1595,8 @@
fflush(stdout);
/* Test recursive mutex locking. */
- if(test_for_thread_safety())
- ast_verbose("Warning! Asterisk is not thread safe.\n");
+ if (test_for_thread_safety())
+ ast_verbose("Warning! Asterisk is not thread safe.\n");
if (option_console && !option_verbose)
ast_verbose("[ Reading Master Configuration ]");
@@ -1611,11 +1610,11 @@
if (option_console) {
- if (el_hist == NULL || el == NULL)
- ast_el_initialize();
+ if (el_hist == NULL || el == NULL)
+ ast_el_initialize();
- if (!ast_strlen_zero(filename))
- ast_el_read_history(filename);
+ if (!ast_strlen_zero(filename))
+ ast_el_read_history(filename);
}
if (ast_tryconnect()) {
@@ -1768,12 +1767,12 @@
consolehandler((char *)buf);
} else {
if (option_remote)
- ast_cli(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n");
+ ast_cli(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n");
}
}
} else {
- /* Do nothing */
+ /* Do nothing */
for(;;)
poll(NULL,0, -1);
}
Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- channel.c 24 Jun 2004 03:04:25 -0000 1.123
+++ channel.c 29 Jun 2004 04:42:19 -0000 1.124
@@ -1469,7 +1469,7 @@
int ast_senddigit(struct ast_channel *chan, char digit)
{
- return do_senddigit(chan, digit);
+ return do_senddigit(chan, digit);
}
int ast_prod(struct ast_channel *chan)
Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- logger.c 22 Jun 2004 18:48:59 -0000 1.40
+++ logger.c 29 Jun 2004 04:42:19 -0000 1.41
@@ -39,8 +39,9 @@
LOG_NOTICE,
LOG_WARNING,
LOG_ERR,
- LOG_DEBUG
+ LOG_DEBUG
};
+
#define SYSLOG_NLEVELS 6
#include <asterisk/logger.h>
@@ -58,13 +59,13 @@
} *list = NULL, *last = NULL;
struct logchannel {
- int logmask;
- int facility; /* syslog */
+ int logmask;
+ int facility; /* syslog */
int syslog; /* syslog flag */
- int console; /* console logging */
+ int console; /* console logging */
FILE *fileptr; /* logfile logging */
char filename[256];
- struct logchannel *next;
+ struct logchannel *next;
};
static struct logchannel *logchannels = NULL;
@@ -74,21 +75,21 @@
static FILE *eventlog = NULL;
static char *levels[] = {
- "DEBUG",
- "EVENT",
- "NOTICE",
- "WARNING",
- "ERROR",
- "VERBOSE"
+ "DEBUG",
+ "EVENT",
+ "NOTICE",
+ "WARNING",
+ "ERROR",
+ "VERBOSE"
};
static int colors[] = {
- COLOR_BRGREEN,
- COLOR_BRBLUE,
- COLOR_YELLOW,
- COLOR_BRRED,
- COLOR_RED,
- COLOR_GREEN
+ COLOR_BRGREEN,
+ COLOR_BRBLUE,
+ COLOR_YELLOW,
+ COLOR_BRRED,
+ COLOR_RED,
+ COLOR_GREEN
};
static int make_components(char *s, int lineno)
@@ -389,10 +390,11 @@
handle_logger_rotate, "Rotates and reopens the log files",
logger_rotate_help };
-static int handle_SIGXFSZ(int sig) {
+static int handle_SIGXFSZ(int sig)
+{
/* Indicate need to reload */
pending_logger_reload = 1;
- return 0;
+ return 0;
}
int init_logger(void)
@@ -446,23 +448,24 @@
return;
}
-static void ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *fmt, va_list args) {
- char buf[BUFSIZ];
+static void ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *fmt, va_list args)
+{
+ char buf[BUFSIZ];
- if(level >= SYSLOG_NLEVELS) {
- /* we are locked here, so cannot ast_log() */
- fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
- return;
- }
- if(level == __LOG_VERBOSE) {
- snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self());
- level = __LOG_DEBUG;
- } else {
- snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: ",
- levels[level], (long)pthread_self(), file, line, function);
- }
- vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, args);
- syslog(syslog_level_map[level], "%s", buf);
+ if (level >= SYSLOG_NLEVELS) {
+ /* we are locked here, so cannot ast_log() */
+ fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
+ return;
+ }
+ if (level == __LOG_VERBOSE) {
+ snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self());
+ level = __LOG_DEBUG;
+ } else {
+ snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: ",
+ levels[level], (long)pthread_self(), file, line, function);
+ }
+ vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, args);
+ syslog(syslog_level_map[level], "%s", buf);
}
/*
@@ -470,97 +473,96 @@
*/
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
{
- struct logchannel *chan;
- char buf[BUFSIZ];
- time_t t;
- struct tm tm;
- char date[256];
+ struct logchannel *chan;
+ char buf[BUFSIZ];
+ time_t t;
+ struct tm tm;
+ char date[256];
- va_list ap;
+ va_list ap;
- if (!option_verbose && !option_debug && (level == __LOG_DEBUG)) {
- return;
- }
-
- /* begin critical section */
- ast_mutex_lock(&loglock);
-
- time(&t);
- localtime_r(&t, &tm);
- strftime(date, sizeof(date), dateformat, &tm);
+ if (!option_verbose && !option_debug && (level == __LOG_DEBUG)) {
+ return;
+ }
+ /* begin critical section */
+ ast_mutex_lock(&loglock);
- if (level == __LOG_EVENT) {
- va_start(ap, fmt);
+ time(&t);
+ localtime_r(&t, &tm);
+ strftime(date, sizeof(date), dateformat, &tm);
- fprintf(eventlog, "%s asterisk[%d]: ", date, getpid());
- vfprintf(eventlog, fmt, ap);
- fflush(eventlog);
+ if (level == __LOG_EVENT) {
+ va_start(ap, fmt);
- va_end(ap);
- ast_mutex_unlock(&loglock);
- return;
- }
+ fprintf(eventlog, "%s asterisk[%d]: ", date, getpid());
+ vfprintf(eventlog, fmt, ap);
+ fflush(eventlog);
- if (logchannels) {
- chan = logchannels;
- while(chan) {
- if (chan->syslog && (chan->logmask & (1 << level))) {
- va_start(ap, fmt);
- ast_log_vsyslog(level, file, line, function, fmt, ap);
va_end(ap);
- } else if ((chan->logmask & (1 << level)) && (chan->console)) {
- char linestr[128];
- char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
+ ast_mutex_unlock(&loglock);
+ return;
+ }
- if(level != __LOG_VERBOSE) {
- sprintf(linestr, "%d", line);
- snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ",
- date,
- term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)),
- (long)pthread_self(),
- term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
- term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
- term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
+ if (logchannels) {
+ chan = logchannels;
+ while(chan) {
+ if (chan->syslog && (chan->logmask & (1 << level))) {
+ va_start(ap, fmt);
+ ast_log_vsyslog(level, file, line, function, fmt, ap);
+ va_end(ap);
+ } else if ((chan->logmask & (1 << level)) && (chan->console)) {
+ char linestr[128];
+ char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
+
+ if (level != __LOG_VERBOSE) {
+ sprintf(linestr, "%d", line);
+ snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ",
+ date,
+ term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)),
+ (long)pthread_self(),
+ term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
+ term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
+ term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
- ast_console_puts(buf);
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- ast_console_puts(buf);
+ ast_console_puts(buf);
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ ast_console_puts(buf);
+ }
+ } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {
+ snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date,
+ levels[level], (long)pthread_self());
+ fprintf(chan->fileptr, buf);
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ fputs(buf, chan->fileptr);
+ fflush(chan->fileptr);
+ }
+ chan = chan->next;
}
- } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {
- snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date,
- levels[level], (long)pthread_self());
- fprintf(chan->fileptr, buf);
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- fputs(buf, chan->fileptr);
- fflush(chan->fileptr);
- }
- chan = chan->next;
- }
- } else {
- /*
- * we don't have the logger chain configured yet,
- * so just log to stdout
- */
+ } else {
+ /*
+ * we don't have the logger chain configured yet,
+ * so just log to stdout
+ */
if (level != __LOG_VERBOSE) {
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- fputs(buf, stdout);
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ fputs(buf, stdout);
}
- }
+ }
- ast_mutex_unlock(&loglock);
- /* end critical section */
+ ast_mutex_unlock(&loglock);
+ /* end critical section */
if (pending_logger_reload) {
- reload_logger(1);
- ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ\n");
- if (option_verbose)
- ast_verbose("Rotated Logs Per SIGXFSZ\n");
+ reload_logger(1);
+ ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ\n");
+ if (option_verbose)
+ ast_verbose("Rotated Logs Per SIGXFSZ\n");
}
}
More information about the svn-commits
mailing list