Mercurial > ~mikael > mcabber > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
196:58eb8ad9ef74 | 197:c289e3c39c48 |
---|---|
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 struct stat bufstat; | |
116 guint err = 0; | 117 guint err = 0; |
117 | 118 |
118 if (!FileLoadLogs) return; | 119 if (!FileLoadLogs) return; |
119 | 120 |
120 data = g_new(char, HBB_BLOCKSIZE+32); | 121 data = g_new(char, HBB_BLOCKSIZE+32); |
126 filename = user_histo_file(jid); | 127 filename = user_histo_file(jid); |
127 | 128 |
128 fp = fopen(filename, "r"); | 129 fp = fopen(filename, "r"); |
129 g_free(filename); | 130 g_free(filename); |
130 if (!fp) { g_free(data); return; } | 131 if (!fp) { g_free(data); return; } |
132 | |
133 // If file is large (> 512 here), display a message to inform the user | |
134 // (it can take a while...) | |
135 if (!fstat(fileno(fp), &bufstat)) { | |
136 if (bufstat.st_size > 524288) | |
137 scr_LogPrint("Reading <%s> history file...", jid); | |
138 } | |
131 | 139 |
132 /* See write_histo_line() for line format... */ | 140 /* See write_histo_line() for line format... */ |
133 while (!feof(fp)) { | 141 while (!feof(fp)) { |
134 if (fgets(data, HBB_BLOCKSIZE+24, fp) == NULL) break; | 142 if (fgets(data, HBB_BLOCKSIZE+24, fp) == NULL) break; |
135 | 143 |
159 } | 167 } |
160 //break; | 168 //break; |
161 continue; | 169 continue; |
162 } | 170 } |
163 | 171 |
164 // FIXME This will fail when a message is too big | 172 // XXX This will fail when a message is too big |
165 while (len--) { | 173 while (len--) { |
166 if (fgets(tail, HBB_BLOCKSIZE+24 - (tail-data), fp) == NULL) break; | 174 if (fgets(tail, HBB_BLOCKSIZE+24 - (tail-data), fp) == NULL) break; |
167 | 175 |
168 while (*tail) tail++; | 176 while (*tail) tail++; |
169 } | 177 } |
178 // Remove last CR | |
170 if ((tail > data+18) && (*(tail-1) == '\n')) | 179 if ((tail > data+18) && (*(tail-1) == '\n')) |
171 *(tail-1) = 0; | 180 *(tail-1) = 0; |
172 | 181 |
173 if (type == 'M') { | 182 if (type == 'M') { |
174 if (info == 'S') | 183 if (info == 'S') |