diff options
author | james <> | 2008-03-03 06:04:42 +0000 |
---|---|---|
committer | james <> | 2008-03-03 06:04:42 +0000 |
commit | f2c620137fa5290d913373e5579a97f0fee25fa3 (patch) | |
tree | dfbbe3562ae58e8f540a92654cb4f4d7323d59d7 /src/log.c | |
parent | 800cb4bdfb56dcd606216788fb023fcc23fb69bf (diff) | |
download | sympathy-f2c620137fa5290d913373e5579a97f0fee25fa3.tar.gz sympathy-f2c620137fa5290d913373e5579a97f0fee25fa3.tar.bz2 sympathy-f2c620137fa5290d913373e5579a97f0fee25fa3.zip |
*** empty log message ***
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 80 |
1 files changed, 45 insertions, 35 deletions
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.8 2008/03/03 06:04:42 james + * *** empty log message *** + * * Revision 1.7 2008/03/03 06:04:18 james * *** empty log message *** * @@ -35,7 +38,8 @@ static char rcsid[] = "$Id$"; #include "project.h" -typedef struct { +typedef struct +{ LOG_SIGNATURE; int do_close; int rotate; @@ -72,8 +76,8 @@ flog_log (Log * _l, char *buf) fputc ('\n', l->fp); fflush (l->fp); - if (l->rotate) - rotate_check(l->filename); + if (l->rotate) + rotate_check (l->filename); } @@ -86,25 +90,28 @@ flog_close (Log * _l) if (l->fp && l->do_close) fclose (l->fp); if (l->filename) - free(l->filename); + free (l->filename); free (l); } Log * -file_log_new (char *fn,int rotate) +file_log_new (char *fn, int rotate) { File_Log *l; 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)); @@ -112,8 +119,8 @@ file_log_new (char *fn,int rotate) l->close = flog_close; l->fp = f; l->do_close = dc; - l->rotate=rotate; - l->filename=strdup(fn); + l->rotate = rotate; + l->filename = strdup (fn); fput_cp (f, 0xffef); @@ -132,32 +139,35 @@ 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; + } } |