Mercurial > pidgin
annotate src/log.c @ 4859:a9a831508b43
[gaim-migrate @ 5186]
Including wspell.h for win32 gtkspell interface
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sat, 22 Mar 2003 18:32:50 +0000 |
parents | 677d3cb193a1 |
children | 5425bbaa2630 |
rev | line source |
---|---|
4184 | 1 /* --------------------------------------------------- |
2 * Function to remove a log file entry | |
3 * --------------------------------------------------- | |
4 */ | |
4195 | 5 #ifdef HAVE_CONFIG_H |
6 #include <config.h> | |
7 #endif | |
8 #include <string.h> | |
9 | |
10 #ifndef _WIN32 | |
11 #include <unistd.h> | |
12 #endif | |
13 | |
4184 | 14 #include "gaim.h" |
15 #include "core.h" | |
16 #include "multi.h" | |
17 #include "prpl.h" | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
18 #include <string.h> |
4184 | 19 #include <sys/stat.h> |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
20 #include <unistd.h> |
4184 | 21 |
4192
17187504bfc2
[gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4184
diff
changeset
|
22 #ifdef _WIN32 |
17187504bfc2
[gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4184
diff
changeset
|
23 #include "win32dep.h" |
17187504bfc2
[gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4184
diff
changeset
|
24 #endif |
17187504bfc2
[gaim-migrate @ 4423]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4184
diff
changeset
|
25 |
4184 | 26 void rm_log(struct log_conversation *a) |
27 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
28 struct gaim_conversation *cnv = gaim_find_conversation(a->name); |
4184 | 29 |
30 log_conversations = g_list_remove(log_conversations, a); | |
31 | |
32 save_prefs(); | |
33 | |
34 if (cnv && !(im_options & OPT_IM_ONE_WINDOW)) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
35 gaim_conversation_autoset_title(cnv); |
4184 | 36 } |
37 | |
38 struct log_conversation *find_log_info(const char *name) | |
39 { | |
40 char *pname = g_malloc(BUF_LEN); | |
41 GList *lc = log_conversations; | |
42 struct log_conversation *l; | |
43 | |
44 | |
45 strcpy(pname, normalize(name)); | |
46 | |
47 while (lc) { | |
48 l = (struct log_conversation *)lc->data; | |
4793 | 49 if (!gaim_utf8_strcasecmp(pname, normalize(l->name))) { |
4184 | 50 g_free(pname); |
51 return l; | |
52 } | |
53 lc = lc->next; | |
54 } | |
55 g_free(pname); | |
56 return NULL; | |
57 } | |
58 | |
59 void update_log_convs() | |
60 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
61 GList *cnv; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
62 struct gaim_conversation *c; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
63 struct gaim_gtk_conversation *gtkconv; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
64 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
65 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
66 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
67 c = (struct gaim_conversation *)cnv->data; |
4184 | 68 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
69 if (!GAIM_IS_GTK_CONVERSATION(c)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
70 continue; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
71 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
72 gtkconv = GAIM_GTK_CONVERSATION(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
73 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
74 if (gtkconv->toolbar.log) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
75 if (gaim_conversation_get_type(c) == GAIM_CONV_CHAT) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
76 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
4184 | 77 ((logging_options & OPT_LOG_CHATS)) ? FALSE : TRUE); |
78 else | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
79 gtk_widget_set_sensitive(GTK_WIDGET(gtkconv->toolbar.log), |
4184 | 80 ((logging_options & OPT_LOG_CONVOS)) ? FALSE : TRUE); |
81 } | |
82 } | |
83 } | |
84 | |
4635 | 85 static void do_save_convo(GObject *obj, GtkWidget *wid) |
4184 | 86 { |
4635 | 87 struct gaim_conversation *c = g_object_get_data(obj, "gaim_conversation"); |
4184 | 88 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
89 FILE *f; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
90 |
4184 | 91 if (file_is_dir(filename, wid)) |
92 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
93 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
94 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
95 g_list_find(gaim_get_ims(), c)) || |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
96 (gaim_conversation_get_type(c) == GAIM_CONV_CHAT && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
97 g_list_find(gaim_get_chats(), c)))) |
4184 | 98 filename = NULL; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
99 |
4184 | 100 gtk_widget_destroy(wid); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
101 |
4184 | 102 if (!filename) |
103 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
104 |
4184 | 105 f = fopen(filename, "w+"); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
106 |
4184 | 107 if (!f) |
108 return; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
109 |
4184 | 110 fprintf(f, "%s", c->history->str); |
111 fclose(f); | |
112 } | |
113 | |
114 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
115 void save_convo(GtkWidget *save, struct gaim_conversation *c) |
4184 | 116 { |
117 char buf[BUF_LONG]; | |
118 GtkWidget *window = gtk_file_selection_new(_("Gaim - Save Conversation")); | |
119 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name)); | |
120 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
4635 | 121 g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
122 "gaim_conversation", c); | |
4184 | 123 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
124 "clicked", G_CALLBACK(do_save_convo), window); | |
125 g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), | |
126 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); | |
127 gtk_widget_show(window); | |
128 } | |
129 | |
130 static FILE *open_gaim_log_file(const char *name, int *flag) | |
131 { | |
132 char *buf; | |
133 char *buf2; | |
134 char log_all_file[256]; | |
135 struct stat st; | |
136 FILE *fd; | |
137 #ifndef _WIN32 | |
138 int res; | |
139 #endif | |
140 gchar *gaim_dir; | |
141 | |
142 buf = g_malloc(BUF_LONG); | |
143 buf2 = g_malloc(BUF_LONG); | |
144 gaim_dir = gaim_user_dir(); | |
145 | |
146 /* Dont log yourself */ | |
147 strncpy(log_all_file, gaim_dir, 256); | |
148 | |
149 #ifndef _WIN32 | |
150 stat(log_all_file, &st); | |
151 if (!S_ISDIR(st.st_mode)) | |
152 unlink(log_all_file); | |
153 | |
154 fd = fopen(log_all_file, "r"); | |
155 | |
156 if (!fd) { | |
157 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
158 if (res < 0) { | |
159 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
160 log_all_file); | |
161 do_error_dialog(buf, NULL, GAIM_ERROR); | |
162 g_free(buf); | |
163 g_free(buf2); | |
164 return NULL; | |
165 } | |
166 } else | |
167 fclose(fd); | |
168 | |
169 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
170 | |
171 if (stat(log_all_file, &st) < 0) | |
172 *flag = 1; | |
173 if (!S_ISDIR(st.st_mode)) | |
174 unlink(log_all_file); | |
175 | |
176 fd = fopen(log_all_file, "r"); | |
177 if (!fd) { | |
178 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
179 if (res < 0) { | |
180 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
181 log_all_file); | |
182 do_error_dialog(buf, NULL, GAIM_ERROR); | |
183 g_free(buf); | |
184 g_free(buf2); | |
185 return NULL; | |
186 } | |
187 } else | |
188 fclose(fd); | |
189 #else /* _WIN32 */ | |
190 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
191 | |
192 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) { | |
193 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file); | |
194 do_error_dialog(buf, NULL, GAIM_ERROR); | |
195 g_free(buf); | |
196 g_free(buf2); | |
197 return NULL; | |
198 } | |
199 #endif | |
200 | |
201 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name); | |
202 if (stat(log_all_file, &st) < 0) | |
203 *flag = 1; | |
204 | |
205 debug_printf("Logging to: \"%s\"\n", log_all_file); | |
206 | |
207 fd = fopen(log_all_file, "a"); | |
208 | |
209 g_free(buf); | |
210 g_free(buf2); | |
211 return fd; | |
212 } | |
213 | |
214 static FILE *open_system_log_file(char *name) | |
215 { | |
216 int x; | |
217 | |
218 if (name) | |
219 return open_log_file(name, 2); | |
220 else | |
221 return open_gaim_log_file("system", &x); | |
222 } | |
223 | |
224 FILE *open_log_file(const char *name, int is_chat) | |
225 { | |
226 struct stat st; | |
227 char realname[256]; | |
228 struct log_conversation *l; | |
229 FILE *fd; | |
230 int flag = 0; | |
231 | |
232 if (((is_chat == 2) && !(logging_options & OPT_LOG_INDIVIDUAL)) | |
233 || ((is_chat == 1) && !(logging_options & OPT_LOG_CHATS)) | |
234 || ((is_chat == 0) && !(logging_options & OPT_LOG_CONVOS))) { | |
235 | |
236 l = find_log_info(name); | |
237 if (!l) | |
238 return NULL; | |
239 | |
240 if (stat(l->filename, &st) < 0) | |
241 flag = 1; | |
242 | |
243 fd = fopen(l->filename, "a"); | |
244 | |
245 if (flag) { /* is a new file */ | |
246 if (logging_options & OPT_LOG_STRIP_HTML) { | |
247 fprintf(fd, _("IM Sessions with %s\n"), name); | |
248 } else { | |
249 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
250 fprintf(fd, _("IM Sessions with %s"), name); | |
251 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
252 } | |
253 } | |
254 | |
255 return fd; | |
256 } | |
257 | |
258 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name)); | |
259 fd = open_gaim_log_file(realname, &flag); | |
260 | |
261 if (fd && flag) { /* is a new file */ | |
262 if (logging_options & OPT_LOG_STRIP_HTML) { | |
263 fprintf(fd, _("IM Sessions with %s\n"), name); | |
264 } else { | |
265 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
266 fprintf(fd, _("IM Sessions with %s"), name); | |
267 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
268 } | |
269 } | |
270 | |
271 return fd; | |
272 } | |
273 | |
274 void system_log(enum log_event what, struct gaim_connection *gc, | |
275 struct buddy *who, int why) | |
276 { | |
277 FILE *fd; | |
278 char text[256], html[256]; | |
279 | |
280 if ((logging_options & why) != why) | |
281 return; | |
282 | |
283 if (logging_options & OPT_LOG_INDIVIDUAL) { | |
284 if (why & OPT_LOG_MY_SIGNON) | |
285 fd = open_system_log_file(gc ? gc->username : NULL); | |
286 else | |
287 fd = open_system_log_file(who->name); | |
288 } else | |
289 fd = open_system_log_file(NULL); | |
290 | |
291 if (!fd) | |
292 return; | |
293 | |
294 if (why & OPT_LOG_MY_SIGNON) { | |
295 switch (what) { | |
296 case log_signon: | |
4195 | 297 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
4184 | 298 gc->username, gc->prpl->name, full_date()); |
299 g_snprintf(html, sizeof(html), "<B>%s</B>", text); | |
300 break; | |
301 case log_signoff: | |
4195 | 302 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
4184 | 303 gc->username, gc->prpl->name, full_date()); |
304 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); | |
305 break; | |
306 case log_away: | |
4195 | 307 g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"), |
4184 | 308 gc->username, gc->prpl->name, full_date()); |
309 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); | |
310 break; | |
311 case log_back: | |
4195 | 312 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
4184 | 313 gc->username, gc->prpl->name, full_date()); |
314 g_snprintf(html, sizeof(html), "%s", text); | |
315 break; | |
316 case log_idle: | |
4195 | 317 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
4184 | 318 gc->username, gc->prpl->name, full_date()); |
319 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); | |
320 break; | |
321 case log_unidle: | |
4195 | 322 g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"), |
4184 | 323 gc->username, gc->prpl->name, full_date()); |
324 g_snprintf(html, sizeof(html), "%s", text); | |
325 break; | |
326 case log_quit: | |
4195 | 327 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
4184 | 328 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
329 break; | |
330 } | |
4687 | 331 } else if (gaim_get_buddy_alias_only(who)) { |
4184 | 332 switch (what) { |
333 case log_signon: | |
4195 | 334 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"), |
4687 | 335 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 336 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
337 break; | |
338 case log_signoff: | |
4195 | 339 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"), |
4687 | 340 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 341 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
342 break; | |
343 case log_away: | |
4195 | 344 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"), |
4687 | 345 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 346 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
347 break; | |
348 case log_back: | |
4195 | 349 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"), |
4687 | 350 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 351 g_snprintf(html, sizeof(html), "%s", text); |
352 break; | |
353 case log_idle: | |
4195 | 354 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"), |
4687 | 355 gc->username, gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 356 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
357 break; | |
358 case log_unidle: | |
359 g_snprintf(text, sizeof(text), | |
4195 | 360 _("%s (%s) reported that %s (%s) returned from idle @ %s"), gc->username, |
4687 | 361 gc->prpl->name, gaim_get_buddy_alias(who), who->name, full_date()); |
4184 | 362 g_snprintf(html, sizeof(html), "%s", text); |
363 break; | |
364 default: | |
365 fclose(fd); | |
366 return; | |
367 break; | |
368 } | |
369 } else { | |
370 switch (what) { | |
371 case log_signon: | |
4195 | 372 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed on @ %s"), |
4184 | 373 gc->username, gc->prpl->name, who->name, full_date()); |
374 g_snprintf(html, sizeof(html), "<B>%s</B>", text); | |
375 break; | |
376 case log_signoff: | |
4195 | 377 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed off @ %s"), |
4184 | 378 gc->username, gc->prpl->name, who->name, full_date()); |
379 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); | |
380 break; | |
381 case log_away: | |
4195 | 382 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"), |
4184 | 383 gc->username, gc->prpl->name, who->name, full_date()); |
384 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); | |
385 break; | |
386 case log_back: | |
4195 | 387 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"), |
4184 | 388 gc->username, gc->prpl->name, who->name, full_date()); |
389 g_snprintf(html, sizeof(html), "%s", text); | |
390 break; | |
391 case log_idle: | |
4195 | 392 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"), |
4184 | 393 gc->username, gc->prpl->name, who->name, full_date()); |
394 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); | |
395 break; | |
396 case log_unidle: | |
397 g_snprintf(text, sizeof(text), | |
4195 | 398 _("%s (%s) reported that %s returned from idle @ %s"), gc->username, |
4184 | 399 gc->prpl->name, who->name, full_date()); |
400 g_snprintf(html, sizeof(html), "%s", text); | |
401 break; | |
402 default: | |
403 fclose(fd); | |
404 return; | |
405 break; | |
406 } | |
407 } | |
408 | |
409 if (logging_options & OPT_LOG_STRIP_HTML) { | |
410 fprintf(fd, "---- %s ----\n", text); | |
411 } else { | |
412 if (logging_options & OPT_LOG_INDIVIDUAL) | |
413 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); | |
414 else | |
415 fprintf(fd, "%s<BR>\n", html); | |
416 } | |
417 | |
418 fclose(fd); | |
419 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
420 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
421 char *html_logize(const char *p) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
422 { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
423 const char *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
424 char *buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
425 char *buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
426 int num_cr = 0; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
427 int char_len = 0; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
428 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
429 for (temp_p = p; *temp_p != '\0'; temp_p++) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
430 char_len++; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
431 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
432 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
433 num_cr++; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
434 } |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
435 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
436 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
437 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
438 for (temp_p = p, buffer_start = buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
439 *temp_p != '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
440 temp_p++) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
441 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
442 if (*temp_p == '\n') { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
443 *buffer_p++ = '<'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
444 *buffer_p++ = 'B'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
445 *buffer_p++ = 'R'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
446 *buffer_p++ = '>'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
447 *buffer_p++ = '\n'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
448 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
449 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
450 *buffer_p++ = '&'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
451 *buffer_p++ = 'l'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 *buffer_p++ = 't'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
453 *buffer_p++ = ';'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
454 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
455 } else |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 *buffer_p++ = *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
457 } |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
458 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
459 *buffer_p = '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
460 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
461 return buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
462 } |