reorganize code so that the rfc822parse.c does not needs lib-crypt nor
authorPierre Habouzit <madcoder@debian.org>
Mon, 6 Nov 2006 21:46:29 +0000 (22:46 +0100)
committerPierre Habouzit <madcoder@debian.org>
Mon, 6 Nov 2006 21:46:29 +0000 (22:46 +0100)
mx.h

lib-mime/mime.h
lib-mime/rfc822parse.c
mx.c

index 91195cc..b30b42b 100644 (file)
@@ -63,7 +63,7 @@ void mutt_parse_content_type(char *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
 void mutt_parse_part(FILE *, BODY *);
 BODY *mutt_parse_messageRFC822(FILE *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
 void mutt_parse_part(FILE *, BODY *);
 BODY *mutt_parse_messageRFC822(FILE *, BODY *);
-BODY *mutt_parse_multipart (FILE *, const char *, off_t, int);
+BODY *mutt_parse_multipart(FILE *, const char *, off_t, int);
 
 /*** addresses ***/
 
 
 /*** addresses ***/
 
index 6032132..3fd2610 100644 (file)
 #include <lib-lib/buffer.h>
 #include <lib-lib/date.h>
 
 #include <lib-lib/buffer.h>
 #include <lib-lib/date.h>
 
-#include <lib-crypt/crypt.h>
-
 #include "recvattach.h"
 #include "recvattach.h"
-#include "mx.h"
 #include "url.h"
 
 #include "lib/debug.h"
 #include "url.h"
 
 #include "lib/debug.h"
@@ -673,14 +670,11 @@ static struct tz_t {
  */
 time_t mutt_parse_date(const char *s, HEADER *h)
 {
  */
 time_t mutt_parse_date(const char *s, HEADER *h)
 {
-    int count = 0;
-    char *p;
-    struct tm tm;
-    int tz_offset = 0;
     int zhours = 0, zminutes = 0, zoccident = 0;
     int zhours = 0, zminutes = 0, zoccident = 0;
-    const char *ptz;
-    char tzstr[SHORT_STRING];
     char scratch[SHORT_STRING];
     char scratch[SHORT_STRING];
+    struct tm tm;
+    int count = 0;
+    char *p;
 
     /* Don't modify our argument. Fixed-size buffer is ok here since
        the date format imposes a natural limit.  */
 
     /* Don't modify our argument. Fixed-size buffer is ok here since
        the date format imposes a natural limit.  */
@@ -694,6 +688,9 @@ time_t mutt_parse_date(const char *s, HEADER *h)
     p_clear(&tm, 1);
 
     while ((p = strtok (p, " \t")) != NULL) {
     p_clear(&tm, 1);
 
     while ((p = strtok (p, " \t")) != NULL) {
+        char tzstr[SHORT_STRING];
+        const char *ptz;
+
         switch (count) {
           case 0:                    /* day of the month */
             if (!isdigit((unsigned char)*p))
         switch (count) {
           case 0:                    /* day of the month */
             if (!isdigit((unsigned char)*p))
@@ -766,10 +763,6 @@ time_t mutt_parse_date(const char *s, HEADER *h)
                     }
                 }
             }
                     }
                 }
             }
-
-            tz_offset = zhours * 3600 + zminutes * 60;
-            if (!zoccident)
-                tz_offset = -tz_offset;
             break;
         }
         count++;
             break;
         }
         count++;
@@ -787,45 +780,11 @@ time_t mutt_parse_date(const char *s, HEADER *h)
         h->zoccident = zoccident;
     }
 
         h->zoccident = zoccident;
     }
 
-    return mutt_mktime(&tm, 0) + tz_offset;
+    return mutt_mktime(&tm, 0) + (zoccident ? 1 : -1) * (zhours * 3600 + zminutes * 60);
 }
 
 /*** XXX: MC READ MARK ***/
 
 }
 
 /*** XXX: MC READ MARK ***/
 
-/* extract the first substring that looks like a message-id */
-static char *extract_message_id(const char *s)
-{
-    const char *p;
-
-    if ((s = strchr(s, '<')) == NULL || (p = strchr(s, '>')) == NULL)
-        return NULL;
-    return p_dupstr(s, (p - s) + 1);
-}
-
-void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur)
-{
-  MESSAGE *msg;
-  int flags = 0;
-
-  do {
-    if (cur->content->type != TYPEMESSAGE
-        && cur->content->type != TYPEMULTIPART)
-      break;                     /* nothing to do */
-
-    if (cur->content->parts)
-      break;                     /* The message was parsed earlier. */
-
-    if ((msg = mx_open_message (ctx, cur->msgno))) {
-      mutt_parse_part (msg->fp, cur->content);
-
-      cur->security = crypt_query (cur->content);
-
-      mx_close_message (&msg);
-    }
-  } while (0);
-  mutt_count_body_parts (cur, flags | M_PARTS_RECOUNT);
-}
-
 int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p,
                             short user_hdrs, short weed, short do_2047,
                             LIST ** lastp)
 int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p,
                             short user_hdrs, short weed, short do_2047,
                             LIST ** lastp)
@@ -984,9 +943,13 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p,
       matched = 1;
     }
     else if (!ascii_strcasecmp (line + 1, "essage-id")) {
       matched = 1;
     }
     else if (!ascii_strcasecmp (line + 1, "essage-id")) {
+      const char *beg, *end;
+
       /* We add a new "Message-ID:" when building a message */
       p_delete(&e->message_id);
       /* We add a new "Message-ID:" when building a message */
       p_delete(&e->message_id);
-      e->message_id = extract_message_id (p);
+
+      if ((beg = strchr(p, '<')) && (end = strchr(beg, '>')))
+          e->message_id = p_dupstr(beg, (end - beg) + 1);
       matched = 1;
     }
     else if (!ascii_strncasecmp (line + 1, "ail-", 4)) {
       matched = 1;
     }
     else if (!ascii_strncasecmp (line + 1, "ail-", 4)) {
diff --git a/mx.c b/mx.c
index 5b48ab8..a63b28f 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1423,3 +1423,27 @@ int mx_rebuild_cache (void) {
   return (0);
 #endif
 }
   return (0);
 #endif
 }
+
+void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur)
+{
+  MESSAGE *msg;
+  int flags = 0;
+
+  do {
+    if (cur->content->type != TYPEMESSAGE
+        && cur->content->type != TYPEMULTIPART)
+      break;                     /* nothing to do */
+
+    if (cur->content->parts)
+      break;                     /* The message was parsed earlier. */
+
+    if ((msg = mx_open_message (ctx, cur->msgno))) {
+      mutt_parse_part (msg->fp, cur->content);
+
+      cur->security = crypt_query (cur->content);
+
+      mx_close_message (&msg);
+    }
+  } while (0);
+  mutt_count_body_parts (cur, flags | M_PARTS_RECOUNT);
+}