diff mcabber/src/histolog.c @ 197:c289e3c39c48

[/trunk] Changeset 209 by mikael * screen.c: display prefixes "*<*" or "*>*" when both info and in/out prefixes are requested. * hbuf.c: set HBB_PREFIX_INFO prefix when a line is too long to fit in an hbuf block * histolog.c: display a message when reading a big history file (because it can hang the ui for a while)
author mikael
date Sat, 07 May 2005 07:33:10 +0000
parents 5cbdcccfab29
children 73f6ce668ba8
line wrap: on
line diff
--- a/mcabber/src/histolog.c	Sat May 07 06:34:47 2005 +0000
+++ b/mcabber/src/histolog.c	Sat May 07 07:33:10 2005 +0000
@@ -113,6 +113,7 @@
   guint prefix_flags;
   guint len;
   FILE *fp;
+  struct stat bufstat;
   guint err = 0;
 
   if (!FileLoadLogs) return;
@@ -129,6 +130,13 @@
   g_free(filename);
   if (!fp) { g_free(data); return; }
 
+  // If file is large (> 512 here), display a message to inform the user
+  // (it can take a while...)
+  if (!fstat(fileno(fp), &bufstat)) {
+    if (bufstat.st_size > 524288)
+      scr_LogPrint("Reading <%s> history file...", jid);
+  }
+
   /* See write_histo_line() for line format... */
   while (!feof(fp)) {
     if (fgets(data, HBB_BLOCKSIZE+24, fp) == NULL) break;
@@ -161,12 +169,13 @@
       continue;
     }
 
-    // FIXME This will fail when a message is too big
+    // XXX This will fail when a message is too big
     while (len--) {
       if (fgets(tail, HBB_BLOCKSIZE+24 - (tail-data), fp) == NULL) break;
 
       while (*tail) tail++;
     }
+    // Remove last CR
     if ((tail > data+18) && (*(tail-1) == '\n'))
       *(tail-1) = 0;