Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
9bb7be19
...
9bb7be1916bab7ef490980694e2bfc7a6898c52a
authored
2001-02-07 06:50:17 +0000
by
Alain Magloire
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Put more headers in the cache, (ugly).
1 parent
419da3f7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
377 additions
and
110 deletions
mailbox/attribute.c
mailbox/body.c
mailbox/header.c
mailbox/mbx_mbox.c
mailbox/mbx_mboxscan.c
mailbox/message.c
mailbox/attribute.c
View file @
9bb7be1
...
...
@@ -67,6 +67,14 @@ attribute_is_modified (attribute_t attr)
}
int
attribute_clear_modified
(
attribute_t
attr
)
{
if
(
attr
)
attr
->
flags
&=
~
MU_ATTRIBUTE_MODIFIED
;
return
0
;
}
int
attribute_get_flags
(
attribute_t
attr
,
int
*
pflags
)
{
if
(
attr
==
NULL
)
...
...
mailbox/body.c
View file @
9bb7be1
...
...
@@ -76,6 +76,22 @@ body_get_owner (body_t body)
return
(
body
)
?
body
->
owner
:
NULL
;
}
/* FIXME: not implemented. */
int
body_is_modified
(
body_t
body
)
{
(
void
)
body
;
return
0
;
}
/* FIXME: not implemented. */
int
body_clear_modified
(
body_t
body
)
{
(
void
)
body
;
return
0
;
}
int
body_get_filename
(
body_t
body
,
char
*
filename
,
size_t
len
,
size_t
*
pn
)
{
...
...
mailbox/header.c
View file @
9bb7be1
...
...
@@ -97,6 +97,14 @@ header_is_modified (header_t header)
return
(
header
)
?
(
header
->
flags
&
HEADER_MODIFIED
)
:
0
;
}
int
header_clear_modified
(
header_t
header
)
{
if
(
header
)
header
->
flags
&=
~
HEADER_MODIFIED
;
return
0
;
}
/* Parsing is done in a rather simple fashion, meaning we just consider an
entry to be a field-name an a field-value. So they maybe duplicate of
field-name like "Received" they are just put in the array, see _get_value()
...
...
mailbox/mbx_mbox.c
View file @
9bb7be1
...
...
@@ -58,28 +58,42 @@ struct _mbox_data;
typedef
struct
_mbox_data
*
mbox_data_t
;
typedef
struct
_mbox_message
*
mbox_message_t
;
/* These represent the header field-name that we are caching for speed. */
#define HDRSIZE 9
/* Below are the headers field-names that we are caching for speed, it is
more or less the list of headers in ENVELOPE command from IMAP. */
#define HDRSIZE 15
const
char
*
fhdr_table
[]
=
{
#define HFROM 0
"From"
,
#define HTO 1
"To"
,
#define HCC 2
#define H_BCC 0
"Bcc"
,
#define H_CC 1
"Cc"
,
#define HSUBJECT 3
"Subject"
,
#define HDATE 4
"Date"
,
#define HX_IMAPBASE 5
"X-IMAPbase"
,
#define HX_UIDL 6
"X-UIDL"
,
#define HX_UID 7
"X-UID"
,
#define HCONTENT_TYPE 8
#define H_CONTENT_LANGUAGE 2
"Content-Language"
,
#define H_CONTENT_TRANSFER_ENCODING 3
"Content-Transfer-Encoding"
,
#define H_CONTENT_TYPE 4
"Content-Type"
,
#define H_DATE 5
"Date"
,
#define H_FROM 6
"From"
,
#define H_IN_REPLY_TO 7
"In-Reply-To"
,
#define H_MESSAGE_ID 8
"Message-ID"
,
#define H_REFERENCE 9
"Reply-To"
,
#define H_REPLY_TO 10
"Reply-To"
,
#define H_SENDER 11
"Sender"
,
#define H_SUBJECT 12
"Subject"
,
#define H_TO 13
"To"
,
#define H_X_UIDL 14
"X-UIDL"
};
/* Keep the positions of where the headers and bodies start and end.
...
...
@@ -146,6 +160,7 @@ struct _mbox_data
static
int
mbox_open
__P
((
mailbox_t
,
int
));
static
int
mbox_close
__P
((
mailbox_t
));
static
int
mbox_get_message
__P
((
mailbox_t
,
size_t
,
message_t
*
));
//static int mbox_get_message_by_uid __P ((mailbox_t, size_t, message_t *));
static
int
mbox_append_message
__P
((
mailbox_t
,
message_t
));
static
int
mbox_messages_count
__P
((
mailbox_t
,
size_t
*
));
static
int
mbox_messages_recent
__P
((
mailbox_t
,
size_t
*
));
...
...
@@ -637,8 +652,23 @@ mbox_expunge (mailbox_t mailbox)
continue
;
}
if
(
mum
->
message
)
/* Do the expensive mbox_append_message0() only if mark dirty. */
if
((
mum
->
attr_flags
&
MU_ATTRIBUTE_MODIFIED
)
||
(
mum
->
message
&&
message_is_modified
(
mum
->
message
)))
{
/* The message was not instanciated, probably the dirty flag was
set by mbox_scan(), create one here. */
if
(
mum
->
message
==
0
)
{
message_t
msg
;
status
=
mbox_get_message
(
mailbox
,
i
,
&
msg
);
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"Error expunge:%d: %s"
,
__LINE__
,
strerror
(
status
));
goto
bailout0
;
}
}
status
=
mbox_append_message0
(
tmpmailbox
,
mum
->
message
,
&
total
,
1
,
(
i
==
save_imapbase
));
if
(
status
!=
0
)
...
...
@@ -647,6 +677,9 @@ mbox_expunge (mailbox_t mailbox)
strerror
(
status
));
goto
bailout0
;
}
/* Clear the dirty bit. */
mum
->
attr_flags
&=
~
MU_ATTRIBUTE_MODIFIED
;
message_clear_modified
(
mum
->
message
);
}
else
{
...
...
@@ -811,12 +844,24 @@ mbox_expunge (mailbox_t mailbox)
}
else
{
for
(
i
=
0
;
i
<
HDRSIZE
;
i
++
)
if
(
mum
->
fhdr
[
i
])
{
free
(
mum
->
fhdr
[
i
]);
mum
->
fhdr
[
i
]
=
NULL
;
}
memset
(
mum
,
0
,
sizeof
(
*
mum
));
}
}
mum
->
header_from
=
mum
->
header_from_end
=
0
;
mum
->
body
=
mum
->
body_end
=
0
;
mum
->
header_lines
=
mum
->
body_lines
=
0
;
for
(
i
=
0
;
i
<
HDRSIZE
;
i
++
)
if
(
mum
->
fhdr
[
i
])
{
free
(
mum
->
fhdr
[
i
]);
mum
->
fhdr
[
i
]
=
NULL
;
}
}
monitor_unlock
(
mailbox
->
monitor
);
/* This is should reset the messages_count, the last argument 0 means
...
...
@@ -1387,7 +1432,7 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
*
s
;
size_t
len
=
0
;
envelope_t
envelope
;
envelope_t
envelope
=
NULL
;
message_get_envelope
(
msg
,
&
envelope
);
status
=
envelope_sender
(
envelope
,
mud
->
sender
,
128
,
&
len
);
if
(
status
!=
0
)
...
...
@@ -1414,7 +1459,7 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
*
s
;
size_t
len
=
0
;
envelope_t
envelope
;
envelope_t
envelope
=
NULL
;
char
buffer
[
1024
];
message_get_envelope
(
msg
,
&
envelope
);
status
=
envelope_date
(
envelope
,
mud
->
date
,
128
,
&
len
);
...
...
@@ -1464,8 +1509,8 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
buffer
[
1024
];
size_t
nread
=
0
;
stream_t
is
;
header_t
header
;
stream_t
is
=
NULL
;
header_t
header
=
NULL
;
message_get_header
(
msg
,
&
header
);
header_get_stream
(
header
,
&
is
);
do
...
...
@@ -1572,8 +1617,8 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
{
char
buffer
[
1024
];
size_t
nread
=
0
;
stream_t
is
;
body_t
body
;
stream_t
is
=
NULL
;
body_t
body
=
NULL
;
message_get_body
(
msg
,
&
body
);
body_get_stream
(
body
,
&
is
);
do
...
...
@@ -1616,7 +1661,7 @@ mbox_append_message0 (mailbox_t mailbox, message_t msg, off_t *psize,
/* Append the Message. */
char
buffer
[
1024
];
size_t
nread
=
0
;
stream_t
is
;
stream_t
is
=
NULL
;
message_get_stream
(
msg
,
&
is
);
do
{
...
...
mailbox/mbx_mboxscan.c
View file @
9bb7be1
...
...
@@ -162,6 +162,64 @@ do \
} \
} while (0)
#define ISBCC(buf) (\
(buf[0] == 'B' || buf[0] == 'b') \
&& (buf[1] == 'C' || buf[1] == 'c') \
&& (buf[2] == 'C' || buf[2] == 'c') \
&& (buf[3] == ':' || buf[3] == ' ' || buf[3] == '\t'))
#define ISCC(buf) (\
(buf[0] == 'C' || buf[0] == 'c') \
&& (buf[1] == 'C' || buf[1] == 'c') \
&& (buf[2] == ':' || buf[2] == ' ' || buf[2] == '\t'))
#define ISCONTENT_LANGUAGE(buf) (\
(buf[0] == 'C' || buf[0] == 'c') \
&& (buf[1] == 'O' || buf[1] == 'o') \
&& (buf[2] == 'N' || buf[2] == 'n') \
&& (buf[3] == 'T' || buf[3] == 't') \
&& (buf[4] == 'E' || buf[4] == 'e') \
&& (buf[5] == 'N' || buf[5] == 'n') \
&& (buf[6] == 'T' || buf[6] == 't') \
&& (buf[7] == '-') \
&& (buf[8] == 'L' || buf[8] == 'l') \
&& (buf[9] == 'A' || buf[9] == 'a') \
&& (buf[10] == 'N' || buf[10] == 'n') \
&& (buf[11] == 'G' || buf[11] == 'g') \
&& (buf[12] == 'U' || buf[12] == 'u') \
&& (buf[13] == 'A' || buf[13] == 'a') \
&& (buf[14] == 'G' || buf[14] == 'g') \
&& (buf[15] == 'E' || buf[15] == 'e') \
&& (buf[16] == ':' || buf[16] == ' ' || buf[16] == '\t'))
#define ISCONTENT_TRANSFER_ENCODING(buf) (\
(buf[0] == 'C' || buf[0] == 'c') \
&& (buf[1] == 'O' || buf[1] == 'o') \
&& (buf[2] == 'N' || buf[2] == 'n') \
&& (buf[3] == 'T' || buf[3] == 't') \
&& (buf[4] == 'E' || buf[4] == 'e') \
&& (buf[5] == 'N' || buf[5] == 'n') \
&& (buf[6] == 'T' || buf[6] == 't') \
&& (buf[7] == '-') \
&& (buf[8] == 'T' || buf[8] == 't') \
&& (buf[9] == 'R' || buf[9] == 'r') \
&& (buf[10] == 'A' || buf[10] == 'a') \
&& (buf[11] == 'N' || buf[11] == 'n') \
&& (buf[12] == 'S' || buf[12] == 's') \
&& (buf[13] == 'F' || buf[13] == 'f') \
&& (buf[14] == 'E' || buf[14] == 'e') \
&& (buf[15] == 'R' || buf[15] == 'r') \
&& (buf[16] == '-') \
&& (buf[17] == 'E' || buf[17] == 'e') \
&& (buf[18] == 'N' || buf[18] == 'n') \
&& (buf[19] == 'C' || buf[19] == 'c') \
&& (buf[20] == 'O' || buf[20] == 'o') \
&& (buf[21] == 'D' || buf[21] == 'd') \
&& (buf[22] == 'I' || buf[22] == 'i') \
&& (buf[23] == 'N' || buf[23] == 'n') \
&& (buf[24] == 'G' || buf[24] == 'g') \
&& (buf[25] == ':' || buf[25] == ' ' || buf[25] == '\t'))
#define ISCONTENT_TYPE(buf) (\
(buf[0] == 'C' || buf[0] == 'c') \
&& (buf[1] == 'O' || buf[1] == 'o') \
...
...
@@ -177,11 +235,6 @@ do \
&& (buf[11] == 'E' || buf[11] == 'e') \
&& (buf[12] == ':' || buf[12] == ' ' || buf[12] == '\t'))
#define ISCC(buf) (\
(buf[0] == 'C' || buf[0] == 'c') \
&& (buf[1] == 'C' || buf[1] == 'c') \
&& (buf[2] == ':' || buf[2] == ' ' || buf[2] == '\t'))
#define ISDATE(buf) (\
(buf[0] == 'D' || buf[0] == 'd') \
&& (buf[1] == 'A' || buf[1] == 'a') \
...
...
@@ -196,6 +249,65 @@ do \
&& (buf[3] == 'M' || buf[3] == 'm') \
&& (buf[4] == ':' || buf[4] == ' ' || buf[4] == '\t'))
#define ISIN_REPLY_TO(buf) (\
(buf[0] == 'I' || buf[0] == 'i') \
&& (buf[1] == 'N' || buf[1] == 'n') \
&& (buf[2] == '-' || buf[2] == '-') \
&& (buf[3] == 'R' || buf[3] == 'r') \
&& (buf[4] == 'E' || buf[4] == 'e') \
&& (buf[5] == 'P' || buf[5] == 'p') \
&& (buf[6] == 'L' || buf[6] == 'l') \
&& (buf[7] == 'Y' || buf[7] == 'y') \
&& (buf[8] == '-') \
&& (buf[9] == 'T' || buf[9] == 't') \
&& (buf[10] == 'O' || buf[10] == 'o') \
&& (buf[11] == ':' || buf[11] == ' ' || buf[11] == '\t'))
#define ISMESSAGE_ID(buf) (\
(buf[0] == 'M' || buf[0] == 'm') \
&& (buf[1] == 'E' || buf[1] == 'e') \
&& (buf[2] == 'S' || buf[2] == 's') \
&& (buf[3] == 'S' || buf[3] == 's') \
&& (buf[4] == 'A' || buf[4] == 'a') \
&& (buf[5] == 'G' || buf[5] == 'g') \
&& (buf[6] == 'E' || buf[6] == 'e') \
&& (buf[7] == '-') \
&& (buf[8] == 'I' || buf[8] == 'i') \
&& (buf[9] == 'D' || buf[9] == 'd') \
&& (buf[10] == ':' || buf[10] == ' ' || buf[10] == '\t'))
#define ISREFERENCE(buf) (\
(buf[0] == 'R' || buf[0] == 'r') \
&& (buf[1] == 'E' || buf[1] == 'e') \
&& (buf[2] == 'F' || buf[2] == 'f') \
&& (buf[3] == 'E' || buf[3] == 'e') \
&& (buf[4] == 'R' || buf[4] == 'r') \
&& (buf[5] == 'E' || buf[5] == 'e') \
&& (buf[6] == 'n' || buf[6] == 'n') \
&& (buf[7] == 'C' || buf[7] == 'c') \
&& (buf[8] == 'E' || buf[8] == 'e') \
&& (buf[9] == ':' || buf[9] == ' ' || buf[9] == '\t'))
#define ISREPLY_TO(buf) (\
(buf[0] == 'R' || buf[0] == 'r') \
&& (buf[1] == 'E' || buf[1] == 'e') \
&& (buf[2] == 'P' || buf[2] == 'p') \
&& (buf[3] == 'L' || buf[3] == 'l') \
&& (buf[4] == 'Y' || buf[4] == 'y') \
&& (buf[5] == '-') \
&& (buf[6] == 'T' || buf[6] == 't') \
&& (buf[7] == 'O' || buf[7] == 'o') \
&& (buf[8] == ':' || buf[8] == ' ' || buf[8] == '\t'))
#define ISSENDER(buf) (\
(buf[0] == 'S' || buf[0] == 's') \
&& (buf[1] == 'E' || buf[1] == 'e') \
&& (buf[2] == 'N' || buf[2] == 'n') \
&& (buf[3] == 'D' || buf[3] == 'd') \
&& (buf[4] == 'E' || buf[4] == 'e') \
&& (buf[5] == 'R' || buf[5] == 'r') \
&& (buf[6] == ':' || buf[6] == ' ' || buf[6] == '\t'))
#define ISSTATUS(buf) (\
(buf[0] == 'S' || buf[0] == 's') \
&& (buf[1] == 'T' || buf[1] == 't') \
...
...
@@ -250,10 +362,17 @@ do \
&& (buf[4] == 'D' || buf[4] == 'd') \
&& (buf[5] == ':' || buf[5] == ' ' || buf[5] == '\t'))
/* Skip prepen spaces. */
/* Skip prepen
d
spaces. */
#define SKIPSPACE(p) while (*p == ' ') p++
/* Save/concatenate the field-value in the field. */
#define ATOI(a,i) \
do {\
SKIPSPACE(a); \
for (i = 0; *a >= '0' && *a <= '9'; a++) \
i = 10 * i + (*a - '0'); \
} while (0)
/* Save/concatenate the field-value in the fast header(fhd) field. */
#define FAST_HEADER(field,buf,n) \
do { \
int i = 0; \
...
...
@@ -281,41 +400,65 @@ do { \
} \
} while (0)
#define FAST_HCONTENT_TYPE(mum,sf,buf,n) \
FAST_HEADER(mum->fhdr[HCONTENT_TYPE],buf,n); \
sf = &(mum->fhdr[HCONTENT_TYPE])
#define FAST_H_BCC(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_BCC],buf,n); \
save_field = &(mum->fhdr[H_BCC])
#define FAST_H_CC(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_CC],buf,n); \
save_field = &(mum->fhdr[H_CC])
#define FAST_H_CONTENT_LANGUAGE(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_CONTENT_LANGUAGE],buf,n); \
save_field = &(mum->fhdr[H_CONTENT_LANGUAGE])
#define FAST_H
CC(mum,sf
,buf,n) \
FAST_HEADER(mum->fhdr[H
CC
],buf,n); \
s
f = &(mum->fhdr[HCC
])
#define FAST_H
_CONTENT_TRANSFER_ENCODING(mum,save_field
,buf,n) \
FAST_HEADER(mum->fhdr[H
_CONTENT_TRANSFER_ENCODING
],buf,n); \
s
ave_field = &(mum->fhdr[H_CONTENT_TRANSFER_ENCODING
])
#define FAST_H
DATE(mum,sf
,buf,n) \
FAST_HEADER(mum->fhdr[H
DAT
E],buf,n); \
s
f = &(mum->fhdr[HDAT
E])
#define FAST_H
_CONTENT_TYPE(mum,save_field
,buf,n) \
FAST_HEADER(mum->fhdr[H
_CONTENT_TYP
E],buf,n); \
s
ave_field = &(mum->fhdr[H_CONTENT_TYP
E])
#define FAST_H
FROM(mum,sf
,buf,n) \
FAST_HEADER(mum->fhdr[H
FROM
],buf,n); \
s
f = &(mum->fhdr[HFROM
])
#define FAST_H
_DATE(mum,save_field
,buf,n) \
FAST_HEADER(mum->fhdr[H
_DATE
],buf,n); \
s
ave_field = &(mum->fhdr[H_DATE
])
#define FAST_H
SUBJECT(mum,sf
,buf,n) \
FAST_HEADER(mum->fhdr[H
SUBJECT
],buf,n); \
s
f = &(mum->fhdr[HSUBJECT
])
#define FAST_H
_FROM(mum,save_field
,buf,n) \
FAST_HEADER(mum->fhdr[H
_FROM
],buf,n); \
s
ave_field = &(mum->fhdr[H_FROM
])
#define FAST_H
TO(mum,sf
,buf,n) \
FAST_HEADER(mum->fhdr[HTO],buf,n); \
s
f = &(mum->fhdr[H
TO])
#define FAST_H
_IN_REPLY_TO(mum,save_field
,buf,n) \
FAST_HEADER(mum->fhdr[H
_IN_REPLY_
TO],buf,n); \
s
ave_field = &(mum->fhdr[H_IN_REPLY_
TO])
#define FAST_H
X_IMAPBASE(mum,sf
,buf,n) \
FAST_HEADER(mum->fhdr[H
X_IMAPBASE
],buf,n); \
s
f = &(mum->fhdr[HX_U
ID])
#define FAST_H
_MESSAGE_ID(mum,save_field
,buf,n) \
FAST_HEADER(mum->fhdr[H
_MESSAGE_ID
],buf,n); \
s
ave_field = &(mum->fhdr[H_MESSAGE_
ID])
#define FAST_H
X_UIDL(mum,sf
,buf,n) \
FAST_HEADER(mum->fhdr[H
X_UIDL
],buf,n); \
s
f = &(mum->fhdr[HX_UIDL
])
#define FAST_H
_REFERENCE(mum,save_field
,buf,n) \
FAST_HEADER(mum->fhdr[H
_REFERENCE
],buf,n); \
s
ave_field = &(mum->fhdr[H_REFERENCE
])
#define FAST_HX_UID(mum,sf,buf,n) \
FAST_HEADER(mum->fhdr[HX_UID],buf,n); \
sf = &(mum->fhdr[HX_UID])
#define FAST_H_REPLY_TO(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_REPLY_TO],buf,n); \
save_field = &(mum->fhdr[H_REPLY_TO])
#define FAST_H_SENDER(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_SENDER],buf,n); \
save_field = &(mum->fhdr[H_SENDER])
#define FAST_H_SUBJECT(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_SUBJECT],buf,n); \
save_field = &(mum->fhdr[H_SUBJECT])
#define FAST_H_TO(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_TO],buf,n); \
save_field = &(mum->fhdr[H_TO])
#define FAST_H_X_UIDL(mum,save_field,buf,n) \
FAST_HEADER(mum->fhdr[H_X_UIDL],buf,n); \
save_field = &(mum->fhdr[H_X_UIDL])
/* Notifications ADD_MESG. */
#define DISPATCH_ADD_MSG(mbox,mud) \
...
...
@@ -445,6 +588,18 @@ mbox_scan0 (mailbox_t mailbox, size_t msgno, size_t *pcount, int do_notif)
else
mud
->
messages_count
=
0
;
#if 0
{
size_t j, k;
for (j = 0; j < mud->umessages_count; j++)
{
mum = mud->umessages[j];
for (k = 0; k < HDRSIZE; k++)
if (mum->fhdr[k])
free (mum->fhdr[k]);
}
}
#endif
newline
=
1
;
errno
=
lines
=
inheader
=
inbody
=
0
;
...
...
@@ -488,8 +643,7 @@ mbox_scan0 (mailbox_t mailbox, size_t msgno, size_t *pcount, int do_notif)
mum
->
mud
=
mud
;
mum
->
header_from
=
total
-
n
;
mum
->
header_from_end
=
total
;
mum
->
body_end
=
mum
->
body
=
0
;
mum
->
attr_flags
=
0
;
//mum->body_end = mum->body = 0;
lines
=
0
;
sfield
=
NULL
;
for
(
j
=
0
;
j
<
HDRSIZE
;
j
++
)
...
...
@@ -507,41 +661,88 @@ mbox_scan0 (mailbox_t mailbox, size_t msgno, size_t *pcount, int do_notif)
ATTRIBUTE_SET
(
buf
,
mum
,
'd'
,
'D'
,
MU_ATTRIBUTE_DELETED
);
sfield
=
NULL
;
}
else
if
(
IS
CONTENT_TYPE
(
buf
))
else
if
(
IS
BCC
(
buf
))
{
FAST_H
CONTENT_TYPE
(
mum
,
sfield
,
buf
,
n
);
FAST_H
_BCC
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISCC
(
buf
))
{
FAST_HCC
(
mum
,
sfield
,
buf
,
n
);
FAST_H_CC
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISCONTENT_LANGUAGE
(
buf
))
{
FAST_H_CONTENT_LANGUAGE
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISCONTENT_TRANSFER_ENCODING
(
buf
))
{
FAST_H_CONTENT_TRANSFER_ENCODING
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISCONTENT_TYPE
(
buf
))
{
FAST_H_CONTENT_TYPE
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISDATE
(
buf
))
{
FAST_HDATE
(
mum
,
sfield
,
buf
,
n
);
FAST_H
_
DATE
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISFROM
(
buf
))
{
FAST_HFROM
(
mum
,
sfield
,
buf
,
n
);
char
*
ss
=
NULL
;
if
(
mum
->
fhdr
[
H_FROM
])
*
ss
=
1
;
FAST_H_FROM
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISIN_REPLY_TO
(
buf
))
{
FAST_H_IN_REPLY_TO
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISMESSAGE_ID
(
buf
))
{
FAST_H_MESSAGE_ID
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISREFERENCE
(
buf
))
{
FAST_H_REFERENCE
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISREPLY_TO
(
buf
))
{
FAST_H_REPLY_TO
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISSENDER
(
buf
))
{
FAST_H_SENDER
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISSUBJECT
(
buf
))
{
FAST_HSUBJECT
(
mum
,
sfield
,
buf
,
n
);
char
*
ss
=
NULL
;
if
(
mum
->
fhdr
[
H_SUBJECT
])
*
ss
=
1
;
FAST_H_SUBJECT
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISTO
(
buf
))
{
FAST_HTO
(
mum
,
sfield
,
buf
,
n
);
FAST_H
_
TO
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISX_
IMAPBASE
(
buf
))
else
if
(
ISX_
UIDL
(
buf
))
{
FAST_H
X_IMAPBASE
(
mum
,
sfield
,
buf
,
n
);
FAST_H
_X_UIDL
(
mum
,
sfield
,
buf
,
n
);
}
else
if
(
ISX_UIDL
(
buf
))
else
if
(
ISX_IMAPBASE
(
buf
))
{
char
*
s
=
memchr
(
buf
,
':'
,
n
);
if
(
s
)
{
FAST_HX_UIDL
(
mum
,
sfield
,
buf
,
n
);
s
++
;
ATOI
(
s
,
mud
->
uidvalidity
);
ATOI
(
s
,
mud
->
uidnext
);
}
}
else
if
(
ISX_UID
(
buf
))
{
FAST_HX_UID
(
mum
,
sfield
,
buf
,
n
);
char
*
s
=
memchr
(
buf
,
':'
,
n
);
if
(
s
)
{
s
++
;
ATOI
(
s
,
mum
->
uid
);
}
}
else
if
(
sfield
&&
(
buf
[
0
]
==
' '
||
buf
[
0
]
==
'\t'
))
{
...
...
@@ -596,65 +797,38 @@ mbox_scan0 (mailbox_t mailbox, size_t msgno, size_t *pcount, int do_notif)
if
(
mud
->
messages_count
>
0
)
{
mum
=
mud
->
umessages
[
0
];
if
(
mum
->
fhdr
[
HX_IMAPBASE
])
{
char
*
s
=
mum
->
fhdr
[
HX_IMAPBASE
];
while
(
*
s
&&
!
isdigit
(
*
s
))
s
++
;
mud
->
uidvalidity
=
strtoul
(
s
,
&
s
,
10
);
mud
->
uidnext
=
strtoul
(
s
,
NULL
,
10
);
}
if
(
mud
->
uidvalidity
==
0
)
{
char
u
[
64
];
mud
->
uidvalidity
=
(
unsigned
long
)
time
(
NULL
);
mud
->
uidnext
=
mud
->
messages_count
+
1
;
if
(
mum
->
fhdr
[
HX_IMAPBASE
])
free
(
mum
->
fhdr
[
HX_IMAPBASE
]);
sprintf
(
u
,
"%lu %u"
,
mud
->
uidvalidity
,
mud
->
uidnext
);
mum
->
fhdr
[
HX_IMAPBASE
]
=
strdup
(
u
);
/* Tell that we have been modified for expunging. */
mum
->
attr_flags
|=
MU_ATTRIBUTE_MODIFIED
;
}
}
/* Reset the IMAP uids, if necessary. */
/* Reset the IMAP uids, if necessary. UID according to IMAP RFC is a 32 bit
ascending number for each messages */
{
size_t
uid
;
size_t
ouid
;
size_t
i
;
for
(
uid
=
ouid
=
i
=
0
;
i
<
mud
->
messages_count
;
i
++
)
{
char
*
s
;
mum
=
mud
->
umessages
[
i
];
s
=
mum
->
fhdr
[
HX_UID
];
if
(
s
)
{
while
(
*
s
&&
!
isdigit
(
*
s
))
s
++
;
uid
=
strtoul
(
s
,
&
s
,
10
);
}
else
uid
=
0
;
uid
=
mum
->
uid
;
if
(
uid
<=
ouid
)
{
char
u
[
64
];
uid
=
ouid
+
1
;
sprintf
(
u
,
"%d"
,
uid
);
if
(
mum
->
fhdr
[
HX_UID
])
free
(
mum
->
fhdr
[
HX_UID
]);
mum
->
fhdr
[
HX_UID
]
=
strdup
(
u
);
/* Note that we have modified for expunging. */
mum
->
uid
=
ouid
=
uid
;
/* Note that modification for when expunging. */
mum
->
attr_flags
|=
MU_ATTRIBUTE_MODIFIED
;
}
mum
->
uid
=
ouid
=
uid
;
else
ouid
=
uid
;
}
if
(
uid
>=
mud
->
uidnext
)
if
(
mud
->
messages_count
>
0
&&
uid
>=
mud
->
uidnext
)
{
char
u
[
64
];
mud
->
uidnext
=
uid
+
1
;
mum
=
mud
->
umessages
[
0
];
if
(
mum
->
fhdr
[
HX_IMAPBASE
])
free
(
mum
->
fhdr
[
HX_IMAPBASE
]);
sprintf
(
u
,
"%lu %u"
,
mud
->
uidvalidity
,
uid
+
1
);
mum
->
fhdr
[
HX_IMAPBASE
]
=
strdup
(
u
);
mud
->
uidnext
=
uid
+
1
;
mum
->
attr_flags
|=
MU_ATTRIBUTE_MODIFIED
;
}
}
...
...
mailbox/message.c
View file @
9bb7be1
...
...
@@ -162,10 +162,26 @@ message_is_modified (message_t msg)
int
mod
=
0
;
mod
|=
header_is_modified
(
msg
->
header
);
mod
|=
attribute_is_modified
(
msg
->
attribute
);
mod
|=
body_is_modified
(
msg
->
body
);
return
mod
;
}
int
message_clear_modified
(
message_t
msg
)
{
if
(
msg
)
{
if
(
msg
->
header
)
header_clear_modified
(
msg
->
header
);
if
(
msg
->
attribute
)
attribute_clear_modified
(
msg
->
attribute
);
if
(
msg
->
body
)
body_clear_modified
(
msg
->
body
);
}
return
0
;
}
int
message_set_mailbox
(
message_t
msg
,
mailbox_t
mailbox
)
{
if
(
msg
==
NULL
)
...
...
Please
register
or
sign in
to post a comment