comparison mcabber/src/histolog.c @ 193:5cbdcccfab29

[/trunk] Changeset 205 by mikael * Nicer error reporting in history log files reading
author mikael
date Fri, 06 May 2005 18:06:31 +0000
parents 888ad9f15346
children c289e3c39c48
comparison
equal deleted inserted replaced
192:62bc2992216b 193:5cbdcccfab29
111 char *data, *tail; 111 char *data, *tail;
112 time_t timestamp; 112 time_t timestamp;
113 guint prefix_flags; 113 guint prefix_flags;
114 guint len; 114 guint len;
115 FILE *fp; 115 FILE *fp;
116 guint err = 0;
116 117
117 if (!FileLoadLogs) return; 118 if (!FileLoadLogs) return;
118 119
119 data = g_new(char, HBB_BLOCKSIZE+32); 120 data = g_new(char, HBB_BLOCKSIZE+32);
120 if (!data) { 121 if (!data) {
136 137
137 type = data[0]; 138 type = data[0];
138 info = data[1]; 139 info = data[1];
139 if ((type != 'M' && type != 'S') || 140 if ((type != 'M' && type != 'S') ||
140 (data[13] != ' ') || (data[17] != ' ')) { 141 (data[13] != ' ') || (data[17] != ' ')) {
141 scr_LogPrint("Error in history file format"); 142 if (!err) {
143 scr_LogPrint("Error in history file format (%s)", jid);
144 err = 1;
145 }
142 //break; 146 //break;
143 continue; 147 continue;
144 } 148 }
145 data[13] = data[17] = 0; 149 data[13] = data[17] = 0;
146 timestamp = (unsigned long) atol(&data[3]); 150 timestamp = (unsigned long) atol(&data[3]);
147 len = (unsigned long) atol(&data[14]); 151 len = (unsigned long) atol(&data[14]);
148 152
149 // Some checks 153 // Some checks
150 if (((type == 'M') && (info != 'S' && info != 'R')) || 154 if (((type == 'M') && (info != 'S' && info != 'R')) ||
151 ((type == 'I') && (!strchr("OAIFDCN", info)))) { 155 ((type == 'I') && (!strchr("OAIFDCN", info)))) {
152 scr_LogPrint("Error in history file format"); 156 if (!err) {
157 scr_LogPrint("Error in history file format (%s)", jid);
158 err = 1;
159 }
153 //break; 160 //break;
154 continue; 161 continue;
155 } 162 }
156 163
157 // FIXME This will fail when a message is too big 164 // FIXME This will fail when a message is too big
167 if (info == 'S') 174 if (info == 'S')
168 prefix_flags = HBB_PREFIX_OUT; 175 prefix_flags = HBB_PREFIX_OUT;
169 else 176 else
170 prefix_flags = HBB_PREFIX_IN; 177 prefix_flags = HBB_PREFIX_IN;
171 hbuf_add_line(p_buddyhbuf, &data[18], timestamp, prefix_flags, width); 178 hbuf_add_line(p_buddyhbuf, &data[18], timestamp, prefix_flags, width);
179 err = 0;
172 } 180 }
173 } 181 }
174 fclose(fp); 182 fclose(fp);
175 g_free(data); 183 g_free(data);
176 } 184 }