Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/hbuf.c @ 1486:f83a51eaa5ed
Fix multiline output in /buffer save
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 20 Apr 2008 16:56:43 +0200 |
parents | 0121b6f3047c |
children | f61ed2466f7c |
comparison
equal
deleted
inserted
replaced
1485:0121b6f3047c | 1486:f83a51eaa5ed |
---|---|
422 void hbuf_dump_to_file(GList *hbuf, const char *filename) | 422 void hbuf_dump_to_file(GList *hbuf, const char *filename) |
423 { | 423 { |
424 hbuf_block *blk; | 424 hbuf_block *blk; |
425 hbb_line line; | 425 hbb_line line; |
426 guint last_persist_prefixflags; | 426 guint last_persist_prefixflags; |
427 guint prefixwidth; | |
427 char pref[96]; | 428 char pref[96]; |
428 FILE *fp; | 429 FILE *fp; |
429 struct stat statbuf; | 430 struct stat statbuf; |
430 | 431 |
431 if (!stat(filename, &statbuf)) { | 432 if (!stat(filename, &statbuf)) { |
435 fp = fopen(filename, "w"); | 436 fp = fopen(filename, "w"); |
436 if (!fp) { | 437 if (!fp) { |
437 scr_LogPrint(LPRINT_NORMAL, "Unable to open the file."); | 438 scr_LogPrint(LPRINT_NORMAL, "Unable to open the file."); |
438 return; | 439 return; |
439 } | 440 } |
441 | |
442 prefixwidth = getprefixwidth(); | |
443 prefixwidth = MIN(prefixwidth, sizeof pref); | |
440 | 444 |
441 for (hbuf = g_list_first(hbuf); hbuf; hbuf = g_list_next(hbuf)) { | 445 for (hbuf = g_list_first(hbuf); hbuf; hbuf = g_list_next(hbuf)) { |
442 int maxlen; | 446 int maxlen; |
443 | 447 |
444 blk = (hbuf_block*)(hbuf->data); | 448 blk = (hbuf_block*)(hbuf->data); |
460 // Continuation of a message - omit the prefix | 464 // Continuation of a message - omit the prefix |
461 line.flags |= HBB_PREFIX_CONT; | 465 line.flags |= HBB_PREFIX_CONT; |
462 line.mucnicklen = 0; // The nick is in the first one | 466 line.mucnicklen = 0; // The nick is in the first one |
463 } | 467 } |
464 | 468 |
465 scr_line_prefix(&line, pref, sizeof pref); | 469 scr_line_prefix(&line, pref, prefixwidth); |
466 fprintf(fp, "%s%s\n", pref, line.text); | 470 fprintf(fp, "%s%s\n", pref, line.text); |
467 } | 471 } |
468 | 472 |
469 fclose(fp); | 473 fclose(fp); |
470 return; | 474 return; |