From 3cab1cbc71019baa5a1e659b5294a013fed0c40d Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Sun, 15 Nov 1998 09:42:00 +0000 Subject: [PATCH] My version of Byrial's parse_part patch. --- attach.c | 9 +++------ parse.c | 50 +++++++++++++++++++++++++++----------------------- protos.h | 1 + 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/attach.c b/attach.c index b9145ac73..c2b72aa1d 100644 --- a/attach.c +++ b/attach.c @@ -745,12 +745,9 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path, m->length = st.st_size; m->encoding = ENC8BIT; m->offset = 0; - if (mutt_is_message_type(m->type, m->subtype)) - { - saved_parts = m->parts; - saved_hdr = m->hdr; - m->parts = mutt_parse_messageRFC822 (s.fpin, m); - } + saved_parts = m->parts; + saved_hdr = m->hdr; + mutt_parse_part (s.fpin, m); } else s.fpin = fp; diff --git a/parse.c b/parse.c index cf664e250..cec757146 100644 --- a/parse.c +++ b/parse.c @@ -406,6 +406,30 @@ BODY *mutt_read_mime_header (FILE *fp, int digest) return (p); } +void mutt_parse_part (FILE *fp, BODY *b) +{ + switch (b->type) + { + case TYPEMULTIPART: + fseek (fp, b->offset, SEEK_SET); + b->parts = mutt_parse_multipart (fp, mutt_get_parameter ("boundary", b->parameter), + b->offset + b->length, + mutt_strcasecmp ("digest", b->subtype) == 0); + break; + + case TYPEMESSAGE: + if (b->subtype) + { + fseek (fp, b->offset, SEEK_SET); + if (mutt_is_message_type(b)) + b->parts = mutt_parse_messageRFC822 (fp, b); + else if (mutt_strcasecmp (b->subtype, "external-body") == 0) + b->parts = mutt_read_mime_header (fp, 0); + } + break; + } +} + /* parse a MESSAGE/RFC822 body * * args: @@ -544,29 +568,9 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di last->length = end_off - last->offset; /* parse recursive MIME parts */ - for (last = head; last; last = last->next) - { - switch (last->type) - { - case TYPEMULTIPART: - fseek (fp, last->offset, 0); - last->parts = mutt_parse_multipart (fp, mutt_get_parameter ("boundary", last->parameter), last->offset + last->length, mutt_strcasecmp ("digest", last->subtype) == 0); - break; - - case TYPEMESSAGE: - if (last->subtype) - { - fseek (fp, last->offset, SEEK_SET); - if (mutt_strcasecmp (last->subtype, "rfc822") == 0 || - mutt_strcasecmp (last->subtype, "news") == 0) - last->parts = mutt_parse_messageRFC822 (fp, last); - else if (mutt_strcasecmp (last->subtype, "external-body") == 0) - last->parts = mutt_read_mime_header (fp, 0); - } - break; - } - } - + for(last = head; last; last = last->next) + mutt_parse_part(fp, last); + return (head); } diff --git a/protos.h b/protos.h index dc8cf3146..54d7bc647 100644 --- a/protos.h +++ b/protos.h @@ -166,6 +166,7 @@ void mutt_mktemp (char *); void mutt_nocurses_error (const char *, ...); void mutt_normalize_time (struct tm *); void mutt_parse_mime_message (CONTEXT *ctx, HEADER *); +void mutt_parse_part (FILE *, BODY *); void mutt_pipe_message_to_state (HEADER *, STATE *); void mutt_perror (const char *); void mutt_prepare_envelope (ENVELOPE *); -- 2.40.0