Mercurial > pidgin
annotate src/log.c @ 4523:64d03b6a0864
[gaim-migrate @ 4801]
added gtkft.c
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Wed, 05 Feb 2003 00:40:46 +0000 |
parents | a8249a5250b6 |
children | 42d53c416bb9 |
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; | |
49 if (!g_strcasecmp(pname, normalize(l->name))) { | |
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 | |
85 static void do_save_convo(GtkObject *obj, GtkWidget *wid) | |
86 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
87 struct gaim_conversation *c = gtk_object_get_user_data(obj); |
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); | |
121 gtk_object_set_user_data(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), c); | |
122 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), | |
123 "clicked", G_CALLBACK(do_save_convo), window); | |
124 g_signal_connect_swapped(GTK_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), | |
125 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); | |
126 gtk_widget_show(window); | |
127 } | |
128 | |
129 static FILE *open_gaim_log_file(const char *name, int *flag) | |
130 { | |
131 char *buf; | |
132 char *buf2; | |
133 char log_all_file[256]; | |
134 struct stat st; | |
135 FILE *fd; | |
136 #ifndef _WIN32 | |
137 int res; | |
138 #endif | |
139 gchar *gaim_dir; | |
140 | |
141 buf = g_malloc(BUF_LONG); | |
142 buf2 = g_malloc(BUF_LONG); | |
143 gaim_dir = gaim_user_dir(); | |
144 | |
145 /* Dont log yourself */ | |
146 strncpy(log_all_file, gaim_dir, 256); | |
147 | |
148 #ifndef _WIN32 | |
149 stat(log_all_file, &st); | |
150 if (!S_ISDIR(st.st_mode)) | |
151 unlink(log_all_file); | |
152 | |
153 fd = fopen(log_all_file, "r"); | |
154 | |
155 if (!fd) { | |
156 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
157 if (res < 0) { | |
158 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
159 log_all_file); | |
160 do_error_dialog(buf, NULL, GAIM_ERROR); | |
161 g_free(buf); | |
162 g_free(buf2); | |
163 return NULL; | |
164 } | |
165 } else | |
166 fclose(fd); | |
167 | |
168 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
169 | |
170 if (stat(log_all_file, &st) < 0) | |
171 *flag = 1; | |
172 if (!S_ISDIR(st.st_mode)) | |
173 unlink(log_all_file); | |
174 | |
175 fd = fopen(log_all_file, "r"); | |
176 if (!fd) { | |
177 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
178 if (res < 0) { | |
179 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), | |
180 log_all_file); | |
181 do_error_dialog(buf, NULL, GAIM_ERROR); | |
182 g_free(buf); | |
183 g_free(buf2); | |
184 return NULL; | |
185 } | |
186 } else | |
187 fclose(fd); | |
188 #else /* _WIN32 */ | |
189 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir); | |
190 | |
191 if( _mkdir(log_all_file) < 0 && errno != EEXIST ) { | |
192 g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file); | |
193 do_error_dialog(buf, NULL, GAIM_ERROR); | |
194 g_free(buf); | |
195 g_free(buf2); | |
196 return NULL; | |
197 } | |
198 #endif | |
199 | |
200 g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", gaim_dir, name); | |
201 if (stat(log_all_file, &st) < 0) | |
202 *flag = 1; | |
203 | |
204 debug_printf("Logging to: \"%s\"\n", log_all_file); | |
205 | |
206 fd = fopen(log_all_file, "a"); | |
207 | |
208 g_free(buf); | |
209 g_free(buf2); | |
210 return fd; | |
211 } | |
212 | |
213 static FILE *open_system_log_file(char *name) | |
214 { | |
215 int x; | |
216 | |
217 if (name) | |
218 return open_log_file(name, 2); | |
219 else | |
220 return open_gaim_log_file("system", &x); | |
221 } | |
222 | |
223 FILE *open_log_file(const char *name, int is_chat) | |
224 { | |
225 struct stat st; | |
226 char realname[256]; | |
227 struct log_conversation *l; | |
228 FILE *fd; | |
229 int flag = 0; | |
230 | |
231 if (((is_chat == 2) && !(logging_options & OPT_LOG_INDIVIDUAL)) | |
232 || ((is_chat == 1) && !(logging_options & OPT_LOG_CHATS)) | |
233 || ((is_chat == 0) && !(logging_options & OPT_LOG_CONVOS))) { | |
234 | |
235 l = find_log_info(name); | |
236 if (!l) | |
237 return NULL; | |
238 | |
239 if (stat(l->filename, &st) < 0) | |
240 flag = 1; | |
241 | |
242 fd = fopen(l->filename, "a"); | |
243 | |
244 if (flag) { /* is a new file */ | |
245 if (logging_options & OPT_LOG_STRIP_HTML) { | |
246 fprintf(fd, _("IM Sessions with %s\n"), name); | |
247 } else { | |
248 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
249 fprintf(fd, _("IM Sessions with %s"), name); | |
250 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
251 } | |
252 } | |
253 | |
254 return fd; | |
255 } | |
256 | |
257 g_snprintf(realname, sizeof(realname), "%s.log", normalize(name)); | |
258 fd = open_gaim_log_file(realname, &flag); | |
259 | |
260 if (fd && flag) { /* is a new file */ | |
261 if (logging_options & OPT_LOG_STRIP_HTML) { | |
262 fprintf(fd, _("IM Sessions with %s\n"), name); | |
263 } else { | |
264 fprintf(fd, "<HTML><HEAD><TITLE>"); | |
265 fprintf(fd, _("IM Sessions with %s"), name); | |
266 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n"); | |
267 } | |
268 } | |
269 | |
270 return fd; | |
271 } | |
272 | |
273 void system_log(enum log_event what, struct gaim_connection *gc, | |
274 struct buddy *who, int why) | |
275 { | |
276 FILE *fd; | |
277 char text[256], html[256]; | |
278 | |
279 if ((logging_options & why) != why) | |
280 return; | |
281 | |
282 if (logging_options & OPT_LOG_INDIVIDUAL) { | |
283 if (why & OPT_LOG_MY_SIGNON) | |
284 fd = open_system_log_file(gc ? gc->username : NULL); | |
285 else | |
286 fd = open_system_log_file(who->name); | |
287 } else | |
288 fd = open_system_log_file(NULL); | |
289 | |
290 if (!fd) | |
291 return; | |
292 | |
293 if (why & OPT_LOG_MY_SIGNON) { | |
294 switch (what) { | |
295 case log_signon: | |
4195 | 296 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed on @ %s"), |
4184 | 297 gc->username, gc->prpl->name, full_date()); |
298 g_snprintf(html, sizeof(html), "<B>%s</B>", text); | |
299 break; | |
300 case log_signoff: | |
4195 | 301 g_snprintf(text, sizeof(text), _("+++ %s (%s) signed off @ %s"), |
4184 | 302 gc->username, gc->prpl->name, full_date()); |
303 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); | |
304 break; | |
305 case log_away: | |
4195 | 306 g_snprintf(text, sizeof(text), _("+++ %s (%s) changed away state @ %s"), |
4184 | 307 gc->username, gc->prpl->name, full_date()); |
308 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); | |
309 break; | |
310 case log_back: | |
4195 | 311 g_snprintf(text, sizeof(text), _("+++ %s (%s) came back @ %s"), |
4184 | 312 gc->username, gc->prpl->name, full_date()); |
313 g_snprintf(html, sizeof(html), "%s", text); | |
314 break; | |
315 case log_idle: | |
4195 | 316 g_snprintf(text, sizeof(text), _("+++ %s (%s) became idle @ %s"), |
4184 | 317 gc->username, gc->prpl->name, full_date()); |
318 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); | |
319 break; | |
320 case log_unidle: | |
4195 | 321 g_snprintf(text, sizeof(text), _("+++ %s (%s) returned from idle @ %s"), |
4184 | 322 gc->username, gc->prpl->name, full_date()); |
323 g_snprintf(html, sizeof(html), "%s", text); | |
324 break; | |
325 case log_quit: | |
4195 | 326 g_snprintf(text, sizeof(text), _("+++ Program exit @ %s"), full_date()); |
4184 | 327 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
328 break; | |
329 } | |
4227 | 330 } else if (get_buddy_alias_only(who)) { |
4184 | 331 switch (what) { |
332 case log_signon: | |
4195 | 333 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed on @ %s"), |
4227 | 334 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date()); |
4184 | 335 g_snprintf(html, sizeof(html), "<B>%s</B>", text); |
336 break; | |
337 case log_signoff: | |
4195 | 338 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) signed off @ %s"), |
4227 | 339 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date()); |
4184 | 340 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); |
341 break; | |
342 case log_away: | |
4195 | 343 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) went away @ %s"), |
4227 | 344 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date()); |
4184 | 345 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); |
346 break; | |
347 case log_back: | |
4195 | 348 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) came back @ %s"), |
4227 | 349 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date()); |
4184 | 350 g_snprintf(html, sizeof(html), "%s", text); |
351 break; | |
352 case log_idle: | |
4195 | 353 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s (%s) became idle @ %s"), |
4227 | 354 gc->username, gc->prpl->name, get_buddy_alias(who), who->name, full_date()); |
4184 | 355 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); |
356 break; | |
357 case log_unidle: | |
358 g_snprintf(text, sizeof(text), | |
4195 | 359 _("%s (%s) reported that %s (%s) returned from idle @ %s"), gc->username, |
4227 | 360 gc->prpl->name, get_buddy_alias(who), who->name, full_date()); |
4184 | 361 g_snprintf(html, sizeof(html), "%s", text); |
362 break; | |
363 default: | |
364 fclose(fd); | |
365 return; | |
366 break; | |
367 } | |
368 } else { | |
369 switch (what) { | |
370 case log_signon: | |
4195 | 371 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed on @ %s"), |
4184 | 372 gc->username, gc->prpl->name, who->name, full_date()); |
373 g_snprintf(html, sizeof(html), "<B>%s</B>", text); | |
374 break; | |
375 case log_signoff: | |
4195 | 376 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s signed off @ %s"), |
4184 | 377 gc->username, gc->prpl->name, who->name, full_date()); |
378 g_snprintf(html, sizeof(html), "<I><FONT COLOR=GRAY>%s</FONT></I>", text); | |
379 break; | |
380 case log_away: | |
4195 | 381 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s went away @ %s"), |
4184 | 382 gc->username, gc->prpl->name, who->name, full_date()); |
383 g_snprintf(html, sizeof(html), "<FONT COLOR=OLIVE>%s</FONT>", text); | |
384 break; | |
385 case log_back: | |
4195 | 386 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s came back @ %s"), |
4184 | 387 gc->username, gc->prpl->name, who->name, full_date()); |
388 g_snprintf(html, sizeof(html), "%s", text); | |
389 break; | |
390 case log_idle: | |
4195 | 391 g_snprintf(text, sizeof(text), _("%s (%s) reported that %s became idle @ %s"), |
4184 | 392 gc->username, gc->prpl->name, who->name, full_date()); |
393 g_snprintf(html, sizeof(html), "<FONT COLOR=GRAY>%s</FONT>", text); | |
394 break; | |
395 case log_unidle: | |
396 g_snprintf(text, sizeof(text), | |
4195 | 397 _("%s (%s) reported that %s returned from idle @ %s"), gc->username, |
4184 | 398 gc->prpl->name, who->name, full_date()); |
399 g_snprintf(html, sizeof(html), "%s", text); | |
400 break; | |
401 default: | |
402 fclose(fd); | |
403 return; | |
404 break; | |
405 } | |
406 } | |
407 | |
408 if (logging_options & OPT_LOG_STRIP_HTML) { | |
409 fprintf(fd, "---- %s ----\n", text); | |
410 } else { | |
411 if (logging_options & OPT_LOG_INDIVIDUAL) | |
412 fprintf(fd, "<HR>%s<BR><HR><BR>\n", html); | |
413 else | |
414 fprintf(fd, "%s<BR>\n", html); | |
415 } | |
416 | |
417 fclose(fd); | |
418 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
419 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
420 char *html_logize(const char *p) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
421 { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
422 const char *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
423 char *buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
424 char *buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
425 int num_cr = 0; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
426 int char_len = 0; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
427 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
428 for (temp_p = p; *temp_p != '\0'; temp_p++) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
429 char_len++; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
430 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
431 if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!'))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
432 num_cr++; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
433 } |
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 buffer_p = g_malloc(char_len + (4 * num_cr) + 1); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
436 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
437 for (temp_p = p, buffer_start = buffer_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
438 *temp_p != '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
439 temp_p++) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
440 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
441 if (*temp_p == '\n') { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
442 *buffer_p++ = '<'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
443 *buffer_p++ = 'B'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
444 *buffer_p++ = 'R'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
445 *buffer_p++ = '>'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
446 *buffer_p++ = '\n'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
447 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
448 } else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
449 *buffer_p++ = '&'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
450 *buffer_p++ = 'l'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
451 *buffer_p++ = 't'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
452 *buffer_p++ = ';'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
453 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
454 } else |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
455 *buffer_p++ = *temp_p; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
456 } |
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 *buffer_p = '\0'; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
459 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
460 return buffer_start; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4227
diff
changeset
|
461 } |