[/trunk] Changeset 261 by mikael
* Show more information when a history file parse error occurs
--- a/mcabber/src/histolog.c Tue Jun 14 19:42:25 2005 +0000
+++ b/mcabber/src/histolog.c Sat Jun 25 07:15:29 2005 +0000
@@ -120,6 +120,7 @@
struct stat bufstat;
guint err = 0;
guint oldformat;
+ guint ln = 0; // line number
if (!FileLoadLogs) return;
@@ -146,6 +147,7 @@
while (!feof(fp)) {
int format_off =0;
if (fgets(data, HBB_BLOCKSIZE+24, fp) == NULL) break;
+ ln++;
for (tail = data; *tail; tail++) ;
@@ -162,7 +164,7 @@
(oldformat && ((data[13] != ' ') || (data[17] != ' '))) ||
((!oldformat) && ((data[21] != ' ') || (data[25] != ' ')))) {
if (!err) {
- scr_LogPrint("Error in history file format (%s)", jid);
+ scr_LogPrint("Error in history file format (%s), l.%u", jid, ln);
err = 1;
}
//break;
@@ -179,7 +181,7 @@
if (((type == 'M') && (info != 'S' && info != 'R')) ||
((type == 'I') && (!strchr("OAIFDCN", info)))) {
if (!err) {
- scr_LogPrint("Error in history file format (%s)", jid);
+ scr_LogPrint("Error in history file format (%s), l.%u", jid, ln);
err = 1;
}
//break;
@@ -188,10 +190,15 @@
// XXX This will fail when a message is too big
while (len--) {
+ ln++;
if (fgets(tail, HBB_BLOCKSIZE+24 - (tail-data), fp) == NULL) break;
while (*tail) tail++;
}
+ // Small check for too long messages
+ if (tail+1 >= HBB_BLOCKSIZE+24 + data) {
+ scr_LogPrint("Message is too big in history file!");
+ }
// Remove last CR
if ((tail > data+18+format_off) && (*(tail-1) == '\n'))
*(tail-1) = 0;