Added preliminary Symbian support.
[silc.git] / lib / silcutil / silclog.c
index 2955a5dd761e2203ebb3196dc945871487eb5f4b..9deff33a48fecad72710977349a000d2519bdf97 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2005 Pekka Riikonen
+  Copyright (C) 1997 - 2006 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
 */
 /* $Id$ */
 
-#include "silcincludes.h"
+#include "silc.h"
 
 /* SilcLogSettings context */
 typedef struct {
@@ -106,12 +106,13 @@ static void silc_log_checksize(SilcLog log)
   /* Cycle log file */
   fprintf(log->fp,
          "[%s] [%s] Cycling log file, over max log size (%lu kilobytes)\n",
-         silc_get_time(0), log->typename, (unsigned long)log->maxsize / 1024);
+         silc_time_string(0), log->typename,
+         (unsigned long)log->maxsize / 1024);
   fflush(log->fp);
   fclose(log->fp);
 
   memset(newname, 0, sizeof(newname));
-  snprintf(newname, sizeof(newname) - 1, "%s.old", log->filename);
+  silc_silc_snprintf(newname, sizeof(newname) - 1, "%s.old", log->filename);
   unlink(newname);
   rename(log->filename, newname);
 
@@ -146,9 +147,8 @@ SILC_TASK_CALLBACK(silc_log_fflush_callback)
 
   if (silclog.flushdelay < 2)
     silclog.flushdelay = 2;
-  silc_schedule_task_add(context, 0, silc_log_fflush_callback, context,
-                        silclog.flushdelay, 0, SILC_TASK_TIMEOUT,
-                        SILC_TASK_PRI_NORMAL);
+  silc_schedule_task_add_timeout(context, silc_log_fflush_callback, context,
+                                silclog.flushdelay, 0);
 }
 
 /* Output log message to log file */
@@ -196,7 +196,7 @@ void silc_log_output(SilcLogType type, char *string)
 
  found:
   if (silclog.timestamp)
-    fprintf(fp, "[%s] [%s] %s\n", silc_get_time(0), typename, string);
+    fprintf(fp, "[%s] [%s] %s\n", silc_time_string(0), typename, string);
   else
     fprintf(fp, "[%s] %s\n", typename, string);
 
@@ -217,8 +217,8 @@ void silc_log_output(SilcLogType type, char *string)
 
 /* Set and initialize the specified log file. */
 
-bool silc_log_set_file(SilcLogType type, char *filename, SilcUInt32 maxsize,
-                      SilcSchedule scheduler)
+SilcBool silc_log_set_file(SilcLogType type, char *filename,
+                          SilcUInt32 maxsize, SilcSchedule scheduler)
 {
   FILE *fp = NULL;
   SilcLog log;
@@ -264,8 +264,8 @@ bool silc_log_set_file(SilcLogType type, char *filename, SilcUInt32 maxsize,
   /* Add flush timeout */
   if (scheduler) {
     silc_schedule_task_del_by_callback(scheduler, silc_log_fflush_callback);
-    silc_schedule_task_add(scheduler, 0, silc_log_fflush_callback, scheduler,
-                          10, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+    silc_schedule_task_add_timeout(scheduler, silc_log_fflush_callback,
+                                  scheduler, 10, 0);
     silclog.scheduled = TRUE;
   }
 
@@ -407,7 +407,7 @@ void silc_log_set_debug_string(const char *debug_string)
 
 /* Set timestamp */
 
-void silc_log_timestamp(bool enable)
+void silc_log_timestamp(SilcBool enable)
 {
   silclog.timestamp = enable;
 }
@@ -421,21 +421,21 @@ void silc_log_flushdelay(SilcUInt32 flushdelay)
 
 /* Set quick logging */
 
-void silc_log_quick(bool enable)
+void silc_log_quick(SilcBool enable)
 {
   silclog.quick = enable;
 }
 
 /* Set debugging */
 
-void silc_log_debug(bool enable)
+void silc_log_debug(SilcBool enable)
 {
   silclog.debug = enable;
 }
 
 /* Set debug hexdump */
 
-void silc_log_debug_hexdump(bool enable)
+void silc_log_debug_hexdump(SilcBool enable)
 {
   silclog.debug_hexdump = enable;
 }