diff options
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 80 |
1 files changed, 38 insertions, 42 deletions
@@ -1,4 +1,4 @@ -/* +/* * log.c: * * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>, @@ -8,8 +8,11 @@ static char rcsid[] = "$Id$"; -/* +/* * $Log$ + * Revision 1.10 2008/03/07 12:37:04 james + * *** empty log message *** + * * Revision 1.9 2008/03/03 06:20:14 james * *** empty log message *** * @@ -79,12 +82,11 @@ flog_log (Log * _l, char *buf) fputc ('\n', l->fp); fflush (l->fp); - if (l->rotate && rotate_check (l->filename)) - { - fclose (l->fp); - rotate (l->filename); - l->fp = fopen (l->filename, "a+"); - } + if (l->rotate && rotate_check (l->filename)) { + fclose (l->fp); + rotate (l->filename); + l->fp = fopen (l->filename, "a+"); + } } @@ -108,17 +110,14 @@ file_log_new (char *fn, int rotate) FILE *f; int dc = 1; - if (fn && strcmp (fn, "-")) - { - f = fopen (fn, "a+"); - if (!f) - return NULL; - } - else - { - f = stderr; - dc = 0; - } + if (fn && strcmp (fn, "-")) { + f = fopen (fn, "a+"); + if (!f) + return NULL; + } else { + f = stderr; + dc = 0; + } l = malloc (sizeof (File_Log)); @@ -146,35 +145,32 @@ log_f (Log * log, char *fmt, ...) if (!log) return; - if (!size) - { - size = 128; - buf = malloc (size); - } + if (!size) { + size = 128; + buf = malloc (size); + } if (!buf) return; - while (1) - { - va_start (ap, fmt); - n = vsnprintf (buf, size, fmt, ap); - va_end (ap); + while (1) { + va_start (ap, fmt); + n = vsnprintf (buf, size, fmt, ap); + va_end (ap); - if (n > -1 && n < size) - { - log->log (log, buf); - return; - } + if (n > -1 && n < size) { + log->log (log, buf); + return; + } - if (n > -1) /* glibc 2.1 */ - size = n + 1; - else /* glibc 2.0 */ - size *= 2; /* twice the old size */ + if (n > -1) /* glibc 2.1 */ + size = n + 1; + else /* glibc 2.0 */ + size *= 2; /* twice the old size */ - buf = realloc (buf, size); + buf = realloc (buf, size); - if (!buf) - return; - } + if (!buf) + return; + } } |