aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/log.c b/src/log.c
index 65860f3..0f96964 100644
--- a/src/log.c
+++ b/src/log.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.3 2008/02/23 11:48:37 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/02/22 14:51:54 james
* *** empty log message ***
*
@@ -74,28 +77,32 @@ file_log_new (char *fn)
{
File_Log *l;
FILE *f;
- int dc=1;
+ 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));
l->log = flog_log;
l->close = flog_close;
l->fp = f;
- l->do_close=dc;
+ l->do_close = dc;
return (Log *) l;
}
-void
-log_f (Log *log,char *fmt, ...)
+
+void
+log_f (Log * log, char *fmt, ...)
{
int n;
@@ -103,12 +110,14 @@ log_f (Log *log,char *fmt, ...)
va_list ap;
static int size;
- if (!log) return;
+ if (!log)
+ return;
- if (!size) {
- size = 128;
- buf = malloc (size);
- }
+ if (!size)
+ {
+ size = 128;
+ buf = malloc (size);
+ }
if (!buf)
return;
@@ -116,13 +125,14 @@ log_f (Log *log,char *fmt, ...)
while (1)
{
va_start (ap, fmt);
- n = vsnprintf (buf , size, fmt, ap);
+ 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;
@@ -132,6 +142,6 @@ log_f (Log *log,char *fmt, ...)
buf = realloc (buf, size);
if (!buf)
- return;
+ return;
}
}