]> granicus.if.org Git - neomutt/commitdiff
My version of Byrial's parse_part patch.
authorThomas Roessler <roessler@does-not-exist.org>
Sun, 15 Nov 1998 09:42:00 +0000 (09:42 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sun, 15 Nov 1998 09:42:00 +0000 (09:42 +0000)
attach.c
parse.c
protos.h

index b9145ac732535e505d7360ba329cc54fd9e06ecb..c2b72aa1d58b4d37a793a81b0f51997060555bd5 100644 (file)
--- 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 cf664e2505bccff626b39165c28678ecd48ff235..cec757146674f23ef7e5482dc73d5416d0d12415 100644 (file)
--- 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);
 }
 
index dc8cf314675f0e5c07e087e7fc0e90797880d2b8..54d7bc6478a20c99c23f99d60a744dfd4288b3b4 100644 (file)
--- 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 *);