From: Pierre Habouzit Date: Mon, 6 Nov 2006 21:46:29 +0000 (+0100) Subject: reorganize code so that the rfc822parse.c does not needs lib-crypt nor X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=8bca9860d0edd96e0087b3e47be2814474425654;ds=sidebyside reorganize code so that the rfc822parse.c does not needs lib-crypt nor mx.h --- diff --git a/lib-mime/mime.h b/lib-mime/mime.h index 91195cc..b30b42b 100644 --- a/lib-mime/mime.h +++ b/lib-mime/mime.h @@ -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_parse_multipart (FILE *, const char *, off_t, int); +BODY *mutt_parse_multipart(FILE *, const char *, off_t, int); /*** addresses ***/ diff --git a/lib-mime/rfc822parse.c b/lib-mime/rfc822parse.c index 6032132..3fd2610 100644 --- a/lib-mime/rfc822parse.c +++ b/lib-mime/rfc822parse.c @@ -39,10 +39,7 @@ #include #include -#include - #include "recvattach.h" -#include "mx.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) { - int count = 0; - char *p; - struct tm tm; - int tz_offset = 0; int zhours = 0, zminutes = 0, zoccident = 0; - const char *ptz; - char tzstr[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. */ @@ -694,6 +688,9 @@ time_t mutt_parse_date(const char *s, HEADER *h) 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)) @@ -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++; @@ -787,45 +780,11 @@ time_t mutt_parse_date(const char *s, HEADER *h) 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 ***/ -/* 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) @@ -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")) { + const char *beg, *end; + /* 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)) { diff --git a/mx.c b/mx.c index 5b48ab8..a63b28f 100644 --- a/mx.c +++ b/mx.c @@ -1423,3 +1423,27 @@ int mx_rebuild_cache (void) { 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); +}