Make a copy of a message from a FILE pointer.
651{
653 char prefix[128] = { 0 };
654 LOFF_T new_offset = -1;
655 int rc = 0;
656
658 {
660 if (c_text_flowed)
661 {
663 }
664 else
665 {
669 setlocale(LC_TIME,
NONULL(c_attribution_locale));
672 setlocale(LC_TIME, "");
673 }
674 }
675
677 {
679 {
681 }
683 {
684 int new_lines;
685 int rc_attach_del = -1;
686 LOFF_T new_length = body->
length;
687 struct Buffer *quoted_date = NULL;
688
693
694
696 {
697 goto attach_del_cleanup;
698 }
700 if (del == -1)
701 {
702 goto attach_del_cleanup;
703 }
704 new_lines = e->
lines - del;
705
706
708 goto attach_del_cleanup;
709 fprintf(fp_out, "Content-Length: " OFF_T_FMT "\n", new_length);
710 if (new_lines <= 0)
711 new_lines = 0;
712 else
713 fprintf(fp_out, "Lines: %d\n", new_lines);
714
715 putc('\n', fp_out);
716 if (ferror(fp_out) || feof(fp_out))
717 goto attach_del_cleanup;
718 new_offset = ftello(fp_out);
719
720
722 goto attach_del_cleanup;
724 goto attach_del_cleanup;
725
727
728 LOFF_T fail = ((ftello(fp_out) - new_offset) - new_length);
729 if (fail)
730 {
731 mutt_error(ngettext(
"The length calculation was wrong by %ld byte",
732 "The length calculation was wrong by %ld bytes", fail),
733 fail);
734 new_length += fail;
735 }
736
737
739 {
741 e->
lines = new_lines;
742 body->
offset = new_offset;
743
744 body->
length = new_length;
746 }
747
748 rc_attach_del = 0;
749
750 attach_del_cleanup:
752 return rc_attach_del;
753 }
754
756 (chflags &
CH_PREFIX) ? prefix : NULL, wraplen) == -1)
757 {
758 return -1;
759 }
760
761 new_offset = ftello(fp_out);
762 }
763
765 {
766
767 struct State state = { 0 };
773 {
777 if (!c_pager)
779 }
788
791
793 }
795 {
796 struct Body *cur = NULL;
797 FILE *fp = NULL;
798
801 {
803 return -1;
804 fputs("MIME-Version: 1.0\n", fp_out);
805 }
806
809 {
811 return -1;
812 }
813
814 if (!cur)
815 {
816 mutt_error(
_(
"No decryption engine available for message"));
817 return -1;
818 }
819
821 fputc('\n', fp_out);
822
824 return -1;
826 {
829 return -1;
830 }
833 }
834 else
835 {
837 return -1;
839 {
840 int c;
841 size_t bytes = body->
length;
842
843 fputs(prefix, fp_out);
844
845 while (((c = fgetc(fp_in)) != EOF) && bytes--)
846 {
847 fputc(c, fp_out);
848 if (c == '\n')
849 {
850 fputs(prefix, fp_out);
851 }
852 }
853 }
855 {
856 return -1;
857 }
858 }
859
861 (new_offset != -1))
862 {
863 body->
offset = new_offset;
865 }
866
867 return rc;
868}
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out, CopyHeaderFlags chflags, const char *prefix, int wraplen)
Copy Email header.
static int count_delete_lines(FILE *fp, struct Body *b, LOFF_T *length, size_t datelen)
Count lines to be deleted in this email body.
static int copy_delete_attach(struct Body *b, FILE *fp_in, FILE *fp_out, const char *quoted_date)
Copy a message, deleting marked attachments.
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
#define MUTT_CM_REPLYING
Replying the message.
#define MUTT_CM_PREFIX
Quote the header and body.
#define MUTT_CM_UPDATE
Update structs on sync.
#define MUTT_CM_VERIFY
Do signature verification.
#define MUTT_CM_DECODE_PGP
Used for decoding PGP messages.
#define MUTT_CM_DECODE
Decode the message body into text/plain.
#define MUTT_CM_CHARCONV
Perform character set conversions.
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
#define MUTT_CM_PRINTING
Printing the message - display light.
#define MUTT_CM_DECODE_CRYPT
#define MUTT_CM_NOHEADER
Don't copy the message header.
#define MUTT_CM_DISPLAY
Output is displayed to the user.
int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Wrapper for CryptModuleSpecs::decrypt_mime()
int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Wrapper for CryptModuleSpecs::decrypt_mime()
void mutt_body_free(struct Body **ptr)
Free a Body.
int mutt_file_copy_bytes(FILE *fp_in, FILE *fp_out, size_t size)
Copy some content from one file to another.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
int mutt_body_handler(struct Body *b, struct State *state)
Handler for the Body of an email.
void mutt_make_string(char *buf, size_t buflen, int cols, const char *s, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
@ TYPE_MULTIPART
Type: 'multipart/*'.
@ TYPE_APPLICATION
Type: 'application/*'.
void mutt_date_make_date(struct Buffer *buf, bool local)
Write a date in RFC822 format to a buffer.
#define STATE_PAGER
Output will be displayed in the Pager.
#define STATE_WEED
Weed headers even when not in display mode.
#define STATE_DISPLAY
Output is displayed to the user.
#define STATE_REPLYING
Are we replying?
#define STATE_VERIFY
Perform signature verification.
#define STATE_CHARCONV
Do character set conversions.
#define STATE_PRINTING
Are we printing? - STATE_DISPLAY "light".
#define APPLICATION_PGP
Use PGP to encrypt/sign.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
#define SEC_ENCRYPT
Email is encrypted.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
struct Body * parts
parts of a multipart or message/rfc822
unsigned int type
content-type primary type, ContentType
String manipulation buffer.
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
bool attach_del
Has an attachment marked for deletion.
Keep track when processing files.
int wraplen
Width to wrap lines to (when flags & STATE_DISPLAY)
StateFlags flags
Flags, e.g. STATE_DISPLAY.
FILE * fp_out
File to write to.
char * prefix
String to add to the beginning of each output line.
FILE * fp_in
File to read from.