]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox_from_parse() now returns also the parsed timezone.
authorTimo Sirainen <tss@iki.fi>
Fri, 13 Jun 2008 00:29:40 +0000 (03:29 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 13 Jun 2008 00:29:40 +0000 (03:29 +0300)
--HG--
branch : HEAD

src/deliver/deliver.c
src/lib-mail/mbox-from.c
src/lib-mail/mbox-from.h
src/lib-storage/index/mbox/istream-raw-mbox.c

index e88fe471d57ace8aa2aa2a4c563ecd0faa000173..40ece314382286b89b734ce608042138c3265712 100644 (file)
@@ -563,7 +563,7 @@ static struct istream *create_raw_stream(int fd, time_t *mtime_r)
        const unsigned char *data;
        char *sender = NULL;
        size_t i, size;
-       int ret;
+       int ret, tz;
 
        *mtime_r = (time_t)-1;
        fd_set_nonblock(fd, FALSE);
@@ -581,7 +581,7 @@ static struct istream *create_raw_stream(int fd, time_t *mtime_r)
                                        break;
                        }
                        if (i != size) {
-                               (void)mbox_from_parse(data, i, mtime_r,
+                               (void)mbox_from_parse(data, i, mtime_r, &tz,
                                                      &sender);
                                i_stream_skip(input, i + 1);
                                break;
index 8c0d874f2cb4bc9e98464bf32fe195a01f1f1a01..3b6f268e056efff4e0fc450749511686bc9b9b01 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
+#include "ioloop.h"
 #include "str.h"
 #include "utc-mktime.h"
 #include "mbox-from.h"
@@ -50,7 +51,7 @@ static int mbox_parse_year(const unsigned char *msg, struct tm *tm)
 }
 
 int mbox_from_parse(const unsigned char *msg, size_t size,
-                   time_t *time_r, char **sender_r)
+                   time_t *time_r, int *tz_offset_r, char **sender_r)
 {
        const unsigned char *msg_start, *sender_end, *msg_end;
        struct tm tm;
@@ -229,9 +230,11 @@ int mbox_from_parse(const unsigned char *msg, size_t size,
 
                t -= timezone_secs;
                *time_r = t;
+               *tz_offset_r = timezone_secs/60;
        } else {
                /* assume local timezone */
                *time_r = mktime(&tm);
+               *tz_offset_r = -ioloop_timezone.tz_minuteswest;
        }
 
        *sender_r = i_strdup_until(msg_start, sender_end);
index e4557bb302d6d8e7d01a6b9de95406f42909328c..fbca06643dcb1e371b11c33f4a81e4490a8a5b92 100644 (file)
@@ -4,7 +4,7 @@
 /* Parse time and sender from mbox-compatible From_-line. msg points to the
    data after "From ". */
 int mbox_from_parse(const unsigned char *msg, size_t size,
-                   time_t *time_r, char **sender_r);
+                   time_t *time_r, int *tz_offset_r, char **sender_r);
 /* Return a mbox-compatible From_-line using given sender and time.
    The returned string begins with "From ". */
 const char *mbox_from_create(const char *sender, time_t timestamp);
index 97094e02c3deaf491c90fc554fa5ea53d7bdfa5e..ebbf1ce249f92292f69df0cd22e61de49b15e9a5 100644 (file)
@@ -48,7 +48,7 @@ static int mbox_read_from_line(struct raw_mbox_istream *rstream)
        char *sender;
        time_t received_time;
        size_t pos, line_pos;
-       int skip;
+       int skip, tz;
 
        buf = i_stream_get_data(rstream->istream.parent, &pos);
        i_assert(pos > 0);
@@ -76,7 +76,7 @@ static int mbox_read_from_line(struct raw_mbox_istream *rstream)
 
        /* beginning of mbox */
        if (memcmp(buf, "From ", 5) != 0 ||
-           mbox_from_parse(buf+5, pos-5, &received_time, &sender) < 0) {
+           mbox_from_parse(buf+5, pos-5, &received_time, &tz, &sender) < 0) {
                /* broken From - should happen only at beginning of
                   file if this isn't a mbox.. */
                return -1;
@@ -129,7 +129,7 @@ static ssize_t i_stream_raw_mbox_read(struct istream_private *stream)
        time_t received_time;
        size_t i, pos, new_pos, from_start_pos, from_after_pos;
        ssize_t ret = 0;
-       int eoh_char;
+       int eoh_char, tz;
        bool crlf_ending = FALSE;
 
        i_assert(stream->istream.v_offset >= rstream->from_offset);
@@ -258,7 +258,7 @@ static ssize_t i_stream_raw_mbox_read(struct istream_private *stream)
                                   See if it's a valid one. */
                                if (mbox_from_parse(buf + from_after_pos,
                                                    pos - from_after_pos,
-                                                   &received_time,
+                                                   &received_time, &tz,
                                                    &sender) == 0) {
                                        /* yep, we stop here. */
                                        rstream->next_received_time =
@@ -392,6 +392,7 @@ static int istream_raw_mbox_is_valid_from(struct raw_mbox_istream *rstream)
        size_t size;
        time_t received_time;
        char *sender;
+       int tz;
 
        /* minimal: "From x Thu Nov 29 22:33:52 2001" = 31 chars */
        (void)i_stream_read_data(rstream->istream.parent, &data, &size, 30);
@@ -418,7 +419,7 @@ static int istream_raw_mbox_is_valid_from(struct raw_mbox_istream *rstream)
                        break;
        }
 
-       if (mbox_from_parse(data, size, &received_time, &sender) < 0)
+       if (mbox_from_parse(data, size, &received_time, &tz, &sender) < 0)
                return 0;
 
        rstream->next_received_time = received_time;