Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/histolog.c @ 186:888ad9f15346
[/trunk] Changeset 198 by mikael
* Use lowercase jid for history log files
* Workaround a problem when loading a history file big a (too) big message
* Increase HBB_BLOCKSIZE to 4096
author | mikael |
---|---|
date | Thu, 05 May 2005 20:50:50 +0000 |
parents | b5aa2b9c425a |
children | 5cbdcccfab29 |
comparison
equal
deleted
inserted
replaced
185:e8e447a07641 | 186:888ad9f15346 |
---|---|
41 // Returns history filename for the given jid | 41 // Returns history filename for the given jid |
42 // Note: the caller *must* free the filename after use (if not null). | 42 // Note: the caller *must* free the filename after use (if not null). |
43 static char *user_histo_file(const char *jid) | 43 static char *user_histo_file(const char *jid) |
44 { | 44 { |
45 char *filename; | 45 char *filename; |
46 char *lowerid, *p; | |
46 if (!UseFileLogging && !FileLoadLogs) return NULL; | 47 if (!UseFileLogging && !FileLoadLogs) return NULL; |
48 | |
49 lowerid = g_strdup(jid); | |
50 for (p=lowerid; *p ; p++) | |
51 *p = tolower(*p); | |
47 | 52 |
48 filename = g_new(char, strlen(RootDir) + strlen(jid) + 1); | 53 filename = g_new(char, strlen(RootDir) + strlen(jid) + 1); |
49 strcpy(filename, RootDir); | 54 strcpy(filename, RootDir); |
50 strcat(filename, jid); | 55 strcat(filename, lowerid); |
56 g_free(lowerid); | |
51 return filename; | 57 return filename; |
52 } | 58 } |
53 | 59 |
54 // write_histo_line() | 60 // write_histo_line() |
55 // Adds a history (multi-)line to the jid's history logfile | 61 // Adds a history (multi-)line to the jid's history logfile |
131 type = data[0]; | 137 type = data[0]; |
132 info = data[1]; | 138 info = data[1]; |
133 if ((type != 'M' && type != 'S') || | 139 if ((type != 'M' && type != 'S') || |
134 (data[13] != ' ') || (data[17] != ' ')) { | 140 (data[13] != ' ') || (data[17] != ' ')) { |
135 scr_LogPrint("Error in history file format"); | 141 scr_LogPrint("Error in history file format"); |
136 break; | 142 //break; |
143 continue; | |
137 } | 144 } |
138 data[13] = data[17] = 0; | 145 data[13] = data[17] = 0; |
139 timestamp = (unsigned long) atol(&data[3]); | 146 timestamp = (unsigned long) atol(&data[3]); |
140 len = (unsigned long) atol(&data[14]); | 147 len = (unsigned long) atol(&data[14]); |
141 | 148 |
142 // Some checks | 149 // Some checks |
143 if (((type == 'M') && (info != 'S' && info != 'R')) || | 150 if (((type == 'M') && (info != 'S' && info != 'R')) || |
144 ((type == 'I') && (!strchr("OAIFDCN", info)))) { | 151 ((type == 'I') && (!strchr("OAIFDCN", info)))) { |
145 scr_LogPrint("Error in history file format"); | 152 scr_LogPrint("Error in history file format"); |
146 break; | 153 //break; |
147 } | 154 continue; |
148 | 155 } |
156 | |
157 // FIXME This will fail when a message is too big | |
149 while (len--) { | 158 while (len--) { |
150 if (fgets(tail, HBB_BLOCKSIZE+24 - (tail-data), fp) == NULL) break; | 159 if (fgets(tail, HBB_BLOCKSIZE+24 - (tail-data), fp) == NULL) break; |
151 | 160 |
152 while (*tail) tail++; | 161 while (*tail) tail++; |
153 } | 162 } |