(_mh_message_save): Allow for mh-specific delimiter (a string of dashes) between…
… the headers and the body.
Showing
1 changed file
with
26 additions
and
5 deletions
... | @@ -488,6 +488,19 @@ _mh_tempfile(struct _mh_data *mhd, char **namep) | ... | @@ -488,6 +488,19 @@ _mh_tempfile(struct _mh_data *mhd, char **namep) |
488 | } | 488 | } |
489 | 489 | ||
490 | static int | 490 | static int |
491 | _mh_delim (char *str) | ||
492 | { | ||
493 | if (str[0] == '-') | ||
494 | { | ||
495 | for (; *str == '-'; str++) | ||
496 | ; | ||
497 | for (; *str == ' ' || *str == '\t'; str++) | ||
498 | ; | ||
499 | } | ||
500 | return str[0] == '\n'; | ||
501 | } | ||
502 | |||
503 | static int | ||
491 | _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) | 504 | _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) |
492 | { | 505 | { |
493 | stream_t stream = NULL; | 506 | stream_t stream = NULL; |
... | @@ -540,7 +553,7 @@ _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) | ... | @@ -540,7 +553,7 @@ _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) |
540 | while ((status = stream_readline (stream, buf, bsize, off, &n)) == 0 | 553 | while ((status = stream_readline (stream, buf, bsize, off, &n)) == 0 |
541 | && n != 0) | 554 | && n != 0) |
542 | { | 555 | { |
543 | if (buf[0] == '\n') | 556 | if (_mh_delim(buf)) |
544 | break; | 557 | break; |
545 | 558 | ||
546 | nlines++; | 559 | nlines++; |
... | @@ -559,9 +572,12 @@ _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) | ... | @@ -559,9 +572,12 @@ _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) |
559 | 572 | ||
560 | /* Add imapbase */ | 573 | /* Add imapbase */ |
561 | if (!mhd->msg_head || (mhd->msg_head == mhm)) /*FIXME*/ | 574 | if (!mhd->msg_head || (mhd->msg_head == mhm)) /*FIXME*/ |
562 | fprintf (fp, "X-IMAPbase: %lu %u\n", | 575 | { |
563 | (unsigned long) mhd->uidvalidity, (unsigned) _mh_next_seq(mhd)); | 576 | fprintf (fp, "X-IMAPbase: %lu %u\n", |
564 | 577 | (unsigned long) mhd->uidvalidity, (unsigned) _mh_next_seq(mhd)); | |
578 | nlines++; | ||
579 | } | ||
580 | |||
565 | message_get_envelope (msg, &env); | 581 | message_get_envelope (msg, &env); |
566 | if (envelope_date (env, buffer, sizeof buffer, &n) == 0 && n > 0) | 582 | if (envelope_date (env, buffer, sizeof buffer, &n) == 0 && n > 0) |
567 | { | 583 | { |
... | @@ -570,16 +586,21 @@ _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) | ... | @@ -570,16 +586,21 @@ _mh_message_save (struct _mh_data *mhd, struct _mh_message *mhm, int expunge) |
570 | while (isspace (*p)) | 586 | while (isspace (*p)) |
571 | p++; | 587 | p++; |
572 | fprintf (fp, "%s: %s", MH_ENV_DATE_HEADER, p); | 588 | fprintf (fp, "%s: %s", MH_ENV_DATE_HEADER, p); |
589 | nlines++; | ||
573 | } | 590 | } |
574 | 591 | ||
575 | if (envelope_sender (env, buffer, sizeof buffer, &n) == 0 && n > 0) | 592 | if (envelope_sender (env, buffer, sizeof buffer, &n) == 0 && n > 0) |
576 | fprintf (fp, "%s: %s\n", MH_ENV_SENDER_HEADER, buffer); | 593 | { |
594 | fprintf (fp, "%s: %s\n", MH_ENV_SENDER_HEADER, buffer); | ||
595 | nlines++; | ||
596 | } | ||
577 | 597 | ||
578 | /* Add status */ | 598 | /* Add status */ |
579 | message_get_attribute (msg, &attr); | 599 | message_get_attribute (msg, &attr); |
580 | attribute_to_string (attr, buf, bsize, &n); | 600 | attribute_to_string (attr, buf, bsize, &n); |
581 | fprintf (fp, "%s", buf); | 601 | fprintf (fp, "%s", buf); |
582 | fprintf (fp, "\n"); | 602 | fprintf (fp, "\n"); |
603 | nlines += 2; | ||
583 | 604 | ||
584 | /* Copy message body */ | 605 | /* Copy message body */ |
585 | 606 | ... | ... |
-
Please register or sign in to post a comment