parse the Delivery-date: header field if the Date: field is missing

This commit is contained in:
SJ 2012-12-03 14:21:55 +01:00
parent 47de67e4bc
commit 0ded5892db
6 changed files with 9 additions and 4 deletions

View File

@ -13,7 +13,7 @@
#define VERSION "0.1.22"
#define BUILD 734
#define BUILD 735
#define HOSTID "mailarchiver"

View File

@ -188,7 +188,7 @@ struct session_data {
float __acquire, __parsed, __av, __store, __compress, __encrypt;
char bodydigest[2*DIGEST_LENGTH+1];
char digest[2*DIGEST_LENGTH+1];
time_t now, sent, retained;
time_t now, sent, delivered, retained;
char ms_journal, ms_journal_dropped;
int journal_envelope_length, journal_bottom_length;
#ifdef NEED_MYSQL

View File

@ -67,10 +67,13 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
sdata->sent = 0;
sdata->delivered = 0;
state = parse_message(sdata, 1, cfg);
post_parse(sdata, &state, cfg);
if(sdata->sent <= 0 && sdata->delivered > 0) sdata->sent = sdata->delivered;
if(sdata->sent > sdata->now) sdata->sent = sdata->now;
if(sdata->sent == -1) sdata->sent = 0;

View File

@ -504,7 +504,7 @@ void init_session_data(struct session_data *sdata){
for(i=0; i<MAX_RCPT_TO; i++) memset(sdata->rcptto[i], 0, SMALLBUFSIZE);
time(&(sdata->now));
sdata->sent = sdata->retained = sdata->now;
sdata->sent = sdata->delivered = sdata->retained = sdata->now;
}

View File

@ -347,6 +347,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
else if(strncasecmp(buf, "Subject:", strlen("Subject:")) == 0) state->message_state = MSG_SUBJECT;
else if(strncasecmp(buf, "Recipient:", strlen("Recipient:")) == 0) state->message_state = MSG_RECIPIENT;
else if(strncasecmp(buf, "Date:", strlen("Date:")) == 0 && sdata->sent == 0) sdata->sent = parse_date_header(buf);
else if(strncasecmp(buf, "Delivery-date:", strlen("Delivery-date:")) == 0 && sdata->delivered == 0) sdata->delivered = parse_date_header(buf);
else if(strncasecmp(buf, "Received:", strlen("Received:")) == 0) state->message_state = MSG_RECEIVED;
else if(cfg->extra_to_field[0] != '\0' && strncasecmp(buf, cfg->extra_to_field, strlen(cfg->extra_to_field)) == 0) state->message_state = MSG_TO;

View File

@ -63,6 +63,7 @@ int main(int argc, char **argv){
init_session_data(&sdata);
sdata.sent = 0;
sdata.delivered = 0;
sdata.tot_len = st.st_size;
snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]);
@ -79,7 +80,7 @@ int main(int argc, char **argv){
printf("subject: *%s*\n", state.b_subject);
printf("body: *%s*\n", state.b_body);
printf("sent: %ld\n", sdata.sent);
printf("sent: %ld, delivered-date: %ld\n", sdata.sent, sdata.delivered);
make_digests(&sdata, &cfg);