dovecot-1.2: mbox_from_parse() now returns also the parsed timez...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Jun 13 03:29:50 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/d076e1758c6a
changeset: 7839:d076e1758c6a
user: Timo Sirainen <tss at iki.fi>
date: Fri Jun 13 03:29:40 2008 +0300
description:
mbox_from_parse() now returns also the parsed timezone.
diffstat:
4 files changed, 13 insertions(+), 9 deletions(-)
src/deliver/deliver.c | 4 ++--
src/lib-mail/mbox-from.c | 5 ++++-
src/lib-mail/mbox-from.h | 2 +-
src/lib-storage/index/mbox/istream-raw-mbox.c | 11 ++++++-----
diffs (121 lines):
diff -r 1b1fe3d50079 -r d076e1758c6a src/deliver/deliver.c
--- a/src/deliver/deliver.c Fri Jun 13 03:29:24 2008 +0300
+++ b/src/deliver/deliver.c Fri Jun 13 03:29:40 2008 +0300
@@ -563,7 +563,7 @@ static struct istream *create_raw_stream
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
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;
diff -r 1b1fe3d50079 -r d076e1758c6a src/lib-mail/mbox-from.c
--- a/src/lib-mail/mbox-from.c Fri Jun 13 03:29:24 2008 +0300
+++ b/src/lib-mail/mbox-from.c Fri Jun 13 03:29:40 2008 +0300
@@ -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 unsigne
}
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
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);
diff -r 1b1fe3d50079 -r d076e1758c6a src/lib-mail/mbox-from.h
--- a/src/lib-mail/mbox-from.h Fri Jun 13 03:29:24 2008 +0300
+++ b/src/lib-mail/mbox-from.h Fri Jun 13 03:29:40 2008 +0300
@@ -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);
diff -r 1b1fe3d50079 -r d076e1758c6a src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Fri Jun 13 03:29:24 2008 +0300
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Fri Jun 13 03:29:40 2008 +0300
@@ -48,7 +48,7 @@ static int mbox_read_from_line(struct ra
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 ra
/* 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(st
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(st
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_fro
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_fro
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;
More information about the dovecot-cvs
mailing list