aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c80
1 files changed, 45 insertions, 35 deletions
diff --git a/src/log.c b/src/log.c
index dc15ed9..d8d9896 100644
--- a/src/log.c
+++ b/src/log.c
@@ -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;
+ }
}