Rocco Rutte:
[apps/madmutt.git] / parse.c
diff --git a/parse.c b/parse.c
index bd0772a..ea5c9b8 100644 (file)
--- a/parse.c
+++ b/parse.c
 #endif
 
 #include "mutt.h"
+#include "buffer.h"
+#include "enter.h"
+#include "ascii.h"
+#include "recvattach.h"
 #include "mx.h"
 #include "mime.h"
 #include "rfc2047.h"
@@ -34,7 +38,7 @@
  * lines.  ``line'' must point to a dynamically allocated string; it is
  * increased if more space is required to fit the whole line.
  */
-static char *read_rfc822_line (FILE * f, char *line, size_t * linelen)
+char *mutt_read_rfc822_line (FILE * f, char *line, size_t * linelen)
 {
   char *buf = line;
   char ch;
@@ -421,7 +425,7 @@ BODY *mutt_read_mime_header (FILE * fp, int digest)
   p->type = digest ? TYPEMESSAGE : TYPETEXT;
   p->disposition = DISPINLINE;
 
-  while (*(line = read_rfc822_line (fp, line, &linelen)) != 0) {
+  while (*(line = mutt_read_rfc822_line (fp, line, &linelen)) != 0) {
     /* Find the value of the current header */
     if ((c = strchr (line, ':'))) {
       *c = 0;
@@ -1030,7 +1034,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p,
        * bothered me for _years_ */
       if (!e->from) {
         e->from = rfc822_new_address ();
-        e->from->personal = str_dup (line + 6);
+        e->from->personal = str_dup (p);
       }
       matched = 1;
     }
@@ -1316,7 +1320,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs,
   }
 
   while ((loc = ftell (f)),
-         *(line = read_rfc822_line (f, line, &linelen)) != 0) {
+         *(line = mutt_read_rfc822_line (f, line, &linelen)) != 0) {
     matched = 0;
 
     if ((p = strpbrk (line, ": \t")) == NULL || *p != ':') {
@@ -1389,31 +1393,11 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs,
   if (hdr) {
     hdr->content->hdr_offset = hdr->offset;
     hdr->content->offset = ftell (f);
-
-    /* do RFC2047 decoding */
-    rfc2047_decode_adrlist (e->from);
-    rfc2047_decode_adrlist (e->to);
-    rfc2047_decode_adrlist (e->cc);
-    rfc2047_decode_adrlist (e->bcc);
-    rfc2047_decode_adrlist (e->reply_to);
-    rfc2047_decode_adrlist (e->mail_followup_to);
-    rfc2047_decode_adrlist (e->return_path);
-    rfc2047_decode_adrlist (e->sender);
-
-    if (e->subject) {
-      regmatch_t pmatch[1];
-
-      rfc2047_decode (&e->subject);
-
-      if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0)
-        e->real_subj = e->subject + pmatch[0].rm_eo;
-      else
-        e->real_subj = e->subject;
-    }
-
+    rfc2047_decode_envelope (e);
     /* check for missing or invalid date */
     if (hdr->date_sent <= 0) {
-      debug_print (1, ("no date found, using received time from msg separator\n"));
+      debug_print (1, ("no date found, using received "
+                       "time from msg separator\n"));
       hdr->date_sent = hdr->received;
     }
   }